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

Side by Side Diff: components/web_contents_delegate_android/web_contents_delegate_android.cc

Issue 684133007: Make WebContentsDelegateAndroid pass more calls to Java. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 | « components/web_contents_delegate_android/web_contents_delegate_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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "components/web_contents_delegate_android/web_contents_delegate_android .h" 5 #include "components/web_contents_delegate_android/web_contents_delegate_android .h"
6 6
7 #include <android/keycodes.h> 7 #include <android/keycodes.h>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/jni_array.h" 10 #include "base/android/jni_array.h"
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 } 209 }
210 210
211 void WebContentsDelegateAndroid::RendererResponsive(WebContents* source) { 211 void WebContentsDelegateAndroid::RendererResponsive(WebContents* source) {
212 JNIEnv* env = AttachCurrentThread(); 212 JNIEnv* env = AttachCurrentThread();
213 ScopedJavaLocalRef<jobject> obj = GetJavaDelegate(env); 213 ScopedJavaLocalRef<jobject> obj = GetJavaDelegate(env);
214 if (obj.is_null()) 214 if (obj.is_null())
215 return; 215 return;
216 Java_WebContentsDelegateAndroid_rendererResponsive(env, obj.obj()); 216 Java_WebContentsDelegateAndroid_rendererResponsive(env, obj.obj());
217 } 217 }
218 218
219 void WebContentsDelegateAndroid::DidNavigateToPendingEntry(
220 WebContents* source) {
221 JNIEnv* env = AttachCurrentThread();
222 ScopedJavaLocalRef<jobject> obj = GetJavaDelegate(env);
223 if (obj.is_null())
224 return;
225 Java_WebContentsDelegateAndroid_didNavigateToPendingEntry(env, obj.obj());
226 }
227
228 bool WebContentsDelegateAndroid::ShouldCreateWebContents(
229 WebContents* web_contents,
230 int route_id,
231 WindowContainerType window_container_type,
232 const base::string16& frame_name,
233 const GURL& target_url,
234 const std::string& partition_id,
235 content::SessionStorageNamespace* session_storage_namespace) {
236 JNIEnv* env = AttachCurrentThread();
237 ScopedJavaLocalRef<jobject> obj = GetJavaDelegate(env);
238 if (obj.is_null())
239 return true;
240 ScopedJavaLocalRef<jstring> java_url =
241 ConvertUTF8ToJavaString(env, target_url.spec());
242 return Java_WebContentsDelegateAndroid_shouldCreateWebContents(env, obj.obj(),
243 java_url.obj());
244 }
245
246 bool WebContentsDelegateAndroid::OnGoToEntryOffset(int offset) {
247 JNIEnv* env = AttachCurrentThread();
248 ScopedJavaLocalRef<jobject> obj = GetJavaDelegate(env);
249 if (obj.is_null())
250 return true;
251 return Java_WebContentsDelegateAndroid_onGoToEntryOffset(env, obj.obj(),
252 offset);
253 }
254
255 void WebContentsDelegateAndroid::WebContentsCreated(
256 WebContents* source_contents, int opener_render_frame_id,
257 const base::string16& frame_name, const GURL& target_url,
258 WebContents* new_contents) {
259 JNIEnv* env = AttachCurrentThread();
260 ScopedJavaLocalRef<jobject> obj = GetJavaDelegate(env);
261 if (obj.is_null())
262 return;
263 Java_WebContentsDelegateAndroid_webContentsCreated(env, obj.obj(),
264 reinterpret_cast<intptr_t>(source_contents),
265 opener_render_frame_id,
266 base::android::ConvertUTF16ToJavaString(env, frame_name).Release(),
267 base::android::ConvertUTF8ToJavaString(env, target_url.spec()).Release(),
268 reinterpret_cast<intptr_t>(new_contents));
269 }
270
219 void WebContentsDelegateAndroid::CloseContents(WebContents* source) { 271 void WebContentsDelegateAndroid::CloseContents(WebContents* source) {
220 JNIEnv* env = AttachCurrentThread(); 272 JNIEnv* env = AttachCurrentThread();
221 ScopedJavaLocalRef<jobject> obj = GetJavaDelegate(env); 273 ScopedJavaLocalRef<jobject> obj = GetJavaDelegate(env);
222 if (obj.is_null()) 274 if (obj.is_null())
223 return; 275 return;
224 Java_WebContentsDelegateAndroid_closeContents(env, obj.obj()); 276 Java_WebContentsDelegateAndroid_closeContents(env, obj.obj());
225 } 277 }
226 278
227 void WebContentsDelegateAndroid::MoveContents(WebContents* source, 279 void WebContentsDelegateAndroid::MoveContents(WebContents* source,
228 const gfx::Rect& pos) { 280 const gfx::Rect& pos) {
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 // Native JNI methods 429 // Native JNI methods
378 // ---------------------------------------------------------------------------- 430 // ----------------------------------------------------------------------------
379 431
380 // Register native methods 432 // Register native methods
381 433
382 bool RegisterWebContentsDelegateAndroid(JNIEnv* env) { 434 bool RegisterWebContentsDelegateAndroid(JNIEnv* env) {
383 return RegisterNativesImpl(env); 435 return RegisterNativesImpl(env);
384 } 436 }
385 437
386 } // namespace web_contents_delegate_android 438 } // namespace web_contents_delegate_android
OLDNEW
« no previous file with comments | « components/web_contents_delegate_android/web_contents_delegate_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698