| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ui/android/view_android.h" | 5 #include "ui/android/view_android.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 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 "cc/layers/layer.h" | 11 #include "cc/layers/layer.h" |
| 11 #include "jni/ViewAndroidDelegate_jni.h" | 12 #include "jni/ViewAndroidDelegate_jni.h" |
| 12 #include "ui/android/window_android.h" | 13 #include "ui/android/window_android.h" |
| 13 #include "ui/display/display.h" | 14 #include "ui/display/display.h" |
| 14 #include "ui/display/screen.h" | 15 #include "ui/display/screen.h" |
| 16 #include "url/gurl.h" |
| 15 | 17 |
| 16 namespace ui { | 18 namespace ui { |
| 17 | 19 |
| 20 using base::android::ConvertUTF8ToJavaString; |
| 18 using base::android::JavaRef; | 21 using base::android::JavaRef; |
| 19 using base::android::ScopedJavaLocalRef; | 22 using base::android::ScopedJavaLocalRef; |
| 20 | 23 |
| 21 // ViewAndroid::ScopedAndroidView | 24 // ViewAndroid::ScopedAndroidView |
| 22 ViewAndroid::ScopedAnchorView::ScopedAnchorView( | 25 ViewAndroid::ScopedAnchorView::ScopedAnchorView( |
| 23 JNIEnv* env, | 26 JNIEnv* env, |
| 24 const JavaRef<jobject>& jview, | 27 const JavaRef<jobject>& jview, |
| 25 const JavaRef<jobject>& jdelegate) | 28 const JavaRef<jobject>& jdelegate) |
| 26 : view_(env, jview.obj()), delegate_(env, jdelegate.obj()) { | 29 : view_(env, jview.obj()), delegate_(env, jdelegate.obj()) { |
| 27 // If there's a view, then we need a delegate to remove it. | 30 // If there's a view, then we need a delegate to remove it. |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 return true; | 237 return true; |
| 235 } | 238 } |
| 236 } | 239 } |
| 237 | 240 |
| 238 if (client_ && client_->OnTouchEvent(event)) | 241 if (client_ && client_->OnTouchEvent(event)) |
| 239 return true; | 242 return true; |
| 240 | 243 |
| 241 return false; | 244 return false; |
| 242 } | 245 } |
| 243 | 246 |
| 247 void ViewAndroid::OnBackgroundColorChanged(unsigned int color) { |
| 248 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); |
| 249 if (delegate.is_null()) |
| 250 return; |
| 251 JNIEnv* env = base::android::AttachCurrentThread(); |
| 252 Java_ViewAndroidDelegate_onBackgroundColorChanged(env, delegate, color); |
| 253 } |
| 254 |
| 255 void ViewAndroid::OnTopControlsChanged(float top_controls_offset, |
| 256 float top_content_offset) { |
| 257 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); |
| 258 if (delegate.is_null()) |
| 259 return; |
| 260 JNIEnv* env = base::android::AttachCurrentThread(); |
| 261 Java_ViewAndroidDelegate_onTopControlsChanged( |
| 262 env, delegate, top_controls_offset, top_content_offset); |
| 263 } |
| 264 |
| 265 void ViewAndroid::OnBottomControlsChanged(float bottom_controls_offset, |
| 266 float bottom_content_offset) { |
| 267 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); |
| 268 if (delegate.is_null()) |
| 269 return; |
| 270 JNIEnv* env = base::android::AttachCurrentThread(); |
| 271 Java_ViewAndroidDelegate_onBottomControlsChanged( |
| 272 env, delegate, bottom_controls_offset, bottom_content_offset); |
| 273 } |
| 274 |
| 275 void ViewAndroid::StartContentIntent(const GURL& content_url, |
| 276 bool is_main_frame) { |
| 277 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); |
| 278 if (delegate.is_null()) |
| 279 return; |
| 280 JNIEnv* env = base::android::AttachCurrentThread(); |
| 281 ScopedJavaLocalRef<jstring> jcontent_url = |
| 282 ConvertUTF8ToJavaString(env, content_url.spec()); |
| 283 Java_ViewAndroidDelegate_onStartContentIntent(env, delegate, jcontent_url, |
| 284 is_main_frame); |
| 285 } |
| 244 } // namespace ui | 286 } // namespace ui |
| OLD | NEW |