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

Side by Side Diff: chrome/browser/android/tab_android.cc

Issue 2233023002: Adding BlimpNavigationController to Tab (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@nav_handler_remove
Patch Set: @nyquist feedback Created 4 years, 4 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 unified diff | Download patch
OLDNEW
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_model_factory.h" 21 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h"
18 #include "chrome/browser/android/offline_pages/offline_page_utils.h" 22 #include "chrome/browser/android/offline_pages/offline_page_utils.h"
19 #include "chrome/browser/android/tab_web_contents_delegate_android.h" 23 #include "chrome/browser/android/tab_web_contents_delegate_android.h"
20 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 24 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
21 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h" 25 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h"
22 #include "chrome/browser/browser_about_handler.h" 26 #include "chrome/browser/browser_about_handler.h"
23 #include "chrome/browser/chrome_notification_types.h" 27 #include "chrome/browser/chrome_notification_types.h"
24 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 28 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
25 #include "chrome/browser/infobars/infobar_service.h" 29 #include "chrome/browser/infobars/infobar_service.h"
26 #include "chrome/browser/prerender/prerender_contents.h" 30 #include "chrome/browser/prerender/prerender_contents.h"
27 #include "chrome/browser/prerender/prerender_manager.h" 31 #include "chrome/browser/prerender/prerender_manager.h"
28 #include "chrome/browser/prerender/prerender_manager_factory.h" 32 #include "chrome/browser/prerender/prerender_manager_factory.h"
29 #include "chrome/browser/printing/print_view_manager_basic.h" 33 #include "chrome/browser/printing/print_view_manager_basic.h"
30 #include "chrome/browser/profiles/profile.h" 34 #include "chrome/browser/profiles/profile.h"
31 #include "chrome/browser/profiles/profile_android.h" 35 #include "chrome/browser/profiles/profile_android.h"
36 #include "chrome/browser/profiles/profile_manager.h"
32 #include "chrome/browser/search/instant_service.h" 37 #include "chrome/browser/search/instant_service.h"
33 #include "chrome/browser/search/instant_service_factory.h" 38 #include "chrome/browser/search/instant_service_factory.h"
34 #include "chrome/browser/search/search.h" 39 #include "chrome/browser/search/search.h"
35 #include "chrome/browser/sessions/session_tab_helper.h" 40 #include "chrome/browser/sessions/session_tab_helper.h"
36 #include "chrome/browser/sessions/tab_restore_service_factory.h" 41 #include "chrome/browser/sessions/tab_restore_service_factory.h"
37 #include "chrome/browser/sync/glue/synced_tab_delegate_android.h" 42 #include "chrome/browser/sync/glue/synced_tab_delegate_android.h"
38 #include "chrome/browser/tab_contents/tab_util.h" 43 #include "chrome/browser/tab_contents/tab_util.h"
39 #include "chrome/browser/ui/android/content_settings/popup_blocked_infobar_deleg ate.h" 44 #include "chrome/browser/ui/android/content_settings/popup_blocked_infobar_deleg ate.h"
40 #include "chrome/browser/ui/android/context_menu_helper.h" 45 #include "chrome/browser/ui/android/context_menu_helper.h"
41 #include "chrome/browser/ui/android/infobars/infobar_container_android.h" 46 #include "chrome/browser/ui/android/infobars/infobar_container_android.h"
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 CHECK_EQ(GetProfile()->IsOffTheRecord(), incognito); 420 CHECK_EQ(GetProfile()->IsOffTheRecord(), incognito);
416 421
417 InstantService* instant_service = 422 InstantService* instant_service =
418 InstantServiceFactory::GetForProfile(GetProfile()); 423 InstantServiceFactory::GetForProfile(GetProfile());
419 if (instant_service) 424 if (instant_service)
420 instant_service->AddObserver(this); 425 instant_service->AddObserver(this);
421 426
422 content_layer_->InsertChild(web_contents_->GetNativeView()->GetLayer(), 0); 427 content_layer_->InsertChild(web_contents_->GetNativeView()->GetLayer(), 0);
423 } 428 }
424 429
430 void TabAndroid::InitBlimpContents(JNIEnv* env,
431 const JavaParamRef<jobject>& obj) {
432 bool incognito = Java_Tab_isIncognito(env, weak_java_tab_.get(env).obj());
David Trainor- moved to gerrit 2016/08/18 17:06:30 I don't think we have to bleed this through here.
shaktisahu 2016/08/18 19:36:06 profile->IsOffTheRecord() might not exactly relate
433 CHECK(!incognito) << "Cannot create incognito tab in blimp mode.";
434
435 Profile* profile = ProfileManager::GetLastUsedProfile()->GetOriginalProfile();
436 blimp::client::BlimpClientContext* context =
437 BlimpClientContextFactory::GetForBrowserContext(profile);
438 DCHECK(context);
439 blimp_contents_ = context->CreateBlimpContents();
440 }
441
425 void TabAndroid::UpdateDelegates( 442 void TabAndroid::UpdateDelegates(
426 JNIEnv* env, 443 JNIEnv* env,
427 const JavaParamRef<jobject>& obj, 444 const JavaParamRef<jobject>& obj,
428 const JavaParamRef<jobject>& jweb_contents_delegate, 445 const JavaParamRef<jobject>& jweb_contents_delegate,
429 const JavaParamRef<jobject>& jcontext_menu_populator) { 446 const JavaParamRef<jobject>& jcontext_menu_populator) {
430 ContextMenuHelper::FromWebContents(web_contents())->SetPopulator( 447 ContextMenuHelper::FromWebContents(web_contents())->SetPopulator(
431 jcontext_menu_populator); 448 jcontext_menu_populator);
432 web_contents_delegate_.reset( 449 web_contents_delegate_.reset(
433 new chrome::android::TabWebContentsDelegateAndroid( 450 new chrome::android::TabWebContentsDelegateAndroid(
434 env, jweb_contents_delegate)); 451 env, jweb_contents_delegate));
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 Profile* profile = GetProfile(); 510 Profile* profile = GetProfile();
494 if (!profile) 511 if (!profile)
495 return base::android::ScopedJavaLocalRef<jobject>(); 512 return base::android::ScopedJavaLocalRef<jobject>();
496 ProfileAndroid* profile_android = ProfileAndroid::FromProfile(profile); 513 ProfileAndroid* profile_android = ProfileAndroid::FromProfile(profile);
497 if (!profile_android) 514 if (!profile_android)
498 return base::android::ScopedJavaLocalRef<jobject>(); 515 return base::android::ScopedJavaLocalRef<jobject>();
499 516
500 return profile_android->GetJavaObject(); 517 return profile_android->GetJavaObject();
501 } 518 }
502 519
520 base::android::ScopedJavaLocalRef<jobject> TabAndroid::GetBlimpContents(
521 JNIEnv* env,
522 const base::android::JavaParamRef<jobject>& obj) {
523 if (!blimp_contents_.get())
524 return base::android::ScopedJavaLocalRef<jobject>();
525
526 return blimp_contents_->GetJavaObject();
527 }
528
503 TabAndroid::TabLoadStatus TabAndroid::LoadUrl( 529 TabAndroid::TabLoadStatus TabAndroid::LoadUrl(
504 JNIEnv* env, 530 JNIEnv* env,
505 const JavaParamRef<jobject>& obj, 531 const JavaParamRef<jobject>& obj,
506 const JavaParamRef<jstring>& url, 532 const JavaParamRef<jstring>& url,
507 const JavaParamRef<jstring>& j_extra_headers, 533 const JavaParamRef<jstring>& j_extra_headers,
508 const JavaParamRef<jobject>& j_post_data, 534 const JavaParamRef<jobject>& j_post_data,
509 jint page_transition, 535 jint page_transition,
510 const JavaParamRef<jstring>& j_referrer_url, 536 const JavaParamRef<jstring>& j_referrer_url,
511 jint referrer_policy, 537 jint referrer_policy,
512 jboolean is_renderer_initiated, 538 jboolean is_renderer_initiated,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 if (!fixed_url.is_valid()) 584 if (!fixed_url.is_valid())
559 return PAGE_LOAD_FAILED; 585 return PAGE_LOAD_FAILED;
560 586
561 if (!HandleNonNavigationAboutURL(fixed_url)) { 587 if (!HandleNonNavigationAboutURL(fixed_url)) {
562 // Record UMA "ShowHistory" here. That way it'll pick up both user 588 // Record UMA "ShowHistory" here. That way it'll pick up both user
563 // typing chrome://history as well as selecting from the drop down menu. 589 // typing chrome://history as well as selecting from the drop down menu.
564 if (fixed_url.spec() == chrome::kChromeUIHistoryURL) { 590 if (fixed_url.spec() == chrome::kChromeUIHistoryURL) {
565 content::RecordAction(base::UserMetricsAction("ShowHistory")); 591 content::RecordAction(base::UserMetricsAction("ShowHistory"));
566 } 592 }
567 593
594 if (blimp_contents()) {
595 blimp_contents()->GetNavigationController().LoadURL(fixed_url);
596 return DEFAULT_PAGE_LOAD;
597 }
598
568 content::NavigationController::LoadURLParams load_params(fixed_url); 599 content::NavigationController::LoadURLParams load_params(fixed_url);
569 if (j_extra_headers) { 600 if (j_extra_headers) {
570 load_params.extra_headers = base::android::ConvertJavaStringToUTF8( 601 load_params.extra_headers = base::android::ConvertJavaStringToUTF8(
571 env, 602 env,
572 j_extra_headers); 603 j_extra_headers);
573 } 604 }
574 if (j_post_data) { 605 if (j_post_data) {
575 load_params.load_type = 606 load_params.load_type =
576 content::NavigationController::LOAD_TYPE_HTTP_POST; 607 content::NavigationController::LOAD_TYPE_HTTP_POST;
577 load_params.post_data = 608 load_params.post_data =
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 static void Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { 925 static void Init(JNIEnv* env, const JavaParamRef<jobject>& obj) {
895 TRACE_EVENT0("native", "TabAndroid::Init"); 926 TRACE_EVENT0("native", "TabAndroid::Init");
896 // This will automatically bind to the Java object and pass ownership there. 927 // This will automatically bind to the Java object and pass ownership there.
897 new TabAndroid(env, obj); 928 new TabAndroid(env, obj);
898 } 929 }
899 930
900 // static 931 // static
901 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { 932 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) {
902 return RegisterNativesImpl(env); 933 return RegisterNativesImpl(env);
903 } 934 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698