| 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" |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 const JavaParamRef<jobject>& j_profile, | 427 const JavaParamRef<jobject>& j_profile, |
| 428 jlong window_android_ptr) { | 428 jlong window_android_ptr) { |
| 429 Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile.obj()); | 429 Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile.obj()); |
| 430 DCHECK(!profile->IsOffTheRecord()); | 430 DCHECK(!profile->IsOffTheRecord()); |
| 431 blimp::client::BlimpClientContext* context = | 431 blimp::client::BlimpClientContext* context = |
| 432 BlimpClientContextFactory::GetForBrowserContext(profile); | 432 BlimpClientContextFactory::GetForBrowserContext(profile); |
| 433 DCHECK(context); | 433 DCHECK(context); |
| 434 ui::WindowAndroid* window = | 434 ui::WindowAndroid* window = |
| 435 reinterpret_cast<ui::WindowAndroid*>(window_android_ptr); | 435 reinterpret_cast<ui::WindowAndroid*>(window_android_ptr); |
| 436 blimp_contents_ = context->CreateBlimpContents(window); | 436 blimp_contents_ = context->CreateBlimpContents(window); |
| 437 DCHECK(blimp_contents_); | 437 // If creating a BlimpContents failed, fall back to WebContents-based by |
| 438 // doing an early out here. |
| 439 if (!blimp_contents_) |
| 440 return nullptr; |
| 438 | 441 |
| 439 // Let's detach the layer from WebContents first, just to be sure. | 442 // Let's detach the layer from WebContents first, just to be sure. |
| 440 if (web_contents_ && web_contents_->GetNativeView() && | 443 if (web_contents_ && web_contents_->GetNativeView() && |
| 441 web_contents_->GetNativeView()->GetLayer()) { | 444 web_contents_->GetNativeView()->GetLayer()) { |
| 442 cc::Layer* web_contents_layer = web_contents_->GetNativeView()->GetLayer(); | 445 cc::Layer* web_contents_layer = web_contents_->GetNativeView()->GetLayer(); |
| 443 if (web_contents_layer->parent() == content_layer_.get()) | 446 if (web_contents_layer->parent() == content_layer_.get()) |
| 444 web_contents_layer->RemoveFromParent(); | 447 web_contents_layer->RemoveFromParent(); |
| 445 } | 448 } |
| 446 | 449 |
| 447 // Attach the layer holding the tab contents to the |content_layer_|. | 450 // Attach the layer holding the tab contents to the |content_layer_|. |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 915 static void Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 918 static void Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 916 TRACE_EVENT0("native", "TabAndroid::Init"); | 919 TRACE_EVENT0("native", "TabAndroid::Init"); |
| 917 // This will automatically bind to the Java object and pass ownership there. | 920 // This will automatically bind to the Java object and pass ownership there. |
| 918 new TabAndroid(env, obj); | 921 new TabAndroid(env, obj); |
| 919 } | 922 } |
| 920 | 923 |
| 921 // static | 924 // static |
| 922 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { | 925 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { |
| 923 return RegisterNativesImpl(env); | 926 return RegisterNativesImpl(env); |
| 924 } | 927 } |
| OLD | NEW |