This commit is contained in:
Robert Sayre 2009-12-17 04:26:12 -05:00
Родитель 171194d942 7cc2431e42
Коммит 9efb5261e9
1316 изменённых файлов: 253239 добавлений и 16372 удалений

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

@ -32,4 +32,6 @@ fb32f6e1859c07846a01b4478a7b1678019e0b45 UPDATE_PACKAGING_R7
f817a4378f32b1ad0a7c4b5a9949586dba816da5 FENNEC_M11
5c1e7c779b6edc8ff912001990edc579f80597f4 FENNEC_B1
fe9cc55b8db7f56f7e68a246acba363743854979 UPDATE_PACKAGING_R8
6fd4bb500d425c406c1b52f66e5b195b20ae5e0a chromium-import-r15462
6fd4bb500d425c406c1b52f66e5b195b20ae5e0a chromium-import-latest
376b78fc72230aaf2ca4e279a8f4ef1efd4a1d9f GECKO_1_9_2_BASE

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

@ -408,6 +408,17 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
eARIASelectable,
eARIAReadonly
},
{
"scrollbar",
nsIAccessibleRole::ROLE_SCROLLBAR,
kUseMapRole,
eHasValueMinMax,
eNoAction,
eNoLiveAttr,
kNoReqStates,
eARIAOrientation,
eARIAReadonly
},
{
"separator",
nsIAccessibleRole::ROLE_SEPARATOR,
@ -628,6 +639,11 @@ nsStateMapEntry nsARIAMap::gWAIStateMap[] = {
nsStateMapEntry(&nsAccessibilityAtoms::aria_multiselectable, kBoolType, 0,
nsIAccessibleStates::STATE_MULTISELECTABLE | nsIAccessibleStates::STATE_EXTSELECTABLE, 0),
// eARIAOrientation
nsStateMapEntry(&nsAccessibilityAtoms::aria_orientation, eUseFirstState,
"vertical", 0, nsIAccessibleStates::EXT_STATE_VERTICAL,
"horizontal", 0, nsIAccessibleStates::EXT_STATE_HORIZONTAL),
// eARIAPressed
nsStateMapEntry(&nsAccessibilityAtoms::aria_pressed, kMixedType,
nsIAccessibleStates::STATE_CHECKABLE,
@ -693,6 +709,7 @@ nsAttributeCharacteristics nsARIAMap::gWAIUnivAttrMap[] = {
{&nsAccessibilityAtoms::aria_multiline, ATTR_BYPASSOBJ | ATTR_VALTOKEN },
{&nsAccessibilityAtoms::aria_multiselectable, ATTR_BYPASSOBJ | ATTR_VALTOKEN },
{&nsAccessibilityAtoms::aria_owns, ATTR_BYPASSOBJ },
{&nsAccessibilityAtoms::aria_orientation, ATTR_VALTOKEN },
{&nsAccessibilityAtoms::aria_pressed, ATTR_BYPASSOBJ | ATTR_VALTOKEN },
{&nsAccessibilityAtoms::aria_readonly, ATTR_BYPASSOBJ | ATTR_VALTOKEN },
{&nsAccessibilityAtoms::aria_relevant, ATTR_BYPASSOBJ },
@ -749,6 +766,26 @@ nsStateMapEntry::nsStateMapEntry(nsIAtom **aAttrName,
{
}
nsStateMapEntry::nsStateMapEntry(nsIAtom **aAttrName,
EDefaultStateRule aDefaultStateRule,
const char *aValue1,
PRUint32 aState1, PRUint32 aExtraState1,
const char *aValue2,
PRUint32 aState2, PRUint32 aExtraState2,
const char *aValue3,
PRUint32 aState3, PRUint32 aExtraState3) :
attributeName(aAttrName), isToken(PR_TRUE), permanentState(0),
value1(aValue1), state1(aState1), extraState1(aExtraState1),
value2(aValue2), state2(aState2), extraState2(aExtraState2),
value3(aValue3), state3(aState3), extraState3(aExtraState3),
defaultState(0), defaultExtraState(0), definedIfAbsent(PR_TRUE)
{
if (aDefaultStateRule == eUseFirstState) {
defaultState = aState1;
defaultExtraState = aExtraState1;
}
}
PRBool
nsStateMapEntry::MapToStates(nsIContent *aContent,
PRUint32 *aState, PRUint32 *aExtraState,

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

@ -157,6 +157,12 @@ enum eStateValueType
kMixedType
};
enum EDefaultStateRule
{
//eNoDefaultState,
eUseFirstState
};
/**
* ID for state map entry, used in nsRoleMapEntry.
*/
@ -174,6 +180,7 @@ enum eStateMapEntryID
eARIAInvalid,
eARIAMultiline,
eARIAMultiSelectable,
eARIAOrientation,
eARIAPressed,
eARIAReadonly,
eARIAReadonlyOrEditable,
@ -207,6 +214,17 @@ public:
const char *aValue3 = 0, PRUint32 aState3 = 0,
PRUint32 aExtraState3 = 0);
/**
* Used for ARIA attributes having enumerated values, and where a default
* attribute state should be assumed when not supplied by the author.
*/
nsStateMapEntry(nsIAtom **aAttrName,
EDefaultStateRule aDefaultStateRule,
const char *aValue1, PRUint32 aState1, PRUint32 aExtraState1,
const char *aValue2, PRUint32 aState2, PRUint32 aExtraState2,
const char *aValue3 = 0, PRUint32 aState3 = 0,
PRUint32 aExtraState3 = 0);
/**
* Maps ARIA state map pointed by state map entry ID to accessible states.
*

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

@ -241,6 +241,7 @@ ACCESSIBILITY_ATOM(aria_level, "aria-level")
ACCESSIBILITY_ATOM(aria_live, "aria-live")
ACCESSIBILITY_ATOM(aria_multiline, "aria-multiline")
ACCESSIBILITY_ATOM(aria_multiselectable, "aria-multiselectable")
ACCESSIBILITY_ATOM(aria_orientation, "aria-orientation")
ACCESSIBILITY_ATOM(aria_owns, "aria-owns")
ACCESSIBILITY_ATOM(aria_posinset, "aria-posinset")
ACCESSIBILITY_ATOM(aria_pressed, "aria-pressed")

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

@ -79,6 +79,7 @@ const EXT_STATE_MULTI_LINE = nsIAccessibleStates.EXT_STATE_MULTI_LINE;
const EXT_STATE_SINGLE_LINE = nsIAccessibleStates.EXT_STATE_SINGLE_LINE;
const EXT_STATE_SUPPORTS_AUTOCOMPLETION =
nsIAccessibleStates.EXT_STATE_SUPPORTS_AUTOCOMPLETION;
const EXT_STATE_VERTICAL = nsIAccessibleStates.EXT_STATE_VERTICAL;
////////////////////////////////////////////////////////////////////////////////
// OS detect

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

@ -44,6 +44,7 @@ const ROLE_PUSHBUTTON = nsIAccessibleRole.ROLE_PUSHBUTTON;
const ROLE_RADIOBUTTON = nsIAccessibleRole.ROLE_RADIOBUTTON;
const ROLE_ROW = nsIAccessibleRole.ROLE_ROW;
const ROLE_ROWHEADER = nsIAccessibleRole.ROLE_ROWHEADER;
const ROLE_SCROLLBAR = nsIAccessibleRole.ROLE_SCROLLBAR;
const ROLE_SECTION = nsIAccessibleRole.ROLE_SECTION;
const ROLE_SEPARATOR = nsIAccessibleRole.ROLE_SEPARATOR;
const ROLE_SLIDER = nsIAccessibleRole.ROLE_SLIDER;

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

@ -3,6 +3,7 @@
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=481114
https://bugzilla.mozilla.org/show_bug.cgi?id=469688
https://bugzilla.mozilla.org/show_bug.cgi?id=529289
-->
<head>
<title>Test weak ARIA roles</title>
@ -63,6 +64,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=469688
for (a in abstract_roles)
testRole(abstract_roles[a], ROLE_SECTION);
// aria scrollbar
testRole("scrollbar", ROLE_SCROLLBAR);
SimpleTest.finish();
}
@ -74,6 +77,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=469688
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=481114">Mozilla Bug 481114</a>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=469688">Mozilla Bug 469688</a>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=529289">Mozilla Bug 529289</a>
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
@ -134,5 +139,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=469688
<div role="section" id="section">section</div>
<div role="sectionhead" id="sectionhead">sectionhead</div>
<!-- aria scrollbar -->
<div role="scrollbar" id="scrollbar">scrollbar</div>
</body>
</html>

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

@ -66,6 +66,7 @@
testValue("slider_vn", "5", 5, 0, 1000, 0);
testValue("slider_vnvt", "plain", 0, 0, 5, 0);
testValue("slider_vt", "hi", 0, 0, 3, 0);
testValue("scrollbar", "5", 5, 0, 1000, 0);
// Test value change events
gQueue = new eventQueue(nsIAccessibleEvent.EVENT_VALUE_CHANGE);
@ -73,6 +74,7 @@
gQueue.push(new changeValue("slider_vn", "6", undefined));
gQueue.push(new changeValue("slider_vt", undefined, "hey!"));
gQueue.push(new changeValue("slider_vnvt", "3", "sweet"));
gQueue.push(new changeValue("scrollbar", "6", undefined));
gQueue.invoke(); // Will call SimpleTest.finish();
}
@ -89,6 +91,11 @@
title=" Fire delayed value changed event for aria-valuetext changes">
Mozilla Bug 478032
</a>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=529289"
title="We dont expose new aria role 'scrollbar' and property aria-orientation">
Mozilla Bug 529289
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
@ -98,12 +105,16 @@
<!-- ARIA sliders -->
<div id="slider_vn" role="slider" aria-valuenow="5"
aria-valuemin="0" aria-valuemax="1000">slider</div>
aria-valuemin="0" aria-valuemax="1000">slider</div>
<div id="slider_vt" role="slider" aria-valuetext="hi"
aria-valuemin="0" aria-valuemax="3">greeting slider</div>
aria-valuemin="0" aria-valuemax="3">greeting slider</div>
<div id="slider_vnvt" role="slider" aria-valuenow="0" aria-valuetext="plain"
aria-valuemin="0" aria-valuemax="5">sweetness slider</div>
aria-valuemin="0" aria-valuemax="5">sweetness slider</div>
<!-- ARIA scrollbar -->
<div id="scrollbar" role="scrollbar" aria-valuenow="5"
aria-valuemin="0" aria-valuemax="1000">slider</div>
</body>
</html>

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

@ -93,6 +93,11 @@
testStates("aria_main_anchor", STATE_SELECTABLE);
testStates("aria_navigation_anchor", STATE_SELECTABLE);
// scrollbar
testStates("aria_scrollbar", 0, EXT_STATE_VERTICAL);
testStates("aria_hscrollbar", 0, EXT_STATE_HORIZONTAL);
testStates("aria_vscrollbar", 0, EXT_STATE_VERTICAL);
SimpleTest.finish();
}
@ -183,5 +188,9 @@
<a id="aria_main_anchor" role="main" name="main_anchor">main</a>
<a id="aria_navigation_anchor" role="navigation" name="nav_anchor">nav</a>
<!-- scrollbar -->
<div id="aria_scrollbar" role="scrollbar">scrollbar</a>
<div id="aria_hscrollbar" role="scrollbar" aria-orientation="horizontal">horizontal scrollbar</a>
<div id="aria_vscrollbar" role="scrollbar" aria-orientation="vertical">vertical scrollbar</a>
</body>
</html>

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

@ -311,8 +311,13 @@ pref("browser.microsummary.updateGenerators", true);
pref("browser.search.suggest.enabled", true);
pref("browser.sessionhistory.max_entries", 50);
#ifndef WINCE
pref("browser.history_expire_days", 180);
pref("browser.history_expire_days_min", 90);
#else
pref("browser.history_expire_days", 90);
pref("browser.history_expire_days_min", 45);
#endif
pref("browser.history_expire_sites", 40000);
// handle links targeting new windows
@ -898,6 +903,9 @@ pref("toolbar.customization.usesheet", true);
pref("toolbar.customization.usesheet", false);
#endif
pref("dom.ipc.plugins.enabled", false);
pref("dom.ipc.tabs.enabled", false);
#ifdef XP_WIN
#ifndef WINCE
pref("browser.taskbar.previews.enable", true);

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

@ -2292,7 +2292,7 @@ function SetPageProxyState(aState)
gLastValidURLStr = gURLBar.value;
gURLBar.addEventListener("input", UpdatePageProxyState, false);
PageProxySetIcon(gBrowser.selectedBrowser.mIconURL);
PageProxySetIcon(gBrowser.getIcon());
} else if (aState == "invalid") {
gURLBar.removeEventListener("input", UpdatePageProxyState, false);
PageProxyClearIcon();
@ -3091,10 +3091,10 @@ const BrowserSearch = {
return;
}
#endif
if (window.fullScreen)
var searchBar = this.searchBar;
if (searchBar && window.fullScreen)
FullScreen.mouseoverToggle(true);
var searchBar = this.searchBar;
if (isElementVisible(searchBar)) {
searchBar.select();
searchBar.focus();
@ -3102,7 +3102,7 @@ const BrowserSearch = {
var ss = Cc["@mozilla.org/browser/search-service;1"].
getService(Ci.nsIBrowserSearchService);
var searchForm = ss.defaultEngine.searchForm;
loadURI(searchForm, null, null, false);
openUILinkIn(searchForm, "current");
}
},
@ -3913,9 +3913,9 @@ var XULBrowserWindow = {
}
},
onLinkIconAvailable: function (aBrowser) {
onLinkIconAvailable: function (aBrowser, aIconURL) {
if (gProxyFavIcon && gBrowser.userTypedValue === null)
PageProxySetIcon(aBrowser.mIconURL); // update the favicon in the URL bar
PageProxySetIcon(aIconURL); // update the favicon in the URL bar
},
onProgressChange: function (aWebProgress, aRequest,
@ -3980,7 +3980,7 @@ var XULBrowserWindow = {
if (aWebProgress.DOMWindow == content) {
if (aRequest)
this.endDocumentLoad(aRequest, aStatus);
if (!gBrowser.mTabbedMode && !gBrowser.selectedBrowser.mIconURL)
if (!gBrowser.mTabbedMode && !gBrowser.getIcon())
gBrowser.useDefaultIcon(gBrowser.selectedTab);
}
}

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

@ -700,7 +700,7 @@
let p = this.mProgressListeners[i];
if ('onLinkIconAvailable' in p)
try {
p.onLinkIconAvailable(browser);
p.onLinkIconAvailable(browser, browser.mIconURL);
} catch (e) {
// don't inhibit other listeners
Components.utils.reportError(e);
@ -712,7 +712,7 @@
let p = this.mTabsProgressListeners[i];
if ('onLinkIconAvailable' in p)
try {
p.onLinkIconAvailable(browser);
p.onLinkIconAvailable(browser, browser.mIconURL);
} catch (e) {
// don't inhibit other listeners
Components.utils.reportError(e);
@ -722,6 +722,16 @@
</body>
</method>
<method name="getIcon">
<parameter name="aTab"/>
<body>
<![CDATA[
let browser = aTab ? this.getBrowserForTab(aTab) : this.selectedBrowser;
return browser.mIconURL;
]]>
</body>
</method>
<method name="updateIcon">
<parameter name="aTab"/>
<body>

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

@ -76,7 +76,7 @@ function test() {
}
is(newWindow.gBrowser.selectedTab.hasAttribute("busy"), true);
is(newWindow.gBrowser.selectedTab.linkedBrowser.mIconURL,iconURLSpec);
is(newWindow.gBrowser.getIcon(), iconURLSpec);
newWindow.close();
finish();
}

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

@ -316,6 +316,18 @@ BrowserGlue.prototype = {
// profile shutdown handler (contains profile cleanup routines)
_onProfileShutdown: function()
{
#ifdef WINCE
// If there's a pending update, clear cache to free up disk space.
try {
let um = Cc["@mozilla.org/updates/update-manager;1"].
getService(Ci.nsIUpdateManager);
if (um.activeUpdate && um.activeUpdate.state == "pending") {
let cacheService = Cc["@mozilla.org/network/cache-service;1"].
getService(Ci.nsICacheService);
cacheService.evictEntries(Ci.nsICache.STORE_ANYWHERE);
}
} catch (e) { }
#endif
this._shutdownPlaces();
this._idleService.removeIdleObserver(this, BOOKMARKS_BACKUP_IDLE_TIME);
this._isIdleObserver = false;

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

@ -102,7 +102,6 @@ function test() {
onSecurityChange: function() {},
onStatusChange: function() {},
onRefreshAttempted: function() {},
onLinkIconAvailable: function() {},
onStateChange: function(aBrowser, aWebProgress, aRequest, aStateFlags, aStatus) {
if (aStateFlags & (Ci.nsIWebProgressListener.STATE_STOP |
Ci.nsIWebProgressListener.STATE_IS_WINDOW)) {

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

@ -226,7 +226,7 @@ var gEngineManagerDialog = {
function onDragEngineStart(event) {
var selectedIndex = gEngineView.selectedIndex;
if (selectedIndex > 0) {
if (selectedIndex >= 0) {
event.dataTransfer.setData(ENGINE_FLAVOR, selectedIndex.toString());
event.dataTransfer.effectAllowed = "move";
}

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

@ -72,11 +72,17 @@ const Cr = Components.results;
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
const STATE_RUNNING_STR = "running";
const MAX_FILE_SIZE = 100 * 1024 * 1024; // 100 megabytes
XPCOMUtils.defineLazyServiceGetter(this, "ConsoleSvc",
"@mozilla.org/consoleservice;1", "nsIConsoleService");
XPCOMUtils.defineLazyServiceGetter(this, "ObserverSvc",
"@mozilla.org/observer-service;1", "nsIObserverService");
function debug(aMsg) {
aMsg = ("SessionStartup: " + aMsg).replace(/\S{80}/g, "$&\n");
Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService)
.logStringMessage(aMsg);
ConsoleSvc.logStringMessage(aMsg);
}
/* :::::::: The Service ::::::::::::::: */
@ -145,10 +151,8 @@ SessionStartup.prototype = {
if (this._sessionType != Ci.nsISessionStartup.NO_SESSION) {
// wait for the first browser window to open
var observerService = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
observerService.addObserver(this, "domwindowopened", true);
observerService.addObserver(this, "browser:purge-session-history", true);
ObserverSvc.addObserver(this, "domwindowopened", true);
ObserverSvc.addObserver(this, "browser:purge-session-history", true);
}
},
@ -156,23 +160,20 @@ SessionStartup.prototype = {
* Handle notifications
*/
observe: function sss_observe(aSubject, aTopic, aData) {
var observerService = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
switch (aTopic) {
case "app-startup":
observerService.addObserver(this, "final-ui-startup", true);
observerService.addObserver(this, "quit-application", true);
ObserverSvc.addObserver(this, "final-ui-startup", true);
ObserverSvc.addObserver(this, "quit-application", true);
break;
case "final-ui-startup":
observerService.removeObserver(this, "final-ui-startup");
observerService.removeObserver(this, "quit-application");
ObserverSvc.removeObserver(this, "final-ui-startup");
ObserverSvc.removeObserver(this, "quit-application");
this.init();
break;
case "quit-application":
// no reason for initializing at this point (cf. bug 409115)
observerService.removeObserver(this, "final-ui-startup");
observerService.removeObserver(this, "quit-application");
ObserverSvc.removeObserver(this, "final-ui-startup");
ObserverSvc.removeObserver(this, "quit-application");
break;
case "domwindowopened":
var window = aSubject;
@ -187,7 +188,7 @@ SessionStartup.prototype = {
this._iniString = null;
this._sessionType = Ci.nsISessionStartup.NO_SESSION;
// no need in repeating this, since startup state won't change
observerService.removeObserver(this, "browser:purge-session-history");
ObserverSvc.removeObserver(this, "browser:purge-session-history");
break;
}
},
@ -220,10 +221,8 @@ SessionStartup.prototype = {
if (aWindow.arguments && aWindow.arguments[0] &&
aWindow.arguments[0] == defaultArgs)
aWindow.arguments[0] = null;
var observerService = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
observerService.removeObserver(this, "domwindowopened");
ObserverSvc.removeObserver(this, "domwindowopened");
},
/* ........ Public API ................*/
@ -263,11 +262,9 @@ SessionStartup.prototype = {
var stateString = Cc["@mozilla.org/supports-string;1"].
createInstance(Ci.nsISupportsString);
stateString.data = this._readFile(aFile) || "";
var observerService = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
observerService.notifyObservers(stateString, "sessionstore-state-read", "");
ObserverSvc.notifyObservers(stateString, "sessionstore-state-read", "");
return stateString.data;
},
@ -284,19 +281,21 @@ SessionStartup.prototype = {
stream.init(aFile, 0x01, 0, 0);
var cvstream = Cc["@mozilla.org/intl/converter-input-stream;1"].
createInstance(Ci.nsIConverterInputStream);
cvstream.init(stream, "UTF-8", 1024, Ci.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER);
var content = "";
var fileSize = stream.available();
if (fileSize > MAX_FILE_SIZE)
throw "SessionStartup: sessionstore.js was not processed because it was too large.";
cvstream.init(stream, "UTF-8", fileSize, Ci.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER);
var data = {};
while (cvstream.readString(4096, data)) {
content += data.value;
}
cvstream.readString(fileSize, data);
var content = data.value;
cvstream.close();
return content.replace(/\r\n?/g, "\n");
}
catch (ex) { Components.utils.reportError(ex); }
return null;
},

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

@ -116,18 +116,42 @@ const CAPABILITIES = [
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
function debug(aMsg) {
aMsg = ("SessionStore: " + aMsg).replace(/\S{80}/g, "$&\n");
Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService)
.logStringMessage(aMsg);
}
__defineGetter__("NetUtil", function() {
delete this.NetUtil;
XPCOMUtils.defineLazyGetter(this, "NetUtil", function() {
Cu.import("resource://gre/modules/NetUtil.jsm");
return NetUtil;
});
XPCOMUtils.defineLazyServiceGetter(this, "ConsoleSvc",
"@mozilla.org/consoleservice;1", "nsIConsoleService");
XPCOMUtils.defineLazyServiceGetter(this, "CookieSvc",
"@mozilla.org/cookiemanager;1", "nsICookieManager2");
#ifdef MOZ_CRASH_REPORTER
XPCOMUtils.defineLazyServiceGetter(this, "CrashReporter",
"@mozilla.org/xre/app-info;1", "nsICrashReporter");
#endif
XPCOMUtils.defineLazyServiceGetter(this, "IOSvc",
"@mozilla.org/network/io-service;1", "nsIIOService");
XPCOMUtils.defineLazyServiceGetter(this, "ObserverSvc",
"@mozilla.org/observer-service;1", "nsIObserverService");
XPCOMUtils.defineLazyServiceGetter(this, "SecuritySvc",
"@mozilla.org/scriptsecuritymanager;1", "nsIScriptSecurityManager");
XPCOMUtils.defineLazyServiceGetter(this, "WindowMediator",
"@mozilla.org/appshell/window-mediator;1", "nsIWindowMediator");
XPCOMUtils.defineLazyServiceGetter(this, "WindowWatcher",
"@mozilla.org/embedcomp/window-watcher;1", "nsIWindowWatcher");
function debug(aMsg) {
aMsg = ("SessionStore: " + aMsg).replace(/\S{80}/g, "$&\n");
ConsoleSvc.logStringMessage(aMsg);
}
/* :::::::: The Service ::::::::::::::: */
function SessionStoreService() {
@ -209,11 +233,8 @@ SessionStoreService.prototype = {
getService(Ci.nsIPrefService).getBranch("browser.");
this._prefBranch.QueryInterface(Ci.nsIPrefBranch2);
this._observerService = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
OBSERVING.forEach(function(aTopic) {
this._observerService.addObserver(this, aTopic, true);
ObserverSvc.addObserver(this, aTopic, true);
}, this);
var pbs = Cc["@mozilla.org/privatebrowsing;1"].
@ -608,7 +629,7 @@ SessionStoreService.prototype = {
}
else {
// Nothing to restore, notify observers things are complete.
this._observerService.notifyObservers(null, NOTIFY_WINDOWS_RESTORED, "");
ObserverSvc.notifyObservers(null, NOTIFY_WINDOWS_RESTORED, "");
// the next delayed save request should execute immediately
this._lastSaveTime -= this._interval;
@ -1384,9 +1405,7 @@ SessionStoreService.prototype = {
let storage, storageItemCount = 0;
try {
var principal = Cc["@mozilla.org/scriptsecuritymanager;1"].
getService(Ci.nsIScriptSecurityManager).
getCodebasePrincipal(uri);
var principal = SecuritySvc.getCodebasePrincipal(uri);
// Using getSessionStorageForPrincipal instead of getSessionStorageForURI
// just to be able to pass aCreate = false, that avoids creation of the
@ -1636,7 +1655,6 @@ SessionStoreService.prototype = {
aHash[aHost][aPath][aName] = aCookie;
}
var cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager2);
// collect the cookies per window
for (var i = 0; i < aWindows.length; i++)
aWindows[i].cookies = [];
@ -1647,7 +1665,7 @@ SessionStoreService.prototype = {
var MAX_EXPIRY = Math.pow(2, 62);
aWindows.forEach(function(aWindow) {
for (var host in aWindow._hosts) {
var list = cm.getCookiesFromHost(host);
var list = CookieSvc.getCookiesFromHost(host);
while (list.hasMoreElements()) {
var cookie = list.getNext().QueryInterface(Ci.nsICookie2);
if (cookie.isSession && _this._checkPrivacyLevel(cookie.isSecure)) {
@ -1771,7 +1789,10 @@ SessionStoreService.prototype = {
if (activeWindow) {
this.activeWindowSSiCache = activeWindow.__SSi || "";
}
ix = this.activeWindowSSiCache ? windows.indexOf(this.activeWindowSSiCache) : -1;
ix = windows.indexOf(this.activeWindowSSiCache);
// We don't want to restore focus to a minimized window.
if (ix != -1 && total[ix].sizemode == "minimized")
ix = -1;
return { windows: total, selectedWindow: ix + 1, _closedWindows: lastClosedWindowsCopy };
},
@ -2160,19 +2181,17 @@ SessionStoreService.prototype = {
_deserializeHistoryEntry: function sss_deserializeHistoryEntry(aEntry, aIdMap) {
var shEntry = Cc["@mozilla.org/browser/session-history-entry;1"].
createInstance(Ci.nsISHEntry);
var ioService = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
shEntry.setURI(ioService.newURI(aEntry.url, null, null));
shEntry.setURI(IOSvc.newURI(aEntry.url, null, null));
shEntry.setTitle(aEntry.title || aEntry.url);
if (aEntry.subframe)
shEntry.setIsSubFrame(aEntry.subframe || false);
shEntry.loadType = Ci.nsIDocShellLoadInfo.loadHistory;
if (aEntry.contentType)
shEntry.contentType = aEntry.contentType;
if (aEntry.referrer)
shEntry.referrerURI = ioService.newURI(aEntry.referrer, null, null);
if (aEntry.referrer)
shEntry.referrerURI = IOSvc.newURI(aEntry.referrer, null, null);
if (aEntry.cacheKey) {
var cacheKey = Cc["@mozilla.org/supports-PRUint32;1"].
createInstance(Ci.nsISupportsPRUint32);
@ -2224,10 +2243,8 @@ SessionStoreService.prototype = {
shEntry.owner = binaryStream.readObject(true);
} catch (ex) { debug(ex); }
} else if (aEntry.ownerURI) { // Firefox 2
var uriObj = ioService.newURI(aEntry.ownerURI, null, null);
shEntry.owner = Cc["@mozilla.org/scriptsecuritymanager;1"].
getService(Ci.nsIScriptSecurityManager).
getCodebasePrincipal(uriObj);
var uriObj = IOSvc.newURI(aEntry.ownerURI, null, null);
shEntry.owner = SecuritySvc.getCodebasePrincipal(uriObj);
}
if (aEntry.children && shEntry instanceof Ci.nsISHContainer) {
@ -2250,9 +2267,8 @@ SessionStoreService.prototype = {
* A tab's docshell (containing the sessionStorage)
*/
_deserializeSessionStorage: function sss_deserializeSessionStorage(aStorageData, aDocShell) {
let ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
for (let url in aStorageData) {
let uri = ioService.newURI(url, null, null);
let uri = IOSvc.newURI(url, null, null);
let storage = aDocShell.getSessionStorageForURI(uri);
for (let key in aStorageData[url]) {
try {
@ -2498,15 +2514,15 @@ SessionStoreService.prototype = {
}
aCookies = converted;
}
var cookieManager = Cc["@mozilla.org/cookiemanager;1"].
getService(Ci.nsICookieManager2);
// MAX_EXPIRY should be 2^63-1, but JavaScript can't handle that precision
var MAX_EXPIRY = Math.pow(2, 62);
for (i = 0; i < aCookies.length; i++) {
var cookie = aCookies[i];
try {
cookieManager.add(cookie.host, cookie.path || "", cookie.name || "", cookie.value, !!cookie.secure, !!cookie.httponly, true, "expiry" in cookie ? cookie.expiry : MAX_EXPIRY);
CookieSvc.add(cookie.host, cookie.path || "", cookie.name || "",
cookie.value, !!cookie.secure, !!cookie.httponly, true,
"expiry" in cookie ? cookie.expiry : MAX_EXPIRY);
}
catch (ex) { Cu.reportError(ex); } // don't let a single cookie stop recovering
}
@ -2578,8 +2594,7 @@ SessionStoreService.prototype = {
// parentheses are for backwards compatibility with Firefox 2.0 and 3.0
stateString.data = "(" + this._toJSONString(aStateObj) + ")";
this._observerService.notifyObservers(stateString,
"sessionstore-state-write", "");
ObserverSvc.notifyObservers(stateString, "sessionstore-state-write", "");
// don't touch the file if an observer has deleted all state data
if (stateString.data)
@ -2615,9 +2630,7 @@ SessionStoreService.prototype = {
* Callback each window is passed to
*/
_forEachBrowserWindow: function sss_forEachBrowserWindow(aFunc) {
var windowMediator = Cc["@mozilla.org/appshell/window-mediator;1"].
getService(Ci.nsIWindowMediator);
var windowsEnum = windowMediator.getEnumerator("navigator:browser");
var windowsEnum = WindowMediator.getEnumerator("navigator:browser");
while (windowsEnum.hasMoreElements()) {
var window = windowsEnum.getNext();
@ -2632,10 +2645,7 @@ SessionStoreService.prototype = {
* @returns Window reference
*/
_getMostRecentBrowserWindow: function sss_getMostRecentBrowserWindow() {
var wm = Cc["@mozilla.org/appshell/window-mediator;1"].
getService(Ci.nsIWindowMediator);
var win = wm.getMostRecentWindow("navigator:browser");
var win = WindowMediator.getMostRecentWindow("navigator:browser");
if (!win)
return null;
if (!win.closed)
@ -2643,7 +2653,7 @@ SessionStoreService.prototype = {
#ifdef BROKEN_WM_Z_ORDER
win = null;
var windowsEnum = wm.getEnumerator("navigator:browser");
var windowsEnum = WindowMediator.getEnumerator("navigator:browser");
// this is oldest to newest, so this gets a bit ugly
while (windowsEnum.hasMoreElements()) {
let nextWin = windowsEnum.getNext();
@ -2652,7 +2662,8 @@ SessionStoreService.prototype = {
}
return win;
#else
var windowsEnum = wm.getZOrderDOMWindowEnumerator("navigator:browser", true);
var windowsEnum =
WindowMediator.getZOrderDOMWindowEnumerator("navigator:browser", true);
while (windowsEnum.hasMoreElements()) {
win = windowsEnum.getNext();
if (!win.closed)
@ -2691,17 +2702,24 @@ SessionStoreService.prototype = {
createInstance(Ci.nsISupportsString);
argString.data = "";
//XXXzeniko shouldn't it be possible to set the window's dimensions here (as feature)?
var window = Cc["@mozilla.org/embedcomp/window-watcher;1"].
getService(Ci.nsIWindowWatcher).
openWindow(null, this._prefBranch.getCharPref("chromeURL"), "_blank",
"chrome,dialog=no,all", argString);
// Build feature string
let features = "chrome,dialog=no,all";
let winState = aState.windows[0];
WINDOW_ATTRIBUTES.forEach(function(aFeature) {
// Use !isNaN as an easy way to ignore sizemode and check for numbers
if (aFeature in winState && !isNaN(winState[aFeature]))
features += "," + aFeature + "=" + winState[aFeature];
});
var window =
WindowWatcher.openWindow(null, this._prefBranch.getCharPref("chromeURL"),
"_blank", features, argString);
do {
var ID = "window" + Math.random();
} while (ID in this._statesToRestore);
this._statesToRestore[(window.__SS_restoreID = ID)] = aState;
return window;
},
@ -2793,36 +2811,30 @@ SessionStoreService.prototype = {
* @returns nsIURI
*/
_getURIFromString: function sss_getURIFromString(aString) {
var ioService = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
return ioService.newURI(aString, null, null);
return IOSvc.newURI(aString, null, null);
},
/**
* Annotate a breakpad crash report with the currently selected tab's URL.
*/
_updateCrashReportURL: function sss_updateCrashReportURL(aWindow) {
if (!Ci.nsICrashReporter) {
// if breakpad isn't built, don't bother next time at all
this._updateCrashReportURL = function(aWindow) {};
return;
}
#ifdef MOZ_CRASH_REPORTER
try {
var currentURI = aWindow.gBrowser.currentURI.clone();
// if the current URI contains a username/password, remove it
try {
currentURI.userPass = "";
}
try {
currentURI.userPass = "";
}
catch (ex) { } // ignore failures on about: URIs
var cr = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsICrashReporter);
cr.annotateCrashReport("URL", currentURI.spec);
CrashReporter.annotateCrashReport("URL", currentURI.spec);
}
catch (ex) {
// don't make noise when crashreporter is built but not enabled
if (ex.result != Components.results.NS_ERROR_NOT_INITIALIZED)
debug(ex);
}
#endif
},
/**
@ -2896,7 +2908,7 @@ SessionStoreService.prototype = {
this._restoreCount--;
if (this._restoreCount == 0) {
// This was the last window restored at startup, notify observers.
this._observerService.notifyObservers(null,
ObserverSvc.notifyObservers(null,
this._browserSetState ? NOTIFY_BROWSER_STATE_RESTORED : NOTIFY_WINDOWS_RESTORED,
"");
this._browserSetState = false;
@ -2977,9 +2989,9 @@ SessionStoreService.prototype = {
var self = this;
NetUtil.asyncCopy(istream, ostream, function(rc) {
if (Components.isSuccessCode(rc)) {
self._observerService.notifyObservers(null,
"sessionstore-state-write-complete",
"");
ObserverSvc.notifyObservers(null,
"sessionstore-state-write-complete",
"");
}
});
}

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

@ -110,6 +110,7 @@ _BROWSER_TEST_FILES = \
browser_495495.js \
browser_514751.js \
browser_522545.js \
browser_524745.js \
browser_528776.js \
$(NULL)

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

@ -443,7 +443,29 @@ function test() {
newWin.BrowserTryToCloseWindow();
newWin2.BrowserTryToCloseWindow();
browserWindowsCount([0, 1], "browser windows while running testOpenCloseRestoreFromPopup");
newWin = undoCloseWindow(0);
newWin.addEventListener("load", function () {
info(["testOpenCloseRestoreFromPopup: newWin loaded", newWin.closed, newWin.document]);
var ds = newWin.delayedStartup;
newWin.delayedStartup = function () {
info(["testOpenCloseRestoreFromPopup: newWin delayedStartup", newWin.closed, newWin.document]);
ds.apply(newWin, arguments);
};
}, false);
newWin.addEventListener("unload", function () {
info("testOpenCloseRestoreFromPopup: newWin unloaded");
/*
var data;
try {
data = Cc["@mozilla.org/browser/sessionstore;1"]
.getService(Ci.nsISessionStore)
.getWindowState(newWin);
} catch (e) { }
ok(!data, "getWindowState should not have data about newWin");
*/
}, false);
newWin2 = openDialog(location, "_blank", CHROME_FEATURES);
newWin2.addEventListener("load", function() {
@ -454,10 +476,20 @@ function test() {
is(TEST_URLS.indexOf(newWin2.gBrowser.browsers[0].currentURI.spec), -1,
"Did not restore, as undoCloseWindow() was last called (2)");
browserWindowsCount([2, 3], "browser windows while running testOpenCloseRestoreFromPopup");
info([newWin.closed, newWin.__SSi, newWin.__SS_restoreID, newWin.__SS_dyingCache]);
// Cleanup
newWin.close();
newWin2.close();
info([newWin.closed, newWin.__SSi, newWin.__SS_restoreID, newWin.__SS_dyingCache]);
browserWindowsCount([0, 1], "browser windows while running testOpenCloseRestoreFromPopup");
info([newWin.closed, newWin.__SSi, newWin.__SS_restoreID, newWin.__SS_dyingCache]);
// Next please
executeSoon(nextFn);
});
@ -536,7 +568,7 @@ function test() {
browserWindowsCount([0, 1], "browser windows after testOpenCloseWindowAndPopup");
testOpenCloseOnlyPopup(function () {
browserWindowsCount([0, 1], "browser windows after testOpenCloseOnlyPopup");
testOpenCloseRestoreFromPopup (function () {
testOpenCloseRestoreFromPopup(function () {
browserWindowsCount([0, 1], "browser windows after testOpenCloseRestoreFromPopup");
testNotificationCount(function () {
cleanupTestsuite();

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

@ -0,0 +1,98 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is sessionstore test code.
*
* The Initial Developer of the Original Code is
* Mozilla Corporation.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Paul OShannessy <paul@oshannessy.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
function browserWindowsCount() {
let count = 0;
let e = Cc["@mozilla.org/appshell/window-mediator;1"]
.getService(Ci.nsIWindowMediator)
.getEnumerator("navigator:browser");
while (e.hasMoreElements()) {
if (!e.getNext().closed)
++count;
}
return count;
}
function test() {
/** Test for Bug 524745 **/
is(browserWindowsCount(), 1, "Only one browser window should be open initially");
let ss = Cc["@mozilla.org/browser/sessionstore;1"].
getService(Ci.nsISessionStore);
let ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
getService(Ci.nsIWindowWatcher);
let uniqKey = "bug524745";
let uniqVal = Date.now();
waitForExplicitFinish();
let window_B = openDialog(location, "_blank", "chrome,all,dialog=no");
window_B.addEventListener("load", function(aEvent) {
window_B.removeEventListener("load", arguments.callee, false);
waitForFocus(function() {
// Add identifying information to window_B
ss.setWindowValue(window_B, uniqKey, uniqVal);
let state = JSON.parse(ss.getBrowserState());
let selectedWindow = state.windows[state.selectedWindow - 1];
is(selectedWindow.extData && selectedWindow.extData[uniqKey], uniqVal,
"selectedWindow is window_B");
// Now minimize window_B. The selected window shouldn't have the secret data
window_B.minimize();
waitForFocus(function() {
state = JSON.parse(ss.getBrowserState());
selectedWindow = state.windows[state.selectedWindow - 1];
ok(!selectedWindow.extData || !selectedWindow.extData[uniqKey],
"selectedWindow is not window_B after minimizing it");
// Now minimize the last open window (assumes no other tests left windows open)
window.minimize();
state = JSON.parse(ss.getBrowserState());
is(state.selectedWindow, 0,
"selectedWindow should be 0 when all windows are minimized");
// Cleanup
window.restore();
window_B.close();
is(browserWindowsCount(), 1,
"Only one browser window should be open eventually");
finish();
});
}, window_B);
}, false);
}

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

@ -341,7 +341,7 @@ var WinTaskbarJumpList =
createInstance(Ci.nsILocalHandlerApp);
handlerApp.executable = file;
// handlers default to the leaf name if a name is not specified
if (name.length != 0)
if (name && name.length != 0)
handlerApp.name = name;
handlerApp.detailedDescription = description;
handlerApp.appendParameter(args);

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

@ -517,9 +517,9 @@ TabWindow.prototype = {
},
onStatusChange: function () {
},
onLinkIconAvailable: function (aBrowser) {
onLinkIconAvailable: function (aBrowser, aIconURL) {
let self = this;
getFaviconAsImage(aBrowser.mIconURL, function (img) {
getFaviconAsImage(aIconURL, function (img) {
let index = self.tabbrowser.browsers.indexOf(aBrowser);
// Only add it if we've found the index. The tab could have closed!
if (index != -1)

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

@ -50,6 +50,9 @@
#else
@BINPATH@/@DLL_PREFIX@xul@DLL_SUFFIX@
#endif
#ifdef MOZ_IPC
@BINPATH@/mozilla-runtime@BIN_SUFFIX@
#endif
#ifdef WINCE
@BINPATH@/mozce_shunt.dll
#elifdef XP_WIN32

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

@ -556,6 +556,9 @@ toolbar[mode="full"] .toolbarbutton-menubutton-button {
#home-button {
list-style-image: url("moz-icon://stock/gtk-home?size=toolbar");
}
#home-button[disabled="true"] {
list-style-image: url("moz-icon://stock/gtk-home?size=toolbar&state=disabled");
}
#downloads-button {
-moz-image-region: rect(0px 24px 24px 0px);
@ -678,6 +681,10 @@ toolbar[iconsize="small"] #home-button ,
#home-button.bookmark-item {
list-style-image: url("moz-icon://stock/gtk-home?size=menu");
}
toolbar[iconsize="small"] #home-button[disabled="true"],
#home-button.bookmark-item[disabled="true"] {
list-style-image: url("moz-icon://stock/gtk-home?size=menu&state=disabled");
}
toolbar[iconsize="small"] #downloads-button {
-moz-image-region: rect(0px 16px 16px 0px);

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

@ -582,6 +582,9 @@ toolbar[iconsize="small"] #unified-back-forward-button > #back-forward-dropmarke
#home-button {
-moz-image-region: rect(0px, 180px, 23px, 144px);
}
#home-button[disabled="true"] {
-moz-image-region: rect(23px, 180px, 46px, 144px) !important;
}
#home-button:hover:active {
-moz-image-region: rect(46px, 180px, 69px, 144px);
}

Двоичные данные
browser/themes/winstripe/browser/Toolbar-aero.png Normal file → Executable file

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 49 KiB

После

Ширина:  |  Высота:  |  Размер: 44 KiB

Двоичные данные
browser/themes/winstripe/browser/Toolbar-small-aero.png Normal file → Executable file

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 20 KiB

После

Ширина:  |  Высота:  |  Размер: 16 KiB

Двоичные данные
browser/themes/winstripe/browser/Toolbar-small.png Normal file → Executable file

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 26 KiB

После

Ширина:  |  Высота:  |  Размер: 22 KiB

Двоичные данные
browser/themes/winstripe/browser/Toolbar.png Normal file → Executable file

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 48 KiB

После

Ширина:  |  Высота:  |  Размер: 43 KiB

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

@ -404,6 +404,9 @@ toolbar[iconsize="small"][mode="icons"] #back-forward-dropmarker:not([disabled="
#home-button:hover {
-moz-image-region: rect(24px 120px 48px 96px);
}
#home-button[disabled="true"] {
-moz-image-region: rect(48px 120px 72px 96px);
}
/* download manager button */
@ -599,6 +602,10 @@ toolbar[iconsize="small"] #home-button:hover,
#home-button.bookmark-item:hover {
-moz-image-region: rect(16px 80px 32px 64px);
}
toolbar[iconsize="small"] #home-button[disabled="true"],
#home-button.bookmark-item[disabled="true"] {
-moz-image-region: rect(32px 80px 48px 64px);
}
/* download manager button */

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

@ -49,6 +49,7 @@ import signal
import subprocess
import sys
import threading
import tempfile
from automationutils import checkForCrashes
@ -456,6 +457,7 @@ if IS_WIN32:
import ctypes, time, msvcrt
PeekNamedPipe = ctypes.windll.kernel32.PeekNamedPipe
GetLastError = ctypes.windll.kernel32.GetLastError
def readWithTimeout(f, timeout):
"""Try to read a line of output from the file object |f|.
|f| must be a pipe, like the |stdout| member of a subprocess.Popen
@ -482,7 +484,32 @@ if IS_WIN32:
return (f.readline(), False)
time.sleep(0.01)
return ('', True)
def isPidAlive(pid):
STILL_ACTIVE = 259
PROCESS_QUERY_LIMITED_INFORMATION = 0x1000
pHandle = ctypes.windll.kernel32.OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, 0, pid)
if not pHandle:
return False
pExitCode = ctypes.wintypes.DWORD()
ctypes.windll.kernel32.GetExitCodeProcess(pHandle, ctypes.byref(pExitCode))
ctypes.windll.kernel32.CloseHandle(pHandle)
if (pExitCode.value == STILL_ACTIVE):
return True
else:
return False
def killPid(pid):
PROCESS_TERMINATE = 0x0001
pHandle = ctypes.windll.kernel32.OpenProcess(PROCESS_TERMINATE, 0, pid)
if not pHandle:
return
success = ctypes.windll.kernel32.TerminateProcess(pHandle, 1)
ctypes.windll.kernel32.CloseHandle(pHandle)
else:
import errno
def readWithTimeout(f, timeout):
"""Try to read a line of output from the file object |f|. If no output
is received within |timeout| seconds, return a blank line.
@ -493,6 +520,29 @@ else:
return ('', True)
return (f.readline(), False)
def isPidAlive(pid):
try:
# kill(pid, 0) checks for a valid PID without actually sending a signal
# The method throws OSError if the PID is invalid, which we catch below.
os.kill(pid, 0)
# Wait on it to see if it's a zombie. This can throw OSError.ECHILD if
# the process terminates before we get to this point.
wpid, wstatus = os.waitpid(pid, os.WNOHANG)
if wpid == 0:
return True
return False
except OSError, err:
# Catch the errors we might expect from os.kill/os.waitpid,
# and re-raise any others
if err.errno == errno.ESRCH or err.errno == errno.ECHILD:
return False
raise
def killPid(pid):
os.kill(pid, signal.SIGKILL)
def triggerBreakpad(proc, utilityPath):
"""Attempt to kill this process in a way that triggers Breakpad crash
reporting, if we know how for this platform. Otherwise just .kill() it."""
@ -524,6 +574,9 @@ def runApp(testURL, env, app, profileDir, extraArgs,
# copy env so we don't munge the caller's environment
env = dict(env);
env["NO_EM_RESTART"] = "1"
tmpfd, processLog = tempfile.mkstemp(suffix='pidlog')
os.close(tmpfd)
env["MOZ_PROCESS_LOG"] = processLog
if IS_TEST_BUILD and runSSLTunnel:
# create certificate database for the profile
@ -614,6 +667,28 @@ def runApp(testURL, env, app, profileDir, extraArgs,
log.info("TEST-UNEXPECTED-FAIL | automation.py | Stack fixer process exited with code %d during test run", fixerStatus)
log.info("INFO | automation.py | Application ran for: %s", str(datetime.now() - startTime))
# Do a final check for zombie child processes.
if not os.path.exists(processLog):
log.info('INFO | automation.py | PID log not found: %s', processLog)
else:
log.info('INFO | automation.py | Reading PID log: %s', processLog)
processList = []
pidRE = re.compile(r'launched child process (\d+)$')
processLogFD = open(processLog)
for line in processLogFD:
log.info(line.rstrip())
m = pidRE.search(line)
if m:
processList.append(int(m.group(1)))
processLogFD.close()
os.unlink(processLog)
for processPID in processList:
log.info("INFO | automation.py | Checking for orphan process with PID: %d", processPID)
if isPidAlive(processPID):
log.info("TEST-UNEXPECTED-FAIL | automation.py | child process %d still alive after shutdown", processPID)
killPid(processPID)
if checkForCrashes(os.path.join(profileDir, "minidumps"), symbolsPath):
status = -1

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

@ -200,17 +200,11 @@ def dumpLeakLog(leakLogFile, filter = False):
# Simply copy the log.
log.info(leakReport.rstrip("\n"))
def processLeakLog(leakLogFile, leakThreshold = 0):
"""Process the leak log, parsing it.
Use this function if you want an additional PASS/FAIL summary.
It must be used with the |XPCOM_MEM_BLOAT_LOG| environment variable.
def processSingleLeakFile(leakLogFileName, PID, processType, leakThreshold):
"""Process a single leak log, corresponding to the specified
process PID and type.
"""
if not os.path.exists(leakLogFile):
log.info("WARNING | automationutils.processLeakLog() | refcount logging is off, so leaks can't be detected!")
return
# Per-Inst Leaked Total Rem ...
# 0 TOTAL 17 192 419115886 2 ...
# 833 nsTimerImpl 60 120 24726 2 ...
@ -218,7 +212,10 @@ def processLeakLog(leakLogFile, leakThreshold = 0):
r"(?P<size>-?\d+)\s+(?P<bytesLeaked>-?\d+)\s+"
r"-?\d+\s+(?P<numLeaked>-?\d+)")
leaks = open(leakLogFile, "r")
processString = ""
if PID and processType:
processString = "| %s process %s " % (processType, PID)
leaks = open(leakLogFileName, "r")
for line in leaks:
matches = lineRe.match(line)
if (matches and
@ -228,10 +225,13 @@ def processLeakLog(leakLogFile, leakThreshold = 0):
log.info(line.rstrip())
leaks.close()
leaks = open(leakLogFile, "r")
leaks = open(leakLogFileName, "r")
seenTotal = False
crashedOnPurpose = False
prefix = "TEST-PASS"
for line in leaks:
if line.find("purposefully crash") > -1:
crashedOnPurpose = True
matches = lineRe.match(line)
if not matches:
continue
@ -240,7 +240,8 @@ def processLeakLog(leakLogFile, leakThreshold = 0):
bytesLeaked = int(matches.group("bytesLeaked"))
numLeaked = int(matches.group("numLeaked"))
if size < 0 or bytesLeaked < 0 or numLeaked < 0:
log.info("TEST-UNEXPECTED-FAIL | automationutils.processLeakLog() | negative leaks caught!")
log.info("TEST-UNEXPECTED-FAIL %s| automationutils.processLeakLog() | negative leaks caught!" %
processString)
if name == "TOTAL":
seenTotal = True
elif name == "TOTAL":
@ -248,13 +249,14 @@ def processLeakLog(leakLogFile, leakThreshold = 0):
# Check for leaks.
if bytesLeaked < 0 or bytesLeaked > leakThreshold:
prefix = "TEST-UNEXPECTED-FAIL"
leakLog = "TEST-UNEXPECTED-FAIL | automationutils.processLeakLog() | leaked" \
" %d bytes during test execution" % bytesLeaked
leakLog = "TEST-UNEXPECTED-FAIL %s| automationutils.processLeakLog() | leaked" \
" %d bytes during test execution" % (processString, bytesLeaked)
elif bytesLeaked > 0:
leakLog = "TEST-PASS | automationutils.processLeakLog() | WARNING leaked" \
" %d bytes during test execution" % bytesLeaked
leakLog = "TEST-PASS %s| automationutils.processLeakLog() | WARNING leaked" \
" %d bytes during test execution" % (processString, bytesLeaked)
else:
leakLog = "TEST-PASS | automationutils.processLeakLog() | no leaks detected!"
leakLog = "TEST-PASS %s| automationutils.processLeakLog() | no leaks detected!" \
% processString
# Remind the threshold if it is not 0, which is the default/goal.
if leakThreshold != 0:
leakLog += " (threshold set at %d bytes)" % leakThreshold
@ -268,14 +270,50 @@ def processLeakLog(leakLogFile, leakThreshold = 0):
else:
instance = "instance"
rest = ""
log.info("%(prefix)s | automationutils.processLeakLog() | leaked %(numLeaked)d %(instance)s of %(name)s "
log.info("%(prefix)s %(process)s| automationutils.processLeakLog() | leaked %(numLeaked)d %(instance)s of %(name)s "
"with size %(size)s bytes%(rest)s" %
{ "prefix": prefix,
"process": processString,
"numLeaked": numLeaked,
"instance": instance,
"name": name,
"size": matches.group("size"),
"rest": rest })
if not seenTotal:
log.info("TEST-UNEXPECTED-FAIL | automationutils.processLeakLog() | missing output line for total leaks!")
if crashedOnPurpose:
log.info("INFO | automationutils.processLeakLog() | process %s was " \
"deliberately crashed and thus has no leak log" % PID)
else:
log.info("TEST-UNEXPECTED-FAIL %s| automationutils.processLeakLog() | missing output line for total leaks!" %
processString)
leaks.close()
def processLeakLog(leakLogFile, leakThreshold = 0):
"""Process the leak log, including separate leak logs created
by child processes.
Use this function if you want an additional PASS/FAIL summary.
It must be used with the |XPCOM_MEM_BLOAT_LOG| environment variable.
"""
if not os.path.exists(leakLogFile):
log.info("WARNING | automationutils.processLeakLog() | refcount logging is off, so leaks can't be detected!")
return
(leakLogFileDir, leakFileBase) = os.path.split(leakLogFile)
pidRegExp = re.compile(r".*?_([a-z]*)_pid(\d*)$")
if leakFileBase[-4:] == ".log":
leakFileBase = leakFileBase[:-4]
pidRegExp = re.compile(r".*?_([a-z]*)_pid(\d*).log$")
for fileName in os.listdir(leakLogFileDir):
if fileName.find(leakFileBase) != -1:
thisFile = os.path.join(leakLogFileDir, fileName)
processPID = 0
processType = None
m = pidRegExp.search(fileName)
if m:
processType = m.group(1)
processPID = m.group(2)
processSingleLeakFile(thisFile, processPID, processType, leakThreshold)

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

@ -59,6 +59,9 @@ echo ""
echo " -d debugger Debugger to use."
echo " --debugger debugger"
echo ""
echo " -a debugger_args Arguments passed to [debugger]."
echo " --debugger-args debugger_args"
echo ""
echo " Examples:"
echo ""
echo " Run the mozilla-bin binary"
@ -68,6 +71,10 @@ echo ""
echo " Debug the mozilla-bin binary in gdb"
echo ""
echo " ${cmdname} -g mozilla-bin -d gdb"
echo ""
echo " Run mozilla-bin under valgrind with arguments"
echo ""
echo " ${cmdname} -g -d valgrind -a '--tool=memcheck --leak-check=full' mozilla-bin"
echo ""
return 0
}
@ -162,16 +169,16 @@ moz_debug_program()
# If you are not using ddd, gdb and know of a way to convey the arguments
# over to the prog then add that here- Gagan Saksena 03/15/00
case `basename $debugger` in
gdb) echo "$debugger --args $prog" ${1+"$@"}
exec "$debugger" --args "$prog" ${1+"$@"}
gdb) echo "$debugger $moz_debugger_args --args $prog" ${1+"$@"}
exec "$debugger" $moz_debugger_args --args "$prog" ${1+"$@"}
exitcode=$?
;;
ddd) echo "$debugger --gdb -- --args $prog" ${1+"$@"}
exec "$debugger" --gdb -- --args "$prog" ${1+"$@"}
ddd) echo "$debugger $moz_debugger_args --gdb -- --args $prog" ${1+"$@"}
exec "$debugger" $moz_debugger_args --gdb -- --args "$prog" ${1+"$@"}
exitcode=$?
;;
*) echo "$debugger $prog ${1+"$@"}"
exec $debugger "$prog" ${1+"$@"}
*) echo "$debugger $moz_debugger_args $prog ${1+"$@"}"
exec $debugger $moz_debugger_args "$prog" ${1+"$@"}
exitcode=$?
;;
esac
@ -185,6 +192,7 @@ moz_debug_program()
##
moz_debug=0
moz_debugger=""
moz_debugger_args=""
#
##
## Parse the command line
@ -205,6 +213,15 @@ do
exit 1
fi
;;
-a | --debugger-args)
moz_debugger_args=$2;
if [ "${moz_debugger_args}" != "" ]; then
shift 2
else
echo "-a requires an argument"
exit 1
fi
;;
*)
break;
;;
@ -363,6 +380,7 @@ then
echo " MOZ_TOOLKIT=$MOZ_TOOLKIT"
echo " moz_debug=$moz_debug"
echo " moz_debugger=$moz_debugger"
echo "moz_debugger_args=$moz_debugger_args"
fi
#
export MOZILLA_FIVE_HOME LD_LIBRARY_PATH

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

@ -104,6 +104,8 @@ MOZ_EXTENSIONS = @MOZ_EXTENSIONS@
MOZ_IMG_DECODERS= @MOZ_IMG_DECODERS@
MOZ_IMG_ENCODERS= @MOZ_IMG_ENCODERS@
MOZ_JSDEBUGGER = @MOZ_JSDEBUGGER@
MOZ_IPC = @MOZ_IPC@
MOZ_IPDL_TESTS = @MOZ_IPDL_TESTS@
MOZ_LEAKY = @MOZ_LEAKY@
MOZ_MEMORY = @MOZ_MEMORY@
MOZ_JPROF = @MOZ_JPROF@

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

@ -466,11 +466,7 @@ case "$target" in
WINVER=500
;;
*)
if test -n "$GNU_CC"; then
WINVER=501
else
WINVER=500
fi
WINVER=502
;;
esac
@ -4243,7 +4239,7 @@ dnl =
dnl ========================================================
MOZ_ARG_HEADER(External Packages)
MOZ_ENABLE_LIBXUL=
MOZ_ENABLE_LIBXUL=1
MOZ_ARG_WITH_STRING(libxul-sdk,
[ --with-libxul-sdk=PFX Use the libXUL SDK at <PFX>],
@ -4570,6 +4566,7 @@ MOZ_DBGRINFO_MODULES=
MOZ_FEEDS=1
MOZ_IMG_DECODERS_DEFAULT="png gif jpeg bmp icon"
MOZ_IMG_ENCODERS_DEFAULT="png jpeg"
MOZ_IPC=1
MOZ_JAVAXPCOM=
MOZ_JSDEBUGGER=1
MOZ_JSLOADER=1
@ -5295,6 +5292,49 @@ MOZ_ARG_DISABLE_BOOL(jsd,
MOZ_JSDEBUGGER=1)
dnl ========================================================
dnl = Disable IPC support for tabs and plugins
dnl ========================================================
case "${target}" in
*-apple-darwin*)
MOZ_IPC=
;;
*-wince*)
MOZ_IPC=
;;
esac
MOZ_ARG_DISABLE_BOOL(ipc,
[ --disable-ipc Disable IPC supports for tabs and plugins],
MOZ_IPC=,
MOZ_IPC=1)
if test -n "$MOZ_IPC"; then
AC_DEFINE(MOZ_IPC)
fi
AC_SUBST(MOZ_IPC)
dnl ========================================================
dnl = Enable IPDL's "expensive" unit tests
dnl ========================================================
MOZ_IPDL_TESTS=
MOZ_ARG_ENABLE_BOOL(ipdl-tests,
[ --enable-ipdl-tests Enable expensive IPDL tests],
MOZ_IPDL_TESTS=1,
MOZ_IPDL_TESTS=)
if test -z "$MOZ_IPC" -a -n "$MOZ_IPDL_TESTS"; then
AC_MSG_ERROR([--enable-ipdl-tests requires --enable-ipc])
fi
if test -n "$MOZ_IPDL_TESTS"; then
AC_DEFINE(MOZ_IPDL_TESTS)
fi
AC_SUBST(MOZ_IPDL_TESTS)
dnl ========================================================
dnl = Disable plugin support
dnl ========================================================
@ -7185,6 +7225,7 @@ dnl ========================================================
dnl C++ rtti
dnl Should be smarter and check that the compiler does indeed have rtti
dnl ========================================================
MOZ_ARG_ENABLE_BOOL(cpp-rtti,
[ --enable-cpp-rtti Enable C++ RTTI ],
[ _MOZ_USE_RTTI=1 ],
@ -7296,11 +7337,6 @@ MOZ_ARG_ENABLE_BOOL(static,
BUILD_STATIC_LIBS=1,
BUILD_STATIC_LIBS=)
dnl Disable libxul in debug builds, but not for xulrunner.
if test -n "$MOZ_DEBUG" -a "$MOZ_BUILD_APP" != "xulrunner"; then
MOZ_ENABLE_LIBXUL=
fi
MOZ_ARG_ENABLE_BOOL(libxul,
[ --enable-libxul Enable building of libxul],
MOZ_ENABLE_LIBXUL=1,
@ -7314,6 +7350,10 @@ if test -n "$MOZ_ENABLE_LIBXUL" -a -n "$BUILD_STATIC_LIBS"; then
AC_MSG_ERROR([--enable-libxul is not compatible with --enable-static])
fi
if test -n "$MOZ_IPC" -a -z "$MOZ_ENABLE_LIBXUL"; then
AC_MSG_ERROR([--enable-ipc requires --enable-libxul])
fi
AC_SUBST(LIBXUL_LIBS)
if test -n "$MOZ_ENABLE_LIBXUL"; then

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

@ -245,7 +245,13 @@ nsCrossSiteListenerProxy::CheckRequestApproved(nsIRequest* aRequest,
PRBool succeeded;
rv = http->GetRequestSucceeded(&succeeded);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(succeeded, NS_ERROR_DOM_BAD_URI);
if (!succeeded) {
PRUint32 responseStatus;
rv = http->GetResponseStatus(&responseStatus);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(mAllowedHTTPErrors.Contains(responseStatus),
NS_ERROR_DOM_BAD_URI);
}
}
// Check the Access-Control-Allow-Origin header

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

@ -81,6 +81,11 @@ public:
// Must be called at startup.
static void Startup();
void AllowHTTPResult(PRUint32 aResultCode)
{
mAllowedHTTPErrors.AppendElement(aResultCode);
}
private:
nsresult UpdateChannel(nsIChannel* aChannel);
nsresult CheckRequestApproved(nsIRequest* aRequest, PRBool aIsRedirect);
@ -94,6 +99,7 @@ private:
PRBool mIsPreflight;
nsCString mPreflightMethod;
nsTArray<nsCString> mPreflightHeaders;
nsTArray<PRUint32> mAllowedHTTPErrors;
};
#endif

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

@ -414,6 +414,7 @@ nsINode::GetSelectionRootContent(nsIPresShell* aPresShell)
if (!doc || doc->HasFlag(NODE_IS_EDITABLE) ||
!HasFlag(NODE_IS_EDITABLE)) {
nsIContent* editorRoot = GetEditorRootContent(editor);
NS_ENSURE_TRUE(editorRoot, nsnull);
return nsContentUtils::IsInSameAnonymousTree(this, editorRoot) ?
editorRoot :
GetRootForContentSubtree(static_cast<nsIContent*>(this));
@ -445,6 +446,7 @@ nsINode::GetSelectionRootContent(nsIPresShell* aPresShell)
// This node might be in another subtree, if so, we should find this subtree's
// root. Otherwise, we can return the content simply.
NS_ENSURE_TRUE(content, nsnull);
return nsContentUtils::IsInSameAnonymousTree(this, content) ?
content : GetRootForContentSubtree(static_cast<nsIContent*>(this));
}

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

@ -631,13 +631,16 @@ nsresult nsHTMLMediaElement::LoadResource(nsIURI* aURI)
nsCOMPtr<nsIStreamListener> listener;
if (ShouldCheckAllowOrigin()) {
listener = new nsCrossSiteListenerProxy(loadListener,
NodePrincipal(),
mChannel,
PR_FALSE,
&rv);
NS_ENSURE_SUCCESS(rv,rv);
if (!listener) return NS_ERROR_OUT_OF_MEMORY;
nsCrossSiteListenerProxy* crossSiteListener =
new nsCrossSiteListenerProxy(loadListener,
NodePrincipal(),
mChannel,
PR_FALSE,
&rv);
listener = crossSiteListener;
NS_ENSURE_TRUE(crossSiteListener, NS_ERROR_OUT_OF_MEMORY);
NS_ENSURE_SUCCESS(rv, rv);
crossSiteListener->AllowHTTPResult(HTTP_REQUESTED_RANGE_NOT_SATISFIABLE_CODE);
} else {
rv = nsContentUtils::GetSecurityManager()->
CheckLoadURIWithPrincipal(NodePrincipal(),

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

@ -59,7 +59,6 @@
#define HTTP_OK_CODE 200
#define HTTP_PARTIAL_RESPONSE_CODE 206
#define HTTP_REQUESTED_RANGE_NOT_SATISFIABLE_CODE 416
using mozilla::TimeStamp;
@ -425,13 +424,16 @@ nsresult nsMediaChannelStream::OpenChannel(nsIStreamListener** aStreamListener)
NS_ENSURE_TRUE(element, NS_ERROR_FAILURE);
if (element->ShouldCheckAllowOrigin()) {
nsresult rv;
listener = new nsCrossSiteListenerProxy(mListener,
element->NodePrincipal(),
mChannel,
PR_FALSE,
&rv);
NS_ENSURE_TRUE(listener, NS_ERROR_OUT_OF_MEMORY);
nsCrossSiteListenerProxy* crossSiteListener =
new nsCrossSiteListenerProxy(mListener,
element->NodePrincipal(),
mChannel,
PR_FALSE,
&rv);
listener = crossSiteListener;
NS_ENSURE_TRUE(crossSiteListener, NS_ERROR_OUT_OF_MEMORY);
NS_ENSURE_SUCCESS(rv, rv);
crossSiteListener->AllowHTTPResult(HTTP_REQUESTED_RANGE_NOT_SATISFIABLE_CODE);
} else {
nsresult rv = nsContentUtils::GetSecurityManager()->
CheckLoadURIWithPrincipal(element->NodePrincipal(),

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

@ -53,6 +53,8 @@
// done rather than a byte range request.
#define SEEK_VS_READ_THRESHOLD (32*1024)
#define HTTP_REQUESTED_RANGE_NOT_SATISFIABLE_CODE 416
class nsMediaDecoder;
/**

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

@ -179,6 +179,7 @@ ifdef MOZ_OGG
_TEST_FILES += \
dynamic_redirect.sjs \
file_access_controls.html \
test_access_control.html \
test_bug448534.html \
test_bug468190.html \
test_bug486646.html \
@ -227,7 +228,6 @@ ifneq ($(OS_ARCH),WINNT)
# figure out the random failures. See bug 475369 and bug 526323
_TEST_FILES += \
test_timeupdate3.html \
test_access_control.html \
$(NULL)
endif
endif

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

@ -15,7 +15,7 @@ var gTests = [
},{
// Test 1
url: "redirect.sjs?http://example.com/tests/content/media/test/320x240.allow-origin.ogv",
result: "loaded",
result: "loadeddata",
description: "Can load when redirected to different domain with allow-origin",
},{
// Test 2
@ -25,17 +25,17 @@ var gTests = [
},{
// Test 3
url: "redirect.sjs?http://test1.example.org/tests/content/media/test/320x240.allow-origin.ogv",
result: "loaded",
result: "loadeddata",
description: "Can load when redirected to subdomain with allow-origin",
},{
// Test 4
url: "redirect.sjs?http://example.org/tests/content/media/test/320x240.ogv",
result: "loaded",
result: "loadeddata",
description: "Can load when redirected to same domain",
},{
// Test 5
url: "http://example.org/tests/content/media/test/320x240.ogv",
result: "loaded",
result: "loadeddata",
description: "Can load from same domain"
},{
// Test 6
@ -45,7 +45,7 @@ var gTests = [
},{
// Test 7
url: "http://example.org:8000/tests/content/media/test/320x240.allow-origin.ogv",
result: "loaded",
result: "loadeddata",
description: "Can load from different port on same domain with allow-origin",
},{
// Test 8
@ -55,12 +55,12 @@ var gTests = [
},{
// Test 9
url: "http://example.com/tests/content/media/test/320x240.allow-origin.ogv",
result: "loaded",
result: "loadeddata",
description: "Can load cross domain with allow-origin",
},{
// Test 10
url: "http://test1.example.org/tests/content/media/test/320x240.allow-origin.ogv",
result: "loaded",
result: "loadeddata",
description: "Can load from subdomain with allow-origin",
},{
// Test 11
@ -71,24 +71,25 @@ var gTests = [
];
var gTestNum = 0;
var gExpectedResult = null;
var gTestDescription = null;
var gVideo = null;
var gTestedRemoved = false;
var gOldPref;
function result(code) {
//dump((gTestNum - 1) + ": " + code + "\n");
function eventHandler(event) {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
opener.is(code, gExpectedResult, gTestDescription);
//dump((gTestNum - 1) + ": " + event.type + "\n");
var video = event.target;
opener.is(event.type, video.expectedResult, video.testDescription +
(gTestedRemoved ? " (element not in document)" : " (element in document)"));
// Make sure any extra events cause an error
video.expectedResult = "<none>";
nextTest();
}
function createVideo() {
var v = document.createElement('video');
v.addEventListener('loadeddata', function(){result('loaded');}, false);
v.addEventListener('error', function(){result('error');}, false);
v.id = 'video';
v.addEventListener('loadeddata', eventHandler, false);
v.addEventListener('error', eventHandler, false);
return v;
}
@ -112,7 +113,6 @@ function load() {
function nextTest() {
//dump("nextTest() called, gTestNum="+gTestNum+" gTestedRemoved="+gTestedRemoved+"\n");
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
if (gTestNum == gTests.length) {
//dump("gTestNum == gTests.length\n");
if (!gTestedRemoved) {
@ -126,15 +126,15 @@ function nextTest() {
return;
}
}
gExpectedResult = gTests[gTestNum].result;
gTestDescription = gTests[gTestNum].description;
//dump("Starting test " + gTestNum + " at " + gTests[gTestNum].url + " expecting:" + gExpectedResult + "\n");
if (gVideo && gVideo.parentNode)
gVideo.parentNode.removeChild(gVideo);
gVideo = createVideo();
gVideo.expectedResult = gTests[gTestNum].result;
gVideo.testDescription = gTests[gTestNum].description;
gVideo.src = gTests[gTestNum].url;
//dump("Starting test " + gTestNum + " at " + gVideo.src + " expecting:" + gVideo.expectedResult + "\n");
if (!gTestedRemoved) {
document.body.appendChild(gVideo);
// Will cause load() to be invoked.

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

@ -1870,9 +1870,11 @@ nsXULTemplateBuilder::CompileTemplate(nsIContent* aTemplate,
getter_AddRefs(action));
if (action){
nsCOMPtr<nsIAtom> memberVariable;
DetermineMemberVariable(action, getter_AddRefs(memberVariable));
if (! memberVariable) continue;
nsCOMPtr<nsIAtom> memberVariable = mMemberVariable;
if (!memberVariable) {
memberVariable = DetermineMemberVariable(action);
if (!memberVariable) continue;
}
if (hasQuery) {
nsCOMPtr<nsIAtom> tag;
@ -1994,9 +1996,11 @@ nsXULTemplateBuilder::CompileTemplate(nsIContent* aTemplate,
if (tag)
aQuerySet->SetTag(tag);
nsCOMPtr<nsIAtom> memberVariable;
DetermineMemberVariable(rulenode, getter_AddRefs(memberVariable));
if (! memberVariable) continue;
nsCOMPtr<nsIAtom> memberVariable = mMemberVariable;
if (!memberVariable) {
memberVariable = DetermineMemberVariable(rulenode);
if (!memberVariable) continue;
}
nsCOMPtr<nsIDOMNode> query(do_QueryInterface(aQuerySet->mQueryNode));
@ -2077,53 +2081,26 @@ nsXULTemplateBuilder::CompileExtendedQuery(nsIContent* aRuleElement,
return NS_OK;
}
nsresult
nsXULTemplateBuilder::DetermineMemberVariable(nsIContent* aActionElement,
nsIAtom** aMemberVariable)
already_AddRefed<nsIAtom>
nsXULTemplateBuilder::DetermineMemberVariable(nsIContent* aElement)
{
// If the member variable hasn't already been specified, then
// grovel over <action> to find it. We'll use the first one
// that we find in a breadth-first search.
// recursively iterate over the children looking for an element
// with uri="?..."
for (nsINode::ChildIterator iter(aElement); !iter.IsDone(); iter.Next()) {
nsAutoString uri;
nsIContent *child = iter;
child->GetAttr(kNameSpaceID_None, nsGkAtoms::uri, uri);
if (!uri.IsEmpty() && uri[0] == PRUnichar('?')) {
return NS_NewAtom(uri);
}
if (mMemberVariable) {
*aMemberVariable = mMemberVariable;
NS_IF_ADDREF(*aMemberVariable);
}
else {
*aMemberVariable = nsnull;
nsCOMArray<nsIContent> unvisited;
if (!unvisited.AppendObject(aActionElement))
return NS_ERROR_OUT_OF_MEMORY;
while (unvisited.Count()) {
nsIContent* next = unvisited[0];
unvisited.RemoveObjectAt(0);
nsAutoString uri;
next->GetAttr(kNameSpaceID_None, nsGkAtoms::uri, uri);
if (!uri.IsEmpty() && uri[0] == PRUnichar('?')) {
// Found it.
*aMemberVariable = NS_NewAtom(uri);
break;
}
// otherwise, append the children to the unvisited list: this
// results in a breadth-first search.
PRUint32 count = next->GetChildCount();
for (PRUint32 i = 0; i < count; ++i) {
nsIContent *child = next->GetChildAt(i);
if (!unvisited.AppendObject(child))
return NS_ERROR_OUT_OF_MEMORY;
}
nsCOMPtr<nsIAtom> result = DetermineMemberVariable(child);
if (result) {
return result.forget();
}
}
return NS_OK;
return nsnull;
}
void

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

@ -212,8 +212,7 @@ public:
* Determine the member variable from inside an action body. It will be
* the value of the uri attribute on a node.
*/
nsresult
DetermineMemberVariable(nsIContent* aActionElement, nsIAtom** aMemberVariable);
already_AddRefed<nsIAtom> DetermineMemberVariable(nsIContent* aElement);
/**
* Compile a simple query. A simple query is one that doesn't have a

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

@ -63,7 +63,7 @@
toolkit/components/places/src/nsFaviconService.h should be updated. -->
<link rel="icon" type="image/png" id="favicon" href="chrome://global/skin/icons/warning-16.png"/>
<script type="application/x-javascript"><![CDATA[
<script type="application/javascript"><![CDATA[
// Error url MUST be formatted like this:
// moz-neterror:page?e=error&u=url&d=desc
//
@ -376,7 +376,7 @@
- an onload handler. This is because error pages are loaded as
- LOAD_BACKGROUND, which means that onload handlers will not be executed.
-->
<script type="application/x-javascript">initPage();</script>
<script type="application/javascript">initPage();</script>
</body>
</html>

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

@ -594,8 +594,8 @@ nsSHEntry::AddChild(nsISHEntry * aChild, PRInt32 aOffset)
if (aOffset < mChildren.Count()) {
nsISHEntry* oldChild = mChildren.ObjectAt(aOffset);
if (oldChild && oldChild != aChild) {
NS_ERROR("Adding child where we already have a child? "
"This will likely misbehave");
NS_WARNING("Adding child where we already have a child? "
"This will likely misbehave");
oldChild->SetParent(nsnull);
}
}

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

@ -79,6 +79,7 @@ DIRS += \
base \
src \
locales \
plugins \
$(NULL)
ifdef ENABLE_TESTS

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

@ -419,6 +419,7 @@ public:
NPError ShowNativeContextMenu(NPMenu* menu, void* event);
NPBool ConvertPoint(double sourceX, double sourceY, NPCoordinateSpace sourceSpace,
double *destX, double *destY, NPCoordinateSpace destSpace);
void SendIdleEvent();
NS_DECL_CYCLE_COLLECTION_CLASS(nsDummyJavaPluginOwner)
@ -563,6 +564,11 @@ nsDummyJavaPluginOwner::SetEventModel(PRInt32 eventModel)
return NS_ERROR_NOT_IMPLEMENTED;
}
void
nsDummyJavaPluginOwner::SendIdleEvent()
{
}
/**
* An indirect observer object that means we don't have to implement nsIObserver
* on nsGlobalWindow, where any script could see it.

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

@ -2556,9 +2556,7 @@ nsJSContext::InitContext(nsIScriptGlobalObject *aGlobalObject)
// Now check whether we need to grab a pointer to the
// XPCNativeWrapper class
if (!nsDOMClassInfo::GetXPCNativeWrapperClass()) {
JSAutoRequest ar(mContext);
rv = FindXPCNativeWrapperClass(holder);
NS_ENSURE_SUCCESS(rv, rv);
nsDOMClassInfo::SetXPCNativeWrapperClass(xpc->GetNativeWrapperClass());
}
} else {
// There's already a global object. We are preparing this outer window
@ -2958,52 +2956,6 @@ nsJSContext::AddSupportsPrimitiveTojsvals(nsISupports *aArg, jsval *aArgv)
return NS_OK;
}
nsresult
nsJSContext::FindXPCNativeWrapperClass(nsIXPConnectJSObjectHolder *aHolder)
{
NS_ASSERTION(!nsDOMClassInfo::GetXPCNativeWrapperClass(),
"Why was this called?");
JSObject *globalObj;
aHolder->GetJSObject(&globalObj);
NS_ASSERTION(globalObj, "Must have global by now!");
const char* arg = "arg";
NS_NAMED_LITERAL_STRING(body, "return new XPCNativeWrapper(arg);");
// Can't use CompileFunction() here because our principal isn't
// inited yet and a null principal makes it fail.
JSFunction *fun =
::JS_CompileUCFunction(mContext,
globalObj,
"_XPCNativeWrapperCtor",
1, &arg,
(jschar*)body.get(),
body.Length(),
"javascript:return new XPCNativeWrapper(arg);",
1 // lineno
);
NS_ENSURE_TRUE(fun, NS_ERROR_FAILURE);
jsval globalVal = OBJECT_TO_JSVAL(globalObj);
jsval wrapper;
JSBool ok = ::JS_CallFunction(mContext, globalObj, fun,
1, &globalVal, &wrapper);
if (!ok) {
// No need to notify about pending exceptions here; we don't
// expect any other than out of memory, really.
return NS_ERROR_FAILURE;
}
NS_ASSERTION(JSVAL_IS_OBJECT(wrapper), "This should be an object!");
nsDOMClassInfo::SetXPCNativeWrapperClass(
::JS_GET_CLASS(mContext, JSVAL_TO_OBJECT(wrapper)));
return NS_OK;
}
static JSPropertySpec OptionsProperties[] = {
{"strict", (int8)JSOPTION_STRICT, JSPROP_ENUMERATE | JSPROP_PERMANENT},
{"werror", (int8)JSOPTION_WERROR, JSPROP_ENUMERATE | JSPROP_PERMANENT},

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

@ -205,8 +205,6 @@ public:
protected:
nsresult InitializeExternalClasses();
// aHolder should be holding our global object
nsresult FindXPCNativeWrapperClass(nsIXPConnectJSObjectHolder *aHolder);
// Helper to convert xpcom datatypes to jsvals.
JS_FORCES_STACK nsresult ConvertSupportsTojsvals(nsISupports *aArgs,

59
dom/plugins/AStream.h Normal file
Просмотреть файл

@ -0,0 +1,59 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Plugins.
*
* The Initial Developer of the Original Code is
* The Mozilla Foundation <http://www.mozilla.org/>.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef mozilla_plugins_AStream_h
#define mozilla_plugins_AStream_h
namespace mozilla {
namespace plugins {
/**
* When we are passed NPStream->{ndata,pdata} in {NPN,NPP}_DestroyStream, we
* don't know whether it's a plugin stream or a browser stream. This abstract
* class lets us cast to the right type of object and send the appropriate
* message.
*/
class AStream
{
public:
virtual bool IsBrowserStream() = 0;
};
} // namespace plugins
} // namespace mozilla
#endif

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

@ -0,0 +1,169 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Plugin App.
*
* The Initial Developer of the Original Code is
* Benjamin Smedberg <benjamin@smedbergs.us>
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "BrowserStreamChild.h"
#include "PluginInstanceChild.h"
#include "StreamNotifyChild.h"
namespace mozilla {
namespace plugins {
BrowserStreamChild::BrowserStreamChild(PluginInstanceChild* instance,
const nsCString& url,
const uint32_t& length,
const uint32_t& lastmodified,
const PStreamNotifyChild* notifyData,
const nsCString& headers,
const nsCString& mimeType,
const bool& seekable,
NPError* rv,
uint16_t* stype)
: mInstance(instance)
, mClosed(false)
, mURL(url)
, mHeaders(headers)
{
AssertPluginThread();
memset(&mStream, 0, sizeof(mStream));
mStream.ndata = static_cast<AStream*>(this);
mStream.url = NullableStringGet(mURL);
mStream.end = length;
mStream.lastmodified = lastmodified;
if (notifyData)
mStream.notifyData =
static_cast<const StreamNotifyChild*>(notifyData)->mClosure;
mStream.headers = NullableStringGet(mHeaders);
*rv = mInstance->mPluginIface->newstream(
&mInstance->mData, const_cast<char*>(NullableStringGet(mimeType)),
&mStream, seekable, stype);
if (*rv != NPERR_NO_ERROR)
mClosed = true;
}
bool
BrowserStreamChild::AnswerNPP_WriteReady(const int32_t& newlength,
int32_t *size)
{
AssertPluginThread();
if (mClosed) {
*size = 0;
return true;
}
mStream.end = newlength;
*size = mInstance->mPluginIface->writeready(&mInstance->mData, &mStream);
return true;
}
bool
BrowserStreamChild::AnswerNPP_Write(const int32_t& offset,
const Buffer& data,
int32_t* consumed)
{
_MOZ_LOG(__FUNCTION__);
AssertPluginThread();
if (mClosed) {
*consumed = -1;
return true;
}
*consumed = mInstance->mPluginIface->write(&mInstance->mData, &mStream,
offset, data.Length(),
const_cast<char*>(data.get()));
return true;
}
bool
BrowserStreamChild::AnswerNPP_StreamAsFile(const nsCString& fname)
{
_MOZ_LOG(__FUNCTION__);
AssertPluginThread();
printf("mClosed: %i\n", mClosed);
if (mClosed)
return true;
mInstance->mPluginIface->asfile(&mInstance->mData, &mStream,
fname.get());
return true;
}
bool
BrowserStreamChild::Answer__delete__(const NPError& reason,
const bool& artificial)
{
AssertPluginThread();
if (!artificial)
NPP_DestroyStream(reason);
return true;
}
NPError
BrowserStreamChild::NPN_RequestRead(NPByteRange* aRangeList)
{
AssertPluginThread();
IPCByteRanges ranges;
for (; aRangeList; aRangeList = aRangeList->next) {
IPCByteRange br = {aRangeList->offset, aRangeList->length};
ranges.push_back(br);
}
NPError result;
CallNPN_RequestRead(ranges, &result);
return result;
}
void
BrowserStreamChild::NPP_DestroyStream(NPError reason)
{
AssertPluginThread();
if (mClosed)
return;
mInstance->mPluginIface->destroystream(&mInstance->mData, &mStream, reason);
mClosed = true;
}
} /* namespace plugins */
} /* namespace mozilla */

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

@ -0,0 +1,103 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Plugin App.
*
* The Initial Developer of the Original Code is
* Benjamin Smedberg <benjamin@smedbergs.us>
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef mozilla_plugins_BrowserStreamChild_h
#define mozilla_plugins_BrowserStreamChild_h 1
#include "mozilla/plugins/PBrowserStreamChild.h"
#include "mozilla/plugins/AStream.h"
namespace mozilla {
namespace plugins {
class PluginInstanceChild;
class PStreamNotifyChild;
class BrowserStreamChild : public PBrowserStreamChild, public AStream
{
public:
BrowserStreamChild(PluginInstanceChild* instance,
const nsCString& url,
const uint32_t& length,
const uint32_t& lastmodified,
const PStreamNotifyChild* notifyData,
const nsCString& headers,
const nsCString& mimeType,
const bool& seekable,
NPError* rv,
uint16_t* stype);
virtual ~BrowserStreamChild() { }
NS_OVERRIDE virtual bool IsBrowserStream() { return true; }
virtual bool AnswerNPP_WriteReady(const int32_t& newlength,
int32_t *size);
virtual bool AnswerNPP_Write(const int32_t& offset,
const Buffer& data,
int32_t* consumed);
virtual bool AnswerNPP_StreamAsFile(const nsCString& fname);
virtual bool Answer__delete__(const NPError& reason,
const bool& artificial);
void EnsureCorrectInstance(PluginInstanceChild* i)
{
if (i != mInstance)
NS_RUNTIMEABORT("Incorrect stream instance");
}
void EnsureCorrectStream(NPStream* s)
{
if (s != &mStream)
NS_RUNTIMEABORT("Incorrect stream data");
}
NPError NPN_RequestRead(NPByteRange* aRangeList);
void NPP_DestroyStream(NPError reason);
private:
PluginInstanceChild* mInstance;
NPStream mStream;
bool mClosed;
nsCString mURL;
nsCString mHeaders;
};
} // namespace plugins
} // namespace mozilla
#endif /* mozilla_plugins_BrowserStreamChild_h */

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

@ -0,0 +1,101 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
#include "BrowserStreamParent.h"
#include "PluginInstanceParent.h"
namespace mozilla {
namespace plugins {
BrowserStreamParent::BrowserStreamParent(PluginInstanceParent* npp,
NPStream* stream)
: mNPP(npp)
, mStream(stream)
{
printf("BrowserStreamParent::BrowserStreamParent<%p>\n", (void*) this);
mStream->pdata = static_cast<AStream*>(this);
}
BrowserStreamParent::~BrowserStreamParent()
{
printf("BrowserStreamParent::~BrowserStreamParent<%p>\n", (void*) this);
}
bool
BrowserStreamParent::AnswerNPN_RequestRead(const IPCByteRanges& ranges,
NPError* result)
{
_MOZ_LOG(__FUNCTION__);
if (!mStream)
return false;
if (ranges.size() > PR_INT32_MAX)
return false;
nsAutoArrayPtr<NPByteRange> rp(new NPByteRange[ranges.size()]);
for (PRUint32 i = 0; i < ranges.size(); ++i) {
rp[i].offset = ranges[i].offset;
rp[i].length = ranges[i].length;
rp[i].next = &rp[i + 1];
}
rp[ranges.size() - 1].next = NULL;
*result = mNPP->mNPNIface->requestread(mStream, rp);
return true;
}
bool
BrowserStreamParent::Answer__delete__(const NPError& reason,
const bool& artificial)
{
if (!artificial)
NPN_DestroyStream(reason);
return true;
}
int32_t
BrowserStreamParent::WriteReady()
{
_MOZ_LOG(__FUNCTION__);
int32_t result;
if (!CallNPP_WriteReady(mStream->end, &result))
return -1;
return result;
}
int32_t
BrowserStreamParent::Write(int32_t offset,
int32_t len,
void* buffer)
{
_MOZ_LOG(__FUNCTION__);
int32_t result;
if (!CallNPP_Write(offset,
nsCString(static_cast<char*>(buffer), len),
&result))
return -1;
return result;
}
void
BrowserStreamParent::StreamAsFile(const char* fname)
{
_MOZ_LOG(__FUNCTION__);
CallNPP_StreamAsFile(nsCString(fname));
}
NPError
BrowserStreamParent::NPN_DestroyStream(NPReason reason)
{
_MOZ_LOG(__FUNCTION__);
return mNPP->mNPNIface->destroystream(mNPP->mNPP, mStream, reason);
}
} // namespace plugins
} // namespace mozilla

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

@ -0,0 +1,81 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Plugins.
*
* The Initial Developer of the Original Code is
* The Mozilla Foundation <http://www.mozilla.org/>.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef mozilla_plugins_BrowserStreamParent_h
#define mozilla_plugins_BrowserStreamParent_h
#include "mozilla/plugins/PBrowserStreamParent.h"
#include "mozilla/plugins/AStream.h"
namespace mozilla {
namespace plugins {
class PluginInstanceParent;
class BrowserStreamParent : public PBrowserStreamParent, public AStream
{
friend class PluginModuleParent;
friend class PluginInstanceParent;
public:
BrowserStreamParent(PluginInstanceParent* npp,
NPStream* stream);
virtual ~BrowserStreamParent();
NS_OVERRIDE virtual bool IsBrowserStream() { return true; }
virtual bool AnswerNPN_RequestRead(const IPCByteRanges& ranges,
NPError* result);
virtual bool
Answer__delete__(const NPError& reason, const bool& artificial);
int32_t WriteReady();
int32_t Write(int32_t offset, int32_t len, void* buffer);
void StreamAsFile(const char* fname);
private:
NPError NPN_DestroyStream(NPError reason);
PluginInstanceParent* mNPP;
NPStream* mStream;
};
} // namespace plugins
} // namespace mozilla
#endif

118
dom/plugins/Makefile.in Normal file
Просмотреть файл

@ -0,0 +1,118 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Mozilla Plugins.
#
# The Initial Developer of the Original Code is
# Ben Turner <bent.mozilla@gmail.com>.
# Portions created by the Initial Developer are Copyright (C) 2009
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Chris Jones <jones.chris.g@gmail.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = dom
EXPORTS_NAMESPACES = mozilla
EXPORTS_mozilla = \
PluginLibrary.h \
PluginPRLibrary.h \
$(NULL)
ifdef MOZ_IPC
EXPORTS_NAMESPACES = mozilla mozilla/plugins
EXPORTS_mozilla/plugins = \
BrowserStreamChild.h \
BrowserStreamParent.h \
NPEventOSX.h \
NPEventWindows.h \
NPEventX11.h \
PluginInstanceChild.h \
PluginInstanceParent.h \
PluginMessageUtils.h \
PluginModuleChild.h \
PluginModuleParent.h \
PluginProcessParent.h \
PluginScriptableObjectChild.h \
PluginScriptableObjectParent.h \
PluginInstanceChild.h \
PluginInstanceParent.h \
AStream.h \
BrowserStreamChild.h \
BrowserStreamParent.h \
PluginStreamChild.h \
PluginStreamParent.h \
PluginMessageUtils.h \
PluginProcessParent.h \
PluginThreadChild.h \
StreamNotifyChild.h \
StreamNotifyParent.h \
$(NULL)
MODULE = dom
LIBRARY_NAME = domplugins_s
LIBXUL_LIBRARY = 1
FORCE_STATIC_LIB = 1
EXPORT_LIBRARY = 1
ENABLE_CXX_EXCEPTIONS = 1
CPPSRCS = \
PluginMessageUtils.cpp \
PluginInstanceChild.cpp \
PluginInstanceParent.cpp \
PluginModuleChild.cpp \
PluginModuleParent.cpp \
PluginProcessParent.cpp \
PluginScriptableObjectChild.cpp \
PluginScriptableObjectParent.cpp \
BrowserStreamChild.cpp \
BrowserStreamParent.cpp \
PluginStreamChild.cpp \
PluginStreamParent.cpp \
PluginThreadChild.cpp \
$(NULL)
LOCAL_INCLUDES = \
-I$(topsrcdir)/modules/plugin/base/public/ \
-I$(topsrcdir)/modules/plugin/base/src/ \
$(NULL)
include $(topsrcdir)/config/config.mk
include $(topsrcdir)/ipc/chromium/chromium-config.mk
endif
include $(topsrcdir)/config/rules.mk

79
dom/plugins/NPEventOSX.h Normal file
Просмотреть файл

@ -0,0 +1,79 @@
/* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 8 -*- */
/* vim: set sw=4 ts=8 et tw=80 ft=cpp : */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Plugin App.
*
* The Initial Developer of the Original Code is
* The Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef mozilla_dom_plugins_NPEventOSX_h
#define mozilla_dom_plugins_NPEventOSX_h 1
#include "npapi.h"
#include "IPC/IPCMessageUtils.h"
#warning This is only a stub implementation IMPLEMENT ME
namespace mozilla {
namespace plugins {
struct NPRemoteEvent {
NPEvent event;
};
}
}
namespace IPC {
template <>
struct ParamTraits<mozilla::plugins::NPRemoteEvent>
{
typedef mozilla::plugins::NPRemoteEvent paramType;
static void Write(Message* aMsg, const paramType& aParam)
{
}
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
{
return true;
}
static void Log(const paramType& aParam, std::wstring* aLog)
{
}
};
} // namespace IPC
#endif // ifndef mozilla_dom_plugins_NPEventOSX_h

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

@ -0,0 +1,171 @@
/* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 8 -*- */
/* vim: set sw=4 ts=8 et tw=80 ft=cpp : */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Plugin App.
*
* The Initial Developer of the Original Code is
* The Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef mozilla_dom_plugins_NPEventWindows_h
#define mozilla_dom_plugins_NPEventWindows_h 1
#include "npapi.h"
namespace mozilla {
namespace plugins {
// We use an NPRemoteEvent struct so that we can store the extra data on
// the stack so that we don't need to worry about managing the memory.
struct NPRemoteEvent
{
NPEvent event;
union {
RECT rect;
WINDOWPOS windowpos;
} lParamData;
};
}
}
namespace IPC {
template <>
struct ParamTraits<mozilla::plugins::NPRemoteEvent>
{
typedef mozilla::plugins::NPRemoteEvent paramType;
static void Write(Message* aMsg, const paramType& aParam)
{
// Make a non-const copy of aParam so that we can muck with
// its insides for tranport
paramType paramCopy;
paramCopy.event = aParam.event;
// We can't blindly ipc events because they may sometimes contain
// pointers to memory in the sending process. For example, the
// WM_IME_CONTROL with the IMC_GETCOMPOSITIONFONT message has lParam
// set to a pointer to a LOGFONT structure.
switch (paramCopy.event.event) {
case WM_WINDOWPOSCHANGED:
// The lParam paramter of WM_WINDOWPOSCHANGED holds a pointer to
// a WINDOWPOS structure that contains information about the
// window's new size and position
paramCopy.lParamData.windowpos = *(reinterpret_cast<WINDOWPOS*>(paramCopy.event.lParam));
break;
case WM_PAINT:
// The lParam paramter of WM_PAINT holds a pointer to an RECT
// structure specifying the bounding box of the update area.
paramCopy.lParamData.rect = *(reinterpret_cast<RECT*>(paramCopy.event.lParam));
break;
// the white list of events that we will ipc to the client
case WM_CHAR:
case WM_SYSCHAR:
case WM_KEYUP:
case WM_SYSKEYUP:
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
case WM_DEADCHAR:
case WM_SYSDEADCHAR:
case WM_CONTEXTMENU:
case WM_CUT:
case WM_COPY:
case WM_PASTE:
case WM_CLEAR:
case WM_UNDO:
case WM_MOUSEMOVE:
case WM_LBUTTONDOWN:
case WM_MBUTTONDOWN:
case WM_RBUTTONDOWN:
case WM_LBUTTONUP:
case WM_MBUTTONUP:
case WM_RBUTTONUP:
case WM_LBUTTONDBLCLK:
case WM_MBUTTONDBLCLK:
case WM_RBUTTONDBLCLK:
case WM_SETFOCUS:
case WM_KILLFOCUS:
break;
default:
// RegisterWindowMessage events should be passed.
if (paramCopy.event.event >= 0xC000 && paramCopy.event.event <= 0xFFFF)
break;
// ignore any events we don't expect
return;
}
aMsg->WriteBytes(&paramCopy, sizeof(paramType));
}
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
{
const char* bytes = 0;
if (!aMsg->ReadBytes(aIter, &bytes, sizeof(paramType))) {
return false;
}
memcpy(aResult, bytes, sizeof(paramType));
if (aResult->event.event == WM_PAINT) {
// restore the lParam to point at the RECT
aResult->event.lParam = reinterpret_cast<LPARAM>(&aResult->lParamData.rect);
} else if (aResult->event.event == WM_WINDOWPOSCHANGED) {
// restore the lParam to point at the WINDOWPOS
aResult->event.lParam = reinterpret_cast<LPARAM>(&aResult->lParamData.windowpos);
}
return true;
}
static void Log(const paramType& aParam, std::wstring* aLog)
{
aLog->append(L"(WINEvent)");
}
};
} // namespace IPC
#endif // ifndef mozilla_dom_plugins_NPEventWindows_h

147
dom/plugins/NPEventX11.h Normal file
Просмотреть файл

@ -0,0 +1,147 @@
/* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 8 -*- */
/* vim: set sw=4 ts=8 et tw=80 ft=cpp : */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Plugin App.
*
* The Initial Developer of the Original Code is
* The Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Chris Jones <jones.chris.g@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef mozilla_dom_plugins_NPEventX11_h
#define mozilla_dom_plugins_NPEventX11_h 1
#if defined(MOZ_WIDGET_GTK2)
# include <gdk/gdkx.h>
#else
# error Implement me for your toolkit
#endif
#include "npapi.h"
namespace mozilla {
namespace plugins {
struct NPRemoteEvent {
NPEvent event;
};
}
}
//
// XEvent is defined as a union of all more specific X*Events.
// Luckily, as of xorg 1.6.0 / X protocol 11 rev 0, the only pointer
// field contained in any of these specific X*Event structs is a
// |Display*|. So to simplify serializing these XEvents, we make the
//
// ********** XXX ASSUMPTION XXX **********
//
// that the process to which the event is forwarded shares the same
// display as the process on which the event originated.
//
// With this simplification, serialization becomes a simple memcpy to
// the output stream. Deserialization starts as just a memcpy from
// the input stream, BUT we then have to write the correct |Display*|
// into the right field of each X*Event that contains one.
//
namespace IPC {
template <>
struct ParamTraits<mozilla::plugins::NPRemoteEvent> // synonym for XEvent
{
typedef mozilla::plugins::NPRemoteEvent paramType;
static void Write(Message* aMsg, const paramType& aParam)
{
aMsg->WriteBytes(&aParam, sizeof(paramType));
}
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
{
const char* bytes = 0;
if (!aMsg->ReadBytes(aIter, &bytes, sizeof(paramType))) {
return false;
}
memcpy(aResult, bytes, sizeof(paramType));
SetXDisplay(aResult->event);
return true;
}
static void Log(const paramType& aParam, std::wstring* aLog)
{
// TODO
aLog->append(L"(XEvent)");
}
private:
static Display* GetXDisplay(const XAnyEvent& ev)
{
// TODO: get Display* from Window in |ev|
// FIXME: do this using Xlib, don't use Gdk
return GDK_DISPLAY();
}
static Display* GetXDisplay(const XErrorEvent& ev)
{
// TODO: get Display* from Window in |ev|
// FIXME: do this using Xlib, don't use Gdk
return GDK_DISPLAY();
}
static void SetXDisplay(XEvent& ev)
{
if (ev.type >= KeyPress) {
ev.xany.display = GetXDisplay(ev.xany);
}
else {
// XXX assuming that this is an error event
// (type == 0? not clear from Xlib.h)
ev.xerror.display = GetXDisplay(ev.xerror);
}
}
};
} // namespace IPC
#endif // ifndef mozilla_dom_plugins_NPEventX11_h

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

@ -0,0 +1,83 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Plugins.
*
* The Initial Developer of the Original Code is
* Benjamin Smedberg <benjamin@smedbergs.us>
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
include protocol "PPluginInstance.ipdl";
include "mozilla/plugins/PluginMessageUtils.h";
using mozilla::plugins::Buffer;
using mozilla::plugins::IPCByteRanges;
using NPError;
using NPReason;
namespace mozilla {
namespace plugins {
/**
* NPBrowserStream represents a NPStream sent from the browser to the plugin.
*/
rpc protocol PBrowserStream
{
manager PPluginInstance;
child:
rpc NPP_WriteReady(int32_t newlength)
returns (int32_t size);
rpc NPP_Write(int32_t offset,
Buffer data)
returns (int32_t consumed);
rpc NPP_StreamAsFile(nsCString fname);
parent:
rpc NPN_RequestRead(IPCByteRanges ranges)
returns (NPError result);
both:
/**
* ~PBrowserStream is for both NPN_DestroyStream and NPP_DestroyStream.
* @param artificial True when the stream is closed as a by-product of
* some other call (such as a failure in NPP_Write).
*/
rpc __delete__(NPReason reason, bool artificial);
};
} // namespace plugins
} // namespace mozilla

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

@ -0,0 +1,147 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Plugins.
*
* The Initial Developer of the Original Code is
* Chris Jones <jones.chris.g@gmail.com>.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Benjamin Smedberg <benjamin@smedbergs.us>
* Ben Turner <bent.mozilla@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
include protocol "PPluginModule.ipdl";
include protocol "PPluginScriptableObject.ipdl";
include protocol "PBrowserStream.ipdl";
include protocol "PPluginStream.ipdl";
include protocol "PStreamNotify.ipdl";
include "mozilla/plugins/PluginMessageUtils.h";
using NPError;
using NPRemoteWindow;
using NPRemoteEvent;
using NPRect;
namespace mozilla {
namespace plugins {
rpc protocol PPluginInstance
{
manager PPluginModule;
manages PPluginScriptableObject;
manages PBrowserStream;
manages PPluginStream;
manages PStreamNotify;
child:
rpc __delete__()
returns (NPError rv);
rpc NPP_SetWindow(NPRemoteWindow window)
returns (NPError rv);
rpc NPP_GetValue_NPPVpluginWindow()
returns (bool value, NPError result);
rpc NPP_GetValue_NPPVpluginTransparent()
returns (bool value, NPError result);
// this message is not used on non-X platforms
rpc NPP_GetValue_NPPVpluginNeedsXEmbed()
returns (bool value, NPError result);
rpc NPP_GetValue_NPPVpluginScriptableNPObject()
returns (nullable PPluginScriptableObject value, NPError result);
rpc NPP_HandleEvent(NPRemoteEvent event)
returns (int16_t handled);
parent:
rpc NPN_GetValue_NPNVjavascriptEnabledBool()
returns (bool value, NPError result);
rpc NPN_GetValue_NPNVisOfflineBool()
returns (bool value, NPError result);
rpc NPN_GetValue_NPNVWindowNPObject()
returns (nullable PPluginScriptableObject value, NPError result);
rpc NPN_GetValue_NPNVPluginElementNPObject()
returns (nullable PPluginScriptableObject value, NPError result);
rpc NPN_GetValue_NPNVprivateModeBool()
returns (bool value, NPError result);
rpc NPN_SetValue_NPPVpluginWindow(bool windowed)
returns (NPError result);
rpc NPN_SetValue_NPPVpluginTransparent(bool transparent)
returns (NPError result);
rpc NPN_GetURL(nsCString url, nsCString target)
returns (NPError result);
rpc NPN_PostURL(nsCString url, nsCString target, nsCString buffer, bool file)
returns (NPError result);
/**
* Covers both NPN_GetURLNotify and NPN_PostURLNotify.
* @TODO This would be more readable as an overloaded method,
* but IPDL doesn't allow that for constructors (or any method?).
*/
rpc PStreamNotify(nsCString url, nsCString target, bool post,
nsCString buffer, bool file)
returns (NPError result);
async NPN_InvalidateRect(NPRect rect);
rpc NPN_PushPopupsEnabledState(bool aState)
returns (bool aSuccess);
rpc NPN_PopPopupsEnabledState()
returns (bool aSuccess);
both:
rpc PPluginScriptableObject();
child:
/* NPP_NewStream */
rpc PBrowserStream(nsCString url,
uint32_t length,
uint32_t lastmodified,
nullable PStreamNotify notifyData,
nsCString headers,
nsCString mimeType,
bool seekable)
returns (NPError rv,
uint16_t stype);
parent:
/* NPN_NewStream */
rpc PPluginStream(nsCString mimeType,
nsCString target)
returns (NPError result);
};
} // namespace plugins
} // namespace mozilla

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

@ -0,0 +1,99 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Plugins.
*
* The Initial Developer of the Original Code is
* Chris Jones <jones.chris.g@gmail.com>.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Benjamin Smedberg <benjamin@smedbergs.us>
* Ben Turner <bent.mozilla@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
include protocol "PPluginInstance.ipdl";
include "npapi.h";
include "mozilla/plugins/PluginMessageUtils.h";
using NPError;
using NPNVariable;
using mozilla::ipc::NPRemoteIdentifier;
namespace mozilla {
namespace plugins {
rpc protocol PPluginModule
{
manages PPluginInstance;
child:
rpc NP_Initialize()
returns (NPError rv);
rpc PPluginInstance(nsCString aMimeType,
uint16_t aMode,
nsCString[] aNames,
nsCString[] aValues)
returns (NPError rv);
rpc NP_Shutdown()
returns (NPError rv);
parent:
rpc NPN_UserAgent()
returns (nsCString userAgent);
sync NPN_GetStringIdentifier(nsCString aString)
returns (NPRemoteIdentifier aId);
sync NPN_GetIntIdentifier(int32_t aInt)
returns (NPRemoteIdentifier aId);
// for the following two methods, the returned value is valid iff
// |err == NPERR_NO_ERROR|
sync NPN_UTF8FromIdentifier(NPRemoteIdentifier aId)
returns (NPError err, nsCString aString);
// technically |aInt| is undefined when |aId| is invalid. but it's
// nice to let the other side know that |aId| was invalid
sync NPN_IntFromIdentifier(NPRemoteIdentifier aId)
returns (NPError err, int32_t aInt);
sync NPN_IdentifierIsString(NPRemoteIdentifier aId)
returns (bool aIsString);
sync NPN_GetStringIdentifiers(nsCString[] aNames)
returns (NPRemoteIdentifier[] aIds);
rpc NPN_GetValue_WithBoolReturn(NPNVariable aVariable)
returns (NPError aError,
bool aBoolVal);
};
} // namespace plugins
} // namespace mozilla

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

@ -0,0 +1,115 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Plugins.
*
* The Initial Developer of the Original Code is
* Chris Jones <jones.chris.g@gmail.com>.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Benjamin Smedberg <benjamin@smedbergs.us>
* Ben Turner <bent.mozilla@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
include protocol "PPluginInstance.ipdl";
include "npapi.h";
include "npruntime.h";
include "mozilla/plugins/PluginMessageUtils.h";
using mozilla::ipc::NPRemoteIdentifier;
using mozilla::void_t;
using mozilla::null_t;
namespace mozilla {
namespace plugins {
union Variant {
void_t;
null_t;
bool;
int;
double;
nsCString;
nullable PPluginScriptableObject;
};
rpc protocol PPluginScriptableObject
{
manager PPluginInstance;
both:
rpc __delete__();
parent:
rpc NPN_Evaluate(nsCString aScript)
returns (Variant aResult,
bool aSuccess);
both:
// NPClass methods
rpc Invalidate();
rpc HasMethod(NPRemoteIdentifier aId)
returns (bool aHasMethod);
rpc Invoke(NPRemoteIdentifier aId,
Variant[] aArgs)
returns (Variant aResult,
bool aSuccess);
rpc InvokeDefault(Variant[] aArgs)
returns (Variant aResult,
bool aSuccess);
rpc HasProperty(NPRemoteIdentifier aId)
returns (bool aHasProperty);
rpc GetProperty(NPRemoteIdentifier aId)
returns (Variant aResult,
bool aSuccess);
rpc SetProperty(NPRemoteIdentifier aId,
Variant aValue)
returns (bool aSuccess);
rpc RemoveProperty(NPRemoteIdentifier aId)
returns (bool aSuccess);
rpc Enumerate()
returns (NPRemoteIdentifier[] aProperties,
bool aSuccess);
rpc Construct(Variant[] aArgs)
returns (Variant aResult,
bool aSuccess);
};
} // namespace plugins
} // namespace mozilla

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

@ -0,0 +1,70 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Plugins.
*
* The Initial Developer of the Original Code is
* The Mozilla Foundation <http://www.mozilla.org/>.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
include protocol "PPluginInstance.ipdl";
include "mozilla/plugins/PluginMessageUtils.h";
using mozilla::plugins::Buffer;
using NPError;
using NPReason;
namespace mozilla {
namespace plugins {
/**
* PPluginStream represents an NPStream sent from the plugin to the browser.
*/
rpc protocol PPluginStream
{
manager PPluginInstance;
parent:
rpc NPN_Write(Buffer data) returns (int32_t written);
both:
/**
* ~PPluginStream is for both NPN_DestroyStream and NPP_DestroyStream.
* @param artificial True when the stream is closed as a by-product of
* some other call (such as a failure in NPN_Write).
*/
rpc __delete__(NPReason reason, bool artificial);
};
} // namespace plugins
} // namespace mozilla

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

@ -0,0 +1,27 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
include protocol "PPluginInstance.ipdl";
include "npapi.h";
using NPReason;
namespace mozilla {
namespace plugins {
/**
* This empty protocol exists only to be constructed and destroyed.
*/
rpc protocol PStreamNotify
{
manager PPluginInstance;
child:
/**
* Represents NPP_URLNotify
*/
rpc __delete__(NPReason reason);
};
} // namespace plugins
} // namespace mozilla

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -0,0 +1,226 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: sw=4 ts=4 et :
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Plugin App.
*
* The Initial Developer of the Original Code is
* Chris Jones <jones.chris.g@gmail.com>
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef dom_plugins_PluginInstanceChild_h
#define dom_plugins_PluginInstanceChild_h 1
#include "mozilla/plugins/PPluginInstanceChild.h"
#include "mozilla/plugins/PluginScriptableObjectChild.h"
#include "mozilla/plugins/StreamNotifyChild.h"
#if defined(OS_WIN)
#include "mozilla/gfx/SharedDIBWin.h"
#endif
#include "npfunctions.h"
#include "nsAutoPtr.h"
#include "nsTArray.h"
#undef _MOZ_LOG
#define _MOZ_LOG(s) printf("[PluginInstanceChild] %s\n", s)
namespace mozilla {
namespace plugins {
class PBrowserStreamChild;
class BrowserStreamChild;
class PluginInstanceChild : public PPluginInstanceChild
{
friend class BrowserStreamChild;
friend class PluginStreamChild;
#ifdef OS_WIN
friend LRESULT CALLBACK PluginWindowProc(HWND hWnd,
UINT message,
WPARAM wParam,
LPARAM lParam);
#endif
protected:
virtual bool AnswerNPP_SetWindow(const NPRemoteWindow& window, NPError* rv);
virtual bool Answer__delete__(NPError* rv);
virtual bool
AnswerNPP_GetValue_NPPVpluginWindow(bool* windowed, NPError* rv);
virtual bool
AnswerNPP_GetValue_NPPVpluginTransparent(bool* transparent, NPError* rv);
virtual bool
AnswerNPP_GetValue_NPPVpluginNeedsXEmbed(bool* needs, NPError* rv);
virtual bool
AnswerNPP_GetValue_NPPVpluginScriptableNPObject(PPluginScriptableObjectChild** value,
NPError* result);
virtual bool
AnswerNPP_HandleEvent(const NPRemoteEvent& event, int16_t* handled);
virtual PPluginScriptableObjectChild*
AllocPPluginScriptableObject();
virtual bool
DeallocPPluginScriptableObject(PPluginScriptableObjectChild* aObject);
virtual bool
AnswerPPluginScriptableObjectConstructor(PPluginScriptableObjectChild* aActor);
virtual PBrowserStreamChild*
AllocPBrowserStream(const nsCString& url,
const uint32_t& length,
const uint32_t& lastmodified,
PStreamNotifyChild* notifyData,
const nsCString& headers,
const nsCString& mimeType,
const bool& seekable,
NPError* rv,
uint16_t *stype);
virtual bool
DeallocPBrowserStream(PBrowserStreamChild* stream);
virtual PPluginStreamChild*
AllocPPluginStream(const nsCString& mimeType,
const nsCString& target,
NPError* result);
virtual bool
DeallocPPluginStream(PPluginStreamChild* stream);
virtual PStreamNotifyChild*
AllocPStreamNotify(const nsCString& url, const nsCString& target,
const bool& post, const nsCString& buffer,
const bool& file,
NPError* result);
NS_OVERRIDE virtual bool
DeallocPStreamNotify(PStreamNotifyChild* notifyData);
public:
PluginInstanceChild(const NPPluginFuncs* aPluginIface);
virtual ~PluginInstanceChild();
bool Initialize();
void Destroy();
NPP GetNPP()
{
return &mData;
}
NPError
NPN_GetValue(NPNVariable aVariable, void* aValue);
NPError
NPN_SetValue(NPPVariable aVariable, void* aValue);
PluginScriptableObjectChild*
GetActorForNPObject(NPObject* aObject);
NPError
NPN_NewStream(NPMIMEType aMIMEType, const char* aWindow,
NPStream** aStream);
// Return true if you want to send the notification to the parent process
// also.
bool
InternalInvalidateRect(NPRect* aInvalidRect);
bool NotifyStream(StreamNotifyChild* notifyData, NPReason reason);
private:
#if defined(OS_WIN)
static bool RegisterWindowClass();
bool CreatePluginWindow();
void DestroyPluginWindow();
void ReparentPluginWindow(HWND hWndParent);
void SizePluginWindow(int width, int height);
static LRESULT CALLBACK DummyWindowProc(HWND hWnd,
UINT message,
WPARAM wParam,
LPARAM lParam);
static LRESULT CALLBACK PluginWindowProc(HWND hWnd,
UINT message,
WPARAM wParam,
LPARAM lParam);
#endif
const NPPluginFuncs* mPluginIface;
NPP_t mData;
NPWindow mWindow;
#if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX)
NPSetWindowCallbackStruct mWsInfo;
#elif defined(OS_WIN)
HWND mPluginWindowHWND;
WNDPROC mPluginWndProc;
HWND mPluginParentHWND;
#endif
nsTArray<nsAutoPtr<PluginScriptableObjectChild> > mScriptableObjects;
#if defined(OS_WIN)
private:
// Shared dib rendering management for windowless plugins.
bool SharedSurfaceSetWindow(const NPRemoteWindow& aWindow, NPError* rv);
int16_t SharedSurfacePaint(NPEvent& evcopy);
void SharedSurfaceRelease();
bool AlphaExtractCacheSetup();
void AlphaExtractCacheRelease();
void UpdatePaintClipRect(RECT* aRect);
private:
enum {
RENDER_NATIVE,
RENDER_BACK_ONE,
RENDER_BACK_TWO
};
gfx::SharedDIBWin mSharedSurfaceDib;
struct {
PRUint32 doublePassEvent;
PRUint16 doublePass;
HDC hdc;
HBITMAP bmp;
} mAlphaExtract;
#endif // defined(OS_WIN)
};
} // namespace plugins
} // namespace mozilla
#endif // ifndef dom_plugins_PluginInstanceChild_h

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

@ -0,0 +1,842 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: sw=4 ts=4 et :
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Plugin App.
*
* The Initial Developer of the Original Code is
* Chris Jones <jones.chris.g@gmail.com>
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Jim Mathies <jmathies@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "PluginInstanceParent.h"
#include "BrowserStreamParent.h"
#include "PluginModuleParent.h"
#include "PluginStreamParent.h"
#include "StreamNotifyParent.h"
#include "npfunctions.h"
#include "nsAutoPtr.h"
#if defined(OS_WIN)
#include <windowsx.h>
#endif
using namespace mozilla::plugins;
PluginInstanceParent::PluginInstanceParent(PluginModuleParent* parent,
NPP npp,
const NPNetscapeFuncs* npniface)
: mParent(parent),
mNPP(npp),
mNPNIface(npniface),
mWindowType(NPWindowTypeWindow)
{
}
PluginInstanceParent::~PluginInstanceParent()
{
if (mNPP)
mNPP->pdata = NULL;
}
void
PluginInstanceParent::Destroy()
{
// Copy the actors here so we don't enumerate a mutating array.
nsAutoTArray<PluginScriptableObjectParent*, 10> objects;
PRUint32 count = mScriptableObjects.Length();
for (PRUint32 index = 0; index < count; index++) {
objects.AppendElement(mScriptableObjects[index]);
}
count = objects.Length();
for (PRUint32 index = 0; index < count; index++) {
NPObject* object = objects[index]->GetObject();
if (object->_class == PluginScriptableObjectParent::GetClass()) {
PluginScriptableObjectParent::ScriptableInvalidate(object);
}
}
#if defined(OS_WIN)
SharedSurfaceRelease();
#endif
}
PBrowserStreamParent*
PluginInstanceParent::AllocPBrowserStream(const nsCString& url,
const uint32_t& length,
const uint32_t& lastmodified,
PStreamNotifyParent* notifyData,
const nsCString& headers,
const nsCString& mimeType,
const bool& seekable,
NPError* rv,
uint16_t *stype)
{
NS_RUNTIMEABORT("Not reachable");
return NULL;
}
bool
PluginInstanceParent::DeallocPBrowserStream(PBrowserStreamParent* stream)
{
delete stream;
return true;
}
PPluginStreamParent*
PluginInstanceParent::AllocPPluginStream(const nsCString& mimeType,
const nsCString& target,
NPError* result)
{
return new PluginStreamParent(this, mimeType, target, result);
}
bool
PluginInstanceParent::DeallocPPluginStream(PPluginStreamParent* stream)
{
delete stream;
return true;
}
bool
PluginInstanceParent::AnswerNPN_GetValue_NPNVjavascriptEnabledBool(
bool* value,
NPError* result)
{
NPBool v;
*result = mNPNIface->getvalue(mNPP, NPNVjavascriptEnabledBool, &v);
*value = v;
return true;
}
bool
PluginInstanceParent::AnswerNPN_GetValue_NPNVisOfflineBool(bool* value,
NPError* result)
{
NPBool v;
*result = mNPNIface->getvalue(mNPP, NPNVisOfflineBool, &v);
*value = v;
return true;
}
bool
PluginInstanceParent::InternalGetValueForNPObject(
NPNVariable aVariable,
PPluginScriptableObjectParent** aValue,
NPError* aResult)
{
NPObject* npobject;
NPError result = mNPNIface->getvalue(mNPP, aVariable, (void*)&npobject);
if (result == NPERR_NO_ERROR) {
NS_ASSERTION(npobject, "Shouldn't return null and NPERR_NO_ERROR!");
PluginScriptableObjectParent* actor = GetActorForNPObject(npobject);
mNPNIface->releaseobject(npobject);
if (actor) {
*aValue = actor;
*aResult = NPERR_NO_ERROR;
return true;
}
NS_ERROR("Failed to get actor!");
result = NPERR_GENERIC_ERROR;
}
*aValue = nsnull;
*aResult = result;
return true;
}
bool
PluginInstanceParent::AnswerNPN_GetValue_NPNVWindowNPObject(
PPluginScriptableObjectParent** aValue,
NPError* aResult)
{
return InternalGetValueForNPObject(NPNVWindowNPObject, aValue, aResult);
}
bool
PluginInstanceParent::AnswerNPN_GetValue_NPNVPluginElementNPObject(
PPluginScriptableObjectParent** aValue,
NPError* aResult)
{
return InternalGetValueForNPObject(NPNVPluginElementNPObject, aValue,
aResult);
}
bool
PluginInstanceParent::AnswerNPN_GetValue_NPNVprivateModeBool(bool* value,
NPError* result)
{
NPBool v;
*result = mNPNIface->getvalue(mNPP, NPNVprivateModeBool, &v);
*value = v;
return true;
}
bool
PluginInstanceParent::AnswerNPN_SetValue_NPPVpluginWindow(
const bool& windowed, NPError* result)
{
NPBool isWindowed = windowed;
*result = mNPNIface->setvalue(mNPP, NPPVpluginWindowBool,
(void*)isWindowed);
return true;
}
bool
PluginInstanceParent::AnswerNPN_SetValue_NPPVpluginTransparent(
const bool& transparent, NPError* result)
{
NPBool isTransparent = transparent;
*result = mNPNIface->setvalue(mNPP, NPPVpluginTransparentBool,
(void*)isTransparent);
return true;
}
bool
PluginInstanceParent::AnswerNPN_GetURL(const nsCString& url,
const nsCString& target,
NPError* result)
{
*result = mNPNIface->geturl(mNPP,
NullableStringGet(url),
NullableStringGet(target));
return true;
}
bool
PluginInstanceParent::AnswerNPN_PostURL(const nsCString& url,
const nsCString& target,
const nsCString& buffer,
const bool& file,
NPError* result)
{
*result = mNPNIface->posturl(mNPP, url.get(), NullableStringGet(target),
buffer.Length(), buffer.get(), file);
return true;
}
PStreamNotifyParent*
PluginInstanceParent::AllocPStreamNotify(const nsCString& url,
const nsCString& target,
const bool& post,
const nsCString& buffer,
const bool& file,
NPError* result)
{
return new StreamNotifyParent();
}
bool
PluginInstanceParent::AnswerPStreamNotifyConstructor(PStreamNotifyParent* actor,
const nsCString& url,
const nsCString& target,
const bool& post,
const nsCString& buffer,
const bool& file,
NPError* result)
{
if (!post) {
*result = mNPNIface->geturlnotify(mNPP,
NullableStringGet(url),
NullableStringGet(target),
actor);
}
else {
*result = mNPNIface->posturlnotify(mNPP,
NullableStringGet(url),
NullableStringGet(target),
buffer.Length(),
NullableStringGet(buffer),
file, actor);
}
if (*result != NPERR_NO_ERROR)
PStreamNotifyParent::Call__delete__(actor, NPERR_GENERIC_ERROR);
return true;
}
bool
PluginInstanceParent::DeallocPStreamNotify(PStreamNotifyParent* notifyData)
{
delete notifyData;
return true;
}
bool
PluginInstanceParent::RecvNPN_InvalidateRect(const NPRect& rect)
{
mNPNIface->invalidaterect(mNPP, const_cast<NPRect*>(&rect));
return true;
}
NPError
PluginInstanceParent::NPP_SetWindow(const NPWindow* aWindow)
{
_MOZ_LOG(__FUNCTION__);
NS_ENSURE_TRUE(aWindow, NPERR_GENERIC_ERROR);
NPRemoteWindow window;
mWindowType = aWindow->type;
#if defined(OS_WIN)
// On windowless controls, reset the shared memory surface as needed.
if (mWindowType == NPWindowTypeDrawable) {
// SharedSurfaceSetWindow will take care of NPRemoteWindow.
if (!SharedSurfaceSetWindow(aWindow, window)) {
return NPERR_OUT_OF_MEMORY_ERROR;
}
}
else {
window.window = reinterpret_cast<unsigned long>(aWindow->window);
window.x = aWindow->x;
window.y = aWindow->y;
window.width = aWindow->width;
window.height = aWindow->height;
window.type = aWindow->type;
}
#else
window.window = reinterpret_cast<unsigned long>(aWindow->window);
window.x = aWindow->x;
window.y = aWindow->y;
window.width = aWindow->width;
window.height = aWindow->height;
window.clipRect = aWindow->clipRect; // MacOS specific
window.type = aWindow->type;
#endif
#if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX)
const NPSetWindowCallbackStruct* ws_info =
static_cast<NPSetWindowCallbackStruct*>(aWindow->ws_info);
window.visualID = ws_info->visual ? ws_info->visual->visualid : None;
window.colormap = ws_info->colormap;
#endif
NPError prv;
if (!CallNPP_SetWindow(window, &prv))
return NPERR_GENERIC_ERROR;
return prv;
}
NPError
PluginInstanceParent::NPP_GetValue(NPPVariable aVariable,
void* _retval)
{
printf("[PluginInstanceParent] NPP_GetValue(%s)\n",
NPPVariableToString(aVariable));
switch (aVariable) {
case NPPVpluginWindowBool: {
bool windowed;
NPError rv;
if (!CallNPP_GetValue_NPPVpluginWindow(&windowed, &rv)) {
return NPERR_GENERIC_ERROR;
}
if (NPERR_NO_ERROR != rv) {
return rv;
}
(*(NPBool*)_retval) = windowed;
return NPERR_NO_ERROR;
}
case NPPVpluginTransparentBool: {
bool transparent;
NPError rv;
if (!CallNPP_GetValue_NPPVpluginTransparent(&transparent, &rv)) {
return NPERR_GENERIC_ERROR;
}
if (NPERR_NO_ERROR != rv) {
return rv;
}
(*(NPBool*)_retval) = transparent;
return NPERR_NO_ERROR;
}
#ifdef OS_LINUX
case NPPVpluginNeedsXEmbed: {
bool needsXEmbed;
NPError rv;
if (!CallNPP_GetValue_NPPVpluginNeedsXEmbed(&needsXEmbed, &rv)) {
return NPERR_GENERIC_ERROR;
}
if (NPERR_NO_ERROR != rv) {
return rv;
}
(*(NPBool*)_retval) = needsXEmbed;
return NPERR_NO_ERROR;
}
#endif
case NPPVpluginScriptableNPObject: {
PPluginScriptableObjectParent* actor;
NPError rv;
if (!CallNPP_GetValue_NPPVpluginScriptableNPObject(&actor, &rv)) {
return NPERR_GENERIC_ERROR;
}
if (NPERR_NO_ERROR != rv) {
return rv;
}
if (!actor) {
NS_ERROR("NPPVpluginScriptableNPObject succeeded but null.");
return NPERR_GENERIC_ERROR;
}
const NPNetscapeFuncs* npn = mParent->GetNetscapeFuncs();
if (!npn) {
NS_WARNING("No netscape functions?!");
return NPERR_GENERIC_ERROR;
}
NPObject* object =
static_cast<PluginScriptableObjectParent*>(actor)->GetObject();
NS_ASSERTION(object, "This shouldn't ever be null!");
(*(NPObject**)_retval) = npn->retainobject(object);
return NPERR_NO_ERROR;
}
default:
printf(" unhandled var %s\n", NPPVariableToString(aVariable));
return NPERR_GENERIC_ERROR;
}
}
int16_t
PluginInstanceParent::NPP_HandleEvent(void* event)
{
_MOZ_LOG(__FUNCTION__);
NPEvent* npevent = reinterpret_cast<NPEvent*>(event);
NPRemoteEvent npremoteevent;
npremoteevent.event = *npevent;
int16_t handled;
#if defined(OS_WIN)
RECT rect;
if (mWindowType == NPWindowTypeDrawable) {
switch(npevent->event) {
case WM_PAINT:
{
RECT rect;
SharedSurfaceBeforePaint(rect, npremoteevent);
if (!CallNPP_HandleEvent(npremoteevent, &handled))
return 0;
if (handled)
SharedSurfaceAfterPaint(npevent);
}
break;
case WM_WINDOWPOSCHANGED:
SharedSurfaceSetOrigin(npremoteevent);
if (!CallNPP_HandleEvent(npremoteevent, &handled))
return 0;
break;
case WM_MOUSEMOVE:
case WM_RBUTTONDOWN:
case WM_MBUTTONDOWN:
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_MBUTTONUP:
case WM_RBUTTONUP:
case WM_LBUTTONDBLCLK:
case WM_MBUTTONDBLCLK:
case WM_RBUTTONDBLCLK:
{
// Received mouse events have an origin at the position of the plugin rect
// in the page. However, when rendering to the shared dib, the rect origin
// changes to 0,0 via the WM_WINDOWPOSCHANGED event. In this case we need to
// translate these coords to the proper location.
nsPoint pt(GET_X_LPARAM(npremoteevent.event.lParam), GET_Y_LPARAM(npremoteevent.event.lParam));
pt.MoveBy(-mPluginPosOrigin.x, -mPluginPosOrigin.y);
npremoteevent.event.lParam = MAKELPARAM(pt.x, pt.y);
if (!CallNPP_HandleEvent(npremoteevent, &handled))
return 0;
}
default:
if (!CallNPP_HandleEvent(npremoteevent, &handled))
return 0;
break;
}
}
else {
if (!CallNPP_HandleEvent(npremoteevent, &handled))
return 0;
}
#endif
#if defined(MOZ_X11)
if (GraphicsExpose == npevent->type) {
printf(" schlepping drawable 0x%lx across the pipe\n",
npevent->xgraphicsexpose.drawable);
// Make sure the X server has created the Drawable and completes any
// drawing before the plugin draws on top.
//
// XSync() waits for the X server to complete. Really this parent
// process does not need to wait; the child is the process that needs
// to wait. A possibly-slightly-better alternative would be to send
// an X event to the child that the child would wait for.
# ifdef MOZ_WIDGET_GTK2
XSync(GDK_DISPLAY(), False);
# endif
}
if (!CallNPP_HandleEvent(npremoteevent, &handled))
return 0; // no good way to handle errors here...
#endif
return handled;
}
NPError
PluginInstanceParent::NPP_NewStream(NPMIMEType type, NPStream* stream,
NPBool seekable, uint16_t* stype)
{
_MOZ_LOG(__FUNCTION__);
BrowserStreamParent* bs = new BrowserStreamParent(this, stream);
NPError err;
if (!CallPBrowserStreamConstructor(bs,
NullableString(stream->url),
stream->end,
stream->lastmodified,
static_cast<PStreamNotifyParent*>(stream->notifyData),
NullableString(stream->headers),
NullableString(type), seekable,
&err, stype))
return NPERR_GENERIC_ERROR;
if (NPERR_NO_ERROR != err)
PBrowserStreamParent::Call__delete__(bs, NPERR_GENERIC_ERROR, true);
return err;
}
NPError
PluginInstanceParent::NPP_DestroyStream(NPStream* stream, NPReason reason)
{
_MOZ_LOG(__FUNCTION__);
AStream* s = static_cast<AStream*>(stream->pdata);
if (s->IsBrowserStream()) {
BrowserStreamParent* sp =
static_cast<BrowserStreamParent*>(s);
if (sp->mNPP != this)
NS_RUNTIMEABORT("Mismatched plugin data");
PBrowserStreamParent::Call__delete__(sp, reason, false);
return NPERR_NO_ERROR;
}
else {
PluginStreamParent* sp =
static_cast<PluginStreamParent*>(s);
if (sp->mInstance != this)
NS_RUNTIMEABORT("Mismatched plugin data");
PPluginStreamParent::Call__delete__(sp, reason, false);
return NPERR_NO_ERROR;
}
}
PPluginScriptableObjectParent*
PluginInstanceParent::AllocPPluginScriptableObject()
{
nsAutoPtr<PluginScriptableObjectParent>* object =
mScriptableObjects.AppendElement();
NS_ENSURE_TRUE(object, nsnull);
*object = new PluginScriptableObjectParent();
NS_ENSURE_TRUE(*object, nsnull);
return object->get();
}
bool
PluginInstanceParent::DeallocPPluginScriptableObject(
PPluginScriptableObjectParent* aObject)
{
PluginScriptableObjectParent* object =
reinterpret_cast<PluginScriptableObjectParent*>(aObject);
PRUint32 count = mScriptableObjects.Length();
for (PRUint32 index = 0; index < count; index++) {
if (mScriptableObjects[index] == object) {
mScriptableObjects.RemoveElementAt(index);
return true;
}
}
NS_NOTREACHED("An actor we don't know about?!");
return false;
}
bool
PluginInstanceParent::AnswerPPluginScriptableObjectConstructor(
PPluginScriptableObjectParent* aActor)
{
// This is only called in response to the child process requesting the
// creation of an actor. This actor will represent an NPObject that is
// created by the plugin and returned to the browser.
const NPNetscapeFuncs* npn = mParent->GetNetscapeFuncs();
if (!npn) {
NS_WARNING("No netscape function pointers?!");
return false;
}
NPClass* npclass =
const_cast<NPClass*>(PluginScriptableObjectParent::GetClass());
ParentNPObject* object = reinterpret_cast<ParentNPObject*>(
npn->createobject(mNPP, npclass));
if (!object) {
NS_WARNING("Failed to create NPObject!");
return false;
}
static_cast<PluginScriptableObjectParent*>(aActor)->Initialize(
const_cast<PluginInstanceParent*>(this), object);
return true;
}
void
PluginInstanceParent::NPP_URLNotify(const char* url, NPReason reason,
void* notifyData)
{
_MOZ_LOG(__FUNCTION__);
PStreamNotifyParent* streamNotify =
static_cast<PStreamNotifyParent*>(notifyData);
PStreamNotifyParent::Call__delete__(streamNotify, reason);
}
PluginScriptableObjectParent*
PluginInstanceParent::GetActorForNPObject(NPObject* aObject)
{
NS_ASSERTION(aObject, "Null pointer!");
if (aObject->_class == PluginScriptableObjectParent::GetClass()) {
// One of ours!
ParentNPObject* object = static_cast<ParentNPObject*>(aObject);
NS_ASSERTION(object->parent, "Null actor!");
return object->parent;
}
PRUint32 count = mScriptableObjects.Length();
for (PRUint32 index = 0; index < count; index++) {
nsAutoPtr<PluginScriptableObjectParent>& actor =
mScriptableObjects[index];
if (actor->GetObject() == aObject) {
return actor;
}
}
PluginScriptableObjectParent* actor =
static_cast<PluginScriptableObjectParent*>(
CallPPluginScriptableObjectConstructor());
NS_ENSURE_TRUE(actor, nsnull);
actor->Initialize(const_cast<PluginInstanceParent*>(this), aObject);
return actor;
}
bool
PluginInstanceParent::AnswerNPN_PushPopupsEnabledState(const bool& aState,
bool* aSuccess)
{
*aSuccess = mNPNIface->pushpopupsenabledstate(mNPP, aState ? 1 : 0);
return true;
}
bool
PluginInstanceParent::AnswerNPN_PopPopupsEnabledState(bool* aSuccess)
{
*aSuccess = mNPNIface->poppopupsenabledstate(mNPP);
return true;
}
#if defined(OS_WIN)
/* windowless drawing helpers */
/*
* Origin info:
*
* windowless, offscreen:
*
* WM_WINDOWPOSCHANGED: origin is relative to container
* setwindow: origin is 0,0
* WM_PAINT: origin is 0,0
*
* windowless, native:
*
* WM_WINDOWPOSCHANGED: origin is relative to container
* setwindow: origin is relative to container
* WM_PAINT: origin is relative to container
*
* PluginInstanceParent:
*
* painting: mPluginPort (nsIntRect, saved in SetWindow)
* event translation: mPluginPosOrigin (nsIntPoint, saved in SetOrigin)
*/
void
PluginInstanceParent::SharedSurfaceSetOrigin(NPRemoteEvent& npremoteevent)
{
WINDOWPOS* winpos = (WINDOWPOS*)npremoteevent.event.lParam;
// save the origin, we'll use this to translate input coordinates
mPluginPosOrigin.x = winpos->x;
mPluginPosOrigin.y = winpos->y;
// Reset to the offscreen dib origin
winpos->x = 0;
winpos->y = 0;
}
void
PluginInstanceParent::SharedSurfaceRelease()
{
mSharedSurfaceDib.Close();
}
bool
PluginInstanceParent::SharedSurfaceSetWindow(const NPWindow* aWindow,
NPRemoteWindow& aRemoteWindow)
{
aRemoteWindow.window = nsnull;
aRemoteWindow.x = 0;
aRemoteWindow.y = 0;
aRemoteWindow.width = aWindow->width;
aRemoteWindow.height = aWindow->height;
aRemoteWindow.type = aWindow->type;
nsIntRect newPort(aWindow->x, aWindow->y, aWindow->width, aWindow->height);
// save the the rect location within the browser window.
mPluginPort = newPort;
// move the port to our shared surface origin
newPort.MoveTo(0,0);
// check to see if we have the room in shared surface
if (mSharedSurfaceDib.IsValid() && mSharedSize.Contains(newPort)) {
// ok to paint
aRemoteWindow.surfaceHandle = 0;
return true;
}
// allocate a new shared surface
SharedSurfaceRelease();
if (NS_FAILED(mSharedSurfaceDib.Create(reinterpret_cast<HDC>(aWindow->window),
newPort.width, newPort.height, 32)))
return false;
// save the new shared surface size we just allocated
mSharedSize = newPort;
base::SharedMemoryHandle handle;
if (NS_FAILED(mSharedSurfaceDib.ShareToProcess(mParent->ChildProcessHandle(), &handle)))
return false;
aRemoteWindow.surfaceHandle = handle;
return true;
}
void
PluginInstanceParent::SharedSurfaceBeforePaint(RECT& rect,
NPRemoteEvent& npremoteevent)
{
RECT* dr = (RECT*)npremoteevent.event.lParam;
HDC parentHdc = (HDC)npremoteevent.event.wParam;
nsIntRect dirtyRect(dr->left, dr->top, dr->right-dr->left, dr->bottom-dr->top);
dirtyRect.MoveBy(-mPluginPort.x, -mPluginPort.y); // should always be smaller than dirtyRect
::BitBlt(mSharedSurfaceDib.GetHDC(),
dirtyRect.x,
dirtyRect.y,
dirtyRect.width,
dirtyRect.height,
parentHdc,
dr->left,
dr->top,
SRCCOPY);
// setup the translated dirty rect we'll send to the child
rect.left = dirtyRect.x;
rect.top = dirtyRect.y;
rect.right = dirtyRect.x + dirtyRect.width;
rect.bottom = dirtyRect.y + dirtyRect.height;
npremoteevent.event.wParam = WPARAM(0);
npremoteevent.event.lParam = LPARAM(&rect);
}
void
PluginInstanceParent::SharedSurfaceAfterPaint(NPEvent* npevent)
{
RECT* dr = (RECT*)npevent->lParam;
HDC parentHdc = (HDC)npevent->wParam;
nsIntRect dirtyRect(dr->left, dr->top, dr->right-dr->left, dr->bottom-dr->top);
dirtyRect.MoveBy(-mPluginPort.x, -mPluginPort.y);
// src copy the shared dib into the parent surface we are handed.
::BitBlt(parentHdc,
dr->left,
dr->top,
dirtyRect.width,
dirtyRect.height,
mSharedSurfaceDib.GetHDC(),
dirtyRect.x,
dirtyRect.y,
SRCCOPY);
}
#endif // defined(OS_WIN)

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

@ -0,0 +1,237 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: sw=4 ts=4 et :
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Plugin App.
*
* The Initial Developer of the Original Code is
* Chris Jones <jones.chris.g@gmail.com>
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef dom_plugins_PluginInstanceParent_h
#define dom_plugins_PluginInstanceParent_h 1
#include "mozilla/plugins/PPluginInstanceParent.h"
#include "mozilla/plugins/PluginScriptableObjectParent.h"
#if defined(OS_WIN)
#include "mozilla/gfx/SharedDIBWin.h"
#endif
#include "npfunctions.h"
#include "nsAutoPtr.h"
#include "nsTArray.h"
#include "nsRect.h"
#undef _MOZ_LOG
#define _MOZ_LOG(s) printf("[PluginInstanceParent] %s\n", s)
namespace mozilla {
namespace plugins {
class PBrowserStreamParent;
class PluginModuleParent;
class PluginInstanceParent : public PPluginInstanceParent
{
friend class PluginModuleParent;
friend class BrowserStreamParent;
friend class PluginStreamParent;
public:
PluginInstanceParent(PluginModuleParent* parent,
NPP npp,
const NPNetscapeFuncs* npniface);
virtual ~PluginInstanceParent();
void Destroy();
virtual PPluginScriptableObjectParent*
AllocPPluginScriptableObject();
virtual bool
AnswerPPluginScriptableObjectConstructor(PPluginScriptableObjectParent* aActor);
virtual bool
DeallocPPluginScriptableObject(PPluginScriptableObjectParent* aObject);
virtual PBrowserStreamParent*
AllocPBrowserStream(const nsCString& url,
const uint32_t& length,
const uint32_t& lastmodified,
PStreamNotifyParent* notifyData,
const nsCString& headers,
const nsCString& mimeType,
const bool& seekable,
NPError* rv,
uint16_t *stype);
virtual bool
DeallocPBrowserStream(PBrowserStreamParent* stream);
virtual PPluginStreamParent*
AllocPPluginStream(const nsCString& mimeType,
const nsCString& target,
NPError* result);
virtual bool
DeallocPPluginStream(PPluginStreamParent* stream);
virtual bool
AnswerNPN_GetValue_NPNVjavascriptEnabledBool(bool* value, NPError* result);
virtual bool
AnswerNPN_GetValue_NPNVisOfflineBool(bool* value, NPError* result);
virtual bool
AnswerNPN_GetValue_NPNVWindowNPObject(
PPluginScriptableObjectParent** value,
NPError* result);
virtual bool
AnswerNPN_GetValue_NPNVPluginElementNPObject(
PPluginScriptableObjectParent** value,
NPError* result);
virtual bool
AnswerNPN_GetValue_NPNVprivateModeBool(bool* value, NPError* result);
virtual bool
AnswerNPN_SetValue_NPPVpluginWindow(const bool& windowed, NPError* result);
virtual bool
AnswerNPN_SetValue_NPPVpluginTransparent(const bool& transparent,
NPError* result);
virtual bool
AnswerNPN_GetURL(const nsCString& url, const nsCString& target,
NPError *result);
virtual bool
AnswerNPN_PostURL(const nsCString& url, const nsCString& target,
const nsCString& buffer, const bool& file,
NPError* result);
virtual PStreamNotifyParent*
AllocPStreamNotify(const nsCString& url, const nsCString& target,
const bool& post, const nsCString& buffer,
const bool& file,
NPError* result);
NS_OVERRIDE virtual bool
AnswerPStreamNotifyConstructor(PStreamNotifyParent* actor,
const nsCString& url,
const nsCString& target,
const bool& post, const nsCString& buffer,
const bool& file,
NPError* result);
virtual bool
DeallocPStreamNotify(PStreamNotifyParent* notifyData);
virtual bool
RecvNPN_InvalidateRect(const NPRect& rect);
virtual bool
AnswerNPN_PushPopupsEnabledState(const bool& aState,
bool* aSuccess);
virtual bool
AnswerNPN_PopPopupsEnabledState(bool* aSuccess);
NPError NPP_SetWindow(const NPWindow* aWindow);
NPError NPP_GetValue(NPPVariable variable, void *ret_value);
NPError NPP_SetValue(NPNVariable variable, void *value)
{
_MOZ_LOG(__FUNCTION__);
return 1;
}
NPError NPP_NewStream(NPMIMEType type, NPStream* stream,
NPBool seekable, uint16_t* stype);
NPError NPP_DestroyStream(NPStream* stream, NPReason reason);
void NPP_Print(NPPrint* platformPrint)
{
_MOZ_LOG(__FUNCTION__);
}
int16_t NPP_HandleEvent(void* event);
void NPP_URLNotify(const char* url, NPReason reason, void* notifyData);
PluginModuleParent* Module()
{
return mParent;
}
const NPNetscapeFuncs* GetNPNIface()
{
return mNPNIface;
}
PluginScriptableObjectParent*
GetActorForNPObject(NPObject* aObject);
NPP
GetNPP()
{
return mNPP;
}
private:
bool InternalGetValueForNPObject(NPNVariable aVariable,
PPluginScriptableObjectParent** aValue,
NPError* aResult);
private:
PluginModuleParent* mParent;
NPP mNPP;
const NPNetscapeFuncs* mNPNIface;
NPWindowType mWindowType;
nsTArray<nsAutoPtr<PluginScriptableObjectParent> > mScriptableObjects;
#if defined(OS_WIN)
private:
// Used in rendering windowless plugins in other processes.
bool SharedSurfaceSetWindow(const NPWindow* aWindow, NPRemoteWindow& aRemoteWindow);
void SharedSurfaceBeforePaint(RECT &rect, NPRemoteEvent& npremoteevent);
void SharedSurfaceAfterPaint(NPEvent* npevent);
void SharedSurfaceSetOrigin(NPRemoteEvent& npremoteevent);
void SharedSurfaceRelease();
private:
gfx::SharedDIBWin mSharedSurfaceDib;
nsIntRect mPluginPort;
nsIntRect mSharedSize;
nsIntPoint mPluginPosOrigin;
#endif // defined(XP_WIN)
};
} // namespace plugins
} // namespace mozilla
#endif // ifndef dom_plugins_PluginInstanceParent_h

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

@ -0,0 +1,84 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: sw=4 ts=4 et :
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Foundation.
*
* The Initial Developer of the Original Code is
* Josh Aas <josh@mozilla.com>
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef mozilla_PluginLibrary_h
#define mozilla_PluginLibrary_h 1
#include "prlink.h"
#include "npapi.h"
#include "nscore.h"
class nsNPAPIPlugin;
namespace mozilla {
class PluginLibrary
{
public:
virtual ~PluginLibrary() { }
/**
* Inform this library about the nsNPAPIPlugin which owns it. This
* object will hold a weak pointer to the plugin.
*/
virtual void SetPlugin(nsNPAPIPlugin* plugin) = 0;
virtual bool HasRequiredFunctions() = 0;
#if defined(XP_UNIX) && !defined(XP_MACOSX)
virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, NPError* error) = 0;
#else
virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error) = 0;
#endif
virtual nsresult NP_Shutdown(NPError* error) = 0;
virtual nsresult NP_GetMIMEDescription(char** mimeDesc) = 0;
virtual nsresult NP_GetValue(void *future, NPPVariable aVariable,
void *aValue, NPError* error) = 0;
#if defined(XP_WIN) || defined(XP_MACOSX)
virtual nsresult NP_GetEntryPoints(NPPluginFuncs* pFuncs, NPError* error) = 0;
#endif
virtual nsresult NPP_New(NPMIMEType pluginType, NPP instance,
uint16_t mode, int16_t argc, char* argn[],
char* argv[], NPSavedData* saved,
NPError* error) = 0;
};
} // namespace mozilla
#endif // ifndef mozilla_PluginLibrary_h

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

@ -0,0 +1,99 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8; -*- */
/* vim: set sw=2 ts=8 et tw=80 : */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Content App.
*
* The Initial Developer of the Original Code is
* The Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "PluginMessageUtils.h"
#include "nsIRunnable.h"
#include "nsThreadUtils.h"
namespace {
class DeferNPObjectReleaseRunnable : public nsRunnable
{
public:
DeferNPObjectReleaseRunnable(const NPNetscapeFuncs* f, NPObject* o)
: mFuncs(f)
, mObject(o)
{
NS_ASSERTION(o, "no release null objects");
}
NS_IMETHOD Run();
private:
const NPNetscapeFuncs* mFuncs;
NPObject* mObject;
};
NS_IMETHODIMP
DeferNPObjectReleaseRunnable::Run()
{
mFuncs->releaseobject(mObject);
return NS_OK;
}
} // anonymous namespace
namespace mozilla {
namespace plugins {
void
DeferNPObjectLastRelease(const NPNetscapeFuncs* f, NPObject* o)
{
if (!o)
return;
if (o->referenceCount > 1) {
f->releaseobject(o);
return;
}
NS_DispatchToCurrentThread(new DeferNPObjectReleaseRunnable(f, o));
}
void DeferNPVariantLastRelease(const NPNetscapeFuncs* f, NPVariant* v)
{
if (!NPVARIANT_IS_OBJECT(*v)) {
f->releasevariantvalue(v);
return;
}
DeferNPObjectLastRelease(f, v->value.objectValue);
VOID_TO_NPVARIANT(*v);
}
} // namespace plugins
} // namespace mozilla

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

@ -0,0 +1,611 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: sw=4 ts=4 et :
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Plugin App.
*
* The Initial Developer of the Original Code is
* Chris Jones <jones.chris.g@gmail.com>
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef DOM_PLUGINS_PLUGINMESSAGEUTILS_H
#define DOM_PLUGINS_PLUGINMESSAGEUTILS_H
#include "IPC/IPCMessageUtils.h"
#include "npapi.h"
#include "npruntime.h"
#include "npfunctions.h"
#include "nsAutoPtr.h"
#include "nsStringGlue.h"
#include "nsThreadUtils.h"
namespace mozilla {
// XXX might want to move these to nscore.h or something, they can be
// generally useful
struct void_t { };
struct null_t { };
namespace ipc {
typedef intptr_t NPRemoteIdentifier;
} /* namespace ipc */
namespace plugins {
/**
* This is NPByteRange without the linked list.
*/
struct IPCByteRange
{
int32_t offset;
uint32_t length;
};
typedef std::vector<IPCByteRange> IPCByteRanges;
typedef nsCString Buffer;
struct NPRemoteWindow
{
unsigned long window;
int32_t x;
int32_t y;
uint32_t width;
uint32_t height;
NPRect clipRect;
NPWindowType type;
#if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX)
VisualID visualID;
Colormap colormap;
#endif /* XP_UNIX */
#if defined(XP_WIN)
base::SharedMemoryHandle surfaceHandle;
#endif
};
// XXX maybe not the best place for these. better one?
#define VARSTR(v_) case v_: return #v_
inline const char* const
NPPVariableToString(NPPVariable aVar)
{
switch (aVar) {
VARSTR(NPPVpluginNameString);
VARSTR(NPPVpluginDescriptionString);
VARSTR(NPPVpluginWindowBool);
VARSTR(NPPVpluginTransparentBool);
VARSTR(NPPVjavaClass);
VARSTR(NPPVpluginWindowSize);
VARSTR(NPPVpluginTimerInterval);
VARSTR(NPPVpluginScriptableInstance);
VARSTR(NPPVpluginScriptableIID);
VARSTR(NPPVjavascriptPushCallerBool);
VARSTR(NPPVpluginKeepLibraryInMemory);
VARSTR(NPPVpluginNeedsXEmbed);
VARSTR(NPPVpluginScriptableNPObject);
VARSTR(NPPVformValue);
VARSTR(NPPVpluginUrlRequestsDisplayedBool);
VARSTR(NPPVpluginWantsAllNetworkStreams);
#ifdef XP_MACOSX
VARSTR(NPPVpluginDrawingModel);
VARSTR(NPPVpluginEventModel);
#endif
default: return "???";
}
}
inline const char*
NPNVariableToString(NPNVariable aVar)
{
switch(aVar) {
VARSTR(NPNVxDisplay);
VARSTR(NPNVxtAppContext);
VARSTR(NPNVnetscapeWindow);
VARSTR(NPNVjavascriptEnabledBool);
VARSTR(NPNVasdEnabledBool);
VARSTR(NPNVisOfflineBool);
VARSTR(NPNVserviceManager);
VARSTR(NPNVDOMElement);
VARSTR(NPNVDOMWindow);
VARSTR(NPNVToolkit);
VARSTR(NPNVSupportsXEmbedBool);
VARSTR(NPNVWindowNPObject);
VARSTR(NPNVPluginElementNPObject);
VARSTR(NPNVSupportsWindowless);
VARSTR(NPNVprivateModeBool);
default: return "???";
}
}
#undef VARSTR
inline void AssertPluginThread()
{
NS_ASSERTION(NS_IsMainThread(), "should be on the plugin's main thread!");
}
void DeferNPObjectLastRelease(const NPNetscapeFuncs* f, NPObject* o);
void DeferNPVariantLastRelease(const NPNetscapeFuncs* f, NPVariant* v);
// in NPAPI, char* == NULL is sometimes meaningful. the following is
// helper code for dealing with nullable nsCString's
inline nsCString
NullableString(const char* aString)
{
if (!aString) {
nsCString str;
str.SetIsVoid(PR_TRUE);
return str;
}
return nsCString(aString);
}
inline const char*
NullableStringGet(const nsCString& str)
{
if (str.IsVoid())
return NULL;
return str.get();
}
} /* namespace plugins */
} /* namespace mozilla */
namespace IPC {
template <>
struct ParamTraits<NPRect>
{
typedef NPRect paramType;
static void Write(Message* aMsg, const paramType& aParam)
{
WriteParam(aMsg, aParam.top);
WriteParam(aMsg, aParam.left);
WriteParam(aMsg, aParam.bottom);
WriteParam(aMsg, aParam.right);
}
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
{
uint16_t top, left, bottom, right;
if (ReadParam(aMsg, aIter, &top) &&
ReadParam(aMsg, aIter, &left) &&
ReadParam(aMsg, aIter, &bottom) &&
ReadParam(aMsg, aIter, &right)) {
aResult->top = top;
aResult->left = left;
aResult->bottom = bottom;
aResult->right = right;
return true;
}
return false;
}
static void Log(const paramType& aParam, std::wstring* aLog)
{
aLog->append(StringPrintf(L"[%u, %u, %u, %u]", aParam.top, aParam.left,
aParam.bottom, aParam.right));
}
};
template <>
struct ParamTraits<NPWindowType>
{
typedef NPWindowType paramType;
static void Write(Message* aMsg, const paramType& aParam)
{
aMsg->WriteInt16(int16(aParam));
}
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
{
int16 result;
if (aMsg->ReadInt16(aIter, &result)) {
*aResult = paramType(result);
return true;
}
return false;
}
static void Log(const paramType& aParam, std::wstring* aLog)
{
aLog->append(StringPrintf(L"%d", int16(aParam)));
}
};
template <>
struct ParamTraits<mozilla::plugins::NPRemoteWindow>
{
typedef mozilla::plugins::NPRemoteWindow paramType;
static void Write(Message* aMsg, const paramType& aParam)
{
aMsg->WriteULong(aParam.window);
WriteParam(aMsg, aParam.x);
WriteParam(aMsg, aParam.y);
WriteParam(aMsg, aParam.width);
WriteParam(aMsg, aParam.height);
WriteParam(aMsg, aParam.clipRect);
WriteParam(aMsg, aParam.type);
#if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX)
aMsg->WriteULong(aParam.visualID);
aMsg->WriteULong(aParam.colormap);
#endif
#if defined(XP_WIN)
WriteParam(aMsg, aParam.surfaceHandle);
#endif
}
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
{
unsigned long window;
int32_t x, y;
uint32_t width, height;
NPRect clipRect;
NPWindowType type;
if (!(aMsg->ReadULong(aIter, &window) &&
ReadParam(aMsg, aIter, &x) &&
ReadParam(aMsg, aIter, &y) &&
ReadParam(aMsg, aIter, &width) &&
ReadParam(aMsg, aIter, &height) &&
ReadParam(aMsg, aIter, &clipRect) &&
ReadParam(aMsg, aIter, &type)))
return false;
#if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX)
unsigned long visualID;
unsigned long colormap;
if (!(aMsg->ReadULong(aIter, &visualID) &&
aMsg->ReadULong(aIter, &colormap)))
return false;
#endif
#if defined(XP_WIN)
base::SharedMemoryHandle surfaceHandle;
if (!ReadParam(aMsg, aIter, &surfaceHandle))
return false;
#endif
aResult->window = window;
aResult->x = x;
aResult->y = y;
aResult->width = width;
aResult->height = height;
aResult->clipRect = clipRect;
aResult->type = type;
#if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX)
aResult->visualID = visualID;
aResult->colormap = colormap;
#endif
#if defined(XP_WIN)
aResult->surfaceHandle = surfaceHandle;
#endif
return true;
}
static void Log(const paramType& aParam, std::wstring* aLog)
{
aLog->append(StringPrintf(L"[%u, %d, %d, %u, %u, %d",
(unsigned long)aParam.window,
aParam.x, aParam.y, aParam.width,
aParam.height, (long)aParam.type));
}
};
template <>
struct ParamTraits<NPString>
{
typedef NPString paramType;
static void Write(Message* aMsg, const paramType& aParam)
{
WriteParam(aMsg, aParam.UTF8Length);
aMsg->WriteBytes(aParam.UTF8Characters,
aParam.UTF8Length * sizeof(NPUTF8));
}
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
{
if (ReadParam(aMsg, aIter, &aResult->UTF8Length)) {
int byteCount = aResult->UTF8Length * sizeof(NPUTF8);
if (!byteCount) {
aResult->UTF8Characters = "\0";
return true;
}
const char* messageBuffer = nsnull;
nsAutoArrayPtr<char> newBuffer(new char[byteCount]);
if (newBuffer && aMsg->ReadBytes(aIter, &messageBuffer, byteCount )) {
memcpy((void*)messageBuffer, newBuffer.get(), byteCount);
aResult->UTF8Characters = newBuffer.forget();
return true;
}
}
return false;
}
static void Log(const paramType& aParam, std::wstring* aLog)
{
aLog->append(StringPrintf(L"%s", aParam.UTF8Characters));
}
};
template <>
struct ParamTraits<NPVariant>
{
typedef NPVariant paramType;
static void Write(Message* aMsg, const paramType& aParam)
{
if (NPVARIANT_IS_VOID(aParam)) {
aMsg->WriteInt(0);
return;
}
if (NPVARIANT_IS_NULL(aParam)) {
aMsg->WriteInt(1);
return;
}
if (NPVARIANT_IS_BOOLEAN(aParam)) {
aMsg->WriteInt(2);
WriteParam(aMsg, NPVARIANT_TO_BOOLEAN(aParam));
return;
}
if (NPVARIANT_IS_INT32(aParam)) {
aMsg->WriteInt(3);
WriteParam(aMsg, NPVARIANT_TO_INT32(aParam));
return;
}
if (NPVARIANT_IS_DOUBLE(aParam)) {
aMsg->WriteInt(4);
WriteParam(aMsg, NPVARIANT_TO_DOUBLE(aParam));
return;
}
if (NPVARIANT_IS_STRING(aParam)) {
aMsg->WriteInt(5);
WriteParam(aMsg, NPVARIANT_TO_STRING(aParam));
return;
}
NS_ERROR("Unsupported type!");
}
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
{
int type;
if (!aMsg->ReadInt(aIter, &type)) {
return false;
}
switch (type) {
case 0:
VOID_TO_NPVARIANT(*aResult);
return true;
case 1:
NULL_TO_NPVARIANT(*aResult);
return true;
case 2: {
bool value;
if (ReadParam(aMsg, aIter, &value)) {
BOOLEAN_TO_NPVARIANT(value, *aResult);
return true;
}
} break;
case 3: {
int32 value;
if (ReadParam(aMsg, aIter, &value)) {
INT32_TO_NPVARIANT(value, *aResult);
return true;
}
} break;
case 4: {
double value;
if (ReadParam(aMsg, aIter, &value)) {
DOUBLE_TO_NPVARIANT(value, *aResult);
return true;
}
} break;
case 5: {
NPString value;
if (ReadParam(aMsg, aIter, &value)) {
STRINGN_TO_NPVARIANT(value.UTF8Characters, value.UTF8Length,
*aResult);
return true;
}
} break;
default:
NS_ERROR("Unsupported type!");
}
return false;
}
static void Log(const paramType& aParam, std::wstring* aLog)
{
if (NPVARIANT_IS_VOID(aParam)) {
aLog->append(L"[void]");
return;
}
if (NPVARIANT_IS_NULL(aParam)) {
aLog->append(L"[null]");
return;
}
if (NPVARIANT_IS_BOOLEAN(aParam)) {
LogParam(NPVARIANT_TO_BOOLEAN(aParam), aLog);
return;
}
if (NPVARIANT_IS_INT32(aParam)) {
LogParam(NPVARIANT_TO_INT32(aParam), aLog);
return;
}
if (NPVARIANT_IS_DOUBLE(aParam)) {
LogParam(NPVARIANT_TO_DOUBLE(aParam), aLog);
return;
}
if (NPVARIANT_IS_STRING(aParam)) {
LogParam(NPVARIANT_TO_STRING(aParam), aLog);
return;
}
NS_ERROR("Unsupported type!");
}
};
template<>
struct ParamTraits<mozilla::void_t>
{
typedef mozilla::void_t paramType;
static void Write(Message* aMsg, const paramType& aParam) { }
static bool
Read(const Message* aMsg, void** aIter, paramType* aResult)
{
*aResult = paramType();
return true;
}
};
template<>
struct ParamTraits<mozilla::null_t>
{
typedef mozilla::null_t paramType;
static void Write(Message* aMsg, const paramType& aParam) { }
static bool
Read(const Message* aMsg, void** aIter, paramType* aResult)
{
*aResult = paramType();
return true;
}
};
template <>
struct ParamTraits<mozilla::plugins::IPCByteRange>
{
typedef mozilla::plugins::IPCByteRange paramType;
static void Write(Message* aMsg, const paramType& aParam)
{
WriteParam(aMsg, aParam.offset);
WriteParam(aMsg, aParam.length);
}
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
{
paramType p;
if (ReadParam(aMsg, aIter, &p.offset) &&
ReadParam(aMsg, aIter, &p.length)) {
*aResult = p;
return true;
}
return false;
}
};
template <>
struct ParamTraits<NPNVariable>
{
typedef NPNVariable paramType;
static void Write(Message* aMsg, const paramType& aParam)
{
WriteParam(aMsg, int(aParam));
}
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
{
int intval;
if (ReadParam(aMsg, aIter, &intval)) {
*aResult = paramType(intval);
return true;
}
return false;
}
};
} /* namespace IPC */
// Serializing NPEvents is completely platform-specific and can be rather
// intricate depending on the platform. So for readability we split it
// into separate files and have the only macro crud live here.
//
// NB: these guards are based on those where struct NPEvent is defined
// in npapi.h. They should be kept in sync.
#if defined(XP_MACOSX)
# include "mozilla/plugins/NPEventOSX.h"
#elif defined(XP_WIN)
# include "mozilla/plugins/NPEventWindows.h"
#elif defined(XP_OS2)
# error Sorry, OS/2 is not supported
#elif defined(XP_UNIX) && defined(MOZ_X11)
# include "mozilla/plugins/NPEventX11.h"
#else
# error Unsupported platform
#endif
#endif /* DOM_PLUGINS_PLUGINMESSAGEUTILS_H */

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -0,0 +1,183 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: sw=4 ts=4 et :
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Plugin App.
*
* The Initial Developer of the Original Code is
* Ben Turner <bent.mozilla@gmail.com>.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Chris Jones <jones.chris.g@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef dom_plugins_PluginModuleChild_h
#define dom_plugins_PluginModuleChild_h 1
#include <string>
#include <vector>
#include "base/basictypes.h"
#include "prlink.h"
#include "npapi.h"
#include "npfunctions.h"
#include "nsAutoPtr.h"
#include "nsDataHashtable.h"
#include "nsHashKeys.h"
#include "mozilla/plugins/PPluginModuleChild.h"
#include "mozilla/plugins/PluginInstanceChild.h"
// NOTE: stolen from nsNPAPIPlugin.h
/*
* Use this macro before each exported function
* (between the return address and the function
* itself), to ensure that the function has the
* right calling conventions on OS/2.
*/
#ifdef XP_OS2
#define NP_CALLBACK _System
#else
#define NP_CALLBACK
#endif
#if defined(XP_WIN)
#define NS_NPAPIPLUGIN_CALLBACK(_type, _name) _type (__stdcall * _name)
#elif defined(XP_OS2)
#define NS_NPAPIPLUGIN_CALLBACK(_type, _name) _type (_System * _name)
#else
#define NS_NPAPIPLUGIN_CALLBACK(_type, _name) _type (* _name)
#endif
typedef NS_NPAPIPLUGIN_CALLBACK(NPError, NP_GETENTRYPOINTS) (NPPluginFuncs* pCallbacks);
typedef NS_NPAPIPLUGIN_CALLBACK(NPError, NP_PLUGININIT) (const NPNetscapeFuncs* pCallbacks);
typedef NS_NPAPIPLUGIN_CALLBACK(NPError, NP_PLUGINUNIXINIT) (const NPNetscapeFuncs* pCallbacks, NPPluginFuncs* fCallbacks);
typedef NS_NPAPIPLUGIN_CALLBACK(NPError, NP_PLUGINSHUTDOWN) (void);
#ifdef XP_MACOSX
typedef NS_NPAPIPLUGIN_CALLBACK(NPError, NP_MAIN) (NPNetscapeFuncs* nCallbacks, NPPluginFuncs* pCallbacks, NPP_ShutdownProcPtr* unloadProcPtr);
#endif
#undef _MOZ_LOG
#define _MOZ_LOG(s) printf("[PluginModuleChild] %s\n", s)
namespace mozilla {
namespace plugins {
class PluginScriptableObjectChild;
class PluginModuleChild : public PPluginModuleChild
{
protected:
// Implement the PPluginModuleChild interface
virtual bool AnswerNP_Initialize(NPError* rv);
virtual PPluginInstanceChild*
AllocPPluginInstance(const nsCString& aMimeType,
const uint16_t& aMode,
const nsTArray<nsCString>& aNames,
const nsTArray<nsCString>& aValues,
NPError* rv);
virtual bool
DeallocPPluginInstance(PPluginInstanceChild* aActor);
virtual bool
AnswerPPluginInstanceConstructor(PPluginInstanceChild* aActor,
const nsCString& aMimeType,
const uint16_t& aMode,
const nsTArray<nsCString>& aNames,
const nsTArray<nsCString>& aValues,
NPError* rv);
virtual bool
AnswerNP_Shutdown(NPError *rv);
virtual void
ActorDestroy(ActorDestroyReason why);
public:
PluginModuleChild();
virtual ~PluginModuleChild();
bool Init(const std::string& aPluginFilename,
base::ProcessHandle aParentProcessHandle,
MessageLoop* aIOLoop,
IPC::Channel* aChannel);
void CleanUp();
const char* GetUserAgent();
static const NPNetscapeFuncs sBrowserFuncs;
static PluginModuleChild* current();
bool RegisterNPObject(NPObject* aObject,
PluginScriptableObjectChild* aActor);
void UnregisterNPObject(NPObject* aObject);
PluginScriptableObjectChild* GetActorForNPObject(NPObject* aObject);
#ifdef DEBUG
bool NPObjectIsRegisteredForActor(PluginScriptableObjectChild* aActor);
#endif
bool
PluginInstanceDestroyed(PluginInstanceChild* aActor,
NPError* rv);
private:
bool InitGraphics();
std::string mPluginFilename;
PRLibrary* mLibrary;
nsCString mUserAgent;
// we get this from the plugin
#ifdef OS_POSIX
NP_PLUGINUNIXINIT mInitializeFunc;
#elif OS_WIN
NP_PLUGININIT mInitializeFunc;
NP_GETENTRYPOINTS mGetEntryPointsFunc;
#endif
NP_PLUGINSHUTDOWN mShutdownFunc;
NPPluginFuncs mFunctions;
NPSavedData mSavedData;
nsDataHashtable<nsVoidPtrHashKey, PluginScriptableObjectChild*> mObjectMap;
};
} /* namespace plugins */
} /* namespace mozilla */
#endif // ifndef dom_plugins_PluginModuleChild_h

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

@ -0,0 +1,681 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: sw=4 ts=4 et :
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Plugin App.
*
* The Initial Developer of the Original Code is
* Chris Jones <jones.chris.g@gmail.com>
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "mozilla/plugins/PluginModuleParent.h"
#include "mozilla/plugins/BrowserStreamParent.h"
#include "nsNPAPIPlugin.h"
using mozilla::PluginLibrary;
using mozilla::ipc::NPRemoteIdentifier;
using namespace mozilla::plugins;
PR_STATIC_ASSERT(sizeof(NPIdentifier) == sizeof(void*));
// static
PluginLibrary*
PluginModuleParent::LoadModule(const char* aFilePath)
{
_MOZ_LOG(__FUNCTION__);
// Block on the child process being launched and initialized.
PluginModuleParent* parent = new PluginModuleParent(aFilePath);
parent->mSubprocess->Launch();
parent->Open(parent->mSubprocess->GetChannel(),
parent->mSubprocess->GetChildProcessHandle());
return parent;
}
PluginModuleParent::PluginModuleParent(const char* aFilePath)
: mSubprocess(new PluginProcessParent(aFilePath))
, mShutdown(false)
, mNPNIface(NULL)
, mPlugin(NULL)
{
NS_ASSERTION(mSubprocess, "Out of memory!");
if (!mValidIdentifiers.Init()) {
NS_ERROR("Out of memory");
}
}
PluginModuleParent::~PluginModuleParent()
{
if (!mShutdown) {
NS_WARNING("Plugin host deleted the module without shutting down.");
NPError err;
NP_Shutdown(&err);
}
NS_ASSERTION(mShutdown, "NP_Shutdown didn't");
if (mSubprocess) {
mSubprocess->Delete();
mSubprocess = nsnull;
}
}
void
PluginModuleParent::ActorDestroy(ActorDestroyReason why)
{
switch (why) {
case AbnormalShutdown:
mShutdown = true;
// Defer the PluginCrashed method so that we don't re-enter
// and potentially modify the actor child list while enumerating it.
if (mPlugin) {
nsCOMPtr<nsIRunnable> r =
new nsRunnableMethod<nsNPAPIPlugin>(
mPlugin, &nsNPAPIPlugin::PluginCrashed);
NS_DispatchToMainThread(r);
}
break;
case NormalShutdown:
mShutdown = true;
break;
default:
NS_ERROR("Unexpected shutdown reason for toplevel actor.");
}
}
PPluginInstanceParent*
PluginModuleParent::AllocPPluginInstance(const nsCString& aMimeType,
const uint16_t& aMode,
const nsTArray<nsCString>& aNames,
const nsTArray<nsCString>& aValues,
NPError* rv)
{
NS_ERROR("Not reachable!");
return NULL;
}
bool
PluginModuleParent::DeallocPPluginInstance(PPluginInstanceParent* aActor)
{
_MOZ_LOG(__FUNCTION__);
delete aActor;
return true;
}
void
PluginModuleParent::SetPluginFuncs(NPPluginFuncs* aFuncs)
{
aFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
aFuncs->javaClass = nsnull;
aFuncs->newp = nsnull; // Gecko should always call this through a PluginLibrary object
aFuncs->destroy = NPP_Destroy;
aFuncs->setwindow = NPP_SetWindow;
aFuncs->newstream = NPP_NewStream;
aFuncs->destroystream = NPP_DestroyStream;
aFuncs->asfile = NPP_StreamAsFile;
aFuncs->writeready = NPP_WriteReady;
aFuncs->write = NPP_Write;
aFuncs->print = NPP_Print;
aFuncs->event = NPP_HandleEvent;
aFuncs->urlnotify = NPP_URLNotify;
aFuncs->getvalue = NPP_GetValue;
aFuncs->setvalue = NPP_SetValue;
}
NPError
PluginModuleParent::NPP_Destroy(NPP instance,
NPSavedData** save)
{
// FIXME/cjones:
// (1) send a "destroy" message to the child
// (2) the child shuts down its instance
// (3) remove both parent and child IDs from map
// (4) free parent
_MOZ_LOG(__FUNCTION__);
PluginInstanceParent* parentInstance =
static_cast<PluginInstanceParent*>(instance->pdata);
if (!parentInstance)
return NPERR_NO_ERROR;
parentInstance->Destroy();
NPError prv;
if (!PPluginInstanceParent::Call__delete__(parentInstance, &prv)) {
prv = NPERR_GENERIC_ERROR;
}
instance->pdata = nsnull;
return prv;
}
bool
PluginModuleParent::EnsureValidNPIdentifier(NPIdentifier aIdentifier)
{
if (!mValidIdentifiers.GetEntry(aIdentifier)) {
nsVoidPtrHashKey* newEntry = mValidIdentifiers.PutEntry(aIdentifier);
if (!newEntry) {
NS_ERROR("Out of memory?");
return false;
}
}
return true;
}
NPIdentifier
PluginModuleParent::GetValidNPIdentifier(NPRemoteIdentifier aRemoteIdentifier)
{
NS_ASSERTION(mValidIdentifiers.IsInitialized(), "Not initialized!");
if (aRemoteIdentifier &&
mValidIdentifiers.GetEntry((NPIdentifier)aRemoteIdentifier)) {
return (NPIdentifier)aRemoteIdentifier;
}
return 0;
}
NPError
PluginModuleParent::NPP_NewStream(NPP instance, NPMIMEType type,
NPStream* stream, NPBool seekable,
uint16_t* stype)
{
PluginInstanceParent* i = InstCast(instance);
if (!i)
return NPERR_GENERIC_ERROR;
return i->NPP_NewStream(type, stream, seekable,
stype);
}
NPError
PluginModuleParent::NPP_SetWindow(NPP instance, NPWindow* window)
{
PluginInstanceParent* i = InstCast(instance);
if (!i)
return NPERR_GENERIC_ERROR;
return i->NPP_SetWindow(window);
}
NPError
PluginModuleParent::NPP_DestroyStream(NPP instance,
NPStream* stream,
NPReason reason)
{
PluginInstanceParent* i = InstCast(instance);
if (!i)
return NPERR_GENERIC_ERROR;
return i->NPP_DestroyStream(stream, reason);
}
int32_t
PluginModuleParent::NPP_WriteReady(NPP instance,
NPStream* stream)
{
BrowserStreamParent* s = StreamCast(instance, stream);
if (!s)
return -1;
return s->WriteReady();
}
int32_t
PluginModuleParent::NPP_Write(NPP instance,
NPStream* stream,
int32_t offset,
int32_t len,
void* buffer)
{
BrowserStreamParent* s = StreamCast(instance, stream);
if (!s)
return -1;
return s->Write(offset, len, buffer);
}
void
PluginModuleParent::NPP_StreamAsFile(NPP instance,
NPStream* stream,
const char* fname)
{
BrowserStreamParent* s = StreamCast(instance, stream);
if (!s)
return;
s->StreamAsFile(fname);
}
void
PluginModuleParent::NPP_Print(NPP instance, NPPrint* platformPrint)
{
PluginInstanceParent* i = InstCast(instance);
if (i)
i->NPP_Print(platformPrint);
}
int16_t
PluginModuleParent::NPP_HandleEvent(NPP instance, void* event)
{
PluginInstanceParent* i = InstCast(instance);
if (!i)
return false;
return i->NPP_HandleEvent(event);
}
void
PluginModuleParent::NPP_URLNotify(NPP instance, const char* url,
NPReason reason, void* notifyData)
{
PluginInstanceParent* i = InstCast(instance);
if (!i)
return;
i->NPP_URLNotify(url, reason, notifyData);
}
NPError
PluginModuleParent::NPP_GetValue(NPP instance,
NPPVariable variable, void *ret_value)
{
PluginInstanceParent* i = InstCast(instance);
if (!i)
return NPERR_GENERIC_ERROR;
return i->NPP_GetValue(variable, ret_value);
}
NPError
PluginModuleParent::NPP_SetValue(NPP instance, NPNVariable variable,
void *value)
{
PluginInstanceParent* i = InstCast(instance);
if (!i)
return NPERR_GENERIC_ERROR;
return i->NPP_SetValue(variable, value);
}
bool
PluginModuleParent::AnswerNPN_UserAgent(nsCString* userAgent)
{
*userAgent = NullableString(mNPNIface->uagent(nsnull));
return true;
}
bool
PluginModuleParent::RecvNPN_GetStringIdentifier(const nsCString& aString,
NPRemoteIdentifier* aId)
{
if (aString.IsVoid()) {
NS_ERROR("Someone sent over a void string?!");
return false;
}
NPIdentifier ident =
mozilla::plugins::parent::_getstringidentifier(aString.BeginReading());
if (!ident) {
*aId = 0;
return true;
}
if (!EnsureValidNPIdentifier(ident)) {
NS_ERROR("Out of memory?");
return false;
}
*aId = (NPRemoteIdentifier)ident;
return true;
}
bool
PluginModuleParent::RecvNPN_GetIntIdentifier(const int32_t& aInt,
NPRemoteIdentifier* aId)
{
NPIdentifier ident = mozilla::plugins::parent::_getintidentifier(aInt);
if (!ident) {
*aId = 0;
return true;
}
if (!EnsureValidNPIdentifier(ident)) {
NS_ERROR("Out of memory?");
return false;
}
*aId = (NPRemoteIdentifier)ident;
return true;
}
bool
PluginModuleParent::RecvNPN_UTF8FromIdentifier(const NPRemoteIdentifier& aId,
NPError *err,
nsCString* aString)
{
NPIdentifier ident = GetValidNPIdentifier(aId);
if (!ident) {
*err = NPERR_INVALID_PARAM;
return true;
}
NPUTF8* val = mozilla::plugins::parent::_utf8fromidentifier(ident);
if (!val) {
*err = NPERR_INVALID_PARAM;
return true;
}
aString->Assign(val);
*err = NPERR_NO_ERROR;
return true;
}
bool
PluginModuleParent::RecvNPN_IntFromIdentifier(const NPRemoteIdentifier& aId,
NPError* err,
int32_t* aInt)
{
NPIdentifier ident = GetValidNPIdentifier(aId);
if (!ident) {
*err = NPERR_INVALID_PARAM;
return true;
}
*aInt = mozilla::plugins::parent::_intfromidentifier(ident);
*err = NPERR_NO_ERROR;
return true;
}
bool
PluginModuleParent::RecvNPN_IdentifierIsString(const NPRemoteIdentifier& aId,
bool* aIsString)
{
NPIdentifier ident = GetValidNPIdentifier(aId);
if (!ident) {
*aIsString = false;
return true;
}
*aIsString = mozilla::plugins::parent::_identifierisstring(ident);
return true;
}
bool
PluginModuleParent::RecvNPN_GetStringIdentifiers(const nsTArray<nsCString>& aNames,
nsTArray<NPRemoteIdentifier>* aIds)
{
NS_ASSERTION(aIds->IsEmpty(), "Non-empty array!");
PRUint32 count = aNames.Length();
if (!count) {
NS_ERROR("No names to get!");
return false;
}
nsAutoTArray<NPUTF8*, 10> buffers;
nsAutoTArray<NPIdentifier, 10> ids;
if (!(buffers.SetLength(count) &&
ids.SetLength(count) &&
aIds->SetCapacity(count))) {
NS_ERROR("Out of memory?");
return false;
}
for (PRUint32 index = 0; index < count; index++) {
buffers[index] = const_cast<NPUTF8*>(aNames[index].BeginReading());
NS_ASSERTION(buffers[index], "Null pointer should be impossible!");
}
mozilla::plugins::parent::_getstringidentifiers(
const_cast<const NPUTF8**>(buffers.Elements()), count, ids.Elements());
for (PRUint32 index = 0; index < count; index++) {
NPIdentifier& id = ids[index];
if (id) {
if (!EnsureValidNPIdentifier(id)) {
NS_ERROR("Out of memory?");
return false;
}
}
aIds->AppendElement((NPRemoteIdentifier)id);
}
return true;
}
PluginInstanceParent*
PluginModuleParent::InstCast(NPP instance)
{
PluginInstanceParent* ip =
static_cast<PluginInstanceParent*>(instance->pdata);
// If the plugin crashed and the PluginInstanceParent was deleted,
// instance->pdata will be NULL.
if (!ip)
return NULL;
if (instance != ip->mNPP) {
NS_RUNTIMEABORT("Corrupted plugin data.");
}
return ip;
}
BrowserStreamParent*
PluginModuleParent::StreamCast(NPP instance,
NPStream* s)
{
PluginInstanceParent* ip = InstCast(instance);
if (!ip)
return NULL;
BrowserStreamParent* sp =
static_cast<BrowserStreamParent*>(static_cast<AStream*>(s->pdata));
if (sp->mNPP != ip || s != sp->mStream) {
NS_RUNTIMEABORT("Corrupted plugin stream data.");
}
return sp;
}
bool
PluginModuleParent::HasRequiredFunctions()
{
return true;
}
#if defined(XP_UNIX) && !defined(XP_MACOSX)
nsresult
PluginModuleParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, NPError* error)
{
_MOZ_LOG(__FUNCTION__);
mNPNIface = bFuncs;
if (mShutdown) {
*error = NPERR_GENERIC_ERROR;
return NS_ERROR_FAILURE;
}
if (!CallNP_Initialize(error)) {
return NS_ERROR_FAILURE;
}
else if (*error != NPERR_NO_ERROR) {
return NS_OK;
}
SetPluginFuncs(pFuncs);
return NS_OK;
}
#else
nsresult
PluginModuleParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error)
{
_MOZ_LOG(__FUNCTION__);
mNPNIface = bFuncs;
if (mShutdown) {
*error = NPERR_GENERIC_ERROR;
return NS_ERROR_FAILURE;
}
if (!CallNP_Initialize(error))
return NS_ERROR_FAILURE;
return NS_OK;
}
#endif
nsresult
PluginModuleParent::NP_Shutdown(NPError* error)
{
_MOZ_LOG(__FUNCTION__);
if (mShutdown) {
*error = NPERR_GENERIC_ERROR;
return NS_ERROR_FAILURE;
}
bool ok = CallNP_Shutdown(error);
// if NP_Shutdown() is nested within another RPC call, this will
// break things. but lord help us if we're doing that anyway; the
// plugin dso will have been unloaded on the other side by the
// CallNP_Shutdown() message
Close();
return ok ? NS_OK : NS_ERROR_FAILURE;
}
nsresult
PluginModuleParent::NP_GetMIMEDescription(char** mimeDesc)
{
_MOZ_LOG(__FUNCTION__);
*mimeDesc = (char*)"application/x-foobar";
return NS_OK;
}
nsresult
PluginModuleParent::NP_GetValue(void *future, NPPVariable aVariable,
void *aValue, NPError* error)
{
_MOZ_LOG(__FUNCTION__);
//TODO: implement this correctly
printf("[%s] Not yet implemented\n", __FUNCTION__);
*error = NPERR_GENERIC_ERROR;
return NS_OK;
}
#if defined(XP_WIN) || defined(XP_MACOSX)
nsresult
PluginModuleParent::NP_GetEntryPoints(NPPluginFuncs* pFuncs, NPError* error)
{
NS_ASSERTION(pFuncs, "Null pointer!");
SetPluginFuncs(pFuncs);
*error = NPERR_NO_ERROR;
return NS_OK;
}
#endif
nsresult
PluginModuleParent::NPP_New(NPMIMEType pluginType, NPP instance,
uint16_t mode, int16_t argc, char* argn[],
char* argv[], NPSavedData* saved,
NPError* error)
{
_MOZ_LOG(__FUNCTION__);
if (mShutdown) {
*error = NPERR_GENERIC_ERROR;
return NS_ERROR_FAILURE;
}
// create the instance on the other side
nsTArray<nsCString> names;
nsTArray<nsCString> values;
for (int i = 0; i < argc; ++i) {
names.AppendElement(NullableString(argn[i]));
values.AppendElement(NullableString(argv[i]));
}
PluginInstanceParent* parentInstance =
new PluginInstanceParent(this, instance, mNPNIface);
instance->pdata = parentInstance;
if (!CallPPluginInstanceConstructor(parentInstance,
nsDependentCString(pluginType), mode,
names, values, error)) {
// |parentInstance| is automatically deleted.
instance->pdata = nsnull;
// if IPC is down, we'll get an immediate "failed" return, but
// without *error being set. So make sure that the error
// condition is signaled to nsNPAPIPluginInstance
if (NPERR_NO_ERROR == *error)
*error = NPERR_GENERIC_ERROR;
return NS_ERROR_FAILURE;
}
printf ("[PluginModuleParent] %s: got return value %hd\n", __FUNCTION__,
*error);
if (*error != NPERR_NO_ERROR) {
PPluginInstanceParent::Call__delete__(parentInstance, error);
instance->pdata = nsnull;
return NS_ERROR_FAILURE;
}
return NS_OK;
}
bool
PluginModuleParent::AnswerNPN_GetValue_WithBoolReturn(const NPNVariable& aVariable,
NPError* aError,
bool* aBoolVal)
{
NPBool boolVal = false;
*aError = mozilla::plugins::parent::_getvalue(nsnull, aVariable, &boolVal);
*aBoolVal = boolVal ? true : false;
return true;
}

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

@ -0,0 +1,226 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: sw=4 ts=4 et :
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Plugin App.
*
* The Initial Developer of the Original Code is
* Chris Jones <jones.chris.g@gmail.com>
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef dom_plugins_PluginModuleParent_h
#define dom_plugins_PluginModuleParent_h 1
#include <cstring>
#include "base/basictypes.h"
#include "prlink.h"
#include "npapi.h"
#include "npfunctions.h"
#include "base/string_util.h"
#include "mozilla/PluginLibrary.h"
#include "mozilla/plugins/PPluginModuleParent.h"
#include "mozilla/plugins/PluginInstanceParent.h"
#include "mozilla/plugins/PluginProcessParent.h"
#include "nsAutoPtr.h"
#include "nsTHashtable.h"
#include "nsHashKeys.h"
#undef _MOZ_LOG
#define _MOZ_LOG(s) printf("[PluginModuleParent] %s\n", s)
namespace mozilla {
namespace plugins {
//-----------------------------------------------------------------------------
class BrowserStreamParent;
/**
* PluginModuleParent
*
* This class implements the NPP API from the perspective of the rest
* of Gecko, forwarding NPP calls along to the child process that is
* actually running the plugin.
*
* This class /also/ implements a version of the NPN API, because the
* child process needs to make these calls back into Gecko proper.
* This class is responsible for "actually" making those function calls.
*/
class PluginModuleParent : public PPluginModuleParent, PluginLibrary
{
private:
typedef mozilla::PluginLibrary PluginLibrary;
protected:
PPluginInstanceParent*
AllocPPluginInstance(const nsCString& aMimeType,
const uint16_t& aMode,
const nsTArray<nsCString>& aNames,
const nsTArray<nsCString>& aValues,
NPError* rv);
virtual bool
DeallocPPluginInstance(PPluginInstanceParent* aActor);
public:
PluginModuleParent(const char* aFilePath);
virtual ~PluginModuleParent();
NS_OVERRIDE virtual void SetPlugin(nsNPAPIPlugin* plugin)
{
mPlugin = plugin;
}
NS_OVERRIDE virtual void ActorDestroy(ActorDestroyReason why);
/**
* LoadModule
*
* This may or may not launch a plugin child process,
* and may or may not be very expensive.
*/
static PluginLibrary* LoadModule(const char* aFilePath);
virtual bool
AnswerNPN_UserAgent(nsCString* userAgent);
// NPRemoteIdentifier funcs
virtual bool
RecvNPN_GetStringIdentifier(const nsCString& aString,
NPRemoteIdentifier* aId);
virtual bool
RecvNPN_GetIntIdentifier(const int32_t& aInt,
NPRemoteIdentifier* aId);
virtual bool
RecvNPN_UTF8FromIdentifier(const NPRemoteIdentifier& aId,
NPError* err,
nsCString* aString);
virtual bool
RecvNPN_IntFromIdentifier(const NPRemoteIdentifier& aId,
NPError* err,
int32_t* aInt);
virtual bool
RecvNPN_IdentifierIsString(const NPRemoteIdentifier& aId,
bool* aIsString);
virtual bool
RecvNPN_GetStringIdentifiers(const nsTArray<nsCString>& aNames,
nsTArray<NPRemoteIdentifier>* aIds);
virtual bool
AnswerNPN_GetValue_WithBoolReturn(const NPNVariable& aVariable,
NPError* aError,
bool* aBoolVal);
const NPNetscapeFuncs* GetNetscapeFuncs() {
return mNPNIface;
}
static PluginInstanceParent* InstCast(NPP instance);
static BrowserStreamParent* StreamCast(NPP instance, NPStream* s);
bool EnsureValidNPIdentifier(NPIdentifier aIdentifier);
base::ProcessHandle ChildProcessHandle() { return mSubprocess->GetChildProcessHandle(); }
private:
void SetPluginFuncs(NPPluginFuncs* aFuncs);
// Implement the module-level functions from NPAPI; these are
// normally resolved directly from the DSO.
#ifdef OS_LINUX
NPError NP_Initialize(const NPNetscapeFuncs* npnIface,
NPPluginFuncs* nppIface);
#else
NPError NP_Initialize(const NPNetscapeFuncs* npnIface);
NPError NP_GetEntryPoints(NPPluginFuncs* nppIface);
#endif
// NPP-like API that Gecko calls are trampolined into. These
// messages then get forwarded along to the plugin instance,
// and then eventually the child process.
static NPError NPP_Destroy(NPP instance, NPSavedData** save);
static NPError NPP_SetWindow(NPP instance, NPWindow* window);
static NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream,
NPBool seekable, uint16_t* stype);
static NPError NPP_DestroyStream(NPP instance,
NPStream* stream, NPReason reason);
static int32_t NPP_WriteReady(NPP instance, NPStream* stream);
static int32_t NPP_Write(NPP instance, NPStream* stream,
int32_t offset, int32_t len, void* buffer);
static void NPP_StreamAsFile(NPP instance,
NPStream* stream, const char* fname);
static void NPP_Print(NPP instance, NPPrint* platformPrint);
static int16_t NPP_HandleEvent(NPP instance, void* event);
static void NPP_URLNotify(NPP instance, const char* url,
NPReason reason, void* notifyData);
static NPError NPP_GetValue(NPP instance,
NPPVariable variable, void *ret_value);
static NPError NPP_SetValue(NPP instance, NPNVariable variable,
void *value);
NPIdentifier GetValidNPIdentifier(NPRemoteIdentifier aRemoteIdentifier);
virtual bool HasRequiredFunctions();
#if defined(XP_UNIX) && !defined(XP_MACOSX)
virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, NPError* error);
#else
virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error);
#endif
virtual nsresult NP_Shutdown(NPError* error);
virtual nsresult NP_GetMIMEDescription(char** mimeDesc);
virtual nsresult NP_GetValue(void *future, NPPVariable aVariable,
void *aValue, NPError* error);
#if defined(XP_WIN) || defined(XP_MACOSX)
virtual nsresult NP_GetEntryPoints(NPPluginFuncs* pFuncs, NPError* error);
#endif
virtual nsresult NPP_New(NPMIMEType pluginType, NPP instance,
uint16_t mode, int16_t argc, char* argn[],
char* argv[], NPSavedData* saved,
NPError* error);
private:
PluginProcessParent* mSubprocess;
bool mShutdown;
const NPNetscapeFuncs* mNPNIface;
nsTHashtable<nsVoidPtrHashKey> mValidIdentifiers;
nsNPAPIPlugin* mPlugin;
};
} // namespace plugins
} // namespace mozilla
#endif // ifndef dom_plugins_PluginModuleParent_h

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

@ -0,0 +1,244 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: sw=4 ts=4 et :
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Plugin App.
*
* The Initial Developer of the Original Code is
* Josh Aas <josh@mozilla.com>
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef PluginPRLibrary_h
#define PluginPRLibrary_h 1
#include "mozilla/PluginLibrary.h"
#include "nsNPAPIPlugin.h"
namespace mozilla {
class PluginPRLibrary : public PluginLibrary
{
#if defined(XP_UNIX) && !defined(XP_MACOSX)
typedef NPError (*NP_InitializeFunc)(NPNetscapeFuncs*, NPPluginFuncs*);
#else
typedef NPError (OSCALL *NP_InitializeFunc)(NPNetscapeFuncs*);
#endif
typedef NPError (OSCALL *NP_ShutdownFunc)();
typedef char* (*NP_GetMIMEDescriptionFunc)();
typedef NPError (*NP_GetValueFunc)(void *, NPPVariable, void*);
#if defined(XP_WIN) || defined(XP_MACOSX)
typedef NPError (OSCALL *NP_GetEntryPointsFunc)(NPPluginFuncs*);
#endif
public:
PluginPRLibrary(const char* aFilePath, PRLibrary* aLibrary) :
#if defined(XP_UNIX) && !defined(XP_MACOSX)
mNP_Initialize(nsnull),
#else
mNP_Initialize(nsnull),
#endif
mNP_Shutdown(nsnull),
mNP_GetMIMEDescription(nsnull),
mNP_GetValue(nsnull),
#if defined(XP_WIN) || defined(XP_MACOSX)
mNP_GetEntryPoints(nsnull),
#endif
mNPP_New(nsnull),
mLibrary(aLibrary)
{
NS_ASSERTION(mLibrary, "need non-null lib");
// addref here??
}
virtual ~PluginPRLibrary()
{
// unref here??
}
virtual void SetPlugin(nsNPAPIPlugin*) { }
virtual bool HasRequiredFunctions() {
mNP_Initialize = (NP_InitializeFunc)
PR_FindFunctionSymbol(mLibrary, "NP_Initialize");
if (!mNP_Initialize)
return false;
mNP_Shutdown = (NP_ShutdownFunc)
PR_FindFunctionSymbol(mLibrary, "NP_Shutdown");
if (!mNP_Shutdown)
return false;
mNP_GetMIMEDescription = (NP_GetMIMEDescriptionFunc)
PR_FindFunctionSymbol(mLibrary, "NP_GetMIMEDescription");
#ifndef XP_MACOSX
if (!mNP_GetMIMEDescription)
return false;
#endif
mNP_GetValue = (NP_GetValueFunc)
PR_FindFunctionSymbol(mLibrary, "NP_GetValue");
#ifndef XP_MACOSX
if (!mNP_GetValue)
return false;
#endif
#if defined(XP_WIN) || defined(XP_MACOSX)
mNP_GetEntryPoints = (NP_GetEntryPointsFunc)
PR_FindFunctionSymbol(mLibrary, "NP_GetEntryPoints");
if (!mNP_GetEntryPoints)
return false;
#endif
return true;
}
#if defined(XP_UNIX) && !defined(XP_MACOSX)
virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, NPError* error) {
if (mNP_Initialize) {
*error = mNP_Initialize(bFuncs, pFuncs);
} else {
NP_InitializeFunc pfNP_Initialize = (NP_InitializeFunc)
PR_FindFunctionSymbol(mLibrary, "NP_Initialize");
if (!pfNP_Initialize)
return NS_ERROR_FAILURE;
*error = pfNP_Initialize(bFuncs, pFuncs);
}
// save NPP_New
mNPP_New = pFuncs->newp;
return NS_OK;
}
#else
virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error) {
if (mNP_Initialize) {
*error = mNP_Initialize(bFuncs);
} else {
NP_InitializeFunc pfNP_Initialize = (NP_InitializeFunc)
PR_FindFunctionSymbol(mLibrary, "NP_Initialize");
if (!pfNP_Initialize)
return NS_ERROR_FAILURE;
*error = pfNP_Initialize(bFuncs);
}
return NS_OK;
}
#endif
virtual nsresult NP_Shutdown(NPError* error) {
if (mNP_Shutdown) {
*error = mNP_Shutdown();
} else {
NP_ShutdownFunc pfNP_Shutdown = (NP_ShutdownFunc)
PR_FindFunctionSymbol(mLibrary, "NP_Shutdown");
if (!pfNP_Shutdown)
return NS_ERROR_FAILURE;
*error = pfNP_Shutdown();
}
return NS_OK;
}
virtual nsresult NP_GetMIMEDescription(char** mimeDesc) {
if (mNP_GetMIMEDescription) {
*mimeDesc = mNP_GetMIMEDescription();
}
else {
NP_GetMIMEDescriptionFunc pfNP_GetMIMEDescription =
(NP_GetMIMEDescriptionFunc)
PR_FindFunctionSymbol(mLibrary, "NP_GetMIMEDescription");
if (!pfNP_GetMIMEDescription) {
*mimeDesc = "";
return NS_ERROR_FAILURE;
}
*mimeDesc = pfNP_GetMIMEDescription();
}
return NS_OK;
}
virtual nsresult NP_GetValue(void *future, NPPVariable aVariable,
void *aValue, NPError* error) {
if (mNP_GetValue) {
*error = mNP_GetValue(future, aVariable, aValue);
} else {
NP_GetValueFunc pfNP_GetValue = (NP_GetValueFunc)
PR_FindFunctionSymbol(mLibrary, "NP_GetValue");
if (!pfNP_GetValue)
return NS_ERROR_FAILURE;
*error = pfNP_GetValue(future, aVariable, aValue);
}
return NS_OK;
}
#if defined(XP_WIN) || defined(XP_MACOSX)
virtual nsresult NP_GetEntryPoints(NPPluginFuncs* pFuncs, NPError* error) {
if (mNP_GetEntryPoints) {
*error = mNP_GetEntryPoints(pFuncs);
} else {
NP_GetEntryPointsFunc pfNP_GetEntryPoints = (NP_GetEntryPointsFunc)
PR_FindFunctionSymbol(mLibrary, "NP_GetEntryPoints");
if (!pfNP_GetEntryPoints)
return NS_ERROR_FAILURE;
*error = pfNP_GetEntryPoints(pFuncs);
}
// save NPP_New
mNPP_New = pFuncs->newp;
return NS_OK;
}
#endif
virtual nsresult NPP_New(NPMIMEType pluginType, NPP instance,
uint16_t mode, int16_t argc, char* argn[],
char* argv[], NPSavedData* saved,
NPError* error) {
if (!mNPP_New)
return NS_ERROR_FAILURE;
*error = mNPP_New(pluginType, instance, mode, argc, argn, argv, saved);
return NS_OK;
}
private:
NP_InitializeFunc mNP_Initialize;
NP_ShutdownFunc mNP_Shutdown;
NP_GetMIMEDescriptionFunc mNP_GetMIMEDescription;
NP_GetValueFunc mNP_GetValue;
#if defined(XP_WIN) || defined(XP_MACOSX)
NP_GetEntryPointsFunc mNP_GetEntryPoints;
#endif
NPP_NewProcPtr mNPP_New;
PRLibrary* mLibrary;
};
} // namespace mozilla
#endif // ifndef PluginPRLibrary_h

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

@ -0,0 +1,92 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: sw=4 ts=4 et :
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Plugin App.
*
* The Initial Developer of the Original Code is
* Ben Turner <bent.mozilla@gmail.com>.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Chris Jones <jones.chris.g@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "mozilla/plugins/PluginProcessParent.h"
#include "base/string_util.h"
#include "mozilla/ipc/GeckoThread.h"
using mozilla::ipc::BrowserProcessSubThread;
using mozilla::ipc::GeckoChildProcessHost;
using mozilla::plugins::PluginProcessParent;
template<>
struct RunnableMethodTraits<PluginProcessParent>
{
static void RetainCallee(PluginProcessParent* obj) { }
static void ReleaseCallee(PluginProcessParent* obj) { }
};
PluginProcessParent::PluginProcessParent(const std::string& aPluginFilePath) :
GeckoChildProcessHost(GeckoProcessType_Plugin),
mPluginFilePath(aPluginFilePath)
{
}
PluginProcessParent::~PluginProcessParent()
{
}
bool
PluginProcessParent::Launch()
{
std::vector<std::string> args;
#if defined(XP_WIN)
args.push_back("\""+ mPluginFilePath +"\"");
#else
args.push_back(mPluginFilePath);
#endif
return SyncLaunch(args);
}
void
PluginProcessParent::Delete()
{
MessageLoop* currentLoop = MessageLoop::current();
MessageLoop* ioLoop =
BrowserProcessSubThread::GetMessageLoop(BrowserProcessSubThread::IO);
if (currentLoop == ioLoop) {
delete this;
return;
}
ioLoop->PostTask(FROM_HERE,
NewRunnableMethod(this, &PluginProcessParent::Delete));
}

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

@ -0,0 +1,92 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: sw=4 ts=4 et :
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Plugin App.
*
* The Initial Developer of the Original Code is
* Ben Turner <bent.mozilla@gmail.com>.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Chris Jones <jones.chris.g@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef dom_plugins_PluginProcessParent_h
#define dom_plugins_PluginProcessParent_h 1
#include "base/basictypes.h"
#include "base/file_path.h"
#include "base/scoped_ptr.h"
#include "base/thread.h"
#include "base/waitable_event.h"
#include "chrome/common/child_process_host.h"
#include "mozilla/ipc/GeckoChildProcessHost.h"
#undef _MOZ_LOG
#define _MOZ_LOG(s) printf("[PluginProcessParent] %s\n", s)
namespace mozilla {
namespace plugins {
//-----------------------------------------------------------------------------
class PluginProcessParent : mozilla::ipc::GeckoChildProcessHost
{
public:
PluginProcessParent(const std::string& aPluginFilePath);
~PluginProcessParent();
/**
* Synchronously launch the plugin process.
*/
bool Launch();
void Delete();
virtual bool CanShutdown()
{
return true;
}
using mozilla::ipc::GeckoChildProcessHost::GetShutDownEvent;
using mozilla::ipc::GeckoChildProcessHost::GetChannel;
using mozilla::ipc::GeckoChildProcessHost::GetChildProcessHandle;
private:
std::string mPluginFilePath;
DISALLOW_EVIL_CONSTRUCTORS(PluginProcessParent);
};
} // namespace plugins
} // namespace mozilla
#endif // ifndef dom_plugins_PluginProcessParent_h

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -0,0 +1,204 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: sw=4 ts=4 et :
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Plugin App.
*
* The Initial Developer of the Original Code is
* Ben Turner <bent.mozilla@gmail.com>
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef dom_plugins_PluginScriptableObjectChild_h
#define dom_plugins_PluginScriptableObjectChild_h 1
#include "mozilla/plugins/PPluginScriptableObjectChild.h"
#include "npruntime.h"
namespace mozilla {
namespace plugins {
class PluginInstanceChild;
class PluginScriptableObjectChild;
struct ChildNPObject : NPObject
{
PluginScriptableObjectChild* parent;
bool invalidated;
};
class PluginScriptableObjectChild : public PPluginScriptableObjectChild
{
friend class PluginInstanceChild;
public:
PluginScriptableObjectChild();
virtual ~PluginScriptableObjectChild();
virtual bool
AnswerInvalidate();
virtual bool
AnswerHasMethod(const NPRemoteIdentifier& aId,
bool* aHasMethod);
virtual bool
AnswerInvoke(const NPRemoteIdentifier& aId,
const nsTArray<Variant>& aArgs,
Variant* aResult,
bool* aSuccess);
virtual bool
AnswerInvokeDefault(const nsTArray<Variant>& aArgs,
Variant* aResult,
bool* aSuccess);
virtual bool
AnswerHasProperty(const NPRemoteIdentifier& aId,
bool* aHasProperty);
virtual bool
AnswerGetProperty(const NPRemoteIdentifier& aId,
Variant* aResult,
bool* aSuccess);
virtual bool
AnswerSetProperty(const NPRemoteIdentifier& aId,
const Variant& aValue,
bool* aSuccess);
virtual bool
AnswerRemoveProperty(const NPRemoteIdentifier& aId,
bool* aSuccess);
virtual bool
AnswerEnumerate(nsTArray<NPRemoteIdentifier>* aProperties,
bool* aSuccess);
virtual bool
AnswerConstruct(const nsTArray<Variant>& aArgs,
Variant* aResult,
bool* aSuccess);
void
Initialize(PluginInstanceChild* aInstance,
NPObject* aObject);
NPObject*
GetObject()
{
return mObject;
}
static const NPClass*
GetClass()
{
return &sNPClass;
}
PluginInstanceChild*
GetInstance()
{
return mInstance;
}
bool
Evaluate(NPString* aScript,
NPVariant* aResult);
private:
static NPObject*
ScriptableAllocate(NPP aInstance,
NPClass* aClass);
static void
ScriptableInvalidate(NPObject* aObject);
static void
ScriptableDeallocate(NPObject* aObject);
static bool
ScriptableHasMethod(NPObject* aObject,
NPIdentifier aName);
static bool
ScriptableInvoke(NPObject* aObject,
NPIdentifier aName,
const NPVariant* aArgs,
uint32_t aArgCount,
NPVariant* aResult);
static bool
ScriptableInvokeDefault(NPObject* aObject,
const NPVariant* aArgs,
uint32_t aArgCount,
NPVariant* aResult);
static bool
ScriptableHasProperty(NPObject* aObject,
NPIdentifier aName);
static bool
ScriptableGetProperty(NPObject* aObject,
NPIdentifier aName,
NPVariant* aResult);
static bool
ScriptableSetProperty(NPObject* aObject,
NPIdentifier aName,
const NPVariant* aValue);
static bool
ScriptableRemoveProperty(NPObject* aObject,
NPIdentifier aName);
static bool
ScriptableEnumerate(NPObject* aObject,
NPIdentifier** aIdentifiers,
uint32_t* aCount);
static bool
ScriptableConstruct(NPObject* aObject,
const NPVariant* aArgs,
uint32_t aArgCount,
NPVariant* aResult);
private:
PluginInstanceChild* mInstance;
NPObject* mObject;
static const NPClass sNPClass;
};
} /* namespace plugins */
} /* namespace mozilla */
#endif /* dom_plugins_PluginScriptableObjectChild_h */

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -0,0 +1,211 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: sw=4 ts=4 et :
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Plugin App.
*
* The Initial Developer of the Original Code is
* Ben Turner <bent.mozilla@gmail.com>
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef dom_plugins_PluginScriptableObjectParent_h
#define dom_plugins_PluginScriptableObjectParent_h 1
#include "mozilla/plugins/PPluginScriptableObjectParent.h"
#include "npfunctions.h"
#include "npruntime.h"
namespace mozilla {
namespace plugins {
class PluginInstanceParent;
class PluginScriptableObjectParent;
struct ParentNPObject : NPObject
{
ParentNPObject()
: parent(NULL) { }
PluginScriptableObjectParent* parent;
};
class PluginScriptableObjectParent : public PPluginScriptableObjectParent
{
friend class PluginInstanceParent;
public:
PluginScriptableObjectParent();
virtual ~PluginScriptableObjectParent();
virtual bool
AnswerInvalidate();
virtual bool
AnswerHasMethod(const NPRemoteIdentifier& aId,
bool* aHasMethod);
virtual bool
AnswerInvoke(const NPRemoteIdentifier& aId,
const nsTArray<Variant>& aArgs,
Variant* aResult,
bool* aSuccess);
virtual bool
AnswerInvokeDefault(const nsTArray<Variant>& aArgs,
Variant* aResult,
bool* aSuccess);
virtual bool
AnswerHasProperty(const NPRemoteIdentifier& aId,
bool* aHasProperty);
virtual bool
AnswerGetProperty(const NPRemoteIdentifier& aId,
Variant* aResult,
bool* aSuccess);
virtual bool
AnswerSetProperty(const NPRemoteIdentifier& aId,
const Variant& aValue,
bool* aSuccess);
virtual bool
AnswerRemoveProperty(const NPRemoteIdentifier& aId,
bool* aSuccess);
virtual bool
AnswerEnumerate(nsTArray<NPRemoteIdentifier>* aProperties,
bool* aSuccess);
virtual bool
AnswerConstruct(const nsTArray<Variant>& aArgs,
Variant* aResult,
bool* aSuccess);
virtual bool
AnswerNPN_Evaluate(const nsCString& aScript,
Variant* aResult,
bool* aSuccess);
void
Initialize(PluginInstanceParent* aInstance,
NPObject* aObject);
static const NPClass*
GetClass()
{
return &sNPClass;
}
PluginInstanceParent*
GetInstance()
{
return mInstance;
}
NPObject*
GetObject()
{
return mObject;
}
private:
static NPObject*
ScriptableAllocate(NPP aInstance,
NPClass* aClass);
static void
ScriptableInvalidate(NPObject* aObject);
static void
ScriptableDeallocate(NPObject* aObject);
static bool
ScriptableHasMethod(NPObject* aObject,
NPIdentifier aName);
static bool
ScriptableInvoke(NPObject* aObject,
NPIdentifier aName,
const NPVariant* aArgs,
uint32_t aArgCount,
NPVariant* aResult);
static bool
ScriptableInvokeDefault(NPObject* aObject,
const NPVariant* aArgs,
uint32_t aArgCount,
NPVariant* aResult);
static bool
ScriptableHasProperty(NPObject* aObject,
NPIdentifier aName);
static bool
ScriptableGetProperty(NPObject* aObject,
NPIdentifier aName,
NPVariant* aResult);
static bool
ScriptableSetProperty(NPObject* aObject,
NPIdentifier aName,
const NPVariant* aValue);
static bool
ScriptableRemoveProperty(NPObject* aObject,
NPIdentifier aName);
static bool
ScriptableEnumerate(NPObject* aObject,
NPIdentifier** aIdentifiers,
uint32_t* aCount);
static bool
ScriptableConstruct(NPObject* aObject,
const NPVariant* aArgs,
uint32_t aArgCount,
NPVariant* aResult);
private:
PluginInstanceParent* mInstance;
// This may be a ParentNPObject or some other kind depending on who created
// it. Have to check its class to find out.
NPObject* mObject;
static const NPClass sNPClass;
};
} /* namespace plugins */
} /* namespace mozilla */
#endif /* dom_plugins_PluginScriptableObjectParent_h */

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

@ -0,0 +1,95 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Plugins.
*
* The Initial Developer of the Original Code is
* The Mozilla Foundation <http://www.mozilla.org/>.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "PluginStreamChild.h"
#include "mozilla/plugins/PluginInstanceChild.h"
namespace mozilla {
namespace plugins {
PluginStreamChild::PluginStreamChild()
{
memset(&mStream, 0, sizeof(mStream));
mStream.ndata = static_cast<AStream*>(this);
}
bool
PluginStreamChild::Answer__delete__(const NPReason& reason,
const bool& artificial)
{
AssertPluginThread();
if (!artificial)
NPP_DestroyStream(reason);
return true;
}
int32_t
PluginStreamChild::NPN_Write(int32_t length, void* buffer)
{
AssertPluginThread();
int32_t written = 0;
CallNPN_Write(nsCString(static_cast<char*>(buffer), length),
&written);
if (written < 0)
PPluginStreamChild::Call__delete__(this, NPERR_GENERIC_ERROR, true);
// careful after here! |this| just got deleted
return written;
}
void
PluginStreamChild::NPP_DestroyStream(NPError reason)
{
AssertPluginThread();
if (mClosed)
return;
mClosed = true;
Instance()->mPluginIface->destroystream(
&Instance()->mData, &mStream, reason);
}
PluginInstanceChild*
PluginStreamChild::Instance()
{
return static_cast<PluginInstanceChild*>(Manager());
}
} // namespace plugins
} // namespace mozilla

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

@ -0,0 +1,87 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Plugins.
*
* The Initial Developer of the Original Code is
* The Mozilla Foundation <http://www.mozilla.org/>.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef mozilla_plugins_PluginStreamChild_h
#define mozilla_plugins_PluginStreamChild_h
#include "mozilla/plugins/PPluginStreamChild.h"
#include "mozilla/plugins/AStream.h"
namespace mozilla {
namespace plugins {
class PluginInstanceChild;
class PluginStreamChild : public PPluginStreamChild, public AStream
{
friend class PluginInstanceChild;
public:
PluginStreamChild();
virtual ~PluginStreamChild() { }
NS_OVERRIDE virtual bool IsBrowserStream() { return false; }
virtual bool Answer__delete__(const NPReason& reason,
const bool& artificial);
int32_t NPN_Write(int32_t length, void* buffer);
void NPP_DestroyStream(NPError reason);
void EnsureCorrectInstance(PluginInstanceChild* i)
{
if (i != Instance())
NS_RUNTIMEABORT("Incorrect stream instance");
}
void EnsureCorrectStream(NPStream* s)
{
if (s != &mStream)
NS_RUNTIMEABORT("Incorrect stream data");
}
private:
PluginInstanceChild* Instance();
NPStream mStream;
bool mClosed;
};
} // namespace plugins
} // namespace mozilla
#endif

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

@ -0,0 +1,98 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Plugins.
*
* The Initial Developer of the Original Code is
* The Mozilla Foundation <http://www.mozilla.org/>.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "PluginStreamParent.h"
#include "PluginInstanceParent.h"
namespace mozilla {
namespace plugins {
PluginStreamParent::PluginStreamParent(PluginInstanceParent* npp,
const nsCString& mimeType,
const nsCString& target,
NPError* result)
: mInstance(npp)
, mClosed(false)
{
*result = mInstance->mNPNIface->newstream(mInstance->mNPP,
const_cast<char*>(mimeType.get()),
NullableStringGet(target),
&mStream);
if (*result == NPERR_NO_ERROR)
mStream->pdata = static_cast<AStream*>(this);
else
mStream = NULL;
}
bool
PluginStreamParent::AnswerNPN_Write(const Buffer& data, int32_t* written)
{
if (mClosed) {
*written = -1;
return true;
}
*written = mInstance->mNPNIface->write(mInstance->mNPP, mStream,
data.Length(),
const_cast<char*>(data.get()));
if (*written < 0)
mClosed = true;
return true;
}
bool
PluginStreamParent::Answer__delete__(const NPError& reason,
const bool& artificial)
{
if (!artificial)
this->NPN_DestroyStream(reason);
return true;
}
void
PluginStreamParent::NPN_DestroyStream(NPReason reason)
{
if (mClosed)
return;
mInstance->mNPNIface->destroystream(mInstance->mNPP, mStream, reason);
mClosed = true;
}
} // namespace plugins
} // namespace mozilla

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

@ -0,0 +1,76 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Plugins.
*
* The Initial Developer of the Original Code is
* The Mozilla Foundation <http://www.mozilla.org/>.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef mozilla_plugins_PluginStreamParent_h
#define mozilla_plugins_PluginStreamParent_h
#include "mozilla/plugins/PPluginStreamParent.h"
#include "mozilla/plugins/AStream.h"
namespace mozilla {
namespace plugins {
class PluginInstanceParent;
class PluginStreamParent : public PPluginStreamParent, public AStream
{
friend class PluginModuleParent;
friend class PluginInstanceParent;
public:
PluginStreamParent(PluginInstanceParent* npp, const nsCString& mimeType,
const nsCString& target, NPError* result);
virtual ~PluginStreamParent() { }
NS_OVERRIDE virtual bool IsBrowserStream() { return false; }
virtual bool AnswerNPN_Write(const Buffer& data, int32_t* written);
virtual bool Answer__delete__(const NPError& reason, const bool& artificial);
private:
void NPN_DestroyStream(NPReason reason);
PluginInstanceParent* mInstance;
NPStream* mStream;
bool mClosed;
};
} // namespace plugins
} // namespace mozilla
#endif

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

@ -0,0 +1,104 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: sw=4 ts=4 et :
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Plugin App.
*
* The Initial Developer of the Original Code is
* Ben Turner <bent.mozilla@gmail.com>.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Chris Jones <jones.chris.g@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "mozilla/plugins/PluginThreadChild.h"
#include "prlink.h"
#include "base/command_line.h"
#include "base/string_util.h"
#include "chrome/common/child_process.h"
#include "chrome/common/chrome_switches.h"
using mozilla::ipc::GeckoThread;
namespace mozilla {
namespace plugins {
PluginThreadChild::PluginThreadChild(ProcessHandle aParentHandle) :
GeckoThread(aParentHandle),
mPlugin()
{
}
PluginThreadChild::~PluginThreadChild()
{
}
void
PluginThreadChild::Init()
{
GeckoThread::Init();
std::string pluginFilename;
#if defined(OS_POSIX)
// NB: need to be very careful in ensuring that the first arg
// (after the binary name) here is indeed the plugin module path.
// Keep in sync with dom/plugins/PluginModuleParent.
std::vector<std::string> values = CommandLine::ForCurrentProcess()->argv();
NS_ABORT_IF_FALSE(values.size() >= 2, "not enough args");
pluginFilename = values[1];
#elif defined(OS_WIN)
std::vector<std::wstring> values =
CommandLine::ForCurrentProcess()->GetLooseValues();
NS_ABORT_IF_FALSE(values.size() >= 1, "not enough loose args");
pluginFilename = WideToUTF8(values[0]);
#else
# error Sorry
#endif
// FIXME owner_loop() is bad here
mPlugin.Init(pluginFilename,
GetParentProcessHandle(), owner_loop(), channel());
}
void
PluginThreadChild::CleanUp()
{
mPlugin.CleanUp();
GeckoThread::CleanUp();
}
} // namespace plugins
} // namespace mozilla

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

@ -0,0 +1,83 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: sw=4 ts=4 et :
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Plugin App.
*
* The Initial Developer of the Original Code is
* Ben Turner <bent.mozilla@gmail.com>.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Chris Jones <jones.chris.g@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef dom_plugins_PluginThreadChild_h
#define dom_plugins_PluginThreadChild_h 1
#include "base/basictypes.h"
#include "chrome/common/child_thread.h"
#include "base/file_path.h"
#include "mozilla/ipc/GeckoThread.h"
#include "mozilla/plugins/PluginModuleChild.h"
#undef _MOZ_LOG
#define _MOZ_LOG(s) printf("[PluginThreadChild] %s", s)
namespace mozilla {
namespace plugins {
//-----------------------------------------------------------------------------
// The PluginThreadChild class represents a background thread where plugin instances
// live.
class PluginThreadChild : public mozilla::ipc::GeckoThread {
public:
PluginThreadChild(ProcessHandle aParentHandle);
~PluginThreadChild();
private:
// Thread implementation:
virtual void Init();
virtual void CleanUp();
// FIXME/cjones: this is kinda broken; this thread is generic,
// not NPAPI-specific, but there's not really another good
// place to store this reference. and there's no need to make
// a generic |Plugin| class yet
PluginModuleChild mPlugin;
IPC::Channel* mChannel;
DISALLOW_EVIL_CONSTRUCTORS(PluginThreadChild);
};
} // namespace plugins
} // namespace mozilla
#endif // ifndef dom_plugins_PluginThreadChild_h

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

@ -0,0 +1,72 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
/* vim: set sw=2 ts=2 et : */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Plugin App.
*
* The Initial Developer of the Original Code is
* Chris Jones <jones.chris.g@gmail.com>
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef mozilla_plugins_StreamNotifyChild_h
#define mozilla_plugins_StreamNotifyChild_h
#include "mozilla/plugins/PStreamNotifyChild.h"
namespace mozilla {
namespace plugins {
class StreamNotifyChild : public PStreamNotifyChild
{
friend class PluginInstanceChild;
friend class BrowserStreamChild;
public:
StreamNotifyChild(const nsCString& aURL)
: mURL(aURL)
, mClosure(NULL)
{ }
void SetValid(void* aClosure) {
mClosure = aClosure;
}
bool Answer__delete__(const NPReason& reason);
private:
nsCString mURL;
void* mClosure;
};
} // namespace plugins
} // namespace mozilla
#endif

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

@ -0,0 +1,57 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
/* vim: set sw=2 ts=2 et : */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Plugin App.
*
* The Initial Developer of the Original Code is
* Chris Jones <jones.chris.g@gmail.com>
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef mozilla_plugins_StreamNotifyParent_h
#define mozilla_plugins_StreamNotifyParent_h
#include "mozilla/plugins/PStreamNotifyParent.h"
namespace mozilla {
namespace plugins {
class StreamNotifyParent : public PStreamNotifyParent
{
friend class PluginInstanceParent;
StreamNotifyParent() { }
};
} // namespace plugins
} // namespace mozilla
#endif

44
dom/plugins/ipdl.mk Normal file
Просмотреть файл

@ -0,0 +1,44 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Mozilla Plugins.
#
# The Initial Developer of the Original Code is
# Benjamin Smedberg<benjamin@smedbergs.us>.
# Portions created by the Initial Developer are Copyright (C) 2009
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
IPDLSRCS = \
PPluginModule.ipdl \
PPluginInstance.ipdl \
PPluginScriptableObject.ipdl \
PBrowserStream.ipdl \
PPluginStream.ipdl \
PStreamNotify.ipdl \
$(NULL)

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

@ -1,6 +1,10 @@
function test() {
waitForExplicitFinish();
let secMan = Components.classes["@mozilla.org/scriptsecuritymanager;1"]
.getService(Components.interfaces
.nsIScriptSecurityManager);
let fm = Components.classes["@mozilla.org/focus-manager;1"]
.getService(Components.interfaces.nsIFocusManager);
@ -136,6 +140,32 @@ function test() {
return;
}
// XXX puts some useful information for bug 534420
let activeWindow = fm.activeWindow;
let focusedWindow = fm.focusedWindow;
ok(activeWindow, "We're not active");
ok(focusedWindow, "There is no focused window");
is(activeWindow, window.top, "our window isn't active");
let searchbar = BrowserSearch.searchBar;
let focusedElement = fm.focusedElement;
if (searchbar) {
let principal = searchbar.nodePrincipal;
ok(principal, "principal is null");
info("search bar: tagName=" + searchbar.tagName + " id=" + searchbar.id);
ok(secMan.isSystemPrincipal(principal), "search bar isn't chrome");
} else {
info("search bar is NULL!!");
}
if (focusedElement) {
let principal = focusedElement.nodePrincipal;
ok(principal, "principal is null");
info("focusedElement: tagName=" + focusedElement.tagName +
" id=" + focusedElement.id);
ok(secMan.isSystemPrincipal(principal), "focusedElement isn't chrome");
} else {
info("focusedElement is NULL!!");
}
// The contents shouldn't be able to steal the focus from chrome.
// in foreground tab

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

@ -2321,25 +2321,36 @@ nsEditor::GetRootElement(nsIDOMElement **aRootElement)
return NS_OK;
}
*aRootElement = 0;
*aRootElement = nsnull;
NS_PRECONDITION(mDocWeak, "bad state, null mDocWeak");
nsCOMPtr<nsIDOMHTMLDocument> doc = do_QueryReferent(mDocWeak);
if (!doc) return NS_ERROR_NOT_INITIALIZED;
nsCOMPtr<nsIDOMHTMLDocument> htmlDoc = do_QueryReferent(mDocWeak);
if (!htmlDoc) {
return NS_ERROR_NOT_INITIALIZED;
}
// Use the documents body element as the editor root if we didn't
// Use the HTML documents body element as the editor root if we didn't
// get a root element during initialization.
nsCOMPtr<nsIDOMHTMLElement> bodyElement;
nsresult result = doc->GetBody(getter_AddRefs(bodyElement));
if (NS_FAILED(result))
return result;
nsresult rv = htmlDoc->GetBody(getter_AddRefs(bodyElement));
if (NS_SUCCEEDED(rv) && bodyElement)
{
mRootElement = bodyElement;
}
else
{
// If the document isn't HTML's or there is no HTML body element,
// we should use the document root element instead.
nsCOMPtr<nsIDOMDocument> doc = do_QueryReferent(mDocWeak);
NS_ENSURE_TRUE(doc, NS_ERROR_NOT_INITIALIZED);
if (!bodyElement)
return NS_ERROR_NULL_POINTER;
rv = doc->GetDocumentElement(getter_AddRefs(mRootElement));
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(mRootElement, NS_ERROR_NULL_POINTER);
}
mRootElement = bodyElement;
*aRootElement = bodyElement;
*aRootElement = mRootElement;
NS_ADDREF(*aRootElement);
return NS_OK;

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

@ -52,6 +52,8 @@ _TEST_FILES = \
test_bug478725.html \
test_bug480972.html \
test_bug487524.html \
test_select_all_without_body.html \
file_select_all_without_body.html \
$(NULL)
libs:: $(_TEST_FILES)

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

@ -0,0 +1,41 @@
<html>
<head>
<script type="text/javascript">
function is(aLeft, aRight, aMessage)
{
window.opener.SimpleTest.is(aLeft, aRight, aMessage);
}
function unload()
{
window.opener.SimpleTest.finish();
}
function boom()
{
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var root = document.documentElement;
while(root.firstChild) {
root.removeChild(root.firstChild);
}
root.appendChild(document.createTextNode("Mozilla"));
root.focus();
cespan = document.createElementNS("http://www.w3.org/1999/xhtml", "span");
cespan.setAttributeNS(null, "contenteditable", "true");
root.appendChild(cespan);
try {
document.execCommand("selectAll", false, null);
} catch(e) { }
is(window.getSelection().toString(), "Mozilla",
"The nodes are not selected");
window.close();
}
</script></head>
<body onload="boom();" onunload="unload();"></body>
</html>

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

@ -0,0 +1,29 @@
<html>
<head>
<title>Test select all in HTML editor without body element</title>
<script type="text/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="text/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display">
</p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
window.open("file_select_all_without_body.html", "_blank",
"width=600,height=600");
</script>
</body>
</html>

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

@ -315,6 +315,11 @@ nsAuthSSPI::GetNextToken(const void *inToken,
LOG(("entering nsAuthSSPI::GetNextToken()\n"));
if (!mCred.dwLower && !mCred.dwUpper) {
LOG(("nsAuthSSPI::GetNextToken(), not initialized. exiting."));
return NS_ERROR_NOT_INITIALIZED;
}
if (mServiceFlags & REQ_DELEGATE)
ctxReq |= ISC_REQ_DELEGATE;
if (mServiceFlags & REQ_MUTUAL_AUTH)

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше