Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1759)

Unified Diff: chrome/browser/android/tab_android.cc

Issue 426623004: While loading url in current tab should check if any prerender page avaliable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comments Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/tab_android.cc
diff --git a/chrome/browser/android/tab_android.cc b/chrome/browser/android/tab_android.cc
index f175c0f92587ebb466db9a01ec39c4323ecce6c8..1f10584e2c1f7c4cef3174076a0aff0257e6fc9b 100644
--- a/chrome/browser/android/tab_android.cc
+++ b/chrome/browser/android/tab_android.cc
@@ -79,6 +79,17 @@ WebContents* CreateTargetContents(const chrome::NavigateParams& params,
return target_contents;
}
+bool MaybeSwapWithPrerender(const GURL& url, chrome::NavigateParams* params) {
+ Profile* profile =
+ Profile::FromBrowserContext(params->target_contents->GetBrowserContext());
+
+ prerender::PrerenderManager* prerender_manager =
+ prerender::PrerenderManagerFactory::GetForProfile(profile);
+ if (!prerender_manager)
+ return false;
+ return prerender_manager->MaybeUsePrerenderedPage(url, params);
+}
+
} // namespace
TabAndroid* TabAndroid::FromWebContents(content::WebContents* web_contents) {
@@ -187,12 +198,18 @@ void TabAndroid::HandlePopupNavigation(chrome::NavigateParams* params) {
if (!params->url.is_empty()) {
bool was_blocked = false;
GURL url(params->url);
- NavigationController::LoadURLParams load_url_params(url);
- MakeLoadURLParams(params, &load_url_params);
if (params->disposition == CURRENT_TAB) {
- web_contents_.get()->GetController().LoadURLWithParams(load_url_params);
+ params->target_contents = web_contents_.get();
+ if (!MaybeSwapWithPrerender(url, params)) {
+ NavigationController::LoadURLParams load_url_params(url);
+ MakeLoadURLParams(params, &load_url_params);
+ params->target_contents->GetController().LoadURLWithParams(
+ load_url_params);
+ }
} else {
params->target_contents = CreateTargetContents(*params, url);
+ NavigationController::LoadURLParams load_url_params(url);
+ MakeLoadURLParams(params, &load_url_params);
params->target_contents->GetController().LoadURLWithParams(
load_url_params);
web_contents_delegate_->AddNewContents(params->source_contents,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698