Merge fx-team to m-c.

This commit is contained in:
Ryan VanderMeulen 2014-05-02 16:41:26 -04:00
commit bcfa8fdb25
58 changed files with 461 additions and 549 deletions

View File

@ -1035,6 +1035,7 @@ let PlacesToolbarHelper = {
let BookmarkingUI = {
BOOKMARK_BUTTON_ID: "bookmarks-menu-button",
BOOKMARK_BUTTON_SHORTCUT: "addBookmarkAsKb",
get button() {
delete this.button;
let widgetGroup = CustomizableUI.getWidget(this.BOOKMARK_BUTTON_ID);
@ -1096,14 +1097,22 @@ let BookmarkingUI = {
{
delete this._starredTooltip;
return this._starredTooltip =
gNavigatorBundle.getString("starButtonOn.tooltip");
this._getFormattedTooltip("starButtonOn.tooltip2");
},
get _unstarredTooltip()
{
delete this._unstarredTooltip;
return this._unstarredTooltip =
gNavigatorBundle.getString("starButtonOff.tooltip");
this._getFormattedTooltip("starButtonOff.tooltip2");
},
_getFormattedTooltip: function(strId) {
let args = [];
let shortcut = document.getElementById(this.BOOKMARK_BUTTON_SHORTCUT);
if (shortcut)
args.push(ShortcutUtils.prettifyShortcut(shortcut));
return gNavigatorBundle.getFormattedString(strId, args);
},
/**

View File

@ -1206,8 +1206,6 @@ var gBrowserInit = {
SocialUI.init();
TabView.init();
setTimeout(function () { BrowserChromeTest.markAsReady(); }, 0);
});
this.delayedStartupFinished = true;
@ -4786,8 +4784,11 @@ const nodeToTooltipMap = {
"print-button": "printButton.tooltip",
#endif
"new-window-button": "newWindowButton.tooltip",
"new-tab-button": "newTabButton.tooltip",
"tabs-newtab-button": "newTabButton.tooltip",
"fullscreen-button": "fullscreenButton.tooltip",
"tabview-button": "tabviewButton.tooltip",
"downloads-button": "downloads.tooltip",
};
const nodeToShortcutMap = {
"bookmarks-menu-button": "manBookmarkKb",
@ -4795,12 +4796,15 @@ const nodeToShortcutMap = {
"print-button": "printKb",
#endif
"new-window-button": "key_newNavigator",
"new-tab-button": "key_newNavigatorTab",
"tabs-newtab-button": "key_newNavigatorTab",
"fullscreen-button": "key_fullScreen",
"tabview-button": "key_tabview",
"downloads-button": "key_openDownloads"
};
const gDynamicTooltipCache = new Map();
function UpdateDynamicShortcutTooltipText(aTooltip) {
let nodeId = aTooltip.triggerNode.id;
let nodeId = aTooltip.triggerNode.id || aTooltip.triggerNode.getAttribute("anonid");
if (!gDynamicTooltipCache.has(nodeId) && nodeId in nodeToTooltipMap) {
let strId = nodeToTooltipMap[nodeId];
let args = [];
@ -7178,23 +7182,6 @@ function focusNextFrame(event) {
if (element.ownerDocument == document)
focusAndSelectUrlBar();
}
let BrowserChromeTest = {
_cb: null,
_ready: false,
markAsReady: function () {
this._ready = true;
if (this._cb) {
this._cb();
this._cb = null;
}
},
runWhenReady: function (cb) {
if (this._ready)
cb();
else
this._cb = cb;
}
};
function BrowserOpenNewTabOrWindow(event) {
if (event.shiftKey) {

View File

@ -577,7 +577,7 @@
label="&tabCmd.label;"
command="cmd_newNavigatorTab"
onclick="checkForMiddleClick(this, event);"
tooltiptext="&newTabButton.tooltip;"
tooltip="dynamic-shortcut-tooltip"
ondrop="newTabButtonObserver.onDrop(event)"
ondragover="newTabButtonObserver.onDragOver(event)"
ondragenter="newTabButtonObserver.onDragOver(event)"
@ -874,7 +874,7 @@
label="&downloads.label;"
removable="true"
cui-areatype="toolbar"
tooltiptext="&downloads.tooltip;"/>
tooltip="dynamic-shortcut-tooltip"/>
<toolbarbutton id="home-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
persist="class" removable="true"
@ -1004,11 +1004,11 @@
<toolbarbutton id="print-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
#ifdef XP_MACOSX
command="cmd_print" tooltip="dynamic-shortcut-tooltip"
command="cmd_print"
#else
command="cmd_printPreview" tooltiptext="&printButton.tooltip;"
command="cmd_printPreview"
#endif
label="&printButton.label;"/>
tooltip="dynamic-shortcut-tooltip" label="&printButton.label;"/>
<toolbarbutton id="new-window-button" class="toolbarbutton-1 chromeclass-toolbar-additional"

View File

@ -3369,11 +3369,12 @@
# button, necessary due to the previous hack.
<children/>
<xul:toolbarbutton class="tabs-newtab-button"
anonid="tabs-newtab-button"
command="cmd_newNavigatorTab"
onclick="checkForMiddleClick(this, event);"
onmouseover="document.getBindingParent(this)._enterNewTab();"
onmouseout="document.getBindingParent(this)._leaveNewTab();"
tooltiptext="&newTabButton.tooltip;"/>
tooltip="dynamic-shortcut-tooltip"/>
<xul:spacer class="closing-tabs-spacer" anonid="closing-tabs-spacer"
style="width: 0;"/>
</xul:arrowscrollbox>

View File

@ -1,13 +1,14 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
function whenNewWindowLoaded(aOptions, aCallback) {
let win = OpenBrowserWindow(aOptions);
let gotLoad = false;
let gotActivate = (Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager).activeWindow == win);
let gotActivate = Services.focus.activeWindow == win;
function maybeRunCallback() {
if (gotLoad && gotActivate) {
win.BrowserChromeTest.runWhenReady(function() {
executeSoon(function() { aCallback(win); });
});
executeSoon(function() { aCallback(win); });
}
}
@ -22,12 +23,15 @@ function whenNewWindowLoaded(aOptions, aCallback) {
info("Was activated.");
}
win.addEventListener("load", function onLoad() {
info("Got load");
win.removeEventListener("load", onLoad, false);
gotLoad = true;
maybeRunCallback();
}, false);
Services.obs.addObserver(function observer(aSubject, aTopic) {
if (win == aSubject) {
info("Delayed startup finished");
Services.obs.removeObserver(observer, aTopic);
gotLoad = true;
maybeRunCallback();
}
}, "browser-delayed-startup-finished", false);
return win;
}

View File

@ -4,13 +4,11 @@
function whenNewWindowLoaded(aOptions, aCallback) {
let win = OpenBrowserWindow(aOptions);
let gotLoad = false;
let gotActivate = (Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager).activeWindow == win);
let gotActivate = Services.focus.activeWindow == win;
function maybeRunCallback() {
if (gotLoad && gotActivate) {
win.BrowserChromeTest.runWhenReady(function() {
executeSoon(function() { aCallback(win); });
});
executeSoon(function() { aCallback(win); });
}
}
@ -25,12 +23,15 @@ function whenNewWindowLoaded(aOptions, aCallback) {
info("Was activated.");
}
win.addEventListener("load", function onLoad() {
info("Got load");
win.removeEventListener("load", onLoad, false);
gotLoad = true;
maybeRunCallback();
}, false);
Services.obs.addObserver(function observer(aSubject, aTopic) {
if (win == aSubject) {
info("Delayed startup finished");
Services.obs.removeObserver(observer, aTopic);
gotLoad = true;
maybeRunCallback();
}
}, "browser-delayed-startup-finished", false);
return win;
}

View File

@ -39,21 +39,18 @@ function testCleanExit() {
let isLoaded = promise.defer();
promise.all([isActive.promise, isLoaded.promise]).then(() => {
gWindow.BrowserChromeTest.runWhenReady(() => {
waitForSourceAndCaretAndScopes(gPanel, ".html", 16).then(() => {
is(gDebugger.gThreadClient.paused, true,
"Should be paused after the debugger statement.");
gWindow.close();
deferred.resolve();
finish();
});
gDebuggee.runDebuggerStatement();
waitForSourceAndCaretAndScopes(gPanel, ".html", 16).then(() => {
is(gDebugger.gThreadClient.paused, true,
"Should be paused after the debugger statement.");
gWindow.close();
deferred.resolve();
finish();
});
gDebuggee.runDebuggerStatement();
});
let focusManager = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
if (focusManager.activeWindow != gWindow) {
if (Services.focus.activeWindow != gWindow) {
gWindow.addEventListener("activate", function onActivate(aEvent) {
if (aEvent.target != gWindow) {
return;

View File

@ -75,18 +75,15 @@ function testNewWindow(aWindow) {
let isLoaded = promise.defer();
promise.all([isActive.promise, isLoaded.promise]).then(() => {
gNewWindow.BrowserChromeTest.runWhenReady(() => {
gClient.listTabs(aResponse => {
is(aResponse.selected, 2,
"The second tab is selected.");
gClient.listTabs(aResponse => {
is(aResponse.selected, 2,
"The second tab is selected.");
deferred.resolve();
});
deferred.resolve();
});
});
let focusManager = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
if (focusManager.activeWindow != gNewWindow) {
if (Services.focus.activeWindow != gNewWindow) {
gNewWindow.addEventListener("activate", function onActivate(aEvent) {
if (aEvent.target != gNewWindow) {
return;
@ -118,10 +115,6 @@ function testFocusFirst() {
let deferred = promise.defer();
once(window.content, "focus").then(() => {
let topWindow = Services.wm.getMostRecentWindow("navigator:browser");
is(top, getDOMWindow(window),
"The first window is on top.");
gClient.listTabs(aResponse => {
is(aResponse.selected, 1,
"The first tab is selected after focusing on it.");

View File

@ -62,11 +62,11 @@ function dbg_assert(cond, e) {
function addWindow(aUrl) {
info("Adding window: " + aUrl);
return promise.resolve(getDOMWindow(window.open(aUrl)));
return promise.resolve(getChromeWindow(window.open(aUrl)));
}
function getDOMWindow(aReference) {
return aReference
function getChromeWindow(aWindow) {
return aWindow
.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShellTreeItem).rootTreeItem
.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindow);

View File

@ -165,7 +165,6 @@ These should match what Safari and other Apple applications use on OS X Lion. --
<!ENTITY stopButton.tooltip "Stop loading this page">
<!ENTITY goEndCap.tooltip "Go to the address in the Location Bar">
<!ENTITY printButton.label "Print">
<!ENTITY printButton.tooltip "Print this page">
<!ENTITY locationItem.title "Location">
<!ENTITY searchItem.title "Search">
@ -199,7 +198,6 @@ These should match what Safari and other Apple applications use on OS X Lion. --
<!ENTITY keywordfield.accesskey "K">
<!ENTITY downloads.label "Downloads">
<!ENTITY downloads.tooltip "Display the progress of ongoing downloads">
<!ENTITY downloads.accesskey "D">
<!ENTITY downloads.commandkey "j">
<!ENTITY downloadsUnix.commandkey "y">
@ -563,12 +561,8 @@ you can use these alternative items. Otherwise, their values should be empty. -
<!ENTITY fullZoom.label "Zoom">
<!ENTITY fullZoom.accesskey "Z">
<!ENTITY newTabButton.tooltip "Open a new tab">
<!ENTITY newWindowButton.tooltip "Open a new window">
<!ENTITY sidebarCloseButton.tooltip "Close sidebar">
<!ENTITY fullScreenButton.tooltip "Display the window in full screen">
<!ENTITY quitApplicationCmdWin.label "Exit">
<!ENTITY quitApplicationCmdWin.accesskey "x">
<!ENTITY quitApplicationCmdWin.tooltip "Exit &brandShortName;">

View File

@ -237,11 +237,16 @@ refreshBlocked.redirectLabel=%S prevented this page from automatically redirecti
# %S is the keyboard shortcut for "Show All Bookmarks"
bookmarksMenuButton.tooltip=Show your bookmarks (%S)
# Star button
starButtonOn.tooltip=Edit this bookmark
starButtonOff.tooltip=Bookmark this page
starButtonOn.tooltip2=Edit this bookmark (%S)
starButtonOff.tooltip2=Bookmark this page (%S)
starButtonOverflowed.label=Bookmark This Page
starButtonOverflowedStarred.label=Edit This Bookmark
# Downloads button tooltip
# LOCALIZATION NOTE (downloads.tooltip):
# %S is the keyboard shortcut for "Downloads"
downloads.tooltip=Display the progress of ongoing downloads (%S)
# Print button tooltip on OS X
# LOCALIZATION NOTE (printButton.tooltip):
# Use the unicode ellipsis char, \u2026,
@ -254,6 +259,11 @@ printButton.tooltip=Print this page… (%S)
# %S is the keyboard shortcut for "New Window"
newWindowButton.tooltip=Open a new window (%S)
# New Tab button tooltip
# LOCALIZATION NOTE (newTabButton.tooltip):
# %S is the keyboard shortcut for "New Tab"
newTabButton.tooltip=Open a new tab (%S)
# Offline web applications
offlineApps.available=This website (%S) is asking to store data on your computer for offline use.
offlineApps.allow=Allow

View File

@ -3,4 +3,3 @@
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<!ENTITY closeTab.label "Close Tab">
<!ENTITY newTabButton.tooltip "Open a new tab">

View File

@ -740,6 +740,7 @@ toolbarbutton[sdk-button="true"][cui-areatype="toolbar"] > .toolbarbutton-icon {
}
#forward-button {
-moz-box-align: stretch; /* let the button shape grow vertically with the location bar */
padding: 0;
}
@ -878,7 +879,7 @@ toolbarbutton[sdk-button="true"][cui-areatype="toolbar"] > .toolbarbutton-icon {
padding: 1px;
border: 1px solid ThreeDShadow;
border-radius: 2px;
margin: 1px 3px;
margin: 0 3px;
}
#urlbar[focused],

View File

@ -877,6 +877,7 @@ toolbarbutton[sdk-button="true"][cui-areatype="toolbar"] > .toolbarbutton-icon {
/* unified back/forward button */
#forward-button {
-moz-box-align: stretch; /* let the button shape grow vertically with the location bar */
padding: 0 !important;
}
@ -1116,7 +1117,7 @@ toolbarbutton[sdk-button="true"][cui-areatype="toolbar"] > .toolbarbutton-icon {
#urlbar,
.searchbar-textbox {
-moz-appearance: none;
margin: 1px 3px;
margin: 0 3px;
padding: 0;
background-clip: padding-box;
border: 1px solid ThreeDShadow;

View File

@ -72,7 +72,7 @@ public class FennecNativeActions implements Actions {
}
};
GeckoAppShell.registerEventListener(mGeckoEvent, mListener);
EventDispatcher.getInstance().registerGeckoThreadListener(mListener, mGeckoEvent);
mIsRegistered = true;
}
@ -158,7 +158,7 @@ public class FennecNativeActions implements Actions {
FennecNativeDriver.log(LogLevel.INFO,
"EventExpecter: no longer listening for " + mGeckoEvent);
GeckoAppShell.unregisterEventListener(mGeckoEvent, mListener);
EventDispatcher.getInstance().unregisterGeckoThreadListener(mListener, mGeckoEvent);
mIsRegistered = false;
}

View File

@ -234,7 +234,7 @@ public class FennecNativeDriver implements Driver {
}
public void setupScrollHandling() {
GeckoAppShell.registerEventListener("robocop:scroll", new GeckoEventListener() {
EventDispatcher.getInstance().registerGeckoThreadListener(new GeckoEventListener() {
@Override
public void handleMessage(final String event, final JSONObject message) {
try {
@ -250,7 +250,7 @@ public class FennecNativeDriver implements Driver {
"expected fields: " + e);
}
}
});
}, "robocop:scroll");
}
/**

View File

@ -1,3 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
function test() {
var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
let baseProvider = "http://mochi.test:8888/browser/dom/tests/browser/network_geolocation.sjs";
@ -19,30 +22,35 @@ function test() {
function testOnWindow(aIsPrivate, aCallback) {
let win = OpenBrowserWindow({private: aIsPrivate});
let gotLoad = false;
let gotActivate =
(Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager).activeWindow == win);
let gotActivate = Services.focus.activeWindow == win;
function maybeRunCallback() {
if (gotLoad && gotActivate) {
windowsToClose.push(win);
executeSoon(function() { aCallback(win); });
}
}
if (!gotActivate) {
win.addEventListener("activate", function onActivate() {
info("got activate");
win.removeEventListener("activate", onActivate, true);
gotActivate = true;
if (gotLoad) {
windowsToClose.push(win);
win.BrowserChromeTest.runWhenReady(function() { aCallback(win) });
}
maybeRunCallback();
}, true);
} else {
info("Was activated");
}
win.addEventListener("load", function onLoad() {
info("Got load");
win.removeEventListener("load", onLoad, true);
gotLoad = true;
if (gotActivate) {
windowsToClose.push(win);
setTimeout(function() { aCallback(win) }, 1000);
Services.obs.addObserver(function observer(aSubject, aTopic) {
if (win == aSubject) {
info("Delayed startup finished");
Services.obs.removeObserver(observer, aTopic);
gotLoad = true;
maybeRunCallback();
}
}, true);
}, "browser-delayed-startup-finished", false);
}
testOnWindow(false, function(aNormalWindow) {

View File

@ -526,25 +526,26 @@ abstract public class BrowserApp extends GeckoApp
mFindInPageBar = (FindInPageBar) findViewById(R.id.find_in_page);
mMediaCastingBar = (MediaCastingBar) findViewById(R.id.media_casting);
registerEventListener("CharEncoding:Data");
registerEventListener("CharEncoding:State");
registerEventListener("Feedback:LastUrl");
registerEventListener("Feedback:OpenPlayStore");
registerEventListener("Feedback:MaybeLater");
registerEventListener("Telemetry:Gather");
registerEventListener("Settings:Show");
registerEventListener("Updater:Launch");
registerEventListener("Menu:Add");
registerEventListener("Menu:Remove");
registerEventListener("Menu:Update");
registerEventListener("Accounts:Create");
registerEventListener("Accounts:Exist");
registerEventListener("Prompt:ShowTop");
registerEventListener("Reader:ListStatusRequest");
registerEventListener("Reader:Added");
registerEventListener("Reader:Removed");
registerEventListener("Reader:Share");
registerEventListener("Reader:FaviconRequest");
EventDispatcher.getInstance().registerGeckoThreadListener(this,
"CharEncoding:Data",
"CharEncoding:State",
"Feedback:LastUrl",
"Feedback:OpenPlayStore",
"Feedback:MaybeLater",
"Telemetry:Gather",
"Settings:Show",
"Updater:Launch",
"Menu:Add",
"Menu:Remove",
"Menu:Update",
"Accounts:Create",
"Accounts:Exist",
"Prompt:ShowTop",
"Reader:ListStatusRequest",
"Reader:Added",
"Reader:Removed",
"Reader:Share",
"Reader:FaviconRequest");
Distribution.init(this);
JavaAddonManager.getInstance().init(getApplicationContext());
@ -606,14 +607,14 @@ abstract public class BrowserApp extends GeckoApp
@Override
public void onResume() {
super.onResume();
unregisterEventListener("Prompt:ShowTop");
EventDispatcher.getInstance().unregisterGeckoThreadListener(this, "Prompt:ShowTop");
}
@Override
public void onPause() {
super.onPause();
// Register for Prompt:ShowTop so we can foreground this activity even if it's hidden.
registerEventListener("Prompt:ShowTop");
EventDispatcher.getInstance().registerGeckoThreadListener(this, "Prompt:ShowTop");
}
private void setBrowserToolbarListeners() {
@ -885,24 +886,26 @@ abstract public class BrowserApp extends GeckoApp
mBrowserHealthReporter = null;
}
unregisterEventListener("CharEncoding:Data");
unregisterEventListener("CharEncoding:State");
unregisterEventListener("Feedback:LastUrl");
unregisterEventListener("Feedback:OpenPlayStore");
unregisterEventListener("Feedback:MaybeLater");
unregisterEventListener("Telemetry:Gather");
unregisterEventListener("Settings:Show");
unregisterEventListener("Updater:Launch");
unregisterEventListener("Menu:Add");
unregisterEventListener("Menu:Remove");
unregisterEventListener("Menu:Update");
unregisterEventListener("Accounts:Create");
unregisterEventListener("Accounts:Exist");
unregisterEventListener("Reader:ListStatusRequest");
unregisterEventListener("Reader:Added");
unregisterEventListener("Reader:Removed");
unregisterEventListener("Reader:Share");
unregisterEventListener("Reader:FaviconRequest");
EventDispatcher.getInstance().unregisterGeckoThreadListener(this,
"CharEncoding:Data",
"CharEncoding:State",
"Feedback:LastUrl",
"Feedback:OpenPlayStore",
"Feedback:MaybeLater",
"Telemetry:Gather",
"Settings:Show",
"Updater:Launch",
"Menu:Add",
"Menu:Remove",
"Menu:Update",
"Accounts:Create",
"Accounts:Exist",
"Prompt:ShowTop",
"Reader:ListStatusRequest",
"Reader:Added",
"Reader:Removed",
"Reader:Share",
"Reader:FaviconRequest");
if (AppConstants.MOZ_ANDROID_BEAM && Build.VERSION.SDK_INT >= 14) {
NfcAdapter nfc = NfcAdapter.getDefaultAdapter(this);
@ -1687,7 +1690,7 @@ abstract public class BrowserApp extends GeckoApp
message.put("type", BrowserHealthRecorder.EVENT_SEARCH);
message.put("location", where);
message.put("identifier", identifier);
GeckoAppShell.getEventDispatcher().dispatchEvent(message, null);
EventDispatcher.getInstance().dispatchEvent(message, null);
} catch (Exception e) {
Log.w(LOGTAG, "Error recording search.", e);
}

View File

@ -99,21 +99,23 @@ public class ContactService implements GeckoEventListener {
mContentResolver = mActivity.getContentResolver();
mGotDeviceAccount = false;
registerEventListener("Android:Contacts:Clear");
registerEventListener("Android:Contacts:Find");
registerEventListener("Android:Contacts:GetAll");
registerEventListener("Android:Contacts:GetCount");
registerEventListener("Android:Contact:Remove");
registerEventListener("Android:Contact:Save");
EventDispatcher.getInstance().registerGeckoThreadListener(this,
"Android:Contacts:Clear",
"Android:Contacts:Find",
"Android:Contacts:GetAll",
"Android:Contacts:GetCount",
"Android:Contact:Remove",
"Android:Contact:Save");
}
public void destroy() {
unregisterEventListener("Android:Contacts:Clear");
unregisterEventListener("Android:Contacts:Find");
unregisterEventListener("Android:Contacts:GetAll");
unregisterEventListener("Android:Contacts:GetCount");
unregisterEventListener("Android:Contact:Remove");
unregisterEventListener("Android:Contact:Save");
EventDispatcher.getInstance().unregisterGeckoThreadListener(this,
"Android:Contacts:Clear",
"Android:Contacts:Find",
"Android:Contacts:GetAll",
"Android:Contacts:GetCount",
"Android:Contact:Remove",
"Android:Contact:Save");
}
@Override
@ -1507,14 +1509,6 @@ public class ContactService implements GeckoEventListener {
}
}
private void registerEventListener(final String event) {
mEventDispatcher.registerEventListener(event, this);
}
private void unregisterEventListener(final String event) {
mEventDispatcher.unregisterEventListener(event, this);
}
private ContentProviderResult[] applyBatch(ArrayList<ContentProviderOperation> operations) {
try {
return mContentResolver.applyBatch(ContactsContract.AUTHORITY, operations);

View File

@ -40,14 +40,16 @@ public class DoorHangerPopup extends ArrowPopup
mDoorHangers = new HashSet<DoorHanger>();
registerEventListener("Doorhanger:Add");
registerEventListener("Doorhanger:Remove");
EventDispatcher.getInstance().registerGeckoThreadListener(this,
"Doorhanger:Add",
"Doorhanger:Remove");
Tabs.registerOnTabsChangedListener(this);
}
void destroy() {
unregisterEventListener("Doorhanger:Add");
unregisterEventListener("Doorhanger:Remove");
EventDispatcher.getInstance().unregisterGeckoThreadListener(this,
"Doorhanger:Add",
"Doorhanger:Remove");
Tabs.unregisterOnTabsChangedListener(this);
}
@ -336,14 +338,6 @@ public class DoorHangerPopup extends ArrowPopup
}
}
private void registerEventListener(String event) {
GeckoAppShell.getEventDispatcher().registerEventListener(event, this);
}
private void unregisterEventListener(String event) {
GeckoAppShell.getEventDispatcher().unregisterEventListener(event, this);
}
@Override
public void dismiss() {
// If the popup is focusable while it is hidden, we run into crashes

View File

@ -6,6 +6,7 @@ package org.mozilla.gecko;
import org.mozilla.gecko.GeckoAppShell;
import org.mozilla.gecko.GeckoEvent;
import org.mozilla.gecko.mozglue.RobocopTarget;
import org.mozilla.gecko.util.EventCallback;
import org.mozilla.gecko.util.GeckoEventListener;
import org.mozilla.gecko.util.NativeEventListener;
@ -21,6 +22,7 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
@RobocopTarget
public final class EventDispatcher {
private static final String LOGTAG = "GeckoEventDispatcher";
private static final String GUID = "__guid__";
@ -28,6 +30,8 @@ public final class EventDispatcher {
private static final String STATUS_ERROR = "error";
private static final String STATUS_SUCCESS = "success";
private static final EventDispatcher INSTANCE = new EventDispatcher();
/**
* The capacity of a HashMap is rounded up to the next power-of-2. Every time the size
* of the map goes beyond 75% of the capacity, the map is rehashed. Therefore, to
@ -42,6 +46,13 @@ public final class EventDispatcher {
private final Map<String, List<GeckoEventListener>> mGeckoThreadJSONListeners =
new HashMap<String, List<GeckoEventListener>>(GECKO_JSON_EVENTS_COUNT);
public static EventDispatcher getInstance() {
return INSTANCE;
}
private EventDispatcher() {
}
private <T> void registerListener(final Class<? extends List<T>> listType,
final Map<String, List<T>> listenersMap,
final T listener,
@ -109,8 +120,8 @@ public final class EventDispatcher {
@Deprecated // Use NativeEventListener instead
@SuppressWarnings("unchecked")
private void registerGeckoThreadListener(final GeckoEventListener listener,
final String... events) {
public void registerGeckoThreadListener(final GeckoEventListener listener,
final String... events) {
checkNotRegistered(mGeckoThreadNativeListeners, events);
registerListener((Class)CopyOnWriteArrayList.class,
@ -123,21 +134,11 @@ public final class EventDispatcher {
}
@Deprecated // Use NativeEventListener instead
private void unregisterGeckoThreadListener(final GeckoEventListener listener,
final String... events) {
public void unregisterGeckoThreadListener(final GeckoEventListener listener,
final String... events) {
unregisterListener(mGeckoThreadJSONListeners, listener, events);
}
@Deprecated // Use one of the variants above.
public void registerEventListener(final String event, final GeckoEventListener listener) {
registerGeckoThreadListener(listener, event);
}
@Deprecated // Use one of the variants above
public void unregisterEventListener(final String event, final GeckoEventListener listener) {
unregisterGeckoThreadListener(listener, event);
}
public void dispatchEvent(final NativeJSContainer message) {
EventCallback callback = null;
try {

View File

@ -47,7 +47,7 @@ public class FilePicker implements GeckoEventListener {
protected FilePicker(Context context) {
this.context = context;
GeckoAppShell.getEventDispatcher().registerEventListener("FilePicker:Show", this);
EventDispatcher.getInstance().registerGeckoThreadListener(this, "FilePicker:Show");
}
@Override

View File

@ -59,7 +59,7 @@ public class FindInPageBar extends LinearLayout implements TextWatcher, View.OnC
});
mInflated = true;
GeckoAppShell.getEventDispatcher().registerEventListener("TextSelection:Data", this);
EventDispatcher.getInstance().registerGeckoThreadListener(this, "TextSelection:Data");
}
public void show() {
@ -88,7 +88,7 @@ public class FindInPageBar extends LinearLayout implements TextWatcher, View.OnC
if (!mInflated) {
return;
}
GeckoAppShell.getEventDispatcher().unregisterEventListener("TextSelection:Data", this);
EventDispatcher.getInstance().unregisterGeckoThreadListener(this, "TextSelection:Data");
}
// TextWatcher implementation

View File

@ -85,15 +85,17 @@ public class FormAssistPopup extends RelativeLayout implements GeckoEventListene
setFocusable(false);
registerEventListener("FormAssist:AutoComplete");
registerEventListener("FormAssist:ValidationMessage");
registerEventListener("FormAssist:Hide");
EventDispatcher.getInstance().registerGeckoThreadListener(this,
"FormAssist:AutoComplete",
"FormAssist:ValidationMessage",
"FormAssist:Hide");
}
void destroy() {
unregisterEventListener("FormAssist:AutoComplete");
unregisterEventListener("FormAssist:ValidationMessage");
unregisterEventListener("FormAssist:Hide");
EventDispatcher.getInstance().unregisterGeckoThreadListener(this,
"FormAssist:AutoComplete",
"FormAssist:ValidationMessage",
"FormAssist:Hide");
}
@Override
@ -397,12 +399,4 @@ public class FormAssistPopup extends RelativeLayout implements GeckoEventListene
return convertView;
}
}
private void registerEventListener(String event) {
GeckoAppShell.getEventDispatcher().registerEventListener(event, this);
}
private void unregisterEventListener(String event) {
GeckoAppShell.getEventDispatcher().unregisterEventListener(event, this);
}
}

View File

@ -1269,7 +1269,7 @@ public abstract class GeckoApp
// through "onDestroy" -- essentially the same as the lifecycle
// of the activity itself.
final String profilePath = getProfile().getDir().getAbsolutePath();
final EventDispatcher dispatcher = GeckoAppShell.getEventDispatcher();
final EventDispatcher dispatcher = EventDispatcher.getInstance();
Log.i(LOGTAG, "Creating HealthRecorder.");
final String osLocale = Locale.getDefault().toString();
@ -1350,7 +1350,7 @@ public abstract class GeckoApp
if (mLayerView == null) {
LayerView layerView = (LayerView) findViewById(R.id.layer_view);
layerView.initializeView(GeckoAppShell.getEventDispatcher());
layerView.initializeView(EventDispatcher.getInstance());
mLayerView = layerView;
GeckoAppShell.setLayerView(layerView);
// bind the GeckoEditable instance to the new LayerView
@ -1489,33 +1489,34 @@ public abstract class GeckoApp
mAppStateListeners = new LinkedList<GeckoAppShell.AppStateListener>();
//register for events
registerEventListener("log");
registerEventListener("onCameraCapture");
registerEventListener("Gecko:Ready");
registerEventListener("Gecko:DelayedStartup");
registerEventListener("Toast:Show");
registerEventListener("DOMFullScreen:Start");
registerEventListener("DOMFullScreen:Stop");
registerEventListener("ToggleChrome:Hide");
registerEventListener("ToggleChrome:Show");
registerEventListener("ToggleChrome:Focus");
registerEventListener("Permissions:Data");
registerEventListener("Session:StatePurged");
registerEventListener("Bookmark:Insert");
registerEventListener("Accessibility:Event");
registerEventListener("Accessibility:Ready");
registerEventListener("Shortcut:Remove");
registerEventListener("Share:Text");
registerEventListener("Image:SetAs");
registerEventListener("Sanitize:ClearHistory");
registerEventListener("Update:Check");
registerEventListener("Update:Download");
registerEventListener("Update:Install");
registerEventListener("PrivateBrowsing:Data");
registerEventListener("Contact:Add");
registerEventListener("Locale:Set");
registerEventListener("NativeApp:IsDebuggable");
registerEventListener("SystemUI:Visibility");
EventDispatcher.getInstance().registerGeckoThreadListener(this,
"log",
"onCameraCapture",
"Gecko:Ready",
"Gecko:DelayedStartup",
"Toast:Show",
"DOMFullScreen:Start",
"DOMFullScreen:Stop",
"ToggleChrome:Hide",
"ToggleChrome:Show",
"ToggleChrome:Focus",
"Permissions:Data",
"Session:StatePurged",
"Bookmark:Insert",
"Accessibility:Event",
"Accessibility:Ready",
"Shortcut:Remove",
"Share:Text",
"Image:SetAs",
"Sanitize:ClearHistory",
"Update:Check",
"Update:Download",
"Update:Install",
"PrivateBrowsing:Data",
"Contact:Add",
"Locale:Set",
"NativeApp:IsDebuggable",
"SystemUI:Visibility");
EventListener.registerEvents();
@ -1523,14 +1524,14 @@ public abstract class GeckoApp
SmsManager.getInstance().start();
}
mContactService = new ContactService(GeckoAppShell.getEventDispatcher(), this);
mContactService = new ContactService(EventDispatcher.getInstance(), this);
mPromptService = new PromptService(this);
mTextSelection = new TextSelection((TextSelectionHandle) findViewById(R.id.start_handle),
(TextSelectionHandle) findViewById(R.id.middle_handle),
(TextSelectionHandle) findViewById(R.id.end_handle),
GeckoAppShell.getEventDispatcher(),
EventDispatcher.getInstance(),
this);
PrefsHelper.getPref("app.update.autodownload", new PrefsHelper.PrefHandlerBase() {
@ -2022,33 +2023,34 @@ public abstract class GeckoApp
@Override
public void onDestroy()
{
unregisterEventListener("log");
unregisterEventListener("onCameraCapture");
unregisterEventListener("Gecko:Ready");
unregisterEventListener("Gecko:DelayedStartup");
unregisterEventListener("Toast:Show");
unregisterEventListener("DOMFullScreen:Start");
unregisterEventListener("DOMFullScreen:Stop");
unregisterEventListener("ToggleChrome:Hide");
unregisterEventListener("ToggleChrome:Show");
unregisterEventListener("ToggleChrome:Focus");
unregisterEventListener("Permissions:Data");
unregisterEventListener("Session:StatePurged");
unregisterEventListener("Bookmark:Insert");
unregisterEventListener("Accessibility:Event");
unregisterEventListener("Accessibility:Ready");
unregisterEventListener("Shortcut:Remove");
unregisterEventListener("Share:Text");
unregisterEventListener("Image:SetAs");
unregisterEventListener("Sanitize:ClearHistory");
unregisterEventListener("Update:Check");
unregisterEventListener("Update:Download");
unregisterEventListener("Update:Install");
unregisterEventListener("PrivateBrowsing:Data");
unregisterEventListener("Contact:Add");
unregisterEventListener("Locale:Set");
unregisterEventListener("NativeApp:IsDebuggable");
unregisterEventListener("SystemUI:Visibility");
EventDispatcher.getInstance().unregisterGeckoThreadListener(this,
"log",
"onCameraCapture",
"Gecko:Ready",
"Gecko:DelayedStartup",
"Toast:Show",
"DOMFullScreen:Start",
"DOMFullScreen:Stop",
"ToggleChrome:Hide",
"ToggleChrome:Show",
"ToggleChrome:Focus",
"Permissions:Data",
"Session:StatePurged",
"Bookmark:Insert",
"Accessibility:Event",
"Accessibility:Ready",
"Shortcut:Remove",
"Share:Text",
"Image:SetAs",
"Sanitize:ClearHistory",
"Update:Check",
"Update:Download",
"Update:Install",
"PrivateBrowsing:Data",
"Contact:Add",
"Locale:Set",
"NativeApp:IsDebuggable",
"SystemUI:Visibility");
EventListener.unregisterEvents();
@ -2094,14 +2096,6 @@ public abstract class GeckoApp
Tabs.unregisterOnTabsChangedListener(this);
}
protected void registerEventListener(String event) {
GeckoAppShell.getEventDispatcher().registerEventListener(event, this);
}
protected void unregisterEventListener(String event) {
GeckoAppShell.getEventDispatcher().unregisterEventListener(event, this);
}
// Get a temporary directory, may return null
public static File getTempDirectory() {
File dir = GeckoApplication.get().getExternalFilesDir("temp");

View File

@ -135,8 +135,6 @@ public class GeckoAppShell
static private int sDensityDpi = 0;
static private int sScreenDepth = 0;
private static final EventDispatcher sEventDispatcher = new EventDispatcher();
/* Default colors. */
private static final float[] DEFAULT_LAUNCHER_ICON_HSV = { 32.0f, 1.0f, 1.0f };
@ -2282,34 +2280,6 @@ public class GeckoAppShell
}
}
/**
* Adds a listener for a gecko event.
* This method is thread-safe and may be called at any time. In particular, calling it
* with an event that is currently being processed has the properly-defined behaviour that
* any added listeners will not be invoked on the event currently being processed, but
* will be invoked on future events of that type.
*/
@RobocopTarget
public static void registerEventListener(String event, GeckoEventListener listener) {
sEventDispatcher.registerEventListener(event, listener);
}
public static EventDispatcher getEventDispatcher() {
return sEventDispatcher;
}
/**
* Remove a previously-registered listener for a gecko event.
* This method is thread-safe and may be called at any time. In particular, calling it
* with an event that is currently being processed has the properly-defined behaviour that
* any removed listeners will still be invoked on the event currently being processed, but
* will not be invoked on future events of that type.
*/
@RobocopTarget
public static void unregisterEventListener(String event, GeckoEventListener listener) {
sEventDispatcher.unregisterEventListener(event, listener);
}
/*
* Battery API related methods.
*/
@ -2320,7 +2290,7 @@ public class GeckoAppShell
@WrapElementForJNI(stubName = "HandleGeckoMessageWrapper")
public static void handleGeckoMessage(final NativeJSContainer message) {
sEventDispatcher.dispatchEvent(message);
EventDispatcher.getInstance().dispatchEvent(message);
message.dispose();
}

View File

@ -766,13 +766,13 @@ final class GeckoEditable
// cases, and we don't want to unregister an event that was not registered.
mGeckoFocused = false;
mSuppressCompositions = false;
GeckoAppShell.getEventDispatcher().
unregisterEventListener("TextSelection:DraggingHandle", this);
EventDispatcher.getInstance().
unregisterGeckoThreadListener(this, "TextSelection:DraggingHandle");
} else if (type == NOTIFY_IME_OF_FOCUS) {
mGeckoFocused = true;
mSuppressCompositions = false;
GeckoAppShell.getEventDispatcher().
registerEventListener("TextSelection:DraggingHandle", this);
EventDispatcher.getInstance().
registerGeckoThreadListener(this, "TextSelection:DraggingHandle");
}
}

