зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1310378 - Remove support for mozwidget; r=baku
This commit is contained in:
Родитель
e2fdfd7548
Коммит
4a51ebacfa
|
@ -31,7 +31,6 @@
|
|||
#include "mozilla/HashFunctions.h"
|
||||
|
||||
#include "nsIAppsService.h"
|
||||
#include "mozIApplication.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
|
|
|
@ -43,7 +43,6 @@
|
|||
#include "nsIDOMStorage.h"
|
||||
#include "nsIContentViewer.h"
|
||||
#include "nsIDocumentLoaderFactory.h"
|
||||
#include "nsIMozBrowserFrame.h"
|
||||
#include "nsCURILoader.h"
|
||||
#include "nsDocShellCID.h"
|
||||
#include "nsDOMCID.h"
|
||||
|
@ -10774,35 +10773,6 @@ nsDocShell::DoURILoad(nsIURI* aURI,
|
|||
"DoURILoad thinks this is a document and InternalLoad does not");
|
||||
}
|
||||
|
||||
|
||||
// For mozWidget, display a load error if we navigate to a page which is not
|
||||
// claimed in |widgetPages|.
|
||||
// When we go to display a load error for an invalid mozWidget page, we will
|
||||
// try to load an about:neterror page, which is also an invalid mozWidget
|
||||
// page. To avoid recursion, we skip this check if aURI's scheme is "about".
|
||||
|
||||
// The goal is to prevent leaking sensitive information of an invalid page of
|
||||
// an app, so allowing about:blank would not be conflict to the goal.
|
||||
bool isAbout = false;
|
||||
rv = aURI->SchemeIs("about", &isAbout);
|
||||
if (NS_SUCCEEDED(rv) && !isAbout &&
|
||||
nsIDocShell::GetIsApp()) {
|
||||
nsCOMPtr<Element> frameElement = mScriptGlobal->AsOuter()->GetFrameElementInternal();
|
||||
if (frameElement) {
|
||||
nsCOMPtr<nsIMozBrowserFrame> browserFrame = do_QueryInterface(frameElement);
|
||||
// |GetReallyIsApp| indicates the browser frame is a valid app or widget.
|
||||
// Here we prevent navigating to an app or widget which loses its validity
|
||||
// by loading invalid page or other way.
|
||||
if (browserFrame && !browserFrame->GetReallyIsApp()) {
|
||||
nsCOMPtr<nsIObserverService> serv = services::GetObserverService();
|
||||
if (serv) {
|
||||
serv->NotifyObservers(GetDocument(), "invalid-widget", nullptr);
|
||||
}
|
||||
return NS_ERROR_MALFORMED_URI;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// open a channel for the url
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
|
||||
|
|
|
@ -53,15 +53,6 @@ mozIApplication.prototype = {
|
|||
return (perm === Ci.nsIPermissionManager.ALLOW_ACTION);
|
||||
},
|
||||
|
||||
hasWidgetPage: function(aPageURL) {
|
||||
let uri = Services.io.newURI(aPageURL, null, null);
|
||||
let filepath = AppsUtils.getFilePath(uri.path);
|
||||
let eliminatedUri = Services.io.newURI(uri.prePath + filepath, null, null);
|
||||
let equalCriterion = aUrl => Services.io.newURI(aUrl, null, null)
|
||||
.equals(eliminatedUri);
|
||||
return this.widgetPages.find(equalCriterion) !== undefined;
|
||||
},
|
||||
|
||||
get principal() {
|
||||
if (this._principal) {
|
||||
return this._principal;
|
||||
|
@ -122,7 +113,6 @@ function _setAppProperties(aObj, aApp) {
|
|||
aObj.storeId = aApp.storeId || "";
|
||||
aObj.storeVersion = aApp.storeVersion || 0;
|
||||
aObj.role = aApp.role || "";
|
||||
aObj.widgetPages = aApp.widgetPages || [];
|
||||
aObj.kind = aApp.kind;
|
||||
aObj.enabled = aApp.enabled !== undefined ? aApp.enabled : true;
|
||||
aObj.sideloaded = aApp.sideloaded;
|
||||
|
@ -854,10 +844,6 @@ ManifestHelper.prototype = {
|
|||
return this._localeProp("package_path");
|
||||
},
|
||||
|
||||
get widgetPages() {
|
||||
return this._localeProp("widgetPages");
|
||||
},
|
||||
|
||||
get size() {
|
||||
return this._manifest["size"] || 0;
|
||||
},
|
||||
|
|
|
@ -268,11 +268,6 @@ this.PermissionsTable = { geolocation: {
|
|||
privileged: DENY_ACTION,
|
||||
certified: ALLOW_ACTION
|
||||
},
|
||||
"embed-widgets": {
|
||||
app: DENY_ACTION,
|
||||
privileged: ALLOW_ACTION,
|
||||
certified: ALLOW_ACTION
|
||||
},
|
||||
"background-sensors": {
|
||||
app: DENY_ACTION,
|
||||
privileged: DENY_ACTION,
|
||||
|
|
|
@ -1,66 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
var {classes: Cc, interfaces: Ci, utils: Cu} = Components;
|
||||
|
||||
Cu.import("resource:///modules/AppsUtils.jsm");
|
||||
Cu.import("resource:///modules/Services.jsm");
|
||||
|
||||
add_test(function test_has_widget_criterion() {
|
||||
|
||||
// follow the logic |_saveWidgetsFullPath|
|
||||
let baseUri = Services.io.newURI('http://example.com', null, null);
|
||||
let resolve = (aPage)=>{
|
||||
let filepath = AppsUtils.getFilePath(aPage);
|
||||
|
||||
return baseUri.resolve(filepath);
|
||||
};
|
||||
|
||||
let widgetPages = ['/widget.html',
|
||||
'/foo/bar.html'];
|
||||
let resolvedWidgetPages = widgetPages.map(resolve);
|
||||
|
||||
let app = new mozIApplication({widgetPages:resolvedWidgetPages});
|
||||
|
||||
let widgetPageCheck = aPage => app.hasWidgetPage(baseUri.resolve(aPage));
|
||||
|
||||
Assert.ok(widgetPageCheck('/widget.html'), 'should pass for identical path');
|
||||
Assert.ok(widgetPageCheck('/foo/bar.html'), 'should pass for identical path');
|
||||
|
||||
Assert.ok(!widgetPageCheck('/wrong.html'), 'should not pass for wrong path');
|
||||
Assert.ok(!widgetPageCheck('/WIDGET.html'), 'should be case _sensitive_ for path');
|
||||
Assert.ok(!widgetPageCheck('/widget.HTML'), 'should be case _sensitive_ for file extension');
|
||||
|
||||
Assert.ok(widgetPageCheck('/widget.html?aQuery'), 'should be query insensitive');
|
||||
Assert.ok(widgetPageCheck('/widget.html#aHash'), 'should be hash insensitive');
|
||||
Assert.ok(widgetPageCheck('/widget.html?aQuery=aquery#aHash'),
|
||||
'should be hash/query insensitive');
|
||||
|
||||
Assert.ok(widgetPageCheck('HTTP://example.com/widget.html'),
|
||||
'should be case insensitive for protocol');
|
||||
Assert.ok(widgetPageCheck('http://EXAMPLE.COM/widget.html'),
|
||||
'should be case insensitive for domain');
|
||||
Assert.ok(widgetPageCheck('http://example.com:80/widget.html'),
|
||||
'should pass for default port');
|
||||
|
||||
Assert.ok(widgetPageCheck('HTTP://EXAMPLE.COM:80/widget.html?QueryA=queryA&QueryB=queryB#aHash'),
|
||||
'should pass for a really mess one');
|
||||
|
||||
Assert.ok(!widgetPageCheck('foo://example.com/widget.html'),
|
||||
'should not pass for wrong protocol');
|
||||
Assert.ok(!widgetPageCheck('https://example.com/widget.html'),
|
||||
'should not pass for wrong protocol');
|
||||
Assert.ok(!widgetPageCheck('/wrong/widget.html'),
|
||||
'should not pass for additional path');
|
||||
Assert.ok(!widgetPageCheck('/bar.html'),
|
||||
'should not pass for reduced path');
|
||||
Assert.ok(!widgetPageCheck('http://username:password@example.com/widget.html'),
|
||||
'should not pass for userinfo');
|
||||
Assert.ok(!widgetPageCheck('http://example.com:8080/widget.html'),
|
||||
'should not pass non-default port');
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
function run_test() {
|
||||
run_next_test();
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
[DEFAULT]
|
||||
|
||||
[test_has_widget_criterion.js]
|
||||
[test_manifestSanitizer.js]
|
||||
[test_manifestHelper.js]
|
||||
[test_moziapplication.js]
|
||||
|
|
|
@ -1765,22 +1765,6 @@ nsFrameLoader::GetOwnerIsMozBrowserOrAppFrame(bool* aResult)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
nsFrameLoader::OwnerIsWidget()
|
||||
{
|
||||
nsCOMPtr<nsIMozBrowserFrame> browserFrame = do_QueryInterface(mOwnerContent);
|
||||
return browserFrame ? browserFrame->GetReallyIsWidget() : false;
|
||||
}
|
||||
|
||||
|
||||
// The xpcom getter version
|
||||
NS_IMETHODIMP
|
||||
nsFrameLoader::GetOwnerIsWidget(bool* aResult)
|
||||
{
|
||||
*aResult = OwnerIsWidget();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
nsFrameLoader::OwnerIsAppFrame()
|
||||
{
|
||||
|
|
|
@ -248,12 +248,6 @@ private:
|
|||
*/
|
||||
bool OwnerIsMozBrowserOrAppFrame();
|
||||
|
||||
/**
|
||||
* Is this a frameloader for a bona fide <iframe mozwidget>? (I.e., does the
|
||||
* frame return true for nsIMozBrowserFrame::GetReallyIsWidget()?)
|
||||
*/
|
||||
bool OwnerIsWidget();
|
||||
|
||||
/**
|
||||
* Is this a frameloader for a bona fide <iframe mozapp>? (I.e., does the
|
||||
* frame return true for nsIMozBrowserFrame::GetReallyIsApp()?)
|
||||
|
|
|
@ -102,7 +102,6 @@ GK_ATOM(anonid, "anonid")
|
|||
GK_ATOM(anonlocation, "anonlocation")
|
||||
GK_ATOM(any, "any")
|
||||
GK_ATOM(mozapp, "mozapp")
|
||||
GK_ATOM(mozwidget, "mozwidget")
|
||||
GK_ATOM(applet, "applet")
|
||||
GK_ATOM(applyImports, "apply-imports")
|
||||
GK_ATOM(applyTemplates, "apply-templates")
|
||||
|
|
|
@ -213,12 +213,6 @@ interface nsIFrameLoader : nsISupports
|
|||
*/
|
||||
readonly attribute boolean ownerIsMozBrowserOrAppFrame;
|
||||
|
||||
/**
|
||||
* Find out whether the owner content really is a widget. If this attribute
|
||||
* returns true, |ownerIsMozBrowserOrAppFrame| must return true.
|
||||
*/
|
||||
readonly attribute boolean ownerIsWidget;
|
||||
|
||||
/**
|
||||
* The last known width of the frame. Reading this property will not trigger
|
||||
* a reflow, and therefore may not reflect the current state of things. It
|
||||
|
|
|
@ -70,7 +70,6 @@ var OBSERVED_EVENTS = [
|
|||
'xpcom-shutdown',
|
||||
'audio-playback',
|
||||
'activity-done',
|
||||
'invalid-widget',
|
||||
'will-launch-app'
|
||||
];
|
||||
|
||||
|
@ -397,9 +396,6 @@ BrowserElementChild.prototype = {
|
|||
case 'xpcom-shutdown':
|
||||
this._shuttingDown = true;
|
||||
break;
|
||||
case 'invalid-widget':
|
||||
sendAsyncMsg('error', { type: 'invalid-widget' });
|
||||
break;
|
||||
case 'will-launch-app':
|
||||
// If the launcher is not visible, let's ignore the message.
|
||||
if (!docShell.isActive) {
|
||||
|
|
|
@ -177,13 +177,6 @@ BrowserElementParent::DispatchOpenWindowEvent(Element* aOpenerFrameElement,
|
|||
return BrowserElementParent::OPEN_WINDOW_IGNORED;
|
||||
}
|
||||
|
||||
// Do not dispatch a mozbrowseropenwindow event of a widget to its embedder
|
||||
nsCOMPtr<nsIMozBrowserFrame> browserFrame =
|
||||
do_QueryInterface(aOpenerFrameElement);
|
||||
if (browserFrame && browserFrame->GetReallyIsWidget()) {
|
||||
return BrowserElementParent::OPEN_WINDOW_CANCELLED;
|
||||
}
|
||||
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
bool dispatchSucceeded =
|
||||
DispatchCustomDOMEvent(aOpenerFrameElement,
|
||||
|
|
|
@ -319,9 +319,6 @@ BrowserElementParent.prototype = {
|
|||
|
||||
_setupMessageListener: function() {
|
||||
this._mm = this._frameLoader.messageManager;
|
||||
this._isWidget = this._frameLoader
|
||||
.QueryInterface(Ci.nsIFrameLoader)
|
||||
.ownerIsWidget;
|
||||
this._mm.addMessageListener('browser-element-api:call', this);
|
||||
this._mm.loadFrameScript("chrome://global/content/extensions.js", true);
|
||||
},
|
||||
|
@ -389,7 +386,7 @@ BrowserElementParent.prototype = {
|
|||
|
||||
if (aMsg.data.msg_name in mmCalls) {
|
||||
return mmCalls[aMsg.data.msg_name].apply(this, arguments);
|
||||
} else if (!this._isWidget && aMsg.data.msg_name in mmSecuritySensitiveCalls) {
|
||||
} else if (aMsg.data.msg_name in mmSecuritySensitiveCalls) {
|
||||
return mmSecuritySensitiveCalls[aMsg.data.msg_name].apply(this, arguments);
|
||||
}
|
||||
},
|
||||
|
@ -428,10 +425,8 @@ BrowserElementParent.prototype = {
|
|||
}
|
||||
};
|
||||
|
||||
// 1. We don't handle password-only prompts.
|
||||
// 2. We don't handle for widget case because of security concern.
|
||||
if (authDetail.isOnlyPassword ||
|
||||
this._frameLoader.QueryInterface(Ci.nsIFrameLoader).ownerIsWidget) {
|
||||
// We don't handle password-only prompts.
|
||||
if (authDetail.isOnlyPassword) {
|
||||
cancelCallback();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -40,16 +40,6 @@ nsBrowserElement::IsBrowserElementOrThrow(ErrorResult& aRv)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
nsBrowserElement::IsNotWidgetOrThrow(ErrorResult& aRv)
|
||||
{
|
||||
if (!mOwnerIsWidget) {
|
||||
return true;
|
||||
}
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_NODE_TYPE_ERR);
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
nsBrowserElement::InitBrowserElementAPI()
|
||||
{
|
||||
|
@ -58,8 +48,6 @@ nsBrowserElement::InitBrowserElementAPI()
|
|||
NS_ENSURE_TRUE_VOID(frameLoader);
|
||||
nsresult rv = frameLoader->GetOwnerIsMozBrowserOrAppFrame(&isMozBrowserOrApp);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
rv = frameLoader->GetOwnerIsWidget(&mOwnerIsWidget);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
|
||||
if (!isMozBrowserOrApp) {
|
||||
return;
|
||||
|
@ -149,7 +137,6 @@ nsBrowserElement::SendMouseEvent(const nsAString& aType,
|
|||
ErrorResult& aRv)
|
||||
{
|
||||
NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
|
||||
NS_ENSURE_TRUE_VOID(IsNotWidgetOrThrow(aRv));
|
||||
|
||||
nsresult rv = mBrowserElementAPI->SendMouseEvent(aType,
|
||||
aX,
|
||||
|
@ -177,7 +164,6 @@ nsBrowserElement::SendTouchEvent(const nsAString& aType,
|
|||
ErrorResult& aRv)
|
||||
{
|
||||
NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
|
||||
NS_ENSURE_TRUE_VOID(IsNotWidgetOrThrow(aRv));
|
||||
|
||||
if (aIdentifiers.Length() != aCount ||
|
||||
aXs.Length() != aCount ||
|
||||
|
@ -210,7 +196,6 @@ void
|
|||
nsBrowserElement::GoBack(ErrorResult& aRv)
|
||||
{
|
||||
NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
|
||||
NS_ENSURE_TRUE_VOID(IsNotWidgetOrThrow(aRv));
|
||||
|
||||
nsresult rv = mBrowserElementAPI->GoBack();
|
||||
|
||||
|
@ -223,7 +208,6 @@ void
|
|||
nsBrowserElement::GoForward(ErrorResult& aRv)
|
||||
{
|
||||
NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
|
||||
NS_ENSURE_TRUE_VOID(IsNotWidgetOrThrow(aRv));
|
||||
|
||||
nsresult rv = mBrowserElementAPI->GoForward();
|
||||
|
||||
|
@ -236,7 +220,6 @@ void
|
|||
nsBrowserElement::Reload(bool aHardReload, ErrorResult& aRv)
|
||||
{
|
||||
NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
|
||||
NS_ENSURE_TRUE_VOID(IsNotWidgetOrThrow(aRv));
|
||||
|
||||
nsresult rv = mBrowserElementAPI->Reload(aHardReload);
|
||||
|
||||
|
@ -249,7 +232,6 @@ void
|
|||
nsBrowserElement::Stop(ErrorResult& aRv)
|
||||
{
|
||||
NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
|
||||
NS_ENSURE_TRUE_VOID(IsNotWidgetOrThrow(aRv));
|
||||
|
||||
nsresult rv = mBrowserElementAPI->Stop();
|
||||
|
||||
|
@ -264,7 +246,6 @@ nsBrowserElement::Download(const nsAString& aUrl,
|
|||
ErrorResult& aRv)
|
||||
{
|
||||
NS_ENSURE_TRUE(IsBrowserElementOrThrow(aRv), nullptr);
|
||||
NS_ENSURE_TRUE(IsNotWidgetOrThrow(aRv), nullptr);
|
||||
|
||||
nsCOMPtr<nsIDOMDOMRequest> req;
|
||||
nsCOMPtr<nsIXPConnectWrappedJS> wrappedObj = do_QueryInterface(mBrowserElementAPI);
|
||||
|
@ -295,7 +276,6 @@ already_AddRefed<DOMRequest>
|
|||
nsBrowserElement::PurgeHistory(ErrorResult& aRv)
|
||||
{
|
||||
NS_ENSURE_TRUE(IsBrowserElementOrThrow(aRv), nullptr);
|
||||
NS_ENSURE_TRUE(IsNotWidgetOrThrow(aRv), nullptr);
|
||||
|
||||
nsCOMPtr<nsIDOMDOMRequest> req;
|
||||
nsresult rv = mBrowserElementAPI->PurgeHistory(getter_AddRefs(req));
|
||||
|
@ -315,7 +295,6 @@ nsBrowserElement::GetScreenshot(uint32_t aWidth,
|
|||
ErrorResult& aRv)
|
||||
{
|
||||
NS_ENSURE_TRUE(IsBrowserElementOrThrow(aRv), nullptr);
|
||||
NS_ENSURE_TRUE(IsNotWidgetOrThrow(aRv), nullptr);
|
||||
|
||||
nsCOMPtr<nsIDOMDOMRequest> req;
|
||||
nsresult rv = mBrowserElementAPI->GetScreenshot(aWidth, aHeight, aMimeType,
|
||||
|
@ -337,7 +316,6 @@ void
|
|||
nsBrowserElement::Zoom(float aZoom, ErrorResult& aRv)
|
||||
{
|
||||
NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
|
||||
NS_ENSURE_TRUE_VOID(IsNotWidgetOrThrow(aRv));
|
||||
|
||||
nsresult rv = mBrowserElementAPI->Zoom(aZoom);
|
||||
|
||||
|
@ -350,7 +328,6 @@ already_AddRefed<DOMRequest>
|
|||
nsBrowserElement::GetCanGoBack(ErrorResult& aRv)
|
||||
{
|
||||
NS_ENSURE_TRUE(IsBrowserElementOrThrow(aRv), nullptr);
|
||||
NS_ENSURE_TRUE(IsNotWidgetOrThrow(aRv), nullptr);
|
||||
|
||||
nsCOMPtr<nsIDOMDOMRequest> req;
|
||||
nsresult rv = mBrowserElementAPI->GetCanGoBack(getter_AddRefs(req));
|
||||
|
@ -367,7 +344,6 @@ already_AddRefed<DOMRequest>
|
|||
nsBrowserElement::GetCanGoForward(ErrorResult& aRv)
|
||||
{
|
||||
NS_ENSURE_TRUE(IsBrowserElementOrThrow(aRv), nullptr);
|
||||
NS_ENSURE_TRUE(IsNotWidgetOrThrow(aRv), nullptr);
|
||||
|
||||
nsCOMPtr<nsIDOMDOMRequest> req;
|
||||
nsresult rv = mBrowserElementAPI->GetCanGoForward(getter_AddRefs(req));
|
||||
|
@ -384,7 +360,6 @@ already_AddRefed<DOMRequest>
|
|||
nsBrowserElement::GetContentDimensions(ErrorResult& aRv)
|
||||
{
|
||||
NS_ENSURE_TRUE(IsBrowserElementOrThrow(aRv), nullptr);
|
||||
NS_ENSURE_TRUE(IsNotWidgetOrThrow(aRv), nullptr);
|
||||
|
||||
nsCOMPtr<nsIDOMDOMRequest> req;
|
||||
nsresult rv = mBrowserElementAPI->GetContentDimensions(getter_AddRefs(req));
|
||||
|
@ -403,7 +378,6 @@ nsBrowserElement::FindAll(const nsAString& aSearchString,
|
|||
ErrorResult& aRv)
|
||||
{
|
||||
NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
|
||||
NS_ENSURE_TRUE_VOID(IsNotWidgetOrThrow(aRv));
|
||||
|
||||
uint32_t caseSensitivity;
|
||||
if (aCaseSensitivity == BrowserFindCaseSensitivity::Case_insensitive) {
|
||||
|
@ -424,7 +398,6 @@ nsBrowserElement::FindNext(BrowserFindDirection aDirection,
|
|||
ErrorResult& aRv)
|
||||
{
|
||||
NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
|
||||
NS_ENSURE_TRUE_VOID(IsNotWidgetOrThrow(aRv));
|
||||
|
||||
uint32_t direction;
|
||||
if (aDirection == BrowserFindDirection::Backward) {
|
||||
|
@ -444,7 +417,6 @@ void
|
|||
nsBrowserElement::ClearMatch(ErrorResult& aRv)
|
||||
{
|
||||
NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
|
||||
NS_ENSURE_TRUE_VOID(IsNotWidgetOrThrow(aRv));
|
||||
|
||||
nsresult rv = mBrowserElementAPI->ClearMatch();
|
||||
|
||||
|
@ -633,7 +605,6 @@ already_AddRefed<DOMRequest>
|
|||
nsBrowserElement::GetMuted(ErrorResult& aRv)
|
||||
{
|
||||
NS_ENSURE_TRUE(IsBrowserElementOrThrow(aRv), nullptr);
|
||||
NS_ENSURE_TRUE(IsNotWidgetOrThrow(aRv), nullptr);
|
||||
|
||||
nsCOMPtr<nsIDOMDOMRequest> req;
|
||||
nsresult rv = mBrowserElementAPI->GetMuted(getter_AddRefs(req));
|
||||
|
@ -650,7 +621,6 @@ void
|
|||
nsBrowserElement::Mute(ErrorResult& aRv)
|
||||
{
|
||||
NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
|
||||
NS_ENSURE_TRUE_VOID(IsNotWidgetOrThrow(aRv));
|
||||
|
||||
nsresult rv = mBrowserElementAPI->Mute();
|
||||
|
||||
|
@ -663,7 +633,6 @@ void
|
|||
nsBrowserElement::Unmute(ErrorResult& aRv)
|
||||
{
|
||||
NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
|
||||
NS_ENSURE_TRUE_VOID(IsNotWidgetOrThrow(aRv));
|
||||
|
||||
nsresult rv = mBrowserElementAPI->Unmute();
|
||||
|
||||
|
@ -676,7 +645,6 @@ already_AddRefed<DOMRequest>
|
|||
nsBrowserElement::GetVolume(ErrorResult& aRv)
|
||||
{
|
||||
NS_ENSURE_TRUE(IsBrowserElementOrThrow(aRv), nullptr);
|
||||
NS_ENSURE_TRUE(IsNotWidgetOrThrow(aRv), nullptr);
|
||||
|
||||
nsCOMPtr<nsIDOMDOMRequest> req;
|
||||
nsresult rv = mBrowserElementAPI->GetVolume(getter_AddRefs(req));
|
||||
|
@ -693,7 +661,6 @@ void
|
|||
nsBrowserElement::SetVolume(float aVolume, ErrorResult& aRv)
|
||||
{
|
||||
NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
|
||||
NS_ENSURE_TRUE_VOID(IsNotWidgetOrThrow(aRv));
|
||||
|
||||
nsresult rv = mBrowserElementAPI->SetVolume(aVolume);
|
||||
|
||||
|
@ -720,7 +687,6 @@ nsBrowserElement::ExecuteScript(const nsAString& aScript,
|
|||
ErrorResult& aRv)
|
||||
{
|
||||
NS_ENSURE_TRUE(IsBrowserElementOrThrow(aRv), nullptr);
|
||||
NS_ENSURE_TRUE(IsNotWidgetOrThrow(aRv), nullptr);
|
||||
|
||||
nsCOMPtr<nsIDOMDOMRequest> req;
|
||||
nsCOMPtr<nsIXPConnectWrappedJS> wrappedObj = do_QueryInterface(mBrowserElementAPI);
|
||||
|
|
|
@ -34,7 +34,7 @@ class ErrorResult;
|
|||
class nsBrowserElement
|
||||
{
|
||||
public:
|
||||
nsBrowserElement() : mOwnerIsWidget(false) {}
|
||||
nsBrowserElement() {}
|
||||
virtual ~nsBrowserElement() {}
|
||||
|
||||
void SetVisible(bool aVisible, ErrorResult& aRv);
|
||||
|
@ -136,8 +136,6 @@ protected:
|
|||
|
||||
private:
|
||||
bool IsBrowserElementOrThrow(ErrorResult& aRv);
|
||||
bool IsNotWidgetOrThrow(ErrorResult& aRv);
|
||||
bool mOwnerIsWidget;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -507,10 +507,6 @@ nsGenericHTMLFrameElement::GetReallyIsBrowserOrApp(bool *aOut)
|
|||
uint32_t permission = nsIPermissionManager::DENY_ACTION;
|
||||
nsresult rv = permMgr->TestPermissionFromPrincipal(principal, "browser", &permission);
|
||||
NS_ENSURE_SUCCESS(rv, NS_OK);
|
||||
if (permission != nsIPermissionManager::ALLOW_ACTION) {
|
||||
rv = permMgr->TestPermissionFromPrincipal(principal, "embed-widgets", &permission);
|
||||
NS_ENSURE_SUCCESS(rv, NS_OK);
|
||||
}
|
||||
*aOut = permission == nsIPermissionManager::ALLOW_ACTION;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -527,20 +523,6 @@ nsGenericHTMLFrameElement::GetReallyIsApp(bool *aOut)
|
|||
|
||||
namespace {
|
||||
|
||||
bool WidgetsEnabled()
|
||||
{
|
||||
static bool sMozWidgetsEnabled = false;
|
||||
static bool sBoolVarCacheInitialized = false;
|
||||
|
||||
if (!sBoolVarCacheInitialized) {
|
||||
sBoolVarCacheInitialized = true;
|
||||
Preferences::AddBoolVarCache(&sMozWidgetsEnabled,
|
||||
"dom.enable_widgets");
|
||||
}
|
||||
|
||||
return sMozWidgetsEnabled;
|
||||
}
|
||||
|
||||
bool NestedEnabled()
|
||||
{
|
||||
static bool sMozNestedEnabled = false;
|
||||
|
@ -557,26 +539,6 @@ bool NestedEnabled()
|
|||
|
||||
} // namespace
|
||||
|
||||
/* [infallible] */ NS_IMETHODIMP
|
||||
nsGenericHTMLFrameElement::GetReallyIsWidget(bool *aOut)
|
||||
{
|
||||
*aOut = false;
|
||||
if (!WidgetsEnabled()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsAutoString appManifestURL;
|
||||
GetManifestURLByType(nsGkAtoms::mozapp, appManifestURL);
|
||||
bool isApp = !appManifestURL.IsEmpty();
|
||||
|
||||
nsAutoString widgetManifestURL;
|
||||
GetManifestURLByType(nsGkAtoms::mozwidget, widgetManifestURL);
|
||||
bool isWidget = !widgetManifestURL.IsEmpty();
|
||||
|
||||
*aOut = isWidget && !isApp;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* [infallible] */ NS_IMETHODIMP
|
||||
nsGenericHTMLFrameElement::GetIsolated(bool *aOut)
|
||||
{
|
||||
|
@ -591,20 +553,15 @@ nsGenericHTMLFrameElement::GetIsolated(bool *aOut)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/** Get manifest url of app or widget
|
||||
* @param AppType: nsGkAtoms::mozapp or nsGkAtoms::mozwidget
|
||||
/*
|
||||
* Get manifest url of app.
|
||||
*/
|
||||
void nsGenericHTMLFrameElement::GetManifestURLByType(nsIAtom *aAppType,
|
||||
nsAString& aManifestURL)
|
||||
void nsGenericHTMLFrameElement::GetManifestURL(nsAString& aManifestURL)
|
||||
{
|
||||
aManifestURL.Truncate();
|
||||
|
||||
if (aAppType != nsGkAtoms::mozapp && aAppType != nsGkAtoms::mozwidget) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsAutoString manifestURL;
|
||||
GetAttr(kNameSpaceID_None, aAppType, manifestURL);
|
||||
GetAttr(kNameSpaceID_None, nsGkAtoms::mozapp, manifestURL);
|
||||
if (manifestURL.IsEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
@ -613,8 +570,7 @@ void nsGenericHTMLFrameElement::GetManifestURLByType(nsIAtom *aAppType,
|
|||
nsCOMPtr<nsIPermissionManager> permMgr = services::GetPermissionManager();
|
||||
NS_ENSURE_TRUE_VOID(permMgr);
|
||||
nsIPrincipal *principal = NodePrincipal();
|
||||
const char* aPermissionType = (aAppType == nsGkAtoms::mozapp) ? "embed-apps"
|
||||
: "embed-widgets";
|
||||
const char* aPermissionType = "embed-apps";
|
||||
uint32_t permission = nsIPermissionManager::DENY_ACTION;
|
||||
nsresult rv = permMgr->TestPermissionFromPrincipal(principal,
|
||||
aPermissionType,
|
||||
|
@ -634,17 +590,6 @@ void nsGenericHTMLFrameElement::GetManifestURLByType(nsIAtom *aAppType,
|
|||
return;
|
||||
}
|
||||
|
||||
bool hasWidgetPage = false;
|
||||
nsAutoString src;
|
||||
if (aAppType == nsGkAtoms::mozwidget) {
|
||||
GetAttr(kNameSpaceID_None, nsGkAtoms::src, src);
|
||||
nsresult rv = app->HasWidgetPage(src, &hasWidgetPage);
|
||||
|
||||
if (!NS_SUCCEEDED(rv) || !hasWidgetPage) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
aManifestURL.Assign(manifestURL);
|
||||
}
|
||||
|
||||
|
@ -668,32 +613,24 @@ nsGenericHTMLFrameElement::GetAppManifestURL(nsAString& aOut)
|
|||
}
|
||||
|
||||
nsAutoString appManifestURL;
|
||||
nsAutoString widgetManifestURL;
|
||||
|
||||
GetManifestURLByType(nsGkAtoms::mozapp, appManifestURL);
|
||||
|
||||
if (WidgetsEnabled()) {
|
||||
GetManifestURLByType(nsGkAtoms::mozwidget, widgetManifestURL);
|
||||
}
|
||||
GetManifestURL(appManifestURL);
|
||||
|
||||
bool isApp = !appManifestURL.IsEmpty();
|
||||
bool isWidget = !widgetManifestURL.IsEmpty();
|
||||
|
||||
if (!isApp && !isWidget) {
|
||||
if (!isApp) {
|
||||
// No valid case to get manifest
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (isApp && isWidget) {
|
||||
NS_WARNING("Can not simultaneously be mozapp and mozwidget");
|
||||
if (isApp) {
|
||||
NS_WARNING("Can not simultaneously be mozapp");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsAutoString manifestURL;
|
||||
if (isApp) {
|
||||
manifestURL.Assign(appManifestURL);
|
||||
} else if (isWidget) {
|
||||
manifestURL.Assign(widgetManifestURL);
|
||||
}
|
||||
|
||||
aOut.Assign(manifestURL);
|
||||
|
|
|
@ -125,7 +125,7 @@ protected:
|
|||
bool mFullscreenFlag = false;
|
||||
|
||||
private:
|
||||
void GetManifestURLByType(nsIAtom *aAppType, nsAString& aOut);
|
||||
void GetManifestURL(nsAString& aOut);
|
||||
};
|
||||
|
||||
#endif // nsGenericHTMLFrameElement_h
|
||||
|
|
|
@ -19,12 +19,6 @@ interface mozIApplication: nsISupports
|
|||
/* Return true if this app has |permission|. */
|
||||
boolean hasPermission(in string permission);
|
||||
|
||||
/**
|
||||
* Return true if this app can be a widget and
|
||||
* its |widgetPages| contains |page|
|
||||
*/
|
||||
boolean hasWidgetPage(in DOMString pageURL);
|
||||
|
||||
/* Application status as defined in nsIPrincipal. */
|
||||
readonly attribute unsigned short appStatus;
|
||||
|
||||
|
|
|
@ -25,24 +25,11 @@ interface nsIMozBrowserFrame : nsIDOMMozBrowserFrame
|
|||
* Gets whether this frame really is an app frame.
|
||||
*
|
||||
* In order to really be an app frame, this frame must really be a browser
|
||||
* frame (this requirement will go away eventually), and must satisfy one
|
||||
* and only one of the following conditions:
|
||||
* 1. the frame's mozapp attribute must point to the manifest of a valid app
|
||||
* 2. the frame's mozwidget attribute must point to the manifest of a valid
|
||||
* app, and the src should be in the |widgetPages| specified by the manifest.
|
||||
* frame (this requirement will go away eventually), and the frame's mozapp
|
||||
* attribute must point to the manifest of a valid app.
|
||||
*/
|
||||
[infallible] readonly attribute boolean reallyIsApp;
|
||||
|
||||
/**
|
||||
* Gets whether this frame really is a widget frame.
|
||||
*
|
||||
* In order to really be a frame, this frame must really be a browser
|
||||
* frame (this requirement will go away eventually), the frame's mozwidget
|
||||
* attribute must point to the manifest of a valid app, and the src should
|
||||
* be in the |widgetPages| specified by the manifest.
|
||||
*/
|
||||
[infallible] readonly attribute boolean reallyIsWidget;
|
||||
|
||||
/**
|
||||
* Gets whether this frame is an isolated frame.
|
||||
*
|
||||
|
@ -58,8 +45,7 @@ interface nsIMozBrowserFrame : nsIDOMMozBrowserFrame
|
|||
[infallible] readonly attribute boolean isolated;
|
||||
|
||||
/**
|
||||
* Gets this frame's app manifest URL or widget manifest URL, if the frame
|
||||
* really is an app frame.
|
||||
* Gets this frame's app manifest URL, if the frame really is an app frame.
|
||||
* Otherwise, returns the empty string.
|
||||
*
|
||||
* This method is guaranteed not to fail.
|
||||
|
|
|
@ -965,7 +965,7 @@ pref("devtools.debugger.prompt-connection", true);
|
|||
// Block tools from seeing / interacting with certified apps
|
||||
pref("devtools.debugger.forbid-certified-apps", true);
|
||||
// List of permissions that a sideloaded app can't ask for
|
||||
pref("devtools.apps.forbidden-permissions", "embed-apps,embed-widgets");
|
||||
pref("devtools.apps.forbidden-permissions", "embed-apps");
|
||||
|
||||
// DevTools default color unit
|
||||
pref("devtools.defaultColorUnit", "authored");
|
||||
|
|
Загрузка…
Ссылка в новой задаче