Bug 950919 - (Part 2) Get rid of "aboutHomePage" flag. r=mcomella

This commit is contained in:
Margaret Leibovic 2013-12-17 22:43:31 -08:00
Родитель 002ef4ddf6
Коммит 8bb6cd1e23
8 изменённых файлов: 44 добавлений и 39 удалений

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

@ -5,6 +5,8 @@
package org.mozilla.gecko;
import android.text.TextUtils;
public class AboutPages {
// All of our special pages.
public static final String ADDONS = "about:addons";
@ -25,12 +27,47 @@ public class AboutPages {
}
public static final boolean isTitlelessAboutPage(final String url) {
return HOME.equals(url) ||
return isAboutHome(url) ||
PRIVATEBROWSING.equals(url);
}
public static final boolean isAboutHome(final String url) {
return HOME.equals(url);
if (url == null || !url.startsWith(HOME)) {
return false;
}
// We sometimes append a parameter to "about:home" to specify which page to
// show when we open the home pager. Discard this parameter when checking
// whether or not this URL is "about:home".
return HOME.equals(url.split("\\?")[0]);
}
public static final String getPageIdFromAboutHomeUrl(final String aboutHomeUrl) {
if (aboutHomeUrl == null) {
return null;
}
final String[] urlParts = aboutHomeUrl.split("\\?");
if (urlParts.length < 2) {
return null;
}
final String query = urlParts[1];
for (final String param : query.split("&")) {
final String pair[] = param.split("=");
final String key = pair[0];
// Key is empty or not "page", discard
if (TextUtils.isEmpty(key) || !key.equals("page")) {
continue;
}
// No value associated with key, discard
if (pair.length < 2) {
continue;
}
return pair[1];
}
return null;
}
public static final boolean isAboutReader(final String url) {

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

@ -535,7 +535,6 @@ abstract public class BrowserApp extends GeckoApp
registerEventListener("Telemetry:Gather");
registerEventListener("Settings:Show");
registerEventListener("Updater:Launch");
registerEventListener("Reader:GoToReadingList");
Distribution.init(this);
JavaAddonManager.getInstance().init(getApplicationContext());
@ -846,7 +845,6 @@ abstract public class BrowserApp extends GeckoApp
unregisterEventListener("Telemetry:Gather");
unregisterEventListener("Settings:Show");
unregisterEventListener("Updater:Launch");
unregisterEventListener("Reader:GoToReadingList");
if (AppConstants.MOZ_ANDROID_BEAM && Build.VERSION.SDK_INT >= 14) {
NfcAdapter nfc = NfcAdapter.getDefaultAdapter(this);
@ -1204,8 +1202,6 @@ abstract public class BrowserApp extends GeckoApp
startActivity(settingsIntent);
} else if (event.equals("Updater:Launch")) {
handleUpdaterLaunch();
} else if (event.equals("Reader:GoToReadingList")) {
openReadingList();
} else if (event.equals("Prompt:ShowTop")) {
// Bring this activity to front so the prompt is visible..
Intent bringToFrontIntent = new Intent();
@ -1394,10 +1390,6 @@ abstract public class BrowserApp extends GeckoApp
return (mHomePager != null && mHomePager.isVisible());
}
private void openReadingList() {
Tabs.getInstance().loadUrl(AboutPages.HOME, Tabs.LOADURL_READING_LIST);
}
/* Favicon stuff. */
private static OnFaviconLoadedListener sFaviconLoadedListener = new OnFaviconLoadedListener() {
@Override
@ -1608,7 +1600,8 @@ abstract public class BrowserApp extends GeckoApp
}
if (isAboutHome(tab)) {
showHomePager(tab.getAboutHomePageId());
final String pageId = AboutPages.getPageIdFromAboutHomeUrl(tab.getURL());
showHomePager(pageId);
if (isDynamicToolbarEnabled()) {
// Show the toolbar.

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

@ -51,7 +51,6 @@ public class Tab {
private int mHistoryIndex;
private int mHistorySize;
private int mParentId;
private String mAboutHomePageId;
private boolean mExternal;
private boolean mBookmark;
private boolean mReadingListItem;
@ -94,7 +93,6 @@ public class Tab {
mUserSearch = "";
mExternal = external;
mParentId = parentId;
mAboutHomePageId = null;
mTitle = title == null ? "" : title;
mFavicon = null;
mFaviconUrl = null;
@ -146,14 +144,6 @@ public class Tab {
return mParentId;
}
public String getAboutHomePageId() {
return mAboutHomePageId;
}
private void setAboutHomePageId(String pageId) {
mAboutHomePageId = pageId;
}
// may be null if user-entered query hasn't yet been resolved to a URI
public synchronized String getURL() {
return mUrl;
@ -655,13 +645,6 @@ public class Tab {
setBackgroundColor(DEFAULT_BACKGROUND_COLOR);
setErrorType(ErrorType.NONE);
final String homePageId = message.getString("aboutHomePage");
if (!TextUtils.isEmpty(homePageId)) {
setAboutHomePageId(homePageId);
} else {
setAboutHomePageId(null);
}
Tabs.getInstance().notifyListeners(this, Tabs.TabEvents.LOCATION_CHANGE, oldUrl);
}

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

@ -61,7 +61,6 @@ public class Tabs implements GeckoEventListener {
public static final int LOADURL_DESKTOP = 1 << 5;
public static final int LOADURL_BACKGROUND = 1 << 6;
public static final int LOADURL_EXTERNAL = 1 << 7;
public static final int LOADURL_READING_LIST = 1 << 8;
private static final long PERSIST_TABS_AFTER_MILLISECONDS = 1000 * 5;
@ -723,8 +722,6 @@ public class Tabs implements GeckoEventListener {
args.put("delayLoad", delayLoad);
args.put("desktopMode", desktopMode);
args.put("selected", !background);
// XXX: Dirty hack to pass reading list page id - let's get rid of this code path in bug 949178.
args.put("aboutHomePage", (flags & LOADURL_READING_LIST) != 0 ? "reading_list-reading_list" : "");
if ((flags & LOADURL_NEW_TAB) != 0) {
int tabId = getNextTabId();

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

@ -143,16 +143,14 @@ class HomeAdapter extends FragmentStatePagerAdapter {
}
private final class PageInfo {
private final String mId;
private final PageEntry mPageEntry;
PageInfo(PageEntry pageEntry) {
mId = pageEntry.getType() + "-" + pageEntry.getId();
mPageEntry = pageEntry;
}
public String getId() {
return mId;
return mPageEntry.getId();
}
public String getTitle() {

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

@ -286,6 +286,7 @@ public class HomePager extends ViewPager {
// Use the default page as defined in the HomePager's configuration
// if the initial page wasn't explicitly set by the show() caller.
if (mInitialPageId != null) {
// XXX: Handle the case where the desired page isn't currently in the adapter (bug 949178)
setCurrentItem(adapter.getItemPosition(mInitialPageId), false);
mInitialPageId = null;
} else {

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

@ -365,7 +365,7 @@ AboutReader.prototype = {
if (!this._article || this._readingListCount < 1)
return;
gChromeWin.sendMessageToJava({ type: "Reader:GoToReadingList" });
gChromeWin.BrowserApp.loadURI("about:home?page=reading_list");
},
_onShare: function Reader_onShare() {

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

@ -798,7 +798,6 @@ var BrowserApp = {
let tab = this.getTabForBrowser(aBrowser);
if (tab) {
if (!tab.aboutHomePage) tab.aboutHomePage = ("aboutHomePage" in aParams) ? aParams.aboutHomePage : "";
if ("userSearch" in aParams) tab.userSearch = aParams.userSearch;
}
@ -1392,7 +1391,6 @@ var BrowserApp = {
flags: flags,
tabID: data.tabID,
isPrivate: (data.isPrivate === true),
aboutHomePage: ("aboutHomePage" in data) ? data.aboutHomePage : "",
pinned: (data.pinned === true),
delayLoad: (delayLoad === true),
desktopMode: (data.desktopMode === true)
@ -2629,7 +2627,6 @@ function Tab(aURL, aParams) {
this.clickToPlayPluginsActivated = false;
this.desktopMode = false;
this.originalURI = null;
this.aboutHomePage = null;
this.savedArticle = null;
this.hasTouchListener = false;
this.browserWidth = 0;
@ -3820,7 +3817,6 @@ Tab.prototype = {
uri: fixedURI.spec,
userSearch: this.userSearch || "",
baseDomain: baseDomain,
aboutHomePage: this.aboutHomePage || "",
contentType: (contentType ? contentType : ""),
sameDocument: sameDocument
};