| 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 "content/browser/android/content_view_core_impl.h" | 5 #include "content/browser/android/content_view_core_impl.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 web_contents->SetUserAgentOverride(spoofed_ua); | 249 web_contents->SetUserAgentOverride(spoofed_ua); |
| 250 | 250 |
| 251 java_bridge_dispatcher_host_ = | 251 java_bridge_dispatcher_host_ = |
| 252 new GinJavaBridgeDispatcherHost(web_contents, | 252 new GinJavaBridgeDispatcherHost(web_contents, |
| 253 java_bridge_retained_object_set); | 253 java_bridge_retained_object_set); |
| 254 | 254 |
| 255 InitWebContents(); | 255 InitWebContents(); |
| 256 } | 256 } |
| 257 | 257 |
| 258 ContentViewCoreImpl::~ContentViewCoreImpl() { | 258 ContentViewCoreImpl::~ContentViewCoreImpl() { |
| 259 root_layer_->RemoveFromParent(); |
| 260 |
| 259 JNIEnv* env = base::android::AttachCurrentThread(); | 261 JNIEnv* env = base::android::AttachCurrentThread(); |
| 260 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 262 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
| 261 java_ref_.reset(); | 263 java_ref_.reset(); |
| 262 if (!j_obj.is_null()) { | 264 if (!j_obj.is_null()) { |
| 263 Java_ContentViewCore_onNativeContentViewCoreDestroyed( | 265 Java_ContentViewCore_onNativeContentViewCoreDestroyed( |
| 264 env, j_obj.obj(), reinterpret_cast<intptr_t>(this)); | 266 env, j_obj.obj(), reinterpret_cast<intptr_t>(this)); |
| 265 } | 267 } |
| 266 } | 268 } |
| 267 | 269 |
| 268 base::android::ScopedJavaLocalRef<jobject> | 270 base::android::ScopedJavaLocalRef<jobject> |
| (...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1296 void ContentViewCoreImpl::SetBackgroundOpaque(JNIEnv* env, jobject jobj, | 1298 void ContentViewCoreImpl::SetBackgroundOpaque(JNIEnv* env, jobject jobj, |
| 1297 jboolean opaque) { | 1299 jboolean opaque) { |
| 1298 if (GetRenderWidgetHostViewAndroid()) { | 1300 if (GetRenderWidgetHostViewAndroid()) { |
| 1299 if (opaque) | 1301 if (opaque) |
| 1300 GetRenderWidgetHostViewAndroid()->SetBackgroundColorToDefault(); | 1302 GetRenderWidgetHostViewAndroid()->SetBackgroundColorToDefault(); |
| 1301 else | 1303 else |
| 1302 GetRenderWidgetHostViewAndroid()->SetBackgroundColor(SK_ColorTRANSPARENT); | 1304 GetRenderWidgetHostViewAndroid()->SetBackgroundColor(SK_ColorTRANSPARENT); |
| 1303 } | 1305 } |
| 1304 } | 1306 } |
| 1305 | 1307 |
| 1308 void ContentViewCoreImpl::SetDrawsContent(JNIEnv* env, |
| 1309 jobject jobj, |
| 1310 jboolean draws) { |
| 1311 GetLayer()->SetHideLayerAndSubtree(!draws); |
| 1312 } |
| 1313 |
| 1306 void ContentViewCoreImpl::RequestTextSurroundingSelection( | 1314 void ContentViewCoreImpl::RequestTextSurroundingSelection( |
| 1307 int max_length, | 1315 int max_length, |
| 1308 const base::Callback< | 1316 const base::Callback< |
| 1309 void(const base::string16& content, int start_offset, int end_offset)>& | 1317 void(const base::string16& content, int start_offset, int end_offset)>& |
| 1310 callback) { | 1318 callback) { |
| 1311 DCHECK(!callback.is_null()); | 1319 DCHECK(!callback.is_null()); |
| 1312 RenderFrameHost* focused_frame = web_contents_->GetFocusedFrame(); | 1320 RenderFrameHost* focused_frame = web_contents_->GetFocusedFrame(); |
| 1313 if (!focused_frame) | 1321 if (!focused_frame) |
| 1314 return; | 1322 return; |
| 1315 if (GetRenderWidgetHostViewAndroid()) { | 1323 if (GetRenderWidgetHostViewAndroid()) { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1381 return NULL; | 1389 return NULL; |
| 1382 | 1390 |
| 1383 return view->GetJavaObject().Release(); | 1391 return view->GetJavaObject().Release(); |
| 1384 } | 1392 } |
| 1385 | 1393 |
| 1386 bool RegisterContentViewCore(JNIEnv* env) { | 1394 bool RegisterContentViewCore(JNIEnv* env) { |
| 1387 return RegisterNativesImpl(env); | 1395 return RegisterNativesImpl(env); |
| 1388 } | 1396 } |
| 1389 | 1397 |
| 1390 } // namespace content | 1398 } // namespace content |
| OLD | NEW |