| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "android_webview/native/aw_contents_client_bridge.h" | 5 #include "android_webview/native/aw_contents_client_bridge.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 LOG(WARNING) << "Ignoring unexpected ssl error proceed callback"; | 83 LOG(WARNING) << "Ignoring unexpected ssl error proceed callback"; |
| 84 return; | 84 return; |
| 85 } | 85 } |
| 86 callback->Run(proceed); | 86 callback->Run(proceed); |
| 87 pending_cert_error_callbacks_.Remove(id); | 87 pending_cert_error_callbacks_.Remove(id); |
| 88 } | 88 } |
| 89 | 89 |
| 90 void AwContentsClientBridge::RunJavaScriptDialog( | 90 void AwContentsClientBridge::RunJavaScriptDialog( |
| 91 content::JavaScriptMessageType message_type, | 91 content::JavaScriptMessageType message_type, |
| 92 const GURL& origin_url, | 92 const GURL& origin_url, |
| 93 const string16& message_text, | 93 const base::string16& message_text, |
| 94 const string16& default_prompt_text, | 94 const base::string16& default_prompt_text, |
| 95 const content::JavaScriptDialogManager::DialogClosedCallback& callback) { | 95 const content::JavaScriptDialogManager::DialogClosedCallback& callback) { |
| 96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 97 JNIEnv* env = AttachCurrentThread(); | 97 JNIEnv* env = AttachCurrentThread(); |
| 98 | 98 |
| 99 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 99 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 100 if (obj.is_null()) | 100 if (obj.is_null()) |
| 101 return; | 101 return; |
| 102 | 102 |
| 103 int callback_id = pending_js_dialog_callbacks_.Add( | 103 int callback_id = pending_js_dialog_callbacks_.Add( |
| 104 new content::JavaScriptDialogManager::DialogClosedCallback(callback)); | 104 new content::JavaScriptDialogManager::DialogClosedCallback(callback)); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 127 callback_id); | 127 callback_id); |
| 128 break; | 128 break; |
| 129 } | 129 } |
| 130 default: | 130 default: |
| 131 NOTREACHED(); | 131 NOTREACHED(); |
| 132 } | 132 } |
| 133 } | 133 } |
| 134 | 134 |
| 135 void AwContentsClientBridge::RunBeforeUnloadDialog( | 135 void AwContentsClientBridge::RunBeforeUnloadDialog( |
| 136 const GURL& origin_url, | 136 const GURL& origin_url, |
| 137 const string16& message_text, | 137 const base::string16& message_text, |
| 138 const content::JavaScriptDialogManager::DialogClosedCallback& callback) { | 138 const content::JavaScriptDialogManager::DialogClosedCallback& callback) { |
| 139 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 139 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 140 JNIEnv* env = AttachCurrentThread(); | 140 JNIEnv* env = AttachCurrentThread(); |
| 141 | 141 |
| 142 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 142 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 143 if (obj.is_null()) | 143 if (obj.is_null()) |
| 144 return; | 144 return; |
| 145 | 145 |
| 146 int callback_id = pending_js_dialog_callbacks_.Add( | 146 int callback_id = pending_js_dialog_callbacks_.Add( |
| 147 new content::JavaScriptDialogManager::DialogClosedCallback(callback)); | 147 new content::JavaScriptDialogManager::DialogClosedCallback(callback)); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 170 jobject, | 170 jobject, |
| 171 int id, | 171 int id, |
| 172 jstring prompt) { | 172 jstring prompt) { |
| 173 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 173 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 174 content::JavaScriptDialogManager::DialogClosedCallback* callback = | 174 content::JavaScriptDialogManager::DialogClosedCallback* callback = |
| 175 pending_js_dialog_callbacks_.Lookup(id); | 175 pending_js_dialog_callbacks_.Lookup(id); |
| 176 if (!callback) { | 176 if (!callback) { |
| 177 LOG(WARNING) << "Unexpected JS dialog confirm. " << id; | 177 LOG(WARNING) << "Unexpected JS dialog confirm. " << id; |
| 178 return; | 178 return; |
| 179 } | 179 } |
| 180 string16 prompt_text; | 180 base::string16 prompt_text; |
| 181 if (prompt) { | 181 if (prompt) { |
| 182 prompt_text = ConvertJavaStringToUTF16(env, prompt); | 182 prompt_text = ConvertJavaStringToUTF16(env, prompt); |
| 183 } | 183 } |
| 184 callback->Run(true, prompt_text); | 184 callback->Run(true, prompt_text); |
| 185 pending_js_dialog_callbacks_.Remove(id); | 185 pending_js_dialog_callbacks_.Remove(id); |
| 186 } | 186 } |
| 187 | 187 |
| 188 void AwContentsClientBridge::CancelJsResult(JNIEnv*, jobject, int id) { | 188 void AwContentsClientBridge::CancelJsResult(JNIEnv*, jobject, int id) { |
| 189 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 189 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 190 content::JavaScriptDialogManager::DialogClosedCallback* callback = | 190 content::JavaScriptDialogManager::DialogClosedCallback* callback = |
| 191 pending_js_dialog_callbacks_.Lookup(id); | 191 pending_js_dialog_callbacks_.Lookup(id); |
| 192 if (!callback) { | 192 if (!callback) { |
| 193 LOG(WARNING) << "Unexpected JS dialog cancel. " << id; | 193 LOG(WARNING) << "Unexpected JS dialog cancel. " << id; |
| 194 return; | 194 return; |
| 195 } | 195 } |
| 196 callback->Run(false, string16()); | 196 callback->Run(false, base::string16()); |
| 197 pending_js_dialog_callbacks_.Remove(id); | 197 pending_js_dialog_callbacks_.Remove(id); |
| 198 } | 198 } |
| 199 | 199 |
| 200 bool RegisterAwContentsClientBridge(JNIEnv* env) { | 200 bool RegisterAwContentsClientBridge(JNIEnv* env) { |
| 201 return RegisterNativesImpl(env) >= 0; | 201 return RegisterNativesImpl(env) >= 0; |
| 202 } | 202 } |
| 203 | 203 |
| 204 } // namespace android_webview | 204 } // namespace android_webview |
| OLD | NEW |