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

Side by Side Diff: content/shell/browser/shell_javascript_dialog_manager.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "content/shell/browser/shell_javascript_dialog_manager.h" 5 #include "content/shell/browser/shell_javascript_dialog_manager.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 callback)); 59 callback));
60 #else 60 #else
61 // TODO: implement ShellJavaScriptDialog for other platforms, drop this #if 61 // TODO: implement ShellJavaScriptDialog for other platforms, drop this #if
62 *did_suppress_message = true; 62 *did_suppress_message = true;
63 return; 63 return;
64 #endif 64 #endif
65 } 65 }
66 66
67 void ShellJavaScriptDialogManager::RunBeforeUnloadDialog( 67 void ShellJavaScriptDialogManager::RunBeforeUnloadDialog(
68 WebContents* web_contents, 68 WebContents* web_contents,
69 const base::string16& message_text,
70 bool is_reload, 69 bool is_reload,
71 const DialogClosedCallback& callback) { 70 const DialogClosedCallback& callback) {
72 if (!dialog_request_callback_.is_null()) { 71 if (!dialog_request_callback_.is_null()) {
73 dialog_request_callback_.Run(); 72 dialog_request_callback_.Run();
74 callback.Run(true, base::string16()); 73 callback.Run(true, base::string16());
75 dialog_request_callback_.Reset(); 74 dialog_request_callback_.Reset();
76 return; 75 return;
77 } 76 }
78 77
79 #if defined(OS_MACOSX) || defined(OS_WIN) 78 #if defined(OS_MACOSX) || defined(OS_WIN)
80 if (dialog_) { 79 if (dialog_) {
81 // Seriously!? 80 // Seriously!?
82 callback.Run(true, base::string16()); 81 callback.Run(true, base::string16());
83 return; 82 return;
84 } 83 }
85 84
86 base::string16 new_message_text = 85 base::string16 message_text =
87 message_text + 86 base::ASCIIToUTF16("Is it OK to leave/reload this page?");
88 base::ASCIIToUTF16("\n\nIs it OK to leave/reload this page?");
89 87
90 gfx::NativeWindow parent_window = web_contents->GetTopLevelNativeWindow(); 88 gfx::NativeWindow parent_window = web_contents->GetTopLevelNativeWindow();
91 89
92 dialog_.reset(new ShellJavaScriptDialog(this, 90 dialog_.reset(new ShellJavaScriptDialog(this,
93 parent_window, 91 parent_window,
94 JAVASCRIPT_MESSAGE_TYPE_CONFIRM, 92 JAVASCRIPT_MESSAGE_TYPE_CONFIRM,
95 new_message_text, 93 message_text,
96 base::string16(), // default 94 base::string16(), // default
97 callback)); 95 callback));
98 #else 96 #else
99 // TODO: implement ShellJavaScriptDialog for other platforms, drop this #if 97 // TODO: implement ShellJavaScriptDialog for other platforms, drop this #if
100 callback.Run(true, base::string16()); 98 callback.Run(true, base::string16());
101 return; 99 return;
102 #endif 100 #endif
103 } 101 }
104 102
105 void ShellJavaScriptDialogManager::CancelActiveAndPendingDialogs( 103 void ShellJavaScriptDialogManager::CancelActiveAndPendingDialogs(
(...skipping 14 matching lines...) Expand all
120 void ShellJavaScriptDialogManager::DialogClosed(ShellJavaScriptDialog* dialog) { 118 void ShellJavaScriptDialogManager::DialogClosed(ShellJavaScriptDialog* dialog) {
121 #if defined(OS_MACOSX) || defined(OS_WIN) 119 #if defined(OS_MACOSX) || defined(OS_WIN)
122 DCHECK_EQ(dialog, dialog_.get()); 120 DCHECK_EQ(dialog, dialog_.get());
123 dialog_.reset(); 121 dialog_.reset();
124 #else 122 #else
125 // TODO: implement ShellJavaScriptDialog for other platforms, drop this #if 123 // TODO: implement ShellJavaScriptDialog for other platforms, drop this #if
126 #endif 124 #endif
127 } 125 }
128 126
129 } // namespace content 127 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698