View File

@ -73,7 +73,7 @@ public class GeckoThread extends Thread implements GeckoEventListener {
mAction = action;
mUri = uri;
setName("Gecko");
GeckoAppShell.getEventDispatcher().registerEventListener("Gecko:Ready", this);
EventDispatcher.getInstance().registerGeckoThreadListener(this, "Gecko:Ready");
}
public static boolean isCreated() {
@ -179,7 +179,7 @@ public class GeckoThread extends Thread implements GeckoEventListener {
@Override
public void handleMessage(String event, JSONObject message) {
if ("Gecko:Ready".equals(event)) {
GeckoAppShell.getEventDispatcher().unregisterEventListener(event, this);
EventDispatcher.getInstance().unregisterGeckoThreadListener(this, event);
setLaunchState(LaunchState.GeckoRunning);
GeckoAppShell.sendPendingEventsToGecko();
}

View File

@ -93,17 +93,18 @@ public class GeckoView extends LayerView
tabs.attachToContext(context);
}
GeckoAppShell.registerEventListener("Gecko:Ready", this);
GeckoAppShell.registerEventListener("Content:StateChange", this);
GeckoAppShell.registerEventListener("Content:LoadError", this);
GeckoAppShell.registerEventListener("Content:PageShow", this);
GeckoAppShell.registerEventListener("DOMTitleChanged", this);
GeckoAppShell.registerEventListener("Link:Favicon", this);
GeckoAppShell.registerEventListener("Prompt:Show", this);
GeckoAppShell.registerEventListener("Prompt:ShowTop", this);
EventDispatcher.getInstance().registerGeckoThreadListener(this,
"Gecko:Ready",
"Content:StateChange",
"Content:LoadError",
"Content:PageShow",
"DOMTitleChanged",
"Link:Favicon",
"Prompt:Show",
"Prompt:ShowTop");
ThreadUtils.setUiThread(Thread.currentThread(), new Handler());
initializeView(GeckoAppShell.getEventDispatcher());
initializeView(EventDispatcher.getInstance());
if (GeckoThread.checkAndSetLaunchState(GeckoThread.LaunchState.Launching, GeckoThread.LaunchState.Launched)) {
// This is the first launch, so finish initialization and go.

View File

@ -36,9 +36,7 @@ public final class IntentHelper implements GeckoEventListener {
private IntentHelper(Activity activity) {
this.activity = activity;
for (String event : EVENTS) {
GeckoAppShell.getEventDispatcher().registerEventListener(event, this);
}
EventDispatcher.getInstance().registerGeckoThreadListener(this, EVENTS);
}
public static IntentHelper init(Activity activity) {
@ -53,10 +51,7 @@ public final class IntentHelper implements GeckoEventListener {
public static void destroy() {
if (instance != null) {
for (String event : EVENTS) {
GeckoAppShell.getEventDispatcher().unregisterEventListener(event, instance);
}
EventDispatcher.getInstance().unregisterGeckoThreadListener(instance, EVENTS);
instance = null;
}
}

View File

@ -65,7 +65,7 @@ class JavaAddonManager implements GeckoEventListener {
}
private JavaAddonManager() {
mDispatcher = GeckoAppShell.getEventDispatcher();
mDispatcher = EventDispatcher.getInstance();
mAddonCallbacks = new HashMap<String, Map<String, GeckoEventListener>>();
}
@ -75,8 +75,9 @@ class JavaAddonManager implements GeckoEventListener {
return;
}
mApplicationContext = applicationContext;
mDispatcher.registerEventListener("Dex:Load", this);
mDispatcher.registerEventListener("Dex:Unload", this);
mDispatcher.registerGeckoThreadListener(this,
"Dex:Load",
"Dex:Unload");
}
@Override
@ -121,7 +122,7 @@ class JavaAddonManager implements GeckoEventListener {
addonCallbacks = new HashMap<String, GeckoEventListener>();
for (String event : callbacks.keySet()) {
CallbackWrapper wrapper = new CallbackWrapper(callbacks.get(event));
mDispatcher.registerEventListener(event, wrapper);
mDispatcher.registerGeckoThreadListener(wrapper, event);
addonCallbacks.put(event, wrapper);
}
mAddonCallbacks.put(zipFile, addonCallbacks);
@ -134,7 +135,7 @@ class JavaAddonManager implements GeckoEventListener {
return;
}
for (String event : callbacks.keySet()) {
mDispatcher.unregisterEventListener(event, callbacks.get(event));
mDispatcher.unregisterGeckoThreadListener(callbacks.get(event), event);
}
}

View File

@ -57,8 +57,9 @@ public class LightweightTheme implements GeckoEventListener {
mListeners = new ArrayList<OnChangeListener>();
// unregister isn't needed as the lifetime is same as the application.
GeckoAppShell.getEventDispatcher().registerEventListener("LightweightTheme:Update", this);
GeckoAppShell.getEventDispatcher().registerEventListener("LightweightTheme:Disable", this);
EventDispatcher.getInstance().registerGeckoThreadListener(this,
"LightweightTheme:Update",
"LightweightTheme:Disable");
}
public void addListener(final OnChangeListener listener) {

View File

@ -32,8 +32,9 @@ public class MediaCastingBar extends RelativeLayout implements View.OnClickListe
public MediaCastingBar(Context context, AttributeSet attrs) {
super(context, attrs);
GeckoAppShell.getEventDispatcher().registerEventListener("Casting:Started", this);
GeckoAppShell.getEventDispatcher().registerEventListener("Casting:Stopped", this);
EventDispatcher.getInstance().registerGeckoThreadListener(this,
"Casting:Started",
"Casting:Stopped");
}
public void inflateContent() {
@ -68,8 +69,9 @@ public class MediaCastingBar extends RelativeLayout implements View.OnClickListe
}
public void onDestroy() {
GeckoAppShell.getEventDispatcher().unregisterEventListener("Casting:Started", this);
GeckoAppShell.getEventDispatcher().unregisterEventListener("Casting:Stopped", this);
EventDispatcher.getInstance().unregisterGeckoThreadListener(this,
"Casting:Started",
"Casting:Stopped");
}
// View.OnClickListener implementation

View File

@ -78,15 +78,12 @@ public final class NotificationHelper implements GeckoEventListener {
mInstance = new NotificationHelper();
mContext = context;
mClearableNotifications = new HashSet<String>();
registerEventListener("Notification:Show");
registerEventListener("Notification:Hide");
EventDispatcher.getInstance().registerGeckoThreadListener(mInstance,
"Notification:Show",
"Notification:Hide");
registerReceiver(context);
}
private static void registerEventListener(String event) {
GeckoAppShell.getEventDispatcher().registerEventListener(event, mInstance);
}
@Override
public void handleMessage(String event, JSONObject message) {
if (event.equals("Notification:Show")) {

View File

@ -35,21 +35,21 @@ public final class OrderedBroadcastHelper
public OrderedBroadcastHelper(Context context) {
mContext = context;
EventDispatcher dispatcher = GeckoAppShell.getEventDispatcher();
EventDispatcher dispatcher = EventDispatcher.getInstance();
if (dispatcher == null) {
Log.e(LOGTAG, "Gecko event dispatcher must not be null", new RuntimeException());
return;
}
dispatcher.registerEventListener(SEND_EVENT, this);
dispatcher.registerGeckoThreadListener(this, SEND_EVENT);
}
public synchronized void uninit() {
EventDispatcher dispatcher = GeckoAppShell.getEventDispatcher();
EventDispatcher dispatcher = EventDispatcher.getInstance();
if (dispatcher == null) {
Log.e(LOGTAG, "Gecko event dispatcher must not be null", new RuntimeException());
return;
}
dispatcher.unregisterEventListener(SEND_EVENT, this);
dispatcher.unregisterGeckoThreadListener(this, SEND_EVENT);
}
@Override

View File

@ -63,7 +63,7 @@ public final class PrefsHelper {
return;
}
GeckoAppShell.getEventDispatcher().registerEventListener("Preferences:Data", new GeckoEventListener() {
EventDispatcher.getInstance().registerGeckoThreadListener(new GeckoEventListener() {
@Override public void handleMessage(String event, JSONObject message) {
try {
PrefHandler callback;
@ -107,7 +107,7 @@ public final class PrefsHelper {
Log.e(LOGTAG, "Error handling Preferences:Data message", e);
}
}
});
}, "Preferences:Data");
sRegistered = true;
}

View File

@ -38,26 +38,27 @@ public final class SharedPreferencesHelper
mListeners = new HashMap<String, SharedPreferences.OnSharedPreferenceChangeListener>();
EventDispatcher dispatcher = GeckoAppShell.getEventDispatcher();
EventDispatcher dispatcher = EventDispatcher.getInstance();
if (dispatcher == null) {
Log.e(LOGTAG, "Gecko event dispatcher must not be null", new RuntimeException());
return;
}
dispatcher.registerEventListener("SharedPreferences:Set", this);
dispatcher.registerEventListener("SharedPreferences:Get", this);
dispatcher.registerEventListener("SharedPreferences:Observe", this);
dispatcher.registerGeckoThreadListener(this,
"SharedPreferences:Set",
"SharedPreferences:Get",
"SharedPreferences:Observe");
}
public synchronized void uninit() {
EventDispatcher dispatcher = GeckoAppShell.getEventDispatcher();
EventDispatcher dispatcher = EventDispatcher.getInstance();
if (dispatcher == null) {
Log.e(LOGTAG, "Gecko event dispatcher must not be null", new RuntimeException());
return;
}
dispatcher.unregisterEventListener("SharedPreferences:Set", this);
dispatcher.unregisterEventListener("SharedPreferences:Get", this);
dispatcher.unregisterEventListener("SharedPreferences:Observe", this);
dispatcher.unregisterGeckoThreadListener(this,
"SharedPreferences:Set",
"SharedPreferences:Get",
"SharedPreferences:Observe");
}
private SharedPreferences getSharedPreferences(String branch) {

View File

@ -82,30 +82,31 @@ public class Tabs implements GeckoEventListener {
};
private Tabs() {
registerEventListener("Session:RestoreEnd");
registerEventListener("SessionHistory:New");
registerEventListener("SessionHistory:Back");
registerEventListener("SessionHistory:Forward");
registerEventListener("SessionHistory:Goto");
registerEventListener("SessionHistory:Purge");
registerEventListener("Tab:Added");
registerEventListener("Tab:Close");
registerEventListener("Tab:Select");
registerEventListener("Content:LocationChange");
registerEventListener("Content:SecurityChange");
registerEventListener("Content:ReaderEnabled");
registerEventListener("Content:StateChange");
registerEventListener("Content:LoadError");
registerEventListener("Content:PageShow");
registerEventListener("DOMContentLoaded");
registerEventListener("DOMTitleChanged");
registerEventListener("Link:Favicon");
registerEventListener("Link:Feed");
registerEventListener("Link:OpenSearch");
registerEventListener("DesktopMode:Changed");
registerEventListener("Tab:ViewportMetadata");
registerEventListener("Tab:StreamStart");
registerEventListener("Tab:StreamStop");
EventDispatcher.getInstance().registerGeckoThreadListener(this,
"Session:RestoreEnd",
"SessionHistory:New",
"SessionHistory:Back",
"SessionHistory:Forward",
"SessionHistory:Goto",
"SessionHistory:Purge",
"Tab:Added",
"Tab:Close",
"Tab:Select",
"Content:LocationChange",
"Content:SecurityChange",
"Content:ReaderEnabled",
"Content:StateChange",
"Content:LoadError",
"Content:PageShow",
"DOMContentLoaded",
"DOMTitleChanged",
"Link:Favicon",
"Link:Feed",
"Link:OpenSearch",
"DesktopMode:Changed",
"Tab:ViewportMetadata",
"Tab:StreamStart",
"Tab:StreamStop");
}
@ -636,10 +637,6 @@ public class Tabs implements GeckoEventListener {
backgroundHandler.postDelayed(mPersistTabsRunnable, PERSIST_TABS_AFTER_MILLISECONDS);
}
private void registerEventListener(String event) {
GeckoAppShell.getEventDispatcher().registerEventListener(event, this);
}
/**
* Looks for an open tab with the given URL.
* @param url the URL of the tab we're looking for

View File

@ -91,20 +91,22 @@ class TextSelection extends Layer implements GeckoEventListener {
if (mStartHandle == null || mMiddleHandle == null || mEndHandle == null) {
Log.e(LOGTAG, "Failed to initialize text selection because at least one handle is null");
} else {
registerEventListener("TextSelection:ShowHandles");
registerEventListener("TextSelection:HideHandles");
registerEventListener("TextSelection:PositionHandles");
registerEventListener("TextSelection:Update");
registerEventListener("TextSelection:DraggingHandle");
EventDispatcher.getInstance().registerGeckoThreadListener(this,
"TextSelection:ShowHandles",
"TextSelection:HideHandles",
"TextSelection:PositionHandles",
"TextSelection:Update",
"TextSelection:DraggingHandle");
}
}
void destroy() {
unregisterEventListener("TextSelection:ShowHandles");
unregisterEventListener("TextSelection:HideHandles");
unregisterEventListener("TextSelection:PositionHandles");
unregisterEventListener("TextSelection:Update");
unregisterEventListener("TextSelection:DraggingHandle");
EventDispatcher.getInstance().unregisterGeckoThreadListener(this,
"TextSelection:ShowHandles",
"TextSelection:HideHandles",
"TextSelection:PositionHandles",
"TextSelection:Update",
"TextSelection:DraggingHandle");
}
private TextSelectionHandle getHandle(String name) {
@ -243,14 +245,6 @@ class TextSelection extends Layer implements GeckoEventListener {
});
}
private void registerEventListener(String event) {
mEventDispatcher.registerEventListener(event, this);
}
private void unregisterEventListener(String event) {
mEventDispatcher.unregisterEventListener(event, this);
}
private class TextSelectionActionModeCallback implements Callback {
private JSONArray mItems;
private ActionModeCompat mActionMode;

View File

@ -146,9 +146,10 @@ class JavaPanZoomController
setState(PanZoomState.NOTHING);
mEventDispatcher = eventDispatcher;
registerEventListener(MESSAGE_ZOOM_RECT);
registerEventListener(MESSAGE_ZOOM_PAGE);
registerEventListener(MESSAGE_TOUCH_LISTENER);
mEventDispatcher.registerGeckoThreadListener(this,
MESSAGE_ZOOM_RECT,
MESSAGE_ZOOM_PAGE,
MESSAGE_TOUCH_LISTENER);
mMode = AxisLockMode.STANDARD;
@ -193,9 +194,10 @@ class JavaPanZoomController
@Override
public void destroy() {
unregisterEventListener(MESSAGE_ZOOM_RECT);
unregisterEventListener(MESSAGE_ZOOM_PAGE);
unregisterEventListener(MESSAGE_TOUCH_LISTENER);
mEventDispatcher.unregisterGeckoThreadListener(this,
MESSAGE_ZOOM_RECT,
MESSAGE_ZOOM_PAGE,
MESSAGE_TOUCH_LISTENER);
mSubscroller.destroy();
mTouchEventHandler.destroy();
}
@ -207,14 +209,6 @@ class JavaPanZoomController
return -t*t+1;
}
private void registerEventListener(String event) {
mEventDispatcher.registerEventListener(event, this);
}
private void unregisterEventListener(String event) {
mEventDispatcher.unregisterEventListener(event, this);
}
private void setState(PanZoomState state) {
if (state != mState) {
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("PanZoom:StateChange", state.toString()));

View File

@ -30,13 +30,13 @@ class NativePanZoomController implements PanZoomController, GeckoEventListener {
if (GeckoThread.checkLaunchState(GeckoThread.LaunchState.GeckoRunning)) {
init();
} else {
mDispatcher.registerEventListener("Gecko:Ready", this);
mDispatcher.registerGeckoThreadListener(this, "Gecko:Ready");
}
}
public void handleMessage(String event, JSONObject message) {
if ("Gecko:Ready".equals(event)) {
mDispatcher.unregisterEventListener("Gecko:Ready", this);
mDispatcher.unregisterGeckoThreadListener(this, "Gecko:Ready");
init();
}
}

View File

@ -54,23 +54,17 @@ class SubdocumentScrollHelper implements GeckoEventListener {
mPendingDisplacement = new PointF();
mEventDispatcher = eventDispatcher;
registerEventListener(MESSAGE_PANNING_OVERRIDE);
registerEventListener(MESSAGE_CANCEL_OVERRIDE);
registerEventListener(MESSAGE_SCROLL_ACK);
mEventDispatcher.registerGeckoThreadListener(this,
MESSAGE_PANNING_OVERRIDE,
MESSAGE_CANCEL_OVERRIDE,
MESSAGE_SCROLL_ACK);
}
void destroy() {
unregisterEventListener(MESSAGE_PANNING_OVERRIDE);
unregisterEventListener(MESSAGE_CANCEL_OVERRIDE);
unregisterEventListener(MESSAGE_SCROLL_ACK);
}
private void registerEventListener(String event) {
mEventDispatcher.registerEventListener(event, this);
}
private void unregisterEventListener(String event) {
mEventDispatcher.unregisterEventListener(event, this);
mEventDispatcher.unregisterGeckoThreadListener(this,
MESSAGE_PANNING_OVERRIDE,
MESSAGE_CANCEL_OVERRIDE,
MESSAGE_SCROLL_ACK);
}
boolean scrollBy(PointF displacement) {

View File

@ -193,12 +193,13 @@ public class BrowserHealthRecorder implements HealthRecorder, GeckoEventListener
if (state != State.INITIALIZED) {
return;
}
this.dispatcher.unregisterEventListener(EVENT_SNAPSHOT, this);
this.dispatcher.unregisterEventListener(EVENT_ADDONS_CHANGE, this);
this.dispatcher.unregisterEventListener(EVENT_ADDONS_UNINSTALLING, this);
this.dispatcher.unregisterEventListener(EVENT_PREF_CHANGE, this);
this.dispatcher.unregisterEventListener(EVENT_KEYWORD_SEARCH, this);
this.dispatcher.unregisterEventListener(EVENT_SEARCH, this);
dispatcher.unregisterGeckoThreadListener(this,
EVENT_SNAPSHOT,
EVENT_ADDONS_CHANGE,
EVENT_ADDONS_UNINSTALLING,
EVENT_PREF_CHANGE,
EVENT_KEYWORD_SEARCH,
EVENT_SEARCH);
}
public void onAppLocaleChanged(String to) {
@ -459,9 +460,10 @@ public class BrowserHealthRecorder implements HealthRecorder, GeckoEventListener
try {
// Listen for add-ons and prefs changes.
dispatcher.registerEventListener(EVENT_ADDONS_UNINSTALLING, self);
dispatcher.registerEventListener(EVENT_ADDONS_CHANGE, self);
dispatcher.registerEventListener(EVENT_PREF_CHANGE, self);
dispatcher.registerGeckoThreadListener(self,
EVENT_ADDONS_UNINSTALLING,
EVENT_ADDONS_CHANGE,
EVENT_PREF_CHANGE);
// Initialize each provider here.
initializeSessionsProvider();
@ -526,7 +528,7 @@ public class BrowserHealthRecorder implements HealthRecorder, GeckoEventListener
profileCache.setDistributionString(desc.id, desc.version);
}
Log.d(LOG_TAG, "Requesting all add-ons and FHR prefs from Gecko.");
dispatcher.registerEventListener(EVENT_SNAPSHOT, self);
dispatcher.registerGeckoThreadListener(self, EVENT_SNAPSHOT);
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("HealthReport:RequestSnapshot", null));
}
});
@ -669,8 +671,9 @@ public class BrowserHealthRecorder implements HealthRecorder, GeckoEventListener
// Do this here, rather than in a centralized registration spot, in
// case the above throws and we wind up handling events that we can't
// store.
this.dispatcher.registerEventListener(EVENT_KEYWORD_SEARCH, this);
this.dispatcher.registerEventListener(EVENT_SEARCH, this);
this.dispatcher.registerGeckoThreadListener(this,
EVENT_KEYWORD_SEARCH,
EVENT_SEARCH);
}
/**

View File

@ -9,6 +9,7 @@ import android.content.ContentProviderClient;
import android.content.Context;
import android.util.Log;
import org.mozilla.gecko.EventDispatcher;
import org.mozilla.gecko.GeckoAppShell;
import org.mozilla.gecko.GeckoEvent;
import org.mozilla.gecko.GeckoProfile;
@ -42,7 +43,7 @@ public class BrowserHealthReporter implements GeckoEventListener {
protected final Context context;
public BrowserHealthReporter() {
GeckoAppShell.registerEventListener(EVENT_REQUEST, this);
EventDispatcher.getInstance().registerGeckoThreadListener(this, EVENT_REQUEST);
context = GeckoAppShell.getContext();
if (context == null) {
@ -51,7 +52,7 @@ public class BrowserHealthReporter implements GeckoEventListener {
}
public void uninit() {
GeckoAppShell.unregisterEventListener(EVENT_REQUEST, this);
EventDispatcher.getInstance().unregisterGeckoThreadListener(this, EVENT_REQUEST);
}
/**

View File

@ -5,6 +5,7 @@
package org.mozilla.gecko.home;
import org.mozilla.gecko.EventDispatcher;
import org.mozilla.gecko.GeckoAppShell;
import org.mozilla.gecko.GeckoEvent;
import org.mozilla.gecko.PrefsHelper;
@ -250,7 +251,8 @@ public class BrowserSearch extends HomeFragment
public void onDestroyView() {
super.onDestroyView();
unregisterEventListener("SearchEngines:Data");
EventDispatcher.getInstance().unregisterGeckoThreadListener(this,
"SearchEngines:Data");
mList.setAdapter(null);
mList = null;
@ -321,7 +323,8 @@ public class BrowserSearch extends HomeFragment
});
registerForContextMenu(mList);
registerEventListener("SearchEngines:Data");
EventDispatcher.getInstance().registerGeckoThreadListener(this,
"SearchEngines:Data");
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("SearchEngines:GetVisible", null));
}
@ -707,14 +710,6 @@ public class BrowserSearch extends HomeFragment
return (TextUtils.isEmpty(mSearchTerm) || mSuggestClient == null || !mSuggestionsEnabled) ? 0 : 1;
}
private void registerEventListener(String eventName) {
GeckoAppShell.registerEventListener(eventName, this);
}
private void unregisterEventListener(String eventName) {
GeckoAppShell.unregisterEventListener(eventName, this);
}
private void restartSearchLoader() {
SearchLoader.restart(getLoaderManager(), LOADER_ID_SEARCH, mCursorLoaderCallbacks, mSearchTerm);
}

View File

@ -7,6 +7,7 @@ package org.mozilla.gecko.home;
import org.json.JSONException;
import org.json.JSONObject;
import org.mozilla.gecko.EventDispatcher;
import org.mozilla.gecko.GeckoAppShell;
import org.mozilla.gecko.GeckoEvent;
import org.mozilla.gecko.R;
@ -118,14 +119,14 @@ public class HomeBanner extends LinearLayout
}
});
GeckoAppShell.getEventDispatcher().registerEventListener("HomeBanner:Data", this);
EventDispatcher.getInstance().registerGeckoThreadListener(this, "HomeBanner:Data");
}
@Override
public void onDetachedFromWindow() {
super.onDetachedFromWindow();
GeckoAppShell.getEventDispatcher().unregisterEventListener("HomeBanner:Data", this);
EventDispatcher.getInstance().unregisterGeckoThreadListener(this, "HomeBanner:Data");
}
@Override

View File

@ -17,7 +17,7 @@ import java.util.concurrent.ConcurrentLinkedQueue;
import org.json.JSONException;
import org.json.JSONObject;
import org.mozilla.gecko.db.HomeProvider;
import org.mozilla.gecko.GeckoAppShell;
import org.mozilla.gecko.EventDispatcher;
import org.mozilla.gecko.home.HomeConfig.PanelConfig;
import org.mozilla.gecko.home.PanelInfoManager.PanelInfo;
import org.mozilla.gecko.home.PanelInfoManager.RequestCallback;
@ -85,10 +85,11 @@ public class HomePanelsManager implements GeckoEventListener {
mContext = context;
mHomeConfig = HomeConfig.getDefault(context);
GeckoAppShell.getEventDispatcher().registerEventListener(EVENT_HOMEPANELS_INSTALL, this);
GeckoAppShell.getEventDispatcher().registerEventListener(EVENT_HOMEPANELS_UNINSTALL, this);
GeckoAppShell.getEventDispatcher().registerEventListener(EVENT_HOMEPANELS_UPDATE, this);
GeckoAppShell.getEventDispatcher().registerEventListener(EVENT_HOMEPANELS_REFRESH, this);
EventDispatcher.getInstance().registerGeckoThreadListener(this,
EVENT_HOMEPANELS_INSTALL,
EVENT_HOMEPANELS_UNINSTALL,
EVENT_HOMEPANELS_UPDATE,
EVENT_HOMEPANELS_REFRESH);
}
public void onLocaleReady(final String locale) {

View File

@ -13,6 +13,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.mozilla.gecko.EventDispatcher;
import org.mozilla.gecko.GeckoAppShell;
import org.mozilla.gecko.GeckoEvent;
import org.mozilla.gecko.home.HomeConfig.PanelConfig;
@ -77,7 +78,8 @@ public class PanelInfoManager implements GeckoEventListener {
synchronized(sCallbacks) {
// If there are no pending callbacks, register the event listener.
if (sCallbacks.size() == 0) {
GeckoAppShell.getEventDispatcher().registerEventListener("HomePanels:Data", this);
EventDispatcher.getInstance().registerGeckoThreadListener(this,
"HomePanels:Data");
}
sCallbacks.put(requestId, callback);
}
@ -135,7 +137,8 @@ public class PanelInfoManager implements GeckoEventListener {
// Unregister the event listener if there are no more pending callbacks.
if (sCallbacks.size() == 0) {
GeckoAppShell.getEventDispatcher().unregisterEventListener("HomePanels:Data", this);
EventDispatcher.getInstance().unregisterGeckoThreadListener(this,
"HomePanels:Data");
}
}

View File

@ -11,6 +11,7 @@ import java.util.List;
import org.json.JSONObject;
import org.mozilla.gecko.AppConstants;
import org.mozilla.gecko.DataReportingNotification;
import org.mozilla.gecko.EventDispatcher;
import org.mozilla.gecko.GeckoActivityStatus;
import org.mozilla.gecko.GeckoApp;
import org.mozilla.gecko.GeckoAppShell;
@ -145,7 +146,8 @@ public class GeckoPreferences
addPreferencesFromResource(res);
}
registerEventListener("Sanitize:Finished");
EventDispatcher.getInstance().registerGeckoThreadListener(this,
"Sanitize:Finished");
// Add handling for long-press click.
// This is only for Android 3.0 and below (which use the long-press-context-menu paradigm).
@ -223,7 +225,8 @@ public class GeckoPreferences
@Override
protected void onDestroy() {
super.onDestroy();
unregisterEventListener("Sanitize:Finished");
EventDispatcher.getInstance().unregisterGeckoThreadListener(this,
"Sanitize:Finished");
if (mPrefsRequestId > 0) {
PrefsHelper.removeObserver(mPrefsRequestId);
}
@ -900,14 +903,6 @@ public class GeckoPreferences
});
}
private void registerEventListener(String event) {
GeckoAppShell.getEventDispatcher().registerEventListener(event, this);
}
private void unregisterEventListener(String event) {
GeckoAppShell.getEventDispatcher().unregisterEventListener(event, this);
}
@Override
public boolean isGeckoActivityOpened() {
return false;

View File

@ -13,6 +13,7 @@ import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.mozilla.gecko.EventDispatcher;
import org.mozilla.gecko.GeckoAppShell;
import org.mozilla.gecko.GeckoEvent;
import org.mozilla.gecko.util.GeckoEventListener;
@ -38,13 +39,13 @@ public class SearchPreferenceCategory extends CustomListCategory implements Geck
super.onAttachedToActivity();
// Register for SearchEngines messages and request list of search engines from Gecko.
GeckoAppShell.registerEventListener("SearchEngines:Data", this);
EventDispatcher.getInstance().registerGeckoThreadListener(this, "SearchEngines:Data");
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("SearchEngines:GetVisible", null));
}
@Override
protected void onPrepareForRemoval() {
GeckoAppShell.unregisterEventListener("SearchEngines:Data", this);
EventDispatcher.getInstance().unregisterGeckoThreadListener(this, "SearchEngines:Data");
}
@Override

View File

@ -21,14 +21,16 @@ public class PromptService implements GeckoEventListener {
private final Context mContext;
public PromptService(Context context) {
GeckoAppShell.getEventDispatcher().registerEventListener("Prompt:Show", this);
GeckoAppShell.getEventDispatcher().registerEventListener("Prompt:ShowTop", this);
EventDispatcher.getInstance().registerGeckoThreadListener(this,
"Prompt:Show",
"Prompt:ShowTop");
mContext = context;
}
public void destroy() {
GeckoAppShell.getEventDispatcher().unregisterEventListener("Prompt:Show", this);
GeckoAppShell.getEventDispatcher().unregisterEventListener("Prompt:ShowTop", this);
EventDispatcher.getInstance().unregisterGeckoThreadListener(this,
"Prompt:Show",
"Prompt:ShowTop");
}
public void show(final String aTitle, final String aText, final PromptListItem[] aMenuList,

View File

@ -12,6 +12,7 @@ import java.util.List;
import org.json.JSONObject;
import org.mozilla.gecko.BrowserApp;
import org.mozilla.gecko.EventDispatcher;
import org.mozilla.gecko.GeckoAppShell;
import org.mozilla.gecko.GeckoApplication;
import org.mozilla.gecko.GeckoProfile;
@ -180,8 +181,9 @@ public class BrowserToolbar extends ThemedRelativeLayout
isSwitchingTabs = true;
isAnimatingEntry = false;
registerEventListener("Reader:Click");
registerEventListener("Reader:LongClick");
EventDispatcher.getInstance().registerGeckoThreadListener(this,
"Reader:Click",
"Reader:LongClick");
final Resources res = getResources();
urlBarViewOffset = res.getDimensionPixelSize(R.dimen.url_bar_offset_left);
@ -1358,8 +1360,9 @@ public class BrowserToolbar extends ThemedRelativeLayout
public void onDestroy() {
Tabs.unregisterOnTabsChangedListener(this);
unregisterEventListener("Reader:Click");
unregisterEventListener("Reader:LongClick");
EventDispatcher.getInstance().unregisterGeckoThreadListener(this,
"Reader:Click",
"Reader:LongClick");
}
public boolean openOptionsMenu() {
@ -1401,14 +1404,6 @@ public class BrowserToolbar extends ThemedRelativeLayout
return true;
}
private void registerEventListener(String event) {
GeckoAppShell.getEventDispatcher().registerEventListener(event, this);
}
private void unregisterEventListener(String event) {
GeckoAppShell.getEventDispatcher().unregisterEventListener(event, this);
}
@Override
public void handleMessage(String event, JSONObject message) {
Log.d(LOGTAG, "handleMessage: " + event);

View File

@ -5,6 +5,7 @@
package org.mozilla.gecko.toolbar;
import org.mozilla.gecko.EventDispatcher;
import org.mozilla.gecko.GeckoAppShell;
import org.mozilla.gecko.GeckoEvent;
import org.mozilla.gecko.R;
@ -60,8 +61,9 @@ public class PageActionLayout extends LinearLayout implements GeckoEventListener
setNumberShown(DEFAULT_PAGE_ACTIONS_SHOWN);
refreshPageActionIcons();
registerEventListener("PageActions:Add");
registerEventListener("PageActions:Remove");
EventDispatcher.getInstance().registerGeckoThreadListener(this,
"PageActions:Add",
"PageActions:Remove");
}
private void setNumberShown(int count) {
@ -75,16 +77,9 @@ public class PageActionLayout extends LinearLayout implements GeckoEventListener
}
public void onDestroy() {
unregisterEventListener("PageActions:Add");
unregisterEventListener("PageActions:Remove");
}
protected void registerEventListener(String event) {
GeckoAppShell.getEventDispatcher().registerEventListener(event, this);
}
protected void unregisterEventListener(String event) {
GeckoAppShell.getEventDispatcher().unregisterEventListener(event, this);
EventDispatcher.getInstance().unregisterGeckoThreadListener(this,
"PageActions:Add",
"PageActions:Remove");
}
@Override

View File

@ -53,30 +53,26 @@ public class EventListener implements GeckoEventListener {
return mEventListener;
}
private static void registerEventListener(String event) {
GeckoAppShell.getEventDispatcher().registerEventListener(event, EventListener.getEventListener());
}
private static void unregisterEventListener(String event) {
GeckoAppShell.getEventDispatcher().unregisterEventListener(event, EventListener.getEventListener());
}
public static void registerEvents() {
registerEventListener("Webapps:Preinstall");
registerEventListener("Webapps:InstallApk");
registerEventListener("Webapps:Postinstall");
registerEventListener("Webapps:Open");
registerEventListener("Webapps:Uninstall");
registerEventListener("Webapps:GetApkVersions");
EventDispatcher.getInstance().registerGeckoThreadListener(
EventListener.getEventListener(),
"Webapps:Preinstall",
"Webapps:InstallApk",
"Webapps:Postinstall",
"Webapps:Open",
"Webapps:Uninstall",
"Webapps:GetApkVersions");
}
public static void unregisterEvents() {
unregisterEventListener("Webapps:Preinstall");
unregisterEventListener("Webapps:InstallApk");
unregisterEventListener("Webapps:Postinstall");
unregisterEventListener("Webapps:Open");
unregisterEventListener("Webapps:Uninstall");
unregisterEventListener("Webapps:GetApkVersions");
EventDispatcher.getInstance().unregisterGeckoThreadListener(
EventListener.getEventListener(),
"Webapps:Preinstall",
"Webapps:InstallApk",
"Webapps:Postinstall",
"Webapps:Open",
"Webapps:Uninstall",
"Webapps:GetApkVersions");
}
@Override

View File

@ -14,6 +14,7 @@ import java.io.OutputStream;
import org.json.JSONException;
import org.json.JSONObject;
import org.mozilla.gecko.EventDispatcher;
import org.mozilla.gecko.GeckoAppShell;
import org.mozilla.gecko.GeckoEvent;
import org.mozilla.gecko.GeckoProfile;
@ -149,9 +150,7 @@ public class InstallHelper implements GeckoEventListener {
}
public void registerGeckoListener() {
for (String eventName : INSTALL_EVENT_NAMES) {
GeckoAppShell.registerEventListener(eventName, this);
}
EventDispatcher.getInstance().registerGeckoThreadListener(this, INSTALL_EVENT_NAMES);
}
private void calculateColor() {
@ -164,9 +163,7 @@ public class InstallHelper implements GeckoEventListener {
@Override
public void handleMessage(String event, JSONObject message) {
for (String eventName : INSTALL_EVENT_NAMES) {
GeckoAppShell.unregisterEventListener(eventName, this);
}
EventDispatcher.getInstance().unregisterGeckoThreadListener(this, INSTALL_EVENT_NAMES);
if (mCallback != null) {
mCallback.installCompleted(this, event, message);

View File

@ -24,11 +24,15 @@ XPCOMUtils.defineLazyModuleGetter(this, "CustomizationTabPreloader",
const SIMPLETEST_OVERRIDES =
["ok", "is", "isnot", "ise", "todo", "todo_is", "todo_isnot", "info", "expectAssertions"];
window.addEventListener("load", testOnLoad, false);
function testOnLoad() {
window.removeEventListener("load", testOnLoad, false);
window.addEventListener("load", function testOnLoad() {
window.removeEventListener("load", testOnLoad);
window.addEventListener("MozAfterPaint", function testOnMozAfterPaint() {
window.removeEventListener("MozAfterPaint", testOnMozAfterPaint);
setTimeout(testInit, 0);
});
});
function testInit() {
gConfig = readConfig();
if (gConfig.testRoot == "browser" ||
gConfig.testRoot == "metro" ||
@ -143,15 +147,6 @@ Tester.prototype = {
},
start: function Tester_start() {
// Check whether this window is ready to run tests.
if (window.BrowserChromeTest) {
BrowserChromeTest.runWhenReady(this.actuallyStart.bind(this));
return;
}
this.actuallyStart();
},
actuallyStart: function Tester_actuallyStart() {
//if testOnLoad was not called, then gConfig is not defined
if (!gConfig)
gConfig = readConfig();

View File

@ -1254,7 +1254,7 @@
if (aResult.total == -1) {
this._foundMatches.value = this.pluralForm.get(
this._matchesCountLimit,
this.strBundle.GetStringFromName("FoundTooManyMatches")
this.strBundle.GetStringFromName("FoundMatchesCountLimit")
).replace("#1", this._matchesCountLimit);
} else {
this._foundMatches.value = this.pluralForm.get(

View File

@ -14,8 +14,8 @@ CaseSensitive=(Case sensitive)
# See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
# #1 is currently selected match and #2 the total amount of matches.
FoundMatches=#1 of #2 match;#1 of #2 matches
# LOCALIZATION NOTE (FoundTooManyMatches): Semicolon-separated list of plural
# LOCALIZATION NOTE (FoundMatchesCountLimit): Semicolon-separated list of plural
# forms.
# See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
# #1 is the total amount of matches allowed before counting stops.
FoundTooManyMatches=More than #1 match;More than #1 matches
FoundMatchesCountLimit=More than #1 match;More than #1 matches