Skip to content

Commit

Permalink
[embedlite-components] Align APIs to esr52 changes. JB#49614
Browse files Browse the repository at this point in the history
Do not include InputData.h as that's pulling in internal string
headers.
  • Loading branch information
rainemak committed May 15, 2020
1 parent eb1bf1b commit 78e7cbc
Show file tree
Hide file tree
Showing 14 changed files with 74 additions and 102 deletions.
39 changes: 2 additions & 37 deletions chromehelper/EmbedChromeListener.cpp
Expand Up @@ -28,7 +28,7 @@
#include "nsIWebNavigation.h"
#include "mozilla/dom/ScriptSettings.h"

EmbedChromeListener::EmbedChromeListener(nsIDOMWindow* aWin)
EmbedChromeListener::EmbedChromeListener(mozIDOMWindowProxy *aWin)
: DOMWindow(aWin)
, mWindowCounter(0)
{
Expand All @@ -43,38 +43,6 @@ EmbedChromeListener::~EmbedChromeListener()

NS_IMPL_ISUPPORTS(EmbedChromeListener, nsIDOMEventListener)

nsresult
GetDOMWindowByNode(nsIDOMNode *aNode, nsIDOMWindow **aDOMWindow)
{
nsresult rv;
nsCOMPtr<nsIDOMDocument> ctDoc = do_QueryInterface(aNode, &rv);
NS_ENSURE_SUCCESS(rv , rv);
nsCOMPtr<nsIDOMWindow> targetWin;
rv = ctDoc->GetDefaultView(getter_AddRefs(targetWin));
NS_ENSURE_SUCCESS(rv , rv);
*aDOMWindow = targetWin.forget().take();
return rv;
}

NS_IMETHODIMP
GetTopWindow(nsIDOMWindow* aWin, nsIDOMWindow **aDOMWindow)
{
nsCOMPtr<nsIWebNavigation> navNav(do_GetInterface(aWin));
nsCOMPtr<nsIDocShellTreeItem> navItem(do_QueryInterface(navNav));
NS_ENSURE_TRUE(navItem, NS_ERROR_FAILURE);
nsCOMPtr<nsIDocShellTreeItem> rootItem;
navItem->GetRootTreeItem(getter_AddRefs(rootItem));
nsCOMPtr<nsIDOMWindow> rootWin(do_GetInterface(rootItem));
NS_ENSURE_TRUE(rootWin, NS_ERROR_FAILURE);

nsCOMPtr<nsPIDOMWindow> pwindow(do_QueryInterface(rootWin));
nsCOMPtr<nsIDOMWindow> window = pwindow->GetTop();
getter_AddRefs(window);
*aDOMWindow = window.forget().take();
return NS_OK;
}


NS_IMETHODIMP
EmbedChromeListener::HandleEvent(nsIDOMEvent* aEvent)
{
Expand All @@ -95,11 +63,8 @@ EmbedChromeListener::HandleEvent(nsIDOMEvent* aEvent)
nsCOMPtr<nsIWritablePropertyBag2> root;
json->CreateObject(getter_AddRefs(root));

nsCOMPtr<nsIDOMWindow> docWin = do_GetInterface(DOMWindow);
nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(DOMWindow);

uint32_t winid;
mService->GetIDByWindow(window, &winid);
mService->GetIDByWindow(DOMWindow, &winid);
NS_ENSURE_TRUE(winid , NS_ERROR_FAILURE);
mozilla::dom::AutoNoJSAPI noJSAPI();

Expand Down
4 changes: 2 additions & 2 deletions chromehelper/EmbedChromeListener.h
Expand Up @@ -23,12 +23,12 @@
class EmbedChromeListener : public nsIDOMEventListener
{
public:
EmbedChromeListener(nsIDOMWindow* aWin);
EmbedChromeListener(mozIDOMWindowProxy* aWin);

NS_DECL_ISUPPORTS
NS_DECL_NSIDOMEVENTLISTENER

nsCOMPtr<nsIDOMWindow> DOMWindow;
nsCOMPtr<mozIDOMWindowProxy> DOMWindow;
private:
virtual ~EmbedChromeListener();

Expand Down
12 changes: 6 additions & 6 deletions chromehelper/EmbedChromeManager.cpp
Expand Up @@ -71,11 +71,11 @@ EmbedChromeManager::Observe(nsISupports *aSubject,
{
nsresult rv;
if (!strcmp(aTopic, "domwindowopened")) {
nsCOMPtr<nsIDOMWindow> win = do_QueryInterface(aSubject, &rv);
nsCOMPtr<mozIDOMWindowProxy> win = do_QueryInterface(aSubject, &rv);
NS_ENSURE_SUCCESS(rv, NS_OK);
WindowCreated(win);
} else if (!strcmp(aTopic, "domwindowclosed")) {
nsCOMPtr<nsIDOMWindow> win = do_QueryInterface(aSubject, &rv);
nsCOMPtr<mozIDOMWindowProxy> win = do_QueryInterface(aSubject, &rv);
NS_ENSURE_SUCCESS(rv, NS_OK);
WindowDestroyed(win);
} else {
Expand All @@ -86,10 +86,10 @@ EmbedChromeManager::Observe(nsISupports *aSubject,
}

void
EmbedChromeManager::WindowCreated(nsIDOMWindow* aWin)
EmbedChromeManager::WindowCreated(mozIDOMWindowProxy* aWin)
{
LOGT("WindowOpened: %p", aWin);
nsCOMPtr<nsPIDOMWindow> pidomWindow = do_GetInterface(aWin);
nsCOMPtr<nsPIDOMWindowOuter> pidomWindow = do_GetInterface(aWin);
NS_ENSURE_TRUE(pidomWindow, );
nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(pidomWindow->GetChromeEventHandler());
NS_ENSURE_TRUE(target, );
Expand All @@ -108,10 +108,10 @@ EmbedChromeManager::WindowCreated(nsIDOMWindow* aWin)
}

void
EmbedChromeManager::WindowDestroyed(nsIDOMWindow* aWin)
EmbedChromeManager::WindowDestroyed(mozIDOMWindowProxy *aWin)
{
LOGT("WindowClosed: %p", aWin);
nsCOMPtr<nsPIDOMWindow> pidomWindow = do_GetInterface(aWin);
nsCOMPtr<nsPIDOMWindowOuter> pidomWindow = do_GetInterface(aWin);
NS_ENSURE_TRUE(pidomWindow, );
nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(pidomWindow->GetChromeEventHandler());
NS_ENSURE_TRUE(target, );
Expand Down
4 changes: 2 additions & 2 deletions chromehelper/EmbedChromeManager.h
Expand Up @@ -27,8 +27,8 @@ class EmbedChromeManager : public nsIObserver,
private:
virtual ~EmbedChromeManager();

void WindowCreated(nsIDOMWindow* aWin);
void WindowDestroyed(nsIDOMWindow* aWin);
void WindowCreated(mozIDOMWindowProxy *aWin);
void WindowDestroyed(mozIDOMWindowProxy* aWin);
nsCOMPtr<nsIEmbedAppService> mService;
int mWindowCounter;
typedef nsCOMArray<EmbedChromeListener> ObserversArray;
Expand Down
6 changes: 3 additions & 3 deletions history/EmbedHistoryListener.h
Expand Up @@ -75,7 +75,7 @@ class EmbedHistoryListener : public mozilla::IHistory
* need to cache the pending visit and make sure it doesn't redirect.
*/
RefPtr<nsITimer> mTimer;
typedef nsAutoTArray<nsCOMPtr<nsIURI>, RECENTLY_VISITED_URI_SIZE> PendingVisitArray;
typedef AutoTArray<nsCOMPtr<nsIURI>, RECENTLY_VISITED_URI_SIZE> PendingVisitArray;
PendingVisitArray mPendingVisitURIs;

bool RemovePendingVisitURI(nsIURI* aURI);
Expand All @@ -85,7 +85,7 @@ class EmbedHistoryListener : public mozilla::IHistory
* mRecentlyVisitedURIs remembers URIs which are recently added to the DB,
* to avoid saving these locations repeatedly in a short period.
*/
typedef nsAutoTArray<nsCOMPtr<nsIURI>, RECENTLY_VISITED_URI_SIZE> RecentlyVisitedArray;
typedef AutoTArray<nsCOMPtr<nsIURI>, RECENTLY_VISITED_URI_SIZE> RecentlyVisitedArray;
RecentlyVisitedArray mRecentlyVisitedURIs;
RecentlyVisitedArray::index_type mRecentlyVisitedURIsNextIndex;

Expand All @@ -96,7 +96,7 @@ class EmbedHistoryListener : public mozilla::IHistory
* mEmbedURIs remembers URIs which are explicitly not added to the DB,
* to avoid wasting time on these locations.
*/
typedef nsAutoTArray<nsCOMPtr<nsIURI>, EMBED_URI_SIZE> EmbedArray;
typedef AutoTArray<nsCOMPtr<nsIURI>, EMBED_URI_SIZE> EmbedArray;
EmbedArray::index_type mEmbedURIsNextIndex;
EmbedArray mEmbedURIs;

Expand Down
4 changes: 2 additions & 2 deletions prompt/EmbedPromptRegister.cpp
Expand Up @@ -54,7 +54,7 @@ EmbedPromptRegister::Init()

nsCOMPtr<nsIFactory> oldFactory = do_GetClassObject("@mozilla.org/prompter;1");
if (oldFactory) {
nsCID* cid = NULL;
nsCID* cid = nullptr;
rv = cr->ContractIDToCID("@mozilla.org/prompter;1", &cid);
if (!NS_FAILED(rv)) {
rv = cr->UnregisterFactory(*cid, oldFactory.get());
Expand All @@ -76,7 +76,7 @@ EmbedPromptRegister::Init()
}
oldFactory = do_GetClassObject("@mozilla.org/alerts-service;1");
if (oldFactory) {
nsCID* cid = NULL;
nsCID* cid = nullptr;
rv = cr->ContractIDToCID("@mozilla.org/alerts-service;1", &cid);
if (!NS_FAILED(rv)) {
rv = cr->UnregisterFactory(*cid, oldFactory.get());
Expand Down
23 changes: 14 additions & 9 deletions prompt/EmbedPromptService.cpp
Expand Up @@ -26,6 +26,7 @@
#include "nsNetCID.h"
#include "nsIProtocolHandler.h"
#include "nsIDOMWindow.h"
#include "nsPIDOMWindow.h"
#include "nsIEmbedLiteJSON.h"
#include "nsIObserverService.h"
#include "nsIWindowWatcher.h"
Expand All @@ -39,7 +40,7 @@

using namespace mozilla::embedlite;

EmbedPromptOuterObserver::EmbedPromptOuterObserver(IDestroyNotification* aNotifier, nsIDOMWindow* aWin)
EmbedPromptOuterObserver::EmbedPromptOuterObserver(IDestroyNotification* aNotifier, mozIDOMWindowProxy *aWin)
: mNotifier(aNotifier)
, mWin(aWin)
{
Expand Down Expand Up @@ -89,9 +90,9 @@ NS_IMPL_ISUPPORTS(EmbedPromptFactory, nsIPromptFactory)


NS_IMETHODIMP
EmbedPromptFactory::GetPrompt(nsIDOMWindow* aParent, const nsIID& iid, void **result)
EmbedPromptFactory::GetPrompt(mozIDOMWindowProxy* aParent, const nsIID& iid, void **result)
{
nsCOMPtr<nsIDOMWindow> parent(aParent);
nsCOMPtr<mozIDOMWindowProxy> parent(aParent);
if (!parent) { // if no parent provided, consult the window watcher:
nsresult rv;
nsCOMPtr<nsIWindowWatcher> wwatcher = do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv);
Expand All @@ -116,7 +117,7 @@ EmbedPromptFactory::GetPrompt(nsIDOMWindow* aParent, const nsIID& iid, void **re

// Prompt Service Implementation

EmbedPromptService::EmbedPromptService(nsIDOMWindow* aWin)
EmbedPromptService::EmbedPromptService(mozIDOMWindowProxy *aWin)
: mWin(aWin)
, mModalDepth(0)
{
Expand Down Expand Up @@ -238,7 +239,8 @@ EmbedPromptService::AlertCheck(const char16_t* aDialogTitle,

mozilla::dom::AutoNoJSAPI noJSAPI();

nsCOMPtr<nsIDOMWindowUtils> utils = do_GetInterface(mWin);
nsCOMPtr<nsPIDOMWindowOuter> pidomWindow = do_GetInterface(mWin);
nsCOMPtr<nsIDOMWindowUtils> utils = do_GetInterface(pidomWindow);
NS_ENSURE_TRUE(utils, NS_ERROR_FAILURE);

rv = utils->EnterModalState();
Expand Down Expand Up @@ -321,7 +323,8 @@ EmbedPromptService::ConfirmCheck(const char16_t* aDialogTitle,

mozilla::dom::AutoNoJSAPI noJSAPI();

nsCOMPtr<nsIDOMWindowUtils> utils = do_GetInterface(mWin);
nsCOMPtr<nsPIDOMWindowOuter> pidomWindow = do_GetInterface(mWin);
nsCOMPtr<nsIDOMWindowUtils> utils = do_GetInterface(pidomWindow);
NS_ENSURE_TRUE(utils, NS_ERROR_FAILURE);

rv = utils->EnterModalState();
Expand Down Expand Up @@ -415,7 +418,8 @@ EmbedPromptService::Prompt(const char16_t* aDialogTitle,

mozilla::dom::AutoNoJSAPI noJSAPI();

nsCOMPtr<nsIDOMWindowUtils> utils = do_GetInterface(mWin);
nsCOMPtr<nsPIDOMWindowOuter> pidomWindow = do_GetInterface(mWin);
nsCOMPtr<nsIDOMWindowUtils> utils = do_GetInterface(pidomWindow);
NS_ENSURE_TRUE(utils, NS_ERROR_FAILURE);

rv = utils->EnterModalState();
Expand Down Expand Up @@ -500,7 +504,7 @@ EmbedPromptService::Select(const char16_t* aDialogTitle,

// Prompt Auth Implementation

EmbedAuthPromptService::EmbedAuthPromptService(nsIDOMWindow* aWin)
EmbedAuthPromptService::EmbedAuthPromptService(mozIDOMWindowProxy* aWin)
: mWin(aWin)
{
mService = do_GetService("@mozilla.org/embedlite-app-service;1");
Expand Down Expand Up @@ -790,7 +794,8 @@ EmbedAuthPromptService::DoSendAsyncPrompt(EmbedAsyncAuthPrompt* mPrompt)
loginInfo->SetPassword(it->second.password);
loginInfo->SetUsernameField(nsString());
loginInfo->SetPasswordField(nsString());
loginMgr->AddLogin(loginInfo);
nsCOMPtr<nsILoginInfo> retValue;
loginMgr->AddLogin(loginInfo, getter_AddRefs(retValue));
}

DoResponseAsyncPrompt(mPrompt, it->second.accepted, it->second.username, it->second.password);
Expand Down
16 changes: 8 additions & 8 deletions prompt/EmbedPromptService.h
Expand Up @@ -55,22 +55,22 @@ class IDestroyNotification
class EmbedPromptOuterObserver : public nsIObserver, public nsSupportsWeakReference
{
public:
EmbedPromptOuterObserver(IDestroyNotification* aNotifier, nsIDOMWindow* aWin);
EmbedPromptOuterObserver(IDestroyNotification* aNotifier, mozIDOMWindowProxy* aWin);

NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
void OnDestroy();
private:
virtual ~EmbedPromptOuterObserver();
IDestroyNotification* mNotifier;
nsCOMPtr<nsIDOMWindow> mWin;
nsCOMPtr<mozIDOMWindowProxy> mWin;
nsCOMPtr<nsIObserverService> mService;
};

class EmbedPromptService : public nsIPrompt, public nsIEmbedMessageListener, public IDestroyNotification
{
public:
EmbedPromptService(nsIDOMWindow* aWin);
EmbedPromptService(mozIDOMWindowProxy* aWin);

NS_DECL_ISUPPORTS
NS_DECL_NSIPROMPT
Expand All @@ -83,7 +83,7 @@ class EmbedPromptService : public nsIPrompt, public nsIEmbedMessageListener, pub
void CancelResponse();
uint32_t CheckWinID();

nsCOMPtr<nsIDOMWindow> mWin;
nsCOMPtr<mozIDOMWindowProxy> mWin;
int mModalDepth;
nsCOMPtr<nsIEmbedAppService> mService;
std::map<uint32_t, EmbedPromptResponse> mResponseMap;
Expand All @@ -101,13 +101,13 @@ class EmbedAsyncAuthPrompt
, mAuthInfo(aAuthInfo)
, mLevel(aLevel)
, mInProgress(aInProgress)
, mService(NULL)
, mService(nullptr)
{
consumers.AppendElement(aCancelable);
}

nsTArray<RefPtr<nsICancelable>> consumers;
nsIDOMWindow* mWin;
mozIDOMWindowProxy* mWin;
nsCOMPtr<nsIChannel> mChannel;
nsCOMPtr<nsIAuthInformation> mAuthInfo;
uint32_t mLevel;
Expand All @@ -120,7 +120,7 @@ class EmbedAsyncAuthPrompt
class EmbedAuthPromptService : public nsIAuthPrompt2, public nsIEmbedMessageListener, public IDestroyNotification
{
public:
EmbedAuthPromptService(nsIDOMWindow* aWin);
EmbedAuthPromptService(mozIDOMWindowProxy *aWin);

NS_DECL_ISUPPORTS
NS_DECL_NSIAUTHPROMPT2
Expand All @@ -140,7 +140,7 @@ class EmbedAuthPromptService : public nsIAuthPrompt2, public nsIEmbedMessageList
void CancelResponse();
uint32_t CheckWinID();

nsCOMPtr<nsIDOMWindow> mWin;
nsCOMPtr<mozIDOMWindowProxy> mWin;
std::map<std::string, EmbedAsyncAuthPrompt*> asyncPrompts;
std::map<void*, bool> asyncPromptInProgress;
nsCOMPtr<nsIEmbedAppService> mService;
Expand Down
2 changes: 1 addition & 1 deletion prompt/nsAlertsService.cpp
Expand Up @@ -53,7 +53,7 @@ NS_IMETHODIMP nsEmbedAlertsService::ShowAlertNotification(const nsAString& aImag

// Do not display the alert. Instead call alertfinished and get out.
if (aAlertListener)
aAlertListener->Observe(NULL, "alertclickcallback", PromiseFlatString(aAlertCookie).get());
aAlertListener->Observe(nullptr, "alertclickcallback", PromiseFlatString(aAlertCookie).get());

return NS_OK;
}
Expand Down

0 comments on commit 78e7cbc

Please sign in to comment.