OLD | NEW |
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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 JNIEnv* env = AttachCurrentThread(); | 117 JNIEnv* env = AttachCurrentThread(); |
118 ScopedJavaLocalRef<jobject> obj = GetJavaDelegate(env); | 118 ScopedJavaLocalRef<jobject> obj = GetJavaDelegate(env); |
119 if (obj.is_null()) | 119 if (obj.is_null()) |
120 return; | 120 return; |
121 Java_WebContentsDelegateAndroid_navigationStateChanged( | 121 Java_WebContentsDelegateAndroid_navigationStateChanged( |
122 env, | 122 env, |
123 obj.obj(), | 123 obj.obj(), |
124 changed_flags); | 124 changed_flags); |
125 } | 125 } |
126 | 126 |
127 void WebContentsDelegateAndroid::AddNewContents( | |
128 WebContents* source, | |
129 WebContents* new_contents, | |
130 WindowOpenDisposition disposition, | |
131 const gfx::Rect& initial_pos, | |
132 bool user_gesture, | |
133 bool* was_blocked) { | |
134 JNIEnv* env = AttachCurrentThread(); | |
135 ScopedJavaLocalRef<jobject> obj = GetJavaDelegate(env); | |
136 bool handled = false; | |
137 if (!obj.is_null()) { | |
138 handled = Java_WebContentsDelegateAndroid_addNewContents( | |
139 env, | |
140 obj.obj(), | |
141 reinterpret_cast<jint>(source), | |
142 reinterpret_cast<jint>(new_contents), | |
143 static_cast<jint>(disposition), | |
144 NULL, | |
145 user_gesture); | |
146 } | |
147 if (!handled) | |
148 delete new_contents; | |
149 } | |
150 | |
151 void WebContentsDelegateAndroid::ActivateContents(WebContents* contents) { | 127 void WebContentsDelegateAndroid::ActivateContents(WebContents* contents) { |
152 JNIEnv* env = AttachCurrentThread(); | 128 JNIEnv* env = AttachCurrentThread(); |
153 ScopedJavaLocalRef<jobject> obj = GetJavaDelegate(env); | 129 ScopedJavaLocalRef<jobject> obj = GetJavaDelegate(env); |
154 if (obj.is_null()) | 130 if (obj.is_null()) |
155 return; | 131 return; |
156 Java_WebContentsDelegateAndroid_activateContents(env, obj.obj()); | 132 Java_WebContentsDelegateAndroid_activateContents(env, obj.obj()); |
157 } | 133 } |
158 | 134 |
159 void WebContentsDelegateAndroid::DeactivateContents(WebContents* contents) { | 135 void WebContentsDelegateAndroid::DeactivateContents(WebContents* contents) { |
160 // On desktop the current window is deactivated here, bringing the next window | 136 // On desktop the current window is deactivated here, bringing the next window |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 | 328 |
353 bool RegisterWebContentsDelegateAndroid(JNIEnv* env) { | 329 bool RegisterWebContentsDelegateAndroid(JNIEnv* env) { |
354 if (!HasClass(env, kWebContentsDelegateAndroidClassPath)) { | 330 if (!HasClass(env, kWebContentsDelegateAndroidClassPath)) { |
355 DLOG(ERROR) << "Unable to find class WebContentsDelegateAndroid!"; | 331 DLOG(ERROR) << "Unable to find class WebContentsDelegateAndroid!"; |
356 return false; | 332 return false; |
357 } | 333 } |
358 return RegisterNativesImpl(env); | 334 return RegisterNativesImpl(env); |
359 } | 335 } |
360 | 336 |
361 } // namespace web_contents_delegate_android | 337 } // namespace web_contents_delegate_android |
OLD | NEW |