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

Side by Side Diff: ui/android/view_android.cc

Issue 2694273002: Revert of Refactor ContentViewClient (4/6) (Closed)
Patch Set: Created 3 years, 10 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 | « ui/android/view_android.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 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"
11 #include "cc/layers/layer.h" 10 #include "cc/layers/layer.h"
12 #include "jni/ViewAndroidDelegate_jni.h" 11 #include "jni/ViewAndroidDelegate_jni.h"
13 #include "ui/android/window_android.h" 12 #include "ui/android/window_android.h"
14 #include "ui/display/display.h" 13 #include "ui/display/display.h"
15 #include "ui/display/screen.h" 14 #include "ui/display/screen.h"
16 #include "url/gurl.h"
17 15
18 namespace ui { 16 namespace ui {
19 17
20 using base::android::ConvertUTF8ToJavaString;
21 using base::android::JavaRef; 18 using base::android::JavaRef;
22 using base::android::ScopedJavaLocalRef; 19 using base::android::ScopedJavaLocalRef;
23 20
24 // ViewAndroid::ScopedAndroidView 21 // ViewAndroid::ScopedAndroidView
25 ViewAndroid::ScopedAnchorView::ScopedAnchorView( 22 ViewAndroid::ScopedAnchorView::ScopedAnchorView(
26 JNIEnv* env, 23 JNIEnv* env,
27 const JavaRef<jobject>& jview, 24 const JavaRef<jobject>& jview,
28 const JavaRef<jobject>& jdelegate) 25 const JavaRef<jobject>& jdelegate)
29 : view_(env, jview.obj()), delegate_(env, jdelegate.obj()) { 26 : view_(env, jview.obj()), delegate_(env, jdelegate.obj()) {
30 // If there's a view, then we need a delegate to remove it. 27 // If there's a view, then we need a delegate to remove it.
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 bool ViewAndroid::IsViewRoot() { 208 bool ViewAndroid::IsViewRoot() {
212 return GetViewRoot() == this; 209 return GetViewRoot() == this;
213 } 210 }
214 211
215 bool ViewAndroid::StartDragAndDrop(const JavaRef<jstring>& jtext, 212 bool ViewAndroid::StartDragAndDrop(const JavaRef<jstring>& jtext,
216 const JavaRef<jobject>& jimage) { 213 const JavaRef<jobject>& jimage) {
217 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); 214 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate());
218 if (delegate.is_null()) 215 if (delegate.is_null())
219 return false; 216 return false;
220 JNIEnv* env = base::android::AttachCurrentThread(); 217 JNIEnv* env = base::android::AttachCurrentThread();
221 return Java_ViewAndroidDelegate_startDragAndDrop(env, 218 return Java_ViewAndroidDelegate_startDragAndDrop(env, delegate, jtext,
222 delegate,
223 jtext,
224 jimage); 219 jimage);
225 } 220 }
226 221
227 bool ViewAndroid::OnTouchEventInternal(const MotionEventData& event) { 222 bool ViewAndroid::OnTouchEventInternal(const MotionEventData& event) {
228 if (!children_.empty()) { 223 if (!children_.empty()) {
229 const MotionEventData& e = 224 const MotionEventData& e =
230 origin_.IsOrigin() ? event : event.Offset(-origin_.x(), -origin_.y()); 225 origin_.IsOrigin() ? event : event.Offset(-origin_.x(), -origin_.y());
231 226
232 for (auto it = children_.rbegin(); it != children_.rend(); ++it) { 227 for (auto it = children_.rbegin(); it != children_.rend(); ++it) {
233 bool matched = (*it)->match_parent_; 228 bool matched = (*it)->match_parent_;
234 if (!matched) { 229 if (!matched) {
235 gfx::Rect bound((*it)->origin_, (*it)->size_); 230 gfx::Rect bound((*it)->origin_, (*it)->size_);
236 matched = bound.Contains(e.GetX(), e.GetY()); 231 matched = bound.Contains(e.GetX(), e.GetY());
237 } 232 }
238 if (matched && (*it)->OnTouchEventInternal(e)) 233 if (matched && (*it)->OnTouchEventInternal(e))
239 return true; 234 return true;
240 } 235 }
241 } 236 }
242 237
243 if (client_ && client_->OnTouchEvent(event)) 238 if (client_ && client_->OnTouchEvent(event))
244 return true; 239 return true;
245 240
246 return false; 241 return false;
247 } 242 }
248 243
249 void ViewAndroid::OnBackgroundColorChanged(unsigned int color) {
250 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate());
251 if (delegate.is_null())
252 return;
253 JNIEnv* env = base::android::AttachCurrentThread();
254 Java_ViewAndroidDelegate_onBackgroundColorChanged(env,
255 delegate,
256 color);
257 }
258
259 void ViewAndroid::OnTopControlsChanged(float top_controls_offset,
260 float top_content_offset) {
261 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate());
262 if (delegate.is_null())
263 return;
264 JNIEnv* env = base::android::AttachCurrentThread();
265 Java_ViewAndroidDelegate_onTopControlsChanged(env,
266 delegate,
267 top_controls_offset,
268 top_content_offset);
269 }
270
271 void ViewAndroid::OnBottomControlsChanged(float bottom_controls_offset,
272 float bottom_content_offset) {
273 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate());
274 if (delegate.is_null())
275 return;
276 JNIEnv* env = base::android::AttachCurrentThread();
277 Java_ViewAndroidDelegate_onBottomControlsChanged(env,
278 delegate,
279 bottom_controls_offset,
280 bottom_content_offset);
281 }
282
283 void ViewAndroid::StartContentIntent(const GURL& content_url,
284 bool is_main_frame) {
285 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate());
286 if (delegate.is_null())
287 return;
288 JNIEnv* env = base::android::AttachCurrentThread();
289 ScopedJavaLocalRef<jstring> jcontent_url =
290 ConvertUTF8ToJavaString(env, content_url.spec());
291 Java_ViewAndroidDelegate_onStartContentIntent(env,
292 delegate,
293 jcontent_url,
294 is_main_frame);
295
296 }
297 } // namespace ui 244 } // namespace ui
OLDNEW
« no previous file with comments | « ui/android/view_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698