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

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

Issue 2279403003: blimp: Hook up the layer holding the tab content into Chrome. (Closed)
Patch Set: tab_android Created 4 years, 3 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"
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 409
410 // Verify that the WebContents this tab represents matches the expected 410 // Verify that the WebContents this tab represents matches the expected
411 // off the record state. 411 // off the record state.
412 CHECK_EQ(GetProfile()->IsOffTheRecord(), incognito); 412 CHECK_EQ(GetProfile()->IsOffTheRecord(), incognito);
413 413
414 InstantService* instant_service = 414 InstantService* instant_service =
415 InstantServiceFactory::GetForProfile(GetProfile()); 415 InstantServiceFactory::GetForProfile(GetProfile());
416 if (instant_service) 416 if (instant_service)
417 instant_service->AddObserver(this); 417 instant_service->AddObserver(this);
418 418
419 content_layer_->InsertChild(web_contents_->GetNativeView()->GetLayer(), 0); 419 if (!blimp_contents_)
420 content_layer_->InsertChild(web_contents_->GetNativeView()->GetLayer(), 0);
420 } 421 }
421 422
422 base::android::ScopedJavaLocalRef<jobject> TabAndroid::InitBlimpContents( 423 base::android::ScopedJavaLocalRef<jobject> TabAndroid::InitBlimpContents(
423 JNIEnv* env, 424 JNIEnv* env,
424 const JavaParamRef<jobject>& obj, 425 const JavaParamRef<jobject>& obj,
425 const JavaParamRef<jobject>& j_profile) { 426 const JavaParamRef<jobject>& j_profile) {
426 Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile.obj()); 427 Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile.obj());
427 DCHECK(!profile->IsOffTheRecord()); 428 DCHECK(!profile->IsOffTheRecord());
428 blimp::client::BlimpClientContext* context = 429 blimp::client::BlimpClientContext* context =
429 BlimpClientContextFactory::GetForBrowserContext(profile); 430 BlimpClientContextFactory::GetForBrowserContext(profile);
430 DCHECK(context); 431 DCHECK(context);
431 blimp_contents_ = context->CreateBlimpContents(); 432 blimp_contents_ = context->CreateBlimpContents();
432 DCHECK(blimp_contents_); 433 DCHECK(blimp_contents_);
434
435 // Let's detach the layer from WebContents first, just to be sure.
436 cc::Layer* web_contents_layer = web_contents_->GetNativeView()->GetLayer();
nyquist 2016/08/29 23:09:45 Are you sure web_contents_ is never nullptr here?
Khushal 2016/08/30 00:51:10 Thanks for catching it. Done.
437 if (web_contents_layer->parent() == content_layer_.get())
438 web_contents_layer->RemoveFromParent();
439
440 // Attach the layer holding the tab contents to the |content_layer_|.
441 content_layer_->InsertChild(blimp_contents_->GetNativeView()->GetLayer(), 0);
442
433 return blimp_contents_->GetJavaObject(); 443 return blimp_contents_->GetJavaObject();
434 } 444 }
435 445
436 void TabAndroid::UpdateDelegates( 446 void TabAndroid::UpdateDelegates(
437 JNIEnv* env, 447 JNIEnv* env,
438 const JavaParamRef<jobject>& obj, 448 const JavaParamRef<jobject>& obj,
439 const JavaParamRef<jobject>& jweb_contents_delegate, 449 const JavaParamRef<jobject>& jweb_contents_delegate,
440 const JavaParamRef<jobject>& jcontext_menu_populator) { 450 const JavaParamRef<jobject>& jcontext_menu_populator) {
441 ContextMenuHelper::FromWebContents(web_contents())->SetPopulator( 451 ContextMenuHelper::FromWebContents(web_contents())->SetPopulator(
442 jcontext_menu_populator); 452 jcontext_menu_populator);
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 static void Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { 908 static void Init(JNIEnv* env, const JavaParamRef<jobject>& obj) {
899 TRACE_EVENT0("native", "TabAndroid::Init"); 909 TRACE_EVENT0("native", "TabAndroid::Init");
900 // This will automatically bind to the Java object and pass ownership there. 910 // This will automatically bind to the Java object and pass ownership there.
901 new TabAndroid(env, obj); 911 new TabAndroid(env, obj);
902 } 912 }
903 913
904 // static 914 // static
905 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { 915 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) {
906 return RegisterNativesImpl(env); 916 return RegisterNativesImpl(env);
907 } 917 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698