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

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: Addressed comments 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
« no previous file with comments | « blimp/client/public/contents/blimp_contents.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 if (web_contents_ && web_contents_->GetNativeView() &&
437 web_contents_->GetNativeView()->GetLayer()) {
438 cc::Layer* web_contents_layer = web_contents_->GetNativeView()->GetLayer();
439 if (web_contents_layer->parent() == content_layer_.get())
440 web_contents_layer->RemoveFromParent();
441 }
442
443 // Attach the layer holding the tab contents to the |content_layer_|.
444 content_layer_->InsertChild(blimp_contents_->GetNativeView()->GetLayer(), 0);
445
433 return blimp_contents_->GetJavaObject(); 446 return blimp_contents_->GetJavaObject();
434 } 447 }
435 448
436 void TabAndroid::UpdateDelegates( 449 void TabAndroid::UpdateDelegates(
437 JNIEnv* env, 450 JNIEnv* env,
438 const JavaParamRef<jobject>& obj, 451 const JavaParamRef<jobject>& obj,
439 const JavaParamRef<jobject>& jweb_contents_delegate, 452 const JavaParamRef<jobject>& jweb_contents_delegate,
440 const JavaParamRef<jobject>& jcontext_menu_populator) { 453 const JavaParamRef<jobject>& jcontext_menu_populator) {
441 ContextMenuHelper::FromWebContents(web_contents())->SetPopulator( 454 ContextMenuHelper::FromWebContents(web_contents())->SetPopulator(
442 jcontext_menu_populator); 455 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) { 911 static void Init(JNIEnv* env, const JavaParamRef<jobject>& obj) {
899 TRACE_EVENT0("native", "TabAndroid::Init"); 912 TRACE_EVENT0("native", "TabAndroid::Init");
900 // This will automatically bind to the Java object and pass ownership there. 913 // This will automatically bind to the Java object and pass ownership there.
901 new TabAndroid(env, obj); 914 new TabAndroid(env, obj);
902 } 915 }
903 916
904 // static 917 // static
905 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { 918 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) {
906 return RegisterNativesImpl(env); 919 return RegisterNativesImpl(env);
907 } 920 }
OLDNEW
« no previous file with comments | « blimp/client/public/contents/blimp_contents.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698