Bug 983845 - Port nsIFeedWriter to WebIDL and stop exposing BrowserFeedWriter to the Web; r=bzbarsky

X-Git-Commit-ID: 487d201e67d932da2d4a73b680181072a13e35b3
This commit is contained in:
Ehsan Akhgari 2014-03-19 12:29:00 -04:00
Родитель 2566204ca3
Коммит 1ce346ca00
10 изменённых файлов: 79 добавлений и 52 удалений

Просмотреть файл

@ -11,7 +11,6 @@ var SubscribeHandler = {
init: function SH_init() {
this._feedWriter = new BrowserFeedWriter();
this._feedWriter.init(window);
},
writeContent: function SH_writeContent() {
@ -20,9 +19,5 @@ var SubscribeHandler = {
uninit: function SH_uninit() {
this._feedWriter.close();
},
subscribe: function SH_subscribe() {
this._feedWriter.subscribe();
}
};

Просмотреть файл

@ -6,7 +6,6 @@
XPIDL_SOURCES += [
'nsIFeedResultService.idl',
'nsIFeedWriter.idl',
'nsIWebContentConverterRegistrar.idl',
]

Просмотреть файл

@ -1,35 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
interface nsIDOMWindow;
/**
* Instances of this component write UI into the display page. This component
* is trusted so can access preferences etc, but page content isn't and so
* cannot.
*/
[scriptable, uuid(67003393-018c-4e96-af10-c6c51a049fad)]
interface nsIFeedWriter : nsISupports
{
/**
* Initializes the feed writer and loads the feed subscription UI.
* @param aWindow
* The DOMWindow of the preview page.
* window.location.href == the URI of the feed.
*/
void init(in nsIDOMWindow aWindow);
/**
* Writes the feed content, assumes that the feed writer is initialized.
*/
void writeContent();
/**
* Uninitialize the feed writer.
*/
void close();
};

Просмотреть файл

@ -23,7 +23,6 @@ component {1c31ed79-accd-4b94-b517-06e0c81999d5} FeedConverter.js
contract @mozilla.org/network/protocol;1?name=pcast {1c31ed79-accd-4b94-b517-06e0c81999d5}
component {49bb6593-3aff-4eb3-a068-2712c28bd58e} FeedWriter.js
contract @mozilla.org/browser/feeds/result-writer;1 {49bb6593-3aff-4eb3-a068-2712c28bd58e}
category JavaScript-global-constructor BrowserFeedWriter @mozilla.org/browser/feeds/result-writer;1
component {792a7e82-06a0-437c-af63-b2d12e808acc} WebContentConverter.js
contract @mozilla.org/embeddor.implemented/web-content-handler-registrar;1 {792a7e82-06a0-437c-af63-b2d12e808acc}
category app-startup WebContentConverter service,@mozilla.org/embeddor.implemented/web-content-handler-registrar;1 application={3c2e2abc-06d4-11e1-ac3b-374f68613e61} application={ec8030f7-c20a-464f-9b0e-13a3a9e97384} application={aa3c5121-dab2-40e2-81ca-7ea25febc110} application={a23983c0-fd0e-11dc-95ff-0800200c9a66}

Просмотреть файл

@ -1123,7 +1123,7 @@ FeedWriter.prototype = {
_feedPrincipal: null,
_handlersMenuList: null,
// nsIFeedWriter
// BrowserFeedWriter WebIDL methods
init: function FW_init(aWindow) {
var window = aWindow;
this._feedURI = this._getOriginalURI(window);
@ -1376,13 +1376,9 @@ FeedWriter.prototype = {
},
classID: FEEDWRITER_CID,
classInfo: XPCOMUtils.generateCI({classID: FEEDWRITER_CID,
contractID: FEEDWRITER_CONTRACTID,
interfaces: [Ci.nsIFeedWriter],
flags: Ci.nsIClassInfo.DOM_OBJECT}),
QueryInterface: XPCOMUtils.generateQI([Ci.nsIFeedWriter,
Ci.nsIDOMEventListener, Ci.nsIObserver,
Ci.nsINavHistoryObserver])
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMEventListener, Ci.nsIObserver,
Ci.nsINavHistoryObserver,
Ci.nsIDOMGlobalPropertyInitializer])
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([FeedWriter]);

Просмотреть файл

@ -0,0 +1,47 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "js/TypeDecls.h"
#include "nsGlobalWindow.h"
#include "nsIPrincipal.h"
#include "nsIURI.h"
#include "nsString.h"
#include "xpcpublic.h"
namespace mozilla {
struct FeedWriterEnabled {
static bool IsEnabled(JSContext* cx, JSObject* aGlobal)
{
// Make sure the global is a window
nsGlobalWindow* win = xpc::WindowGlobalOrNull(aGlobal);
if (!win) {
return false;
}
// Make sure that the principal is about:feeds.
nsCOMPtr<nsIPrincipal> principal = win->GetPrincipal();
NS_ENSURE_TRUE(principal, false);
nsCOMPtr<nsIURI> uri;
principal->GetURI(getter_AddRefs(uri));
if (!uri) {
return false;
}
// First check the scheme to avoid getting long specs in the common case.
bool isAbout = false;
uri->SchemeIs("about", &isAbout);
if (!isAbout) {
return false;
}
// Now check the spec itself
nsAutoCString spec;
uri->GetSpec(spec);
return spec.Equals("about:feeds");
}
};
}

Просмотреть файл

@ -8,6 +8,10 @@ SOURCES += [
'nsFeedSniffer.cpp',
]
EXPORTS.mozilla += [
'FeedWriterEnabled.h',
]
EXTRA_COMPONENTS += [
'BrowserFeeds.manifest',
'FeedConverter.js',

Просмотреть файл

@ -163,8 +163,6 @@ var interfaceNamesInGlobalScope =
{name: "BluetoothStatusChangedEvent", b2g: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "BoxObject", xbl: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "BrowserFeedWriter", desktop: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "CallEvent", b2g: true, pref: "dom.telephony.enabled"},
// IMPORTANT: Do not change this list without review from a DOM peer!

Просмотреть файл

@ -0,0 +1,20 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
[JSImplementation="@mozilla.org/browser/feeds/result-writer;1",
Func="mozilla::FeedWriterEnabled::IsEnabled",
Constructor]
interface BrowserFeedWriter {
/**
* Writes the feed content, assumes that the feed writer is initialized.
*/
void writeContent();
/**
* Uninitialize the feed writer.
*/
void close();
};

Просмотреть файл

@ -612,3 +612,7 @@ if CONFIG['MOZ_B2G_BT']:
'BluetoothStatusChangedEvent.webidl',
]
if CONFIG['MOZ_BUILD_APP'] in ['browser', 'xulrunner']:
WEBIDL_FILES += [
'BrowserFeedWriter.webidl',
]