Bug 722661 - Part 5: Miscellaneous fixes. r=mfinkle
authorBrian Nicholson <bnicholson@mozilla.com>
Mon, 29 Oct 2012 16:34:29 -0700
changeset 111852 d70a135377583b38abe38a722b5d3c5d0e7febf2
parent 111851 ba32bc11b66f85dbdc2f56e2c04bf6273d3bf798
child 111853 3e4d63da1bceda810d5e3e504bc43d9e6b48a35a
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersmfinkle
bugs722661
milestone19.0a1
Bug 722661 - Part 5: Miscellaneous fixes. r=mfinkle
mobile/android/base/BrowserApp.java
mobile/android/base/GeckoApp.java
mobile/android/base/Tab.java
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -212,20 +212,16 @@ abstract public class BrowserApp extends
         mBrowserToolbar = new BrowserToolbar(this);
         mBrowserToolbar.from(actionBar);
 
         if (mTabsPanel != null)
             mTabsPanel.setTabsLayoutChangeListener(this);
 
         mFindInPageBar = (FindInPageBar) findViewById(R.id.find_in_page);
 
-        if (savedInstanceState != null) {
-            mBrowserToolbar.setTitle(savedInstanceState.getString(SAVED_STATE_TITLE));
-        }
-
         registerEventListener("CharEncoding:Data");
         registerEventListener("CharEncoding:State");
         registerEventListener("Feedback:LastUrl");
         registerEventListener("Feedback:OpenPlayStore");
         registerEventListener("Feedback:MaybeLater");
         registerEventListener("Dex:Load");
     }
 
