OLD | NEW |
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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 message_text, | 97 message_text, |
98 base::string16(), // default | 98 base::string16(), // default |
99 callback)); | 99 callback)); |
100 #else | 100 #else |
101 // TODO: implement ShellJavaScriptDialog for other platforms, drop this #if | 101 // TODO: implement ShellJavaScriptDialog for other platforms, drop this #if |
102 callback.Run(true, base::string16()); | 102 callback.Run(true, base::string16()); |
103 return; | 103 return; |
104 #endif | 104 #endif |
105 } | 105 } |
106 | 106 |
107 void ShellJavaScriptDialogManager::CancelActiveAndPendingDialogs( | 107 void ShellJavaScriptDialogManager::CancelDialogs(WebContents* web_contents, |
108 WebContents* web_contents) { | 108 bool suppress_callbacks, |
| 109 bool reset_state) { |
109 #if defined(OS_MACOSX) || defined(OS_WIN) | 110 #if defined(OS_MACOSX) || defined(OS_WIN) |
110 if (dialog_) { | 111 if (dialog_) { |
111 dialog_->Cancel(); | 112 dialog_->Cancel(); |
112 dialog_.reset(); | 113 dialog_.reset(); |
113 } | 114 } |
114 #else | 115 #else |
115 // TODO: implement ShellJavaScriptDialog for other platforms, drop this #if | 116 // TODO: implement ShellJavaScriptDialog for other platforms, drop this #if |
116 #endif | 117 #endif |
117 } | |
118 | 118 |
119 void ShellJavaScriptDialogManager::ResetDialogState(WebContents* web_contents) { | |
120 if (before_unload_callback_.is_null()) | 119 if (before_unload_callback_.is_null()) |
121 return; | 120 return; |
122 before_unload_callback_.Run(false, base::string16()); | 121 |
123 before_unload_callback_.Reset(); | 122 if (reset_state) { |
| 123 before_unload_callback_.Run(false, base::string16()); |
| 124 before_unload_callback_.Reset(); |
| 125 } |
124 } | 126 } |
125 | 127 |
126 void ShellJavaScriptDialogManager::DialogClosed(ShellJavaScriptDialog* dialog) { | 128 void ShellJavaScriptDialogManager::DialogClosed(ShellJavaScriptDialog* dialog) { |
127 #if defined(OS_MACOSX) || defined(OS_WIN) | 129 #if defined(OS_MACOSX) || defined(OS_WIN) |
128 DCHECK_EQ(dialog, dialog_.get()); | 130 DCHECK_EQ(dialog, dialog_.get()); |
129 dialog_.reset(); | 131 dialog_.reset(); |
130 #else | 132 #else |
131 // TODO: implement ShellJavaScriptDialog for other platforms, drop this #if | 133 // TODO: implement ShellJavaScriptDialog for other platforms, drop this #if |
132 #endif | 134 #endif |
133 } | 135 } |
134 | 136 |
135 } // namespace content | 137 } // namespace content |
OLD | NEW |