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

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: 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 blimp::client::BlimpClientContext* context =
433 BlimpClientContextFactory::GetForBrowserContext(
434 ProfileManager::GetLastUsedProfile()->GetOriginalProfile());
David Trainor- moved to gerrit 2016/08/11 21:40:19 Should we fail if this is an incognito tab (for no
shaktisahu 2016/08/12 22:11:49 I discussed with Tommy about this. I added a check
435 blimp_contents_ = context->CreateBlimpContents();
436 }
437
425 void TabAndroid::UpdateDelegates( 438 void TabAndroid::UpdateDelegates(
426 JNIEnv* env, 439 JNIEnv* env,
427 const JavaParamRef<jobject>& obj, 440 const JavaParamRef<jobject>& obj,
428 const JavaParamRef<jobject>& jweb_contents_delegate, 441 const JavaParamRef<jobject>& jweb_contents_delegate,
429 const JavaParamRef<jobject>& jcontext_menu_populator) { 442 const JavaParamRef<jobject>& jcontext_menu_populator) {
430 ContextMenuHelper::FromWebContents(web_contents())->SetPopulator( 443 ContextMenuHelper::FromWebContents(web_contents())->SetPopulator(
431 jcontext_menu_populator); 444 jcontext_menu_populator);
432 web_contents_delegate_.reset( 445 web_contents_delegate_.reset(
433 new chrome::android::TabWebContentsDelegateAndroid( 446 new chrome::android::TabWebContentsDelegateAndroid(
434 env, jweb_contents_delegate)); 447 env, jweb_contents_delegate));
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 Profile* profile = GetProfile(); 506 Profile* profile = GetProfile();
494 if (!profile) 507 if (!profile)
495 return base::android::ScopedJavaLocalRef<jobject>(); 508 return base::android::ScopedJavaLocalRef<jobject>();
496 ProfileAndroid* profile_android = ProfileAndroid::FromProfile(profile); 509 ProfileAndroid* profile_android = ProfileAndroid::FromProfile(profile);
497 if (!profile_android) 510 if (!profile_android)
498 return base::android::ScopedJavaLocalRef<jobject>(); 511 return base::android::ScopedJavaLocalRef<jobject>();
499 512
500 return profile_android->GetJavaObject(); 513 return profile_android->GetJavaObject();
501 } 514 }
502 515
516 base::android::ScopedJavaLocalRef<jobject> TabAndroid::GetBlimpContents(
517 JNIEnv* env,
518 const base::android::JavaParamRef<jobject>& obj) {
519 if (!blimp_contents_.get())
520 return base::android::ScopedJavaLocalRef<jobject>();
521
522 return blimp_contents_->GetJavaObject();
523 }
524
503 TabAndroid::TabLoadStatus TabAndroid::LoadUrl( 525 TabAndroid::TabLoadStatus TabAndroid::LoadUrl(
504 JNIEnv* env, 526 JNIEnv* env,
505 const JavaParamRef<jobject>& obj, 527 const JavaParamRef<jobject>& obj,
506 const JavaParamRef<jstring>& url, 528 const JavaParamRef<jstring>& url,
507 const JavaParamRef<jstring>& j_extra_headers, 529 const JavaParamRef<jstring>& j_extra_headers,
508 const JavaParamRef<jobject>& j_post_data, 530 const JavaParamRef<jobject>& j_post_data,
509 jint page_transition, 531 jint page_transition,
510 const JavaParamRef<jstring>& j_referrer_url, 532 const JavaParamRef<jstring>& j_referrer_url,
511 jint referrer_policy, 533 jint referrer_policy,
512 jboolean is_renderer_initiated, 534 jboolean is_renderer_initiated,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 load_params.post_data = 599 load_params.post_data =
578 content::ResourceRequestBody::FromJavaObject(env, j_post_data); 600 content::ResourceRequestBody::FromJavaObject(env, j_post_data);
579 } 601 }
580 load_params.transition_type = 602 load_params.transition_type =
581 ui::PageTransitionFromInt(page_transition); 603 ui::PageTransitionFromInt(page_transition);
582 if (j_referrer_url) { 604 if (j_referrer_url) {
583 load_params.referrer = content::Referrer( 605 load_params.referrer = content::Referrer(
584 GURL(base::android::ConvertJavaStringToUTF8(env, j_referrer_url)), 606 GURL(base::android::ConvertJavaStringToUTF8(env, j_referrer_url)),
585 static_cast<blink::WebReferrerPolicy>(referrer_policy)); 607 static_cast<blink::WebReferrerPolicy>(referrer_policy));
586 } 608 }
609
610 if (blimp_contents()) {
David Trainor- moved to gerrit 2016/08/11 21:40:19 Can we do this before we build the LoadURLParams?
shaktisahu 2016/08/12 22:11:49 Done.
611 blimp_contents()->GetNavigationController().LoadURL(fixed_url);
612 return DEFAULT_PAGE_LOAD;
613 }
614
587 const base::string16 search_terms = 615 const base::string16 search_terms =
588 search::ExtractSearchTermsFromURL(GetProfile(), gurl); 616 search::ExtractSearchTermsFromURL(GetProfile(), gurl);
589 SearchTabHelper* search_tab_helper = 617 SearchTabHelper* search_tab_helper =
590 SearchTabHelper::FromWebContents(web_contents_.get()); 618 SearchTabHelper::FromWebContents(web_contents_.get());
591 if (!search_terms.empty() && search_tab_helper && 619 if (!search_terms.empty() && search_tab_helper &&
592 search_tab_helper->SupportsInstant()) { 620 search_tab_helper->SupportsInstant()) {
593 EmbeddedSearchRequestParams request_params(gurl); 621 EmbeddedSearchRequestParams request_params(gurl);
594 search_tab_helper->Submit(search_terms, request_params); 622 search_tab_helper->Submit(search_terms, request_params);
595 return DEFAULT_PAGE_LOAD; 623 return DEFAULT_PAGE_LOAD;
596 } 624 }
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 static void Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { 922 static void Init(JNIEnv* env, const JavaParamRef<jobject>& obj) {
895 TRACE_EVENT0("native", "TabAndroid::Init"); 923 TRACE_EVENT0("native", "TabAndroid::Init");
896 // This will automatically bind to the Java object and pass ownership there. 924 // This will automatically bind to the Java object and pass ownership there.
897 new TabAndroid(env, obj); 925 new TabAndroid(env, obj);
898 } 926 }
899 927
900 // static 928 // static
901 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { 929 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) {
902 return RegisterNativesImpl(env); 930 return RegisterNativesImpl(env);
903 } 931 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698