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 SwapWithPrerender(const GURL& url, chrome::NavigateParams* params) { | |
Bernhard Bauer
2014/07/28 15:00:05
MaybeSwapWithPrerender()?
Jitu( very slow this week)
2014/07/30 13:48:28
using only this function MaybeSwapWithPrerender()
Bernhard Bauer
2014/07/30 14:19:46
What I was suggesting was to name this method Mayb
| |
83 Profile* profile = | |
84 Profile::FromBrowserContext(params->target_contents->GetBrowserContext()); | |
85 InstantSearchPrerenderer* prerenderer = | |
86 InstantSearchPrerenderer::GetForProfile(profile); | |
87 if (prerenderer && prerenderer->UsePrerenderedPage(url, params)) | |
Bernhard Bauer
2014/07/28 15:00:05
When is |prerenderer| false?
Jitu( very slow this week)
2014/07/30 13:48:27
Removed this as not required.
Thanks.
| |
88 return true; | |
89 | |
90 prerender::PrerenderManager* prerender_manager = | |
91 prerender::PrerenderManagerFactory::GetForProfile(profile); | |
92 return prerender_manager && | |
Bernhard Bauer
2014/07/28 15:00:05
When is |prerender_manager| false?
Jitu( very slow this week)
2014/07/30 13:48:28
Changed.
Thanks
Bernhard Bauer
2014/07/30 14:19:46
If |prerender_manager| can be NULL, the original c
| |
93 prerender_manager->MaybeUsePrerenderedPage(url, params); | |
94 } | |
95 | |
82 } // namespace | 96 } // namespace |
83 | 97 |
84 TabAndroid* TabAndroid::FromWebContents(content::WebContents* web_contents) { | 98 TabAndroid* TabAndroid::FromWebContents(content::WebContents* web_contents) { |
85 CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(web_contents); | 99 CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(web_contents); |
86 if (!core_tab_helper) | 100 if (!core_tab_helper) |
87 return NULL; | 101 return NULL; |
88 | 102 |
89 CoreTabHelperDelegate* core_delegate = core_tab_helper->delegate(); | 103 CoreTabHelperDelegate* core_delegate = core_tab_helper->delegate(); |
90 if (!core_delegate) | 104 if (!core_delegate) |
91 return NULL; | 105 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); | 194 Java_Tab_setSyncId(env, weak_java_tab_.get(env).obj(), sync_id); |
181 } | 195 } |
182 | 196 |
183 void TabAndroid::HandlePopupNavigation(chrome::NavigateParams* params) { | 197 void TabAndroid::HandlePopupNavigation(chrome::NavigateParams* params) { |
184 if (params->disposition != SUPPRESS_OPEN && | 198 if (params->disposition != SUPPRESS_OPEN && |
185 params->disposition != SAVE_TO_DISK && | 199 params->disposition != SAVE_TO_DISK && |
186 params->disposition != IGNORE_ACTION) { | 200 params->disposition != IGNORE_ACTION) { |
187 if (!params->url.is_empty()) { | 201 if (!params->url.is_empty()) { |
188 bool was_blocked = false; | 202 bool was_blocked = false; |
189 GURL url(params->url); | 203 GURL url(params->url); |
190 NavigationController::LoadURLParams load_url_params(url); | |
191 MakeLoadURLParams(params, &load_url_params); | |
192 if (params->disposition == CURRENT_TAB) { | 204 if (params->disposition == CURRENT_TAB) { |
193 web_contents_.get()->GetController().LoadURLWithParams(load_url_params); | 205 bool swapped_with_prerender = false; |
206 params->target_contents = web_contents_.get(); | |
207 swapped_with_prerender = SwapWithPrerender(url, params); | |
208 if (!swapped_with_prerender) { | |
Bernhard Bauer
2014/07/28 15:00:05
You can inline this check.
Jitu( very slow this week)
2014/07/30 13:48:28
Done.
Thanks
| |
209 NavigationController::LoadURLParams load_url_params(url); | |
210 MakeLoadURLParams(params, &load_url_params); | |
211 params->target_contents->GetController().LoadURLWithParams( | |
212 load_url_params); | |
213 } | |
194 } else { | 214 } else { |
195 params->target_contents = CreateTargetContents(*params, url); | 215 params->target_contents = CreateTargetContents(*params, url); |
216 NavigationController::LoadURLParams load_url_params(url); | |
217 MakeLoadURLParams(params, &load_url_params); | |
196 params->target_contents->GetController().LoadURLWithParams( | 218 params->target_contents->GetController().LoadURLWithParams( |
197 load_url_params); | 219 load_url_params); |
198 web_contents_delegate_->AddNewContents(params->source_contents, | 220 web_contents_delegate_->AddNewContents(params->source_contents, |
199 params->target_contents, | 221 params->target_contents, |
200 params->disposition, | 222 params->disposition, |
201 params->window_bounds, | 223 params->window_bounds, |
202 params->user_gesture, | 224 params->user_gesture, |
203 &was_blocked); | 225 &was_blocked); |
204 if (was_blocked) | 226 if (was_blocked) |
205 params->target_contents = NULL; | 227 params->target_contents = NULL; |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
581 | 603 |
582 static void Init(JNIEnv* env, jobject obj) { | 604 static void Init(JNIEnv* env, jobject obj) { |
583 TRACE_EVENT0("native", "TabAndroid::Init"); | 605 TRACE_EVENT0("native", "TabAndroid::Init"); |
584 // This will automatically bind to the Java object and pass ownership there. | 606 // This will automatically bind to the Java object and pass ownership there. |
585 new TabAndroid(env, obj); | 607 new TabAndroid(env, obj); |
586 } | 608 } |
587 | 609 |
588 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { | 610 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { |
589 return RegisterNativesImpl(env); | 611 return RegisterNativesImpl(env); |
590 } | 612 } |
OLD | NEW |