Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/android/tab_android.h" | 5 #include "chrome/browser/android/tab_android.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 create_params.opener = params.source_contents; | 72 create_params.opener = params.source_contents; |
| 73 } | 73 } |
| 74 if (params.disposition == NEW_BACKGROUND_TAB) | 74 if (params.disposition == NEW_BACKGROUND_TAB) |
| 75 create_params.initially_hidden = true; | 75 create_params.initially_hidden = true; |
| 76 | 76 |
| 77 WebContents* target_contents = WebContents::Create(create_params); | 77 WebContents* target_contents = WebContents::Create(create_params); |
| 78 | 78 |
| 79 return target_contents; | 79 return target_contents; |
| 80 } | 80 } |
| 81 | 81 |
| 82 bool MaybeSwapWithPrerender(const GURL& url, chrome::NavigateParams* params) { | |
| 83 Profile* profile = | |
| 84 Profile::FromBrowserContext(params->target_contents->GetBrowserContext()); | |
| 85 | |
| 86 prerender::PrerenderManager* prerender_manager = | |
| 87 prerender::PrerenderManagerFactory::GetForProfile(profile); | |
| 88 if (!prerender_manager) { | |
| 89 return false; | |
| 90 } else { | |
|
Bernhard Bauer
2014/07/31 08:11:00
Don't put an "else" after a branch that ends with
Jitu( very slow this week)
2014/07/31 08:19:47
Done.
| |
| 91 return prerender_manager->MaybeUsePrerenderedPage(url, params); | |
| 92 } | |
| 93 } | |
| 94 | |
| 82 } // namespace | 95 } // namespace |
| 83 | 96 |
| 84 TabAndroid* TabAndroid::FromWebContents(content::WebContents* web_contents) { | 97 TabAndroid* TabAndroid::FromWebContents(content::WebContents* web_contents) { |
| 85 CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(web_contents); | 98 CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(web_contents); |
| 86 if (!core_tab_helper) | 99 if (!core_tab_helper) |
| 87 return NULL; | 100 return NULL; |
| 88 | 101 |
| 89 CoreTabHelperDelegate* core_delegate = core_tab_helper->delegate(); | 102 CoreTabHelperDelegate* core_delegate = core_tab_helper->delegate(); |
| 90 if (!core_delegate) | 103 if (!core_delegate) |
| 91 return NULL; | 104 return NULL; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 180 Java_Tab_setSyncId(env, weak_java_tab_.get(env).obj(), sync_id); | 193 Java_Tab_setSyncId(env, weak_java_tab_.get(env).obj(), sync_id); |
| 181 } | 194 } |
| 182 | 195 |
| 183 void TabAndroid::HandlePopupNavigation(chrome::NavigateParams* params) { | 196 void TabAndroid::HandlePopupNavigation(chrome::NavigateParams* params) { |
| 184 if (params->disposition != SUPPRESS_OPEN && | 197 if (params->disposition != SUPPRESS_OPEN && |
| 185 params->disposition != SAVE_TO_DISK && | 198 params->disposition != SAVE_TO_DISK && |
| 186 params->disposition != IGNORE_ACTION) { | 199 params->disposition != IGNORE_ACTION) { |
| 187 if (!params->url.is_empty()) { | 200 if (!params->url.is_empty()) { |
| 188 bool was_blocked = false; | 201 bool was_blocked = false; |
| 189 GURL url(params->url); | 202 GURL url(params->url); |
| 190 NavigationController::LoadURLParams load_url_params(url); | |
| 191 MakeLoadURLParams(params, &load_url_params); | |
| 192 if (params->disposition == CURRENT_TAB) { | 203 if (params->disposition == CURRENT_TAB) { |
| 193 web_contents_.get()->GetController().LoadURLWithParams(load_url_params); | 204 params->target_contents = web_contents_.get(); |
| 205 if (!MaybeSwapWithPrerender(url, params)) { | |
| 206 NavigationController::LoadURLParams load_url_params(url); | |
| 207 MakeLoadURLParams(params, &load_url_params); | |
| 208 params->target_contents->GetController().LoadURLWithParams( | |
| 209 load_url_params); | |
| 210 } | |
| 194 } else { | 211 } else { |
| 195 params->target_contents = CreateTargetContents(*params, url); | 212 params->target_contents = CreateTargetContents(*params, url); |
| 213 NavigationController::LoadURLParams load_url_params(url); | |
| 214 MakeLoadURLParams(params, &load_url_params); | |
| 196 params->target_contents->GetController().LoadURLWithParams( | 215 params->target_contents->GetController().LoadURLWithParams( |
| 197 load_url_params); | 216 load_url_params); |
| 198 web_contents_delegate_->AddNewContents(params->source_contents, | 217 web_contents_delegate_->AddNewContents(params->source_contents, |
| 199 params->target_contents, | 218 params->target_contents, |
| 200 params->disposition, | 219 params->disposition, |
| 201 params->window_bounds, | 220 params->window_bounds, |
| 202 params->user_gesture, | 221 params->user_gesture, |
| 203 &was_blocked); | 222 &was_blocked); |
| 204 if (was_blocked) | 223 if (was_blocked) |
| 205 params->target_contents = NULL; | 224 params->target_contents = NULL; |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 581 | 600 |
| 582 static void Init(JNIEnv* env, jobject obj) { | 601 static void Init(JNIEnv* env, jobject obj) { |
| 583 TRACE_EVENT0("native", "TabAndroid::Init"); | 602 TRACE_EVENT0("native", "TabAndroid::Init"); |
| 584 // This will automatically bind to the Java object and pass ownership there. | 603 // This will automatically bind to the Java object and pass ownership there. |
| 585 new TabAndroid(env, obj); | 604 new TabAndroid(env, obj); |
| 586 } | 605 } |
| 587 | 606 |
| 588 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { | 607 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { |
| 589 return RegisterNativesImpl(env); | 608 return RegisterNativesImpl(env); |
| 590 } | 609 } |
| OLD | NEW |