OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
13 #include "base/trace_event/trace_event.h" | 13 #include "base/trace_event/trace_event.h" |
| 14 #include "blimp/client/public/blimp_client_context.h" |
| 15 #include "blimp/client/public/contents/blimp_contents.h" |
| 16 #include "blimp/client/public/contents/blimp_navigation_controller.h" |
14 #include "cc/layers/layer.h" | 17 #include "cc/layers/layer.h" |
| 18 #include "chrome/browser/android/blimp/blimp_client_context_factory.h" |
15 #include "chrome/browser/android/compositor/tab_content_manager.h" | 19 #include "chrome/browser/android/compositor/tab_content_manager.h" |
16 #include "chrome/browser/android/metrics/uma_utils.h" | 20 #include "chrome/browser/android/metrics/uma_utils.h" |
17 #include "chrome/browser/android/offline_pages/offline_page_bridge.h" | 21 #include "chrome/browser/android/offline_pages/offline_page_bridge.h" |
18 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" | 22 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" |
19 #include "chrome/browser/android/offline_pages/offline_page_utils.h" | 23 #include "chrome/browser/android/offline_pages/offline_page_utils.h" |
20 #include "chrome/browser/android/tab_web_contents_delegate_android.h" | 24 #include "chrome/browser/android/tab_web_contents_delegate_android.h" |
21 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 25 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
22 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h" | 26 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h" |
23 #include "chrome/browser/browser_about_handler.h" | 27 #include "chrome/browser/browser_about_handler.h" |
24 #include "chrome/browser/chrome_notification_types.h" | 28 #include "chrome/browser/chrome_notification_types.h" |
25 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 29 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
26 #include "chrome/browser/infobars/infobar_service.h" | 30 #include "chrome/browser/infobars/infobar_service.h" |
27 #include "chrome/browser/prerender/prerender_contents.h" | 31 #include "chrome/browser/prerender/prerender_contents.h" |
28 #include "chrome/browser/prerender/prerender_manager.h" | 32 #include "chrome/browser/prerender/prerender_manager.h" |
29 #include "chrome/browser/prerender/prerender_manager_factory.h" | 33 #include "chrome/browser/prerender/prerender_manager_factory.h" |
30 #include "chrome/browser/printing/print_view_manager_basic.h" | 34 #include "chrome/browser/printing/print_view_manager_basic.h" |
31 #include "chrome/browser/profiles/profile.h" | 35 #include "chrome/browser/profiles/profile.h" |
32 #include "chrome/browser/profiles/profile_android.h" | 36 #include "chrome/browser/profiles/profile_android.h" |
| 37 #include "chrome/browser/profiles/profile_manager.h" |
33 #include "chrome/browser/search/instant_service.h" | 38 #include "chrome/browser/search/instant_service.h" |
34 #include "chrome/browser/search/instant_service_factory.h" | 39 #include "chrome/browser/search/instant_service_factory.h" |
35 #include "chrome/browser/search/search.h" | 40 #include "chrome/browser/search/search.h" |
36 #include "chrome/browser/sessions/session_tab_helper.h" | 41 #include "chrome/browser/sessions/session_tab_helper.h" |
37 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 42 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
38 #include "chrome/browser/sync/glue/synced_tab_delegate_android.h" | 43 #include "chrome/browser/sync/glue/synced_tab_delegate_android.h" |
39 #include "chrome/browser/tab_contents/tab_util.h" | 44 #include "chrome/browser/tab_contents/tab_util.h" |
40 #include "chrome/browser/ui/android/content_settings/popup_blocked_infobar_deleg
ate.h" | 45 #include "chrome/browser/ui/android/content_settings/popup_blocked_infobar_deleg
ate.h" |
41 #include "chrome/browser/ui/android/context_menu_helper.h" | 46 #include "chrome/browser/ui/android/context_menu_helper.h" |
42 #include "chrome/browser/ui/android/infobars/infobar_container_android.h" | 47 #include "chrome/browser/ui/android/infobars/infobar_container_android.h" |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 CHECK_EQ(GetProfile()->IsOffTheRecord(), incognito); | 412 CHECK_EQ(GetProfile()->IsOffTheRecord(), incognito); |
408 | 413 |
409 InstantService* instant_service = | 414 InstantService* instant_service = |
410 InstantServiceFactory::GetForProfile(GetProfile()); | 415 InstantServiceFactory::GetForProfile(GetProfile()); |
411 if (instant_service) | 416 if (instant_service) |
412 instant_service->AddObserver(this); | 417 instant_service->AddObserver(this); |
413 | 418 |
414 content_layer_->InsertChild(web_contents_->GetNativeView()->GetLayer(), 0); | 419 content_layer_->InsertChild(web_contents_->GetNativeView()->GetLayer(), 0); |
415 } | 420 } |
416 | 421 |
| 422 base::android::ScopedJavaLocalRef<jobject> TabAndroid::InitBlimpContents( |
| 423 JNIEnv* env, |
| 424 const JavaParamRef<jobject>& obj, |
| 425 const JavaParamRef<jobject>& j_profile) { |
| 426 Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile.obj()); |
| 427 DCHECK(!profile->IsOffTheRecord()); |
| 428 blimp::client::BlimpClientContext* context = |
| 429 BlimpClientContextFactory::GetForBrowserContext(profile); |
| 430 DCHECK(context); |
| 431 blimp_contents_ = context->CreateBlimpContents(); |
| 432 DCHECK(blimp_contents_); |
| 433 return blimp_contents_->GetJavaObject(); |
| 434 } |
| 435 |
417 void TabAndroid::UpdateDelegates( | 436 void TabAndroid::UpdateDelegates( |
418 JNIEnv* env, | 437 JNIEnv* env, |
419 const JavaParamRef<jobject>& obj, | 438 const JavaParamRef<jobject>& obj, |
420 const JavaParamRef<jobject>& jweb_contents_delegate, | 439 const JavaParamRef<jobject>& jweb_contents_delegate, |
421 const JavaParamRef<jobject>& jcontext_menu_populator) { | 440 const JavaParamRef<jobject>& jcontext_menu_populator) { |
422 ContextMenuHelper::FromWebContents(web_contents())->SetPopulator( | 441 ContextMenuHelper::FromWebContents(web_contents())->SetPopulator( |
423 jcontext_menu_populator); | 442 jcontext_menu_populator); |
424 web_contents_delegate_.reset( | 443 web_contents_delegate_.reset( |
425 new chrome::android::TabWebContentsDelegateAndroid( | 444 new chrome::android::TabWebContentsDelegateAndroid( |
426 env, jweb_contents_delegate)); | 445 env, jweb_contents_delegate)); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 if (!fixed_url.is_valid()) | 569 if (!fixed_url.is_valid()) |
551 return PAGE_LOAD_FAILED; | 570 return PAGE_LOAD_FAILED; |
552 | 571 |
553 if (!HandleNonNavigationAboutURL(fixed_url)) { | 572 if (!HandleNonNavigationAboutURL(fixed_url)) { |
554 // Record UMA "ShowHistory" here. That way it'll pick up both user | 573 // Record UMA "ShowHistory" here. That way it'll pick up both user |
555 // typing chrome://history as well as selecting from the drop down menu. | 574 // typing chrome://history as well as selecting from the drop down menu. |
556 if (fixed_url.spec() == chrome::kChromeUIHistoryURL) { | 575 if (fixed_url.spec() == chrome::kChromeUIHistoryURL) { |
557 content::RecordAction(base::UserMetricsAction("ShowHistory")); | 576 content::RecordAction(base::UserMetricsAction("ShowHistory")); |
558 } | 577 } |
559 | 578 |
| 579 if (blimp_contents()) { |
| 580 blimp_contents()->GetNavigationController().LoadURL(fixed_url); |
| 581 return DEFAULT_PAGE_LOAD; |
| 582 } |
| 583 |
560 content::NavigationController::LoadURLParams load_params(fixed_url); | 584 content::NavigationController::LoadURLParams load_params(fixed_url); |
561 if (j_extra_headers) { | 585 if (j_extra_headers) { |
562 load_params.extra_headers = base::android::ConvertJavaStringToUTF8( | 586 load_params.extra_headers = base::android::ConvertJavaStringToUTF8( |
563 env, | 587 env, |
564 j_extra_headers); | 588 j_extra_headers); |
565 } | 589 } |
566 if (j_post_data) { | 590 if (j_post_data) { |
567 load_params.load_type = | 591 load_params.load_type = |
568 content::NavigationController::LOAD_TYPE_HTTP_POST; | 592 content::NavigationController::LOAD_TYPE_HTTP_POST; |
569 load_params.post_data = | 593 load_params.post_data = |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
874 static void Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 898 static void Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
875 TRACE_EVENT0("native", "TabAndroid::Init"); | 899 TRACE_EVENT0("native", "TabAndroid::Init"); |
876 // This will automatically bind to the Java object and pass ownership there. | 900 // This will automatically bind to the Java object and pass ownership there. |
877 new TabAndroid(env, obj); | 901 new TabAndroid(env, obj); |
878 } | 902 } |
879 | 903 |
880 // static | 904 // static |
881 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { | 905 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { |
882 return RegisterNativesImpl(env); | 906 return RegisterNativesImpl(env); |
883 } | 907 } |
OLD | NEW |