Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / chrome / android / java / src / org / chromium / chrome / browser / Tab.java
index b3bb1b7..33f1b73 100644 (file)
@@ -21,7 +21,7 @@ import org.chromium.chrome.browser.contextmenu.ContextMenuParams;
 import org.chromium.chrome.browser.contextmenu.ContextMenuPopulator;
 import org.chromium.chrome.browser.contextmenu.ContextMenuPopulatorWrapper;
 import org.chromium.chrome.browser.contextmenu.EmptyChromeContextMenuItemDelegate;
-import org.chromium.chrome.browser.dom_distiller.FeedbackReporter;
+import org.chromium.chrome.browser.dom_distiller.DomDistillerFeedbackReporter;
 import org.chromium.chrome.browser.infobar.AutoLoginProcessor;
 import org.chromium.chrome.browser.infobar.InfoBarContainer;
 import org.chromium.chrome.browser.profiles.Profile;
@@ -32,7 +32,6 @@ import org.chromium.content.browser.ContentViewCore;
 import org.chromium.content.browser.LoadUrlParams;
 import org.chromium.content.browser.NavigationClient;
 import org.chromium.content.browser.NavigationHistory;
-import org.chromium.content.browser.PageInfo;
 import org.chromium.content.browser.WebContentsObserverAndroid;
 import org.chromium.content_public.browser.WebContents;
 import org.chromium.ui.base.Clipboard;
@@ -129,7 +128,7 @@ public class Tab implements NavigationClient {
     private WebContentsObserverAndroid mWebContentsObserver;
     private VoiceSearchTabHelper mVoiceSearchTabHelper;
     private TabChromeWebContentsDelegateAndroid mWebContentsDelegate;
-    private FeedbackReporter mFeedbackReporter;
+    private DomDistillerFeedbackReporter mDomDistillerFeedbackReporter;
 
     /**
      * If this tab was opened from another tab, store the id of the tab that
@@ -143,6 +142,8 @@ public class Tab implements NavigationClient {
      */
     private boolean mGroupedWithParent = true;
 
+    private boolean mIsClosing = false;
+
     /**
      * A default {@link ChromeContextMenuItemDelegate} that supports some of the context menu
      * functionality.
@@ -451,8 +452,7 @@ public class Tab implements NavigationClient {
      *         be {@code null}, if the tab is frozen or being initialized or destroyed.
      */
     public View getView() {
-        PageInfo pageInfo = getPageInfo();
-        return pageInfo != null ? pageInfo.getView() : null;
+        return mNativePage != null ? mNativePage.getView() : mContentView;
     }
 
     /**
@@ -509,7 +509,7 @@ public class Tab implements NavigationClient {
     }
 
     /**
-     * Reloads the current page content if it is a {@link ContentView}.
+     * Reloads the current page content.
      */
     public void reload() {
         // TODO(dtrainor): Should we try to rebuild the ContentView if it's frozen?
@@ -517,7 +517,7 @@ public class Tab implements NavigationClient {
     }
 
     /**
-     * Reloads the current page content if it is a {@link ContentView}.
+     * Reloads the current page content.
      * This version ignores the cache and reloads from the network.
      */
     public void reloadIgnoringCache() {
@@ -533,7 +533,9 @@ public class Tab implements NavigationClient {
      * @return The background color of the tab.
      */
     public int getBackgroundColor() {
-        return getPageInfo() != null ? getPageInfo().getBackgroundColor() : Color.WHITE;
+        if (mNativePage != null) return mNativePage.getBackgroundColor();
+        if (mContentViewCore != null) return mContentViewCore.getBackgroundColor();
+        return Color.WHITE;
     }
 
     /**
@@ -588,14 +590,6 @@ public class Tab implements NavigationClient {
     }
 
     /**
-     * @return A {@link PageInfo} describing the current page.  This is always not {@code null}
-     *         except during initialization, destruction, and when the tab is frozen.
-     */
-    public PageInfo getPageInfo() {
-        return mNativePage != null ? mNativePage : mContentView;
-    }
-
-    /**
      * @return The {@link NativePage} associated with the current page, or {@code null} if there is
      *         no current page or the current page is displayed using something besides
      *         {@link NativePage}.
@@ -766,7 +760,7 @@ public class Tab implements NavigationClient {
 
     /**
      * Completes the {@link ContentView} specific initialization around a native WebContents
-     * pointer.  {@link #getPageInfo()} will still return the {@link NativePage} if there is one.
+     * pointer. {@link #getNativePage()} will still return the {@link NativePage} if there is one.
      * All initialization that needs to reoccur after a web contents swap should be added here.
      * <p />
      * NOTE: If you attempt to pass a native WebContents that does not have the same incognito
@@ -810,8 +804,8 @@ public class Tab implements NavigationClient {
             mAppBannerManager = new AppBannerManager(this);
         }
 
-        if (FeedbackReporter.isEnabled() && mFeedbackReporter == null) {
-            mFeedbackReporter = new FeedbackReporter(this);
+        if (DomDistillerFeedbackReporter.isEnabled() && mDomDistillerFeedbackReporter == null) {
+            mDomDistillerFeedbackReporter = new DomDistillerFeedbackReporter(this);
         }
 
         for (TabObserver observer : mObservers) observer.onContentChanged(this);
@@ -858,7 +852,7 @@ public class Tab implements NavigationClient {
      */
     @CalledByNative
     public String getUrl() {
-        return mContentView != null ? mContentView.getUrl() : "";
+        return mContentViewCore != null ? mContentViewCore.getUrl() : "";
     }
 
     /**
@@ -866,7 +860,9 @@ public class Tab implements NavigationClient {
      */
     @CalledByNative
     public String getTitle() {
-        return getPageInfo() != null ? getPageInfo().getTitle() : "";
+        if (mNativePage != null) return mNativePage.getTitle();
+        if (mContentViewCore != null) return mContentViewCore.getTitle();
+        return "";
     }
 
     /**
@@ -879,15 +875,29 @@ public class Tab implements NavigationClient {
     }
 
     /**
-     * Restores the tab if it is frozen or crashed.
-     * @return true iff tab restore was triggered.
+     * Loads the tab if it's not loaded (e.g. because it was killed in background).
+     * @return true iff tab load was triggered
      */
     @CalledByNative
-    public boolean restoreIfNeeded() {
+    public boolean loadIfNeeded() {
         return false;
     }
 
     /**
+     * @return Whether or not the tab is in the closing process.
+     */
+    public boolean isClosing() {
+        return mIsClosing;
+    }
+
+    /**
+     * @param closing Whether or not the tab is in the closing process.
+     */
+    public void setClosing(boolean closing) {
+        mIsClosing = closing;
+    }
+
+    /**
      * @return The id of the tab that caused this tab to be opened.
      */
     public int getParentId() {
@@ -913,7 +923,7 @@ public class Tab implements NavigationClient {
 
     private void destroyNativePageInternal(NativePage nativePage) {
         if (nativePage == null) return;
-        assert getPageInfo() != nativePage : "Attempting to destroy active page.";
+        assert nativePage != mNativePage : "Attempting to destroy active page.";
 
         nativePage.destroy();
     }