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

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

Issue 2682593002: 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
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"
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::ScopedAnchorView::ScopedAnchorView( 24 ViewAndroid::ScopedAnchorView::ScopedAnchorView(
22 JNIEnv* env, 25 JNIEnv* env,
23 const JavaRef<jobject>& jview, 26 const JavaRef<jobject>& jview,
24 const JavaRef<jobject>& jdelegate) 27 const JavaRef<jobject>& jdelegate)
25 : view_(env, jview.obj()), delegate_(env, jdelegate.obj()) { 28 : view_(env, jview.obj()), delegate_(env, jdelegate.obj()) {
26 // If there's a view, then we need a delegate to remove it. 29 // If there's a view, then we need a delegate to remove it.
27 DCHECK(!jdelegate.is_null() || jview.is_null()); 30 DCHECK(!jdelegate.is_null() || jview.is_null());
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 void ViewAndroid::SetLayer(scoped_refptr<cc::Layer> layer) { 177 void ViewAndroid::SetLayer(scoped_refptr<cc::Layer> layer) {
175 layer_ = layer; 178 layer_ = layer;
176 } 179 }
177 180
178 bool ViewAndroid::StartDragAndDrop(const JavaRef<jstring>& jtext, 181 bool ViewAndroid::StartDragAndDrop(const JavaRef<jstring>& jtext,
179 const JavaRef<jobject>& jimage) { 182 const JavaRef<jobject>& jimage) {
180 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); 183 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate());
181 if (delegate.is_null()) 184 if (delegate.is_null())
182 return false; 185 return false;
183 JNIEnv* env = base::android::AttachCurrentThread(); 186 JNIEnv* env = base::android::AttachCurrentThread();
184 return Java_ViewAndroidDelegate_startDragAndDrop(env, delegate, jtext, 187 return Java_ViewAndroidDelegate_startDragAndDrop(env,
188 delegate,
189 jtext,
185 jimage); 190 jimage);
186 } 191 }
187 192
193 void ViewAndroid::OnBackgroundColorChanged(unsigned int color) {
194 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate());
195 if (delegate.is_null())
196 return;
197 JNIEnv* env = base::android::AttachCurrentThread();
198 return Java_ViewAndroidDelegate_onBackgroundColorChanged(env,
boliu 2017/02/07 21:47:06 not return for void methods
Jinsuk Kim 2017/02/07 23:51:04 Done. Interesting the compiler does't complain...
199 delegate,
200 color);
201 }
202
203 void ViewAndroid::OnTopControlsChanged(float top_controls_offset,
204 float top_content_offset) {
205 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate());
206 if (delegate.is_null())
207 return;
208 JNIEnv* env = base::android::AttachCurrentThread();
209 return Java_ViewAndroidDelegate_onTopControlsChanged(env,
210 delegate,
211 top_controls_offset,
212 top_content_offset);
213 }
214
215 void ViewAndroid::OnBottomControlsChanged(float bottom_controls_offset,
216 float bottom_content_offset) {
217 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate());
218 if (delegate.is_null())
219 return;
220 JNIEnv* env = base::android::AttachCurrentThread();
221 return Java_ViewAndroidDelegate_onBottomControlsChanged(
222 env,
223 delegate,
224 bottom_controls_offset,
225 bottom_content_offset);
226 }
227
228 void ViewAndroid::StartContentIntent(const GURL& content_url,
229 bool is_main_frame) {
230 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate());
231 if (delegate.is_null())
232 return;
233 JNIEnv* env = base::android::AttachCurrentThread();
234 ScopedJavaLocalRef<jstring> jcontent_url =
235 ConvertUTF8ToJavaString(env, content_url.spec());
236 return Java_ViewAndroidDelegate_onStartContentIntent(env,
237 delegate,
238 jcontent_url,
239 is_main_frame);
240
241 }
188 } // namespace ui 242 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698