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

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

Issue 2708703004: Reland "Refactor ContentViewClient (4/6)" (Closed)
Patch Set: rebased 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"
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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 bool ViewAndroid::StartDragAndDrop(const JavaRef<jstring>& jtext, 180 bool ViewAndroid::StartDragAndDrop(const JavaRef<jstring>& jtext,
178 const JavaRef<jobject>& jimage) { 181 const JavaRef<jobject>& jimage) {
179 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); 182 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate());
180 if (delegate.is_null()) 183 if (delegate.is_null())
181 return false; 184 return false;
182 JNIEnv* env = base::android::AttachCurrentThread(); 185 JNIEnv* env = base::android::AttachCurrentThread();
183 return Java_ViewAndroidDelegate_startDragAndDrop(env, delegate, jtext, 186 return Java_ViewAndroidDelegate_startDragAndDrop(env, delegate, jtext,
184 jimage); 187 jimage);
185 } 188 }
186 189
190 void ViewAndroid::OnBackgroundColorChanged(unsigned int color) {
191 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate());
192 if (delegate.is_null())
193 return;
194 JNIEnv* env = base::android::AttachCurrentThread();
195 Java_ViewAndroidDelegate_onBackgroundColorChanged(env, delegate, color);
196 }
197
198 void ViewAndroid::OnTopControlsChanged(float top_controls_offset,
199 float top_content_offset) {
200 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate());
201 if (delegate.is_null())
202 return;
203 JNIEnv* env = base::android::AttachCurrentThread();
204 Java_ViewAndroidDelegate_onTopControlsChanged(
205 env, delegate, top_controls_offset, top_content_offset);
206 }
207
208 void ViewAndroid::OnBottomControlsChanged(float bottom_controls_offset,
209 float bottom_content_offset) {
210 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate());
211 if (delegate.is_null())
212 return;
213 JNIEnv* env = base::android::AttachCurrentThread();
214 Java_ViewAndroidDelegate_onBottomControlsChanged(
215 env, delegate, bottom_controls_offset, bottom_content_offset);
216 }
217
218 void ViewAndroid::StartContentIntent(const GURL& content_url,
219 bool is_main_frame) {
220 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate());
221 if (delegate.is_null())
222 return;
223 JNIEnv* env = base::android::AttachCurrentThread();
224 ScopedJavaLocalRef<jstring> jcontent_url =
225 ConvertUTF8ToJavaString(env, content_url.spec());
226 Java_ViewAndroidDelegate_onStartContentIntent(env, delegate, jcontent_url,
227 is_main_frame);
228 }
229
187 } // namespace ui 230 } // 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