@@ -266,19 +262,22 @@ abstract public class BrowserApp extends
         mBrowserToolbar.updateForwardButton(false);
 
         mDoorHangerPopup.setAnchor(mBrowserToolbar.mFavicon);
 
         if (!isExternalURL) {
             // show about:home if we aren't restoring previous session
             if (mRestoreMode == RESTORE_NONE) {
                 Tab tab = Tabs.getInstance().loadUrl("about:home", Tabs.LOADURL_NEW_TAB);
+            } else {
+                hideAboutHome();
             }
         } else {
-            Tabs.getInstance().loadUrl(uri, Tabs.LOADURL_NEW_TAB | Tabs.LOADURL_USER_ENTERED);
+            int flags = Tabs.LOADURL_NEW_TAB | Tabs.LOADURL_USER_ENTERED;
+            Tabs.getInstance().loadUrl(uri, flags);
         }
     }
 
     void toggleChrome(final boolean aShow) {
         mMainHandler.post(new Runnable() {
             public void run() {
                 if (aShow) {
                     mBrowserToolbar.show();
@@ -629,29 +628,29 @@ abstract public class BrowserApp extends
     }
 
     private void hideAboutHome() {
         // If hideAboutHome gets called before showAboutHome, we still need
         // to create an AboutHomeRunnable to hide the about:home content.
         if (mAboutHomeShowing != null && !mAboutHomeShowing)
             return;
 
+        mBrowserToolbar.setShadowVisibility(true);
         mAboutHomeShowing = false;
         Runnable r = new AboutHomeRunnable(false);
         mMainHandler.postAtFrontOfQueue(r);
     }
 
     private class AboutHomeRunnable implements Runnable {
         boolean mShow;
         AboutHomeRunnable(boolean show) {
             mShow = show;
         }
 
         public void run() {
-            mFormAssistPopup.hide();
             if (mShow) {
                 if (mAboutHomeContent == null) {
                     mAboutHomeContent = (AboutHomeContent) findViewById(R.id.abouthome_content);
                     mAboutHomeContent.init();
                     mAboutHomeContent.update(AboutHomeContent.UpdateFlags.ALL);
                     mAboutHomeContent.setUriLoadCallback(new AboutHomeContent.UriLoadCallback() {
                         public void callback(String url) {
                             mBrowserToolbar.setProgressVisibility(true);
--- a/mobile/android/base/GeckoApp.java
+++ b/mobile/android/base/GeckoApp.java
@@ -137,17 +137,16 @@ abstract public class GeckoApp
     public static final String ACTION_ALERT_CALLBACK = "org.mozilla.gecko.ACTION_ALERT_CALLBACK";
     public static final String ACTION_ANNOUNCEMENTS_PREF = "org.mozilla.gecko.ANNOUNCEMENTS_PREF";
     public static final String ACTION_WEBAPP_PREFIX = "org.mozilla.gecko.WEBAPP";
     public static final String ACTION_DEBUG         = "org.mozilla.gecko.DEBUG";
     public static final String ACTION_BOOKMARK      = "org.mozilla.gecko.BOOKMARK";
     public static final String ACTION_LOAD          = "org.mozilla.gecko.LOAD";
     public static final String ACTION_INIT_PW       = "org.mozilla.gecko.INIT_PW";
     public static final String ACTION_WIDGET        = "org.mozilla.gecko.WIDGET";
-    public static final String SAVED_STATE_TITLE         = "title";
     public static final String SAVED_STATE_IN_BACKGROUND = "inBackground";
     public static final String SAVED_STATE_PRIVATE_SESSION = "privateSession";
 
     public static final String PREFS_NAME          = "GeckoApp";
     public static final String PREFS_OOM_EXCEPTION = "OOMException";
     public static final String PREFS_WAS_STOPPED   = "wasStopped";
 
     static public final int RESTORE_NONE = 0;
@@ -696,37 +695,35 @@ abstract public class GeckoApp
     }
 
     protected void onSaveInstanceState(Bundle outState) {
         super.onSaveInstanceState(outState);
 
         if (outState == null)
             outState = new Bundle();
 
-        Tab tab = Tabs.getInstance().getSelectedTab();
-        if (tab != null)
-            outState.putString(SAVED_STATE_TITLE, tab.getDisplayTitle());
-
         boolean inBackground =
             ((GeckoApplication)getApplication()).isApplicationInBackground();
 
         outState.putBoolean(SAVED_STATE_IN_BACKGROUND, inBackground);
         outState.putString(SAVED_STATE_PRIVATE_SESSION, mPrivateBrowsingSession);
     }
 
     void getAndProcessThumbnailForTab(final Tab tab) {
         if ("about:home".equals(tab.getURL())) {
             tab.updateThumbnail(null);
             return;
         }
 
         if (tab.getState() == Tab.STATE_DELAYED) {
-            byte[] thumbnail = BrowserDB.getThumbnailForUrl(getContentResolver(), tab.getURL());
-            if (thumbnail != null)
-                processThumbnail(tab, null, thumbnail);
+            if (tab.getURL() != null) {
+                byte[] thumbnail = BrowserDB.getThumbnailForUrl(getContentResolver(), tab.getURL());
+                if (thumbnail != null)
+                    processThumbnail(tab, null, thumbnail);
+            }
             return;
         }
 
         int dw = Tabs.getThumbnailWidth();
         int dh = Tabs.getThumbnailHeight();
         GeckoAppShell.sendEventToGecko(GeckoEvent.createScreenshotEvent(tab.getId(), 0, 0, 0, 0, 0, 0, dw, dh, dw, dh, ScreenshotHandler.SCREENSHOT_THUMBNAIL, tab.getThumbnailBuffer()));
     }
 
--- a/mobile/android/base/Tab.java
+++ b/mobile/android/base/Tab.java
@@ -254,17 +254,19 @@ public class Tab {
 
     public synchronized void updateTitle(String title) {
         // Keep the title unchanged while entering reader mode
         if (mEnteringReaderMode)
             return;
 
         mTitle = (title == null ? "" : title);
 
-        updateHistory(mUrl, mTitle);
+        if (mUrl != null)
+            updateHistory(mUrl, mTitle);
+
         Tabs.getInstance().notifyListeners(this, Tabs.TabEvents.TITLE);
     }
 
     protected void addHistory(final String uri) {
         GeckoAppShell.getHandler().post(new Runnable() {
             public void run() {
                 GlobalHistory.getInstance().add(uri);
             }