mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 755245 - Implement System Message Handler : Part 2, Add a getApp() method to nsGlobalWindow [r=mounir]
This commit is contained in:
parent
98fe91c4f9
commit
c5aa869164
@ -64,6 +64,7 @@
|
|||||||
#include "sampler.h"
|
#include "sampler.h"
|
||||||
#include "nsDOMBlobBuilder.h"
|
#include "nsDOMBlobBuilder.h"
|
||||||
#include "nsIDOMFileHandle.h"
|
#include "nsIDOMFileHandle.h"
|
||||||
|
#include "nsIDOMApplicationRegistry.h"
|
||||||
|
|
||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
using namespace mozilla::dom;
|
using namespace mozilla::dom;
|
||||||
@ -2569,3 +2570,16 @@ nsDOMWindowUtils::SetApp(const nsAString& aManifestURL)
|
|||||||
|
|
||||||
return static_cast<nsGlobalWindow*>(window.get())->SetApp(aManifestURL);
|
return static_cast<nsGlobalWindow*>(window.get())->SetApp(aManifestURL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsDOMWindowUtils::GetApp(mozIDOMApplication** aApplication)
|
||||||
|
{
|
||||||
|
if (!IsUniversalXPConnectCapable()) {
|
||||||
|
return NS_ERROR_DOM_SECURITY_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
|
||||||
|
NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
|
return static_cast<nsGlobalWindow*>(window.get())->GetApp(aApplication);
|
||||||
|
}
|
||||||
|
@ -10678,22 +10678,14 @@ nsGlobalWindow::SetIsApp(bool aValue)
|
|||||||
bool
|
bool
|
||||||
nsGlobalWindow::IsPartOfApp()
|
nsGlobalWindow::IsPartOfApp()
|
||||||
{
|
{
|
||||||
FORWARD_TO_OUTER(IsPartOfApp, (), TriState_False);
|
mozIDOMApplication* app;
|
||||||
|
nsresult rv = GetApp(&app);
|
||||||
|
|
||||||
// We go trough all window parents until we find one with |mIsApp| set to
|
if (NS_FAILED(rv)) {
|
||||||
// something. If none is found, we are not part of an application.
|
return false;
|
||||||
for (nsGlobalWindow* w = this; w;
|
|
||||||
w = static_cast<nsGlobalWindow*>(w->GetParentInternal())) {
|
|
||||||
if (w->mIsApp == TriState_True) {
|
|
||||||
// The window should be part of an application.
|
|
||||||
MOZ_ASSERT(w->mApp);
|
|
||||||
return true;
|
|
||||||
} else if (w->mIsApp == TriState_False) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return app != nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
@ -10723,6 +10715,30 @@ nsGlobalWindow::SetApp(const nsAString& aManifestURL)
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
nsGlobalWindow::GetApp(mozIDOMApplication** aApplication)
|
||||||
|
{
|
||||||
|
*aApplication = nsnull;
|
||||||
|
|
||||||
|
FORWARD_TO_OUTER(GetApp, (aApplication), NS_OK);
|
||||||
|
|
||||||
|
// We go trough all window parents until we find one with |mIsApp| set to
|
||||||
|
// something. If none is found, we are not part of an application.
|
||||||
|
for (nsGlobalWindow* w = this; w;
|
||||||
|
w = static_cast<nsGlobalWindow*>(w->GetParentInternal())) {
|
||||||
|
if (w->mIsApp == TriState_True) {
|
||||||
|
// The window should be part of an application.
|
||||||
|
MOZ_ASSERT(w->mApp);
|
||||||
|
NS_IF_ADDREF(*aApplication = w->mApp);
|
||||||
|
return NS_OK;
|
||||||
|
} else if (w->mIsApp == TriState_False) {
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
// nsGlobalChromeWindow implementation
|
// nsGlobalChromeWindow implementation
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_CLASS(nsGlobalChromeWindow)
|
NS_IMPL_CYCLE_COLLECTION_CLASS(nsGlobalChromeWindow)
|
||||||
|
@ -894,6 +894,7 @@ protected:
|
|||||||
|
|
||||||
void SetIsApp(bool aValue);
|
void SetIsApp(bool aValue);
|
||||||
nsresult SetApp(const nsAString& aManifestURL);
|
nsresult SetApp(const nsAString& aManifestURL);
|
||||||
|
nsresult GetApp(mozIDOMApplication** aApplication);
|
||||||
|
|
||||||
// Implements Get{Real,Scriptable}Top.
|
// Implements Get{Real,Scriptable}Top.
|
||||||
nsresult GetTopImpl(nsIDOMWindow **aWindow, bool aScriptable);
|
nsresult GetTopImpl(nsIDOMWindow **aWindow, bool aScriptable);
|
||||||
|
@ -38,6 +38,7 @@ interface nsIDOMFile;
|
|||||||
interface nsIFile;
|
interface nsIFile;
|
||||||
interface nsIDOMTouch;
|
interface nsIDOMTouch;
|
||||||
interface nsIDOMClientRect;
|
interface nsIDOMClientRect;
|
||||||
|
interface mozIDOMApplication;
|
||||||
|
|
||||||
[scriptable, uuid(858578f1-9653-4d5c-821a-07479bf2d9b2)]
|
[scriptable, uuid(858578f1-9653-4d5c-821a-07479bf2d9b2)]
|
||||||
interface nsIDOMWindowUtils : nsISupports {
|
interface nsIDOMWindowUtils : nsISupports {
|
||||||
@ -1165,4 +1166,9 @@ interface nsIDOMWindowUtils : nsISupports {
|
|||||||
* or isn't the manifest URL of an installed application.
|
* or isn't the manifest URL of an installed application.
|
||||||
*/
|
*/
|
||||||
void setApp(in DOMString manifestURL);
|
void setApp(in DOMString manifestURL);
|
||||||
|
/**
|
||||||
|
* Retrieves the Application object associated to this window.
|
||||||
|
* Can be null if |setApp()| has not been called.
|
||||||
|
*/
|
||||||
|
mozIDOMApplication getApp();
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user