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 13 matching lines...) Expand all Loading... |
24 #include "chrome/browser/search/search.h" | 24 #include "chrome/browser/search/search.h" |
25 #include "chrome/browser/sessions/session_tab_helper.h" | 25 #include "chrome/browser/sessions/session_tab_helper.h" |
26 #include "chrome/browser/sync/glue/synced_tab_delegate_android.h" | 26 #include "chrome/browser/sync/glue/synced_tab_delegate_android.h" |
27 #include "chrome/browser/ui/android/content_settings/popup_blocked_infobar_deleg
ate.h" | 27 #include "chrome/browser/ui/android/content_settings/popup_blocked_infobar_deleg
ate.h" |
28 #include "chrome/browser/ui/android/context_menu_helper.h" | 28 #include "chrome/browser/ui/android/context_menu_helper.h" |
29 #include "chrome/browser/ui/android/infobars/infobar_container_android.h" | 29 #include "chrome/browser/ui/android/infobars/infobar_container_android.h" |
30 #include "chrome/browser/ui/android/tab_model/tab_model.h" | 30 #include "chrome/browser/ui/android/tab_model/tab_model.h" |
31 #include "chrome/browser/ui/android/tab_model/tab_model_list.h" | 31 #include "chrome/browser/ui/android/tab_model/tab_model_list.h" |
32 #include "chrome/browser/ui/android/window_android_helper.h" | 32 #include "chrome/browser/ui/android/window_android_helper.h" |
33 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" | 33 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" |
| 34 #include "chrome/browser/ui/search/instant_search_prerenderer.h" |
34 #include "chrome/browser/ui/search/search_tab_helper.h" | 35 #include "chrome/browser/ui/search/search_tab_helper.h" |
35 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 36 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
36 #include "chrome/browser/ui/tab_helpers.h" | 37 #include "chrome/browser/ui/tab_helpers.h" |
37 #include "chrome/browser/ui/toolbar/toolbar_model_impl.h" | 38 #include "chrome/browser/ui/toolbar/toolbar_model_impl.h" |
38 #include "chrome/common/url_constants.h" | 39 #include "chrome/common/url_constants.h" |
39 #include "components/google/core/browser/google_url_tracker.h" | 40 #include "components/google/core/browser/google_url_tracker.h" |
40 #include "components/infobars/core/infobar_container.h" | 41 #include "components/infobars/core/infobar_container.h" |
41 #include "components/url_fixer/url_fixer.h" | 42 #include "components/url_fixer/url_fixer.h" |
42 #include "content/public/browser/android/content_view_core.h" | 43 #include "content/public/browser/android/content_view_core.h" |
43 #include "content/public/browser/navigation_entry.h" | 44 #include "content/public/browser/navigation_entry.h" |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 | 389 |
389 // If the page was prerendered, use it. | 390 // If the page was prerendered, use it. |
390 // Note in incognito mode, we don't have a PrerenderManager. | 391 // Note in incognito mode, we don't have a PrerenderManager. |
391 | 392 |
392 prerender::PrerenderManager* prerender_manager = | 393 prerender::PrerenderManager* prerender_manager = |
393 prerender::PrerenderManagerFactory::GetForProfile(GetProfile()); | 394 prerender::PrerenderManagerFactory::GetForProfile(GetProfile()); |
394 if (prerender_manager) { | 395 if (prerender_manager) { |
395 bool prefetched_page_loaded = HasPrerenderedUrl(gurl); | 396 bool prefetched_page_loaded = HasPrerenderedUrl(gurl); |
396 // Getting the load status before MaybeUsePrerenderedPage() b/c it resets. | 397 // Getting the load status before MaybeUsePrerenderedPage() b/c it resets. |
397 chrome::NavigateParams params(NULL, web_contents()); | 398 chrome::NavigateParams params(NULL, web_contents()); |
| 399 InstantSearchPrerenderer* prerenderer = |
| 400 InstantSearchPrerenderer::GetForProfile(GetProfile()); |
| 401 if (prerenderer) { |
| 402 const base::string16& search_terms = |
| 403 chrome::ExtractSearchTermsFromURL(GetProfile(), gurl); |
| 404 if (!search_terms.empty() && |
| 405 prerenderer->CanCommitQuery(web_contents_.get(), search_terms)) { |
| 406 prerenderer->Commit(search_terms); |
| 407 |
| 408 if (prerenderer->UsePrerenderedPage(gurl, ¶ms)) |
| 409 return FULL_PRERENDERED_PAGE_LOAD; |
| 410 } |
| 411 prerenderer->Cancel(); |
| 412 } |
398 if (prerender_manager->MaybeUsePrerenderedPage(gurl, ¶ms)) { | 413 if (prerender_manager->MaybeUsePrerenderedPage(gurl, ¶ms)) { |
399 return prefetched_page_loaded ? | 414 return prefetched_page_loaded ? |
400 FULL_PRERENDERED_PAGE_LOAD : PARTIAL_PRERENDERED_PAGE_LOAD; | 415 FULL_PRERENDERED_PAGE_LOAD : PARTIAL_PRERENDERED_PAGE_LOAD; |
401 } | 416 } |
402 } | 417 } |
403 | 418 |
404 GURL fixed_url( | 419 GURL fixed_url( |
405 url_fixer::FixupURL(gurl.possibly_invalid_spec(), std::string())); | 420 url_fixer::FixupURL(gurl.possibly_invalid_spec(), std::string())); |
406 if (!fixed_url.is_valid()) | 421 if (!fixed_url.is_valid()) |
407 return PAGE_LOAD_FAILED; | 422 return PAGE_LOAD_FAILED; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 | 526 |
512 static void Init(JNIEnv* env, jobject obj) { | 527 static void Init(JNIEnv* env, jobject obj) { |
513 TRACE_EVENT0("native", "TabAndroid::Init"); | 528 TRACE_EVENT0("native", "TabAndroid::Init"); |
514 // This will automatically bind to the Java object and pass ownership there. | 529 // This will automatically bind to the Java object and pass ownership there. |
515 new TabAndroid(env, obj); | 530 new TabAndroid(env, obj); |
516 } | 531 } |
517 | 532 |
518 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { | 533 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { |
519 return RegisterNativesImpl(env); | 534 return RegisterNativesImpl(env); |
520 } | 535 } |
OLD | NEW |