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

Side by Side Diff: android_webview/native/aw_contents_client_bridge.cc

Issue 1714573002: Remove the ability of webpages to specify strings for the onbeforeunload dialog. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase again Created 4 years, 9 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 (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 "android_webview/common/devtools_instrumentation.h" 7 #include "android_webview/common/devtools_instrumentation.h"
8 #include "android_webview/native/aw_contents.h" 8 #include "android_webview/native/aw_contents.h"
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"
11 #include "base/android/jni_string.h" 11 #include "base/android/jni_string.h"
12 #include "base/callback_helpers.h" 12 #include "base/callback_helpers.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
15 #include "content/public/browser/client_certificate_delegate.h" 15 #include "content/public/browser/client_certificate_delegate.h"
16 #include "content/public/browser/render_process_host.h" 16 #include "content/public/browser/render_process_host.h"
17 #include "content/public/browser/render_view_host.h" 17 #include "content/public/browser/render_view_host.h"
18 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
19 #include "crypto/scoped_openssl_types.h" 19 #include "crypto/scoped_openssl_types.h"
20 #include "grit/components_strings.h"
20 #include "jni/AwContentsClientBridge_jni.h" 21 #include "jni/AwContentsClientBridge_jni.h"
21 #include "net/android/keystore_openssl.h" 22 #include "net/android/keystore_openssl.h"
22 #include "net/cert/x509_certificate.h" 23 #include "net/cert/x509_certificate.h"
23 #include "net/ssl/openssl_client_key_store.h" 24 #include "net/ssl/openssl_client_key_store.h"
24 #include "net/ssl/ssl_cert_request_info.h" 25 #include "net/ssl/ssl_cert_request_info.h"
25 #include "net/ssl/ssl_client_cert_type.h" 26 #include "net/ssl/ssl_client_cert_type.h"
27 #include "ui/base/l10n/l10n_util.h"
26 #include "url/gurl.h" 28 #include "url/gurl.h"
27 29
28 using base::android::AttachCurrentThread; 30 using base::android::AttachCurrentThread;
29 using base::android::ConvertJavaStringToUTF16; 31 using base::android::ConvertJavaStringToUTF16;
30 using base::android::ConvertUTF8ToJavaString; 32 using base::android::ConvertUTF8ToJavaString;
31 using base::android::ConvertUTF16ToJavaString; 33 using base::android::ConvertUTF16ToJavaString;
32 using base::android::JavaRef; 34 using base::android::JavaRef;
33 using base::android::ScopedJavaLocalRef; 35 using base::android::ScopedJavaLocalRef;
34 using content::BrowserThread; 36 using content::BrowserThread;
35 37
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 callback_id); 313 callback_id);
312 break; 314 break;
313 } 315 }
314 default: 316 default:
315 NOTREACHED(); 317 NOTREACHED();
316 } 318 }
317 } 319 }
318 320
319 void AwContentsClientBridge::RunBeforeUnloadDialog( 321 void AwContentsClientBridge::RunBeforeUnloadDialog(
320 const GURL& origin_url, 322 const GURL& origin_url,
321 const base::string16& message_text,
322 const content::JavaScriptDialogManager::DialogClosedCallback& callback) { 323 const content::JavaScriptDialogManager::DialogClosedCallback& callback) {
323 DCHECK_CURRENTLY_ON(BrowserThread::UI); 324 DCHECK_CURRENTLY_ON(BrowserThread::UI);
324 JNIEnv* env = AttachCurrentThread(); 325 JNIEnv* env = AttachCurrentThread();
325 326
326 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); 327 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
327 if (obj.is_null()) { 328 if (obj.is_null()) {
328 callback.Run(false, base::string16()); 329 callback.Run(false, base::string16());
329 return; 330 return;
330 } 331 }
331 332
333 const base::string16 message_text =
334 l10n_util::GetStringUTF16(IDS_BEFOREUNLOAD_MESSAGEBOX_MESSAGE);
335
332 int callback_id = pending_js_dialog_callbacks_.Add( 336 int callback_id = pending_js_dialog_callbacks_.Add(
333 new content::JavaScriptDialogManager::DialogClosedCallback(callback)); 337 new content::JavaScriptDialogManager::DialogClosedCallback(callback));
334 ScopedJavaLocalRef<jstring> jurl( 338 ScopedJavaLocalRef<jstring> jurl(
335 ConvertUTF8ToJavaString(env, origin_url.spec())); 339 ConvertUTF8ToJavaString(env, origin_url.spec()));
336 ScopedJavaLocalRef<jstring> jmessage( 340 ScopedJavaLocalRef<jstring> jmessage(
337 ConvertUTF16ToJavaString(env, message_text)); 341 ConvertUTF16ToJavaString(env, message_text));
338 342
339 devtools_instrumentation::ScopedEmbedderCallbackTask("onJsBeforeUnload"); 343 devtools_instrumentation::ScopedEmbedderCallbackTask("onJsBeforeUnload");
340 Java_AwContentsClientBridge_handleJsBeforeUnload( 344 Java_AwContentsClientBridge_handleJsBeforeUnload(
341 env, obj.obj(), jurl.obj(), jmessage.obj(), callback_id); 345 env, obj.obj(), jurl.obj(), jmessage.obj(), callback_id);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 pending_client_cert_request_delegates_.Remove(request_id); 401 pending_client_cert_request_delegates_.Remove(request_id);
398 402
399 delete delegate; 403 delete delegate;
400 } 404 }
401 405
402 bool RegisterAwContentsClientBridge(JNIEnv* env) { 406 bool RegisterAwContentsClientBridge(JNIEnv* env) {
403 return RegisterNativesImpl(env); 407 return RegisterNativesImpl(env);
404 } 408 }
405 409
406 } // namespace android_webview 410 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/native/aw_contents_client_bridge.h ('k') | android_webview/native/webview_native.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698