diff options
author | nya@google.com <nya@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-30 08:47:41 +0000 |
---|---|---|
committer | nya@google.com <nya@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-30 08:47:41 +0000 |
commit | 9aa1f62801cc082dba4d0c3e8d4ed8dc2759418d (patch) | |
tree | 0442655a7fcbdff7ced85d58952f02e978f843a2 | |
parent | d9f0f28f86d6f8affe714469a84958c5f25ef1bd (diff) | |
download | chromium_src-9aa1f62801cc082dba4d0c3e8d4ed8dc2759418d.zip chromium_src-9aa1f62801cc082dba4d0c3e8d4ed8dc2759418d.tar.gz chromium_src-9aa1f62801cc082dba4d0c3e8d4ed8dc2759418d.tar.bz2 |
Pass rendering state on swapping in a prerendered page.
Android Chrome needs to learn whether or not WebContentsObserver::DidFinishLoad() has been called on the prerendered WebContents during the call to CoreTabHelperDelegate::SwapTabContents() here:
https://code.google.com/p/chromium/codesearch#chromium/src/chrome/browser/prerender/prerender_manager.cc&l=634&q=prerendermanager&type=cs&sq=package:chromium
BUG=335479
Review URL: https://codereview.chromium.org/143463012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247902 0039d316-1c4b-4281-b951-d872f2087c98
11 files changed, 38 insertions, 13 deletions
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/EmptyTabObserver.java b/chrome/android/java/src/org/chromium/chrome/browser/EmptyTabObserver.java index 214616c..24c7d6a 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/EmptyTabObserver.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/EmptyTabObserver.java @@ -27,7 +27,7 @@ public class EmptyTabObserver implements TabObserver { public void onUrlUpdated(TabBase tab) { } @Override - public void onWebContentsSwapped(TabBase tab) { } + public void onWebContentsSwapped(TabBase tab, boolean didStartLoad, boolean didFinishLoad) { } @Override public void onContextMenuShown(TabBase tab, ContextMenu menu) { } diff --git a/chrome/android/java/src/org/chromium/chrome/browser/TabBase.java b/chrome/android/java/src/org/chromium/chrome/browser/TabBase.java index ef424bf..af617c8 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/TabBase.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/TabBase.java @@ -830,7 +830,8 @@ public abstract class TabBase implements NavigationClient { /** This is currently called when committing a pre-rendered page. */ @CalledByNative - private void swapWebContents(final long newWebContents) { + private void swapWebContents( + final long newWebContents, boolean didStartLoad, boolean didFinishLoad) { if (mContentViewCore != null) mContentViewCore.onHide(); destroyContentView(false); NativePage previousNativePage = mNativePage; @@ -840,7 +841,9 @@ public abstract class TabBase implements NavigationClient { mContentViewCore.attachImeAdapter(); for (TabObserver observer : mObservers) observer.onContentChanged(this); destroyNativePageInternal(previousNativePage); - for (TabObserver observer : mObservers) observer.onWebContentsSwapped(this); + for (TabObserver observer : mObservers) { + observer.onWebContentsSwapped(this, didStartLoad, didFinishLoad); + } } @CalledByNative diff --git a/chrome/android/java/src/org/chromium/chrome/browser/TabObserver.java b/chrome/android/java/src/org/chromium/chrome/browser/TabObserver.java index 059b897..189c9d7 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/TabObserver.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/TabObserver.java @@ -46,8 +46,11 @@ public interface TabObserver { /** * Called when the WebContents of a {@link TabBase} have been swapped. * @param tab The notifying {@link TabBase}. + * @param didStartLoad Whether WebContentsObserver::DidStartProvisionalLoadForFrame() has + * already been called. + * @param didFinishLoad Whether WebContentsObserver::DidFinishLoad() has already been called. */ - void onWebContentsSwapped(TabBase tab); + void onWebContentsSwapped(TabBase tab, boolean didStartLoad, boolean didFinishLoad); /** * Called when a context menu is shown for a {@link ContentView} owned by a {@link TabBase}. diff --git a/chrome/browser/android/tab_android.cc b/chrome/browser/android/tab_android.cc index 73e61c0..3f622b1 100644 --- a/chrome/browser/android/tab_android.cc +++ b/chrome/browser/android/tab_android.cc @@ -258,7 +258,9 @@ bool TabAndroid::ShouldWelcomePageLinkToTermsOfService() { } void TabAndroid::SwapTabContents(content::WebContents* old_contents, - content::WebContents* new_contents) { + content::WebContents* new_contents, + bool did_start_load, + bool did_finish_load) { JNIEnv* env = base::android::AttachCurrentThread(); // We need to notify the native InfobarContainer so infobars can be swapped. @@ -274,7 +276,9 @@ void TabAndroid::SwapTabContents(content::WebContents* old_contents, Java_TabBase_swapWebContents( env, weak_java_tab_.get(env).obj(), - reinterpret_cast<intptr_t>(new_contents)); + reinterpret_cast<intptr_t>(new_contents), + did_start_load, + did_finish_load); } void TabAndroid::Observe(int type, diff --git a/chrome/browser/android/tab_android.h b/chrome/browser/android/tab_android.h index c1ba762..ef445ad 100644 --- a/chrome/browser/android/tab_android.h +++ b/chrome/browser/android/tab_android.h @@ -112,7 +112,9 @@ class TabAndroid : public CoreTabHelperDelegate, // CoreTabHelperDelegate ---------------------------------------------------- virtual void SwapTabContents(content::WebContents* old_contents, - content::WebContents* new_contents) OVERRIDE; + content::WebContents* new_contents, + bool did_start_load, + bool did_finish_load) OVERRIDE; // NotificationObserver ----------------------------------------------------- virtual void Observe(int type, diff --git a/chrome/browser/prerender/prerender_manager.cc b/chrome/browser/prerender/prerender_manager.cc index 7c7e27d..81c5e94 100644 --- a/chrome/browser/prerender/prerender_manager.cc +++ b/chrome/browser/prerender/prerender_manager.cc @@ -633,7 +633,10 @@ WebContents* PrerenderManager::SwapInternal( &old_web_contents->GetController(), should_replace_current_entry); CoreTabHelper::FromWebContents(old_web_contents)->delegate()-> - SwapTabContents(old_web_contents, new_web_contents); + SwapTabContents(old_web_contents, + new_web_contents, + true, + prerender_contents->has_finished_loading()); prerender_contents->CommitHistory(new_web_contents); GURL icon_url = prerender_contents->icon_url(); diff --git a/chrome/browser/sessions/session_restore_android.cc b/chrome/browser/sessions/session_restore_android.cc index 95e772c..43d1bde 100644 --- a/chrome/browser/sessions/session_restore_android.cc +++ b/chrome/browser/sessions/session_restore_android.cc @@ -42,7 +42,7 @@ content::WebContents* SessionRestore::RestoreForeignSessionTab( TabAndroid* current_tab = TabAndroid::FromWebContents(web_contents); DCHECK(current_tab); if (disposition == CURRENT_TAB) { - current_tab->SwapTabContents(web_contents, new_web_contents); + current_tab->SwapTabContents(web_contents, new_web_contents, false, false); delete web_contents; } else { DCHECK(disposition == NEW_FOREGROUND_TAB || diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index b21cca2..f24744a 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -1705,7 +1705,9 @@ gfx::Size Browser::GetSizeForNewRenderView( // Browser, CoreTabHelperDelegate implementation: void Browser::SwapTabContents(content::WebContents* old_contents, - content::WebContents* new_contents) { + content::WebContents* new_contents, + bool did_start_load, + bool did_finish_load) { int index = tab_strip_model_->GetIndexOfWebContents(old_contents); DCHECK_NE(TabStripModel::kNoTab, index); tab_strip_model_->ReplaceWebContentsAt(index, new_contents); diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h index 777dcad..bcfe5b2 100644 --- a/chrome/browser/ui/browser.h +++ b/chrome/browser/ui/browser.h @@ -648,7 +648,9 @@ class Browser : public TabStripModelObserver, // Overridden from CoreTabHelperDelegate: // Note that the caller is responsible for deleting |old_contents|. virtual void SwapTabContents(content::WebContents* old_contents, - content::WebContents* new_contents) OVERRIDE; + content::WebContents* new_contents, + bool did_start_load, + bool did_finish_load) OVERRIDE; virtual bool CanReloadContents( content::WebContents* web_contents) const OVERRIDE; virtual bool CanSaveContents( diff --git a/chrome/browser/ui/tab_contents/core_tab_helper_delegate.cc b/chrome/browser/ui/tab_contents/core_tab_helper_delegate.cc index 0aca9f5..7428293 100644 --- a/chrome/browser/ui/tab_contents/core_tab_helper_delegate.cc +++ b/chrome/browser/ui/tab_contents/core_tab_helper_delegate.cc @@ -9,7 +9,9 @@ CoreTabHelperDelegate::~CoreTabHelperDelegate() { void CoreTabHelperDelegate::SwapTabContents( content::WebContents* old_contents, - content::WebContents* new_contents) { + content::WebContents* new_contents, + bool did_start_load, + bool did_finish_load) { } bool CoreTabHelperDelegate::CanReloadContents( diff --git a/chrome/browser/ui/tab_contents/core_tab_helper_delegate.h b/chrome/browser/ui/tab_contents/core_tab_helper_delegate.h index e06abb2..3f9907d 100644 --- a/chrome/browser/ui/tab_contents/core_tab_helper_delegate.h +++ b/chrome/browser/ui/tab_contents/core_tab_helper_delegate.h @@ -20,8 +20,12 @@ class WebContents; class CoreTabHelperDelegate { public: // The caller is responsible for deleting |old_contents|. + // |did_finish_load| is true if WebContentsObserver::DidFinishLoad() has + // already been called for |new_contents|. virtual void SwapTabContents(content::WebContents* old_contents, - content::WebContents* new_contents); + content::WebContents* new_contents, + bool did_start_load, + bool did_finish_load); // Whether the specified WebContents can be reloaded. // Reloading can be disabled e.g. for the DevTools window. |