| 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 "content/shell/shell_javascript_dialog_creator.h" | 5 #include "content/shell/shell_javascript_dialog_creator.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/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 #endif | 80 #endif |
| 81 } | 81 } |
| 82 | 82 |
| 83 void ShellJavaScriptDialogCreator::RunBeforeUnloadDialog( | 83 void ShellJavaScriptDialogCreator::RunBeforeUnloadDialog( |
| 84 WebContents* web_contents, | 84 WebContents* web_contents, |
| 85 const string16& message_text, | 85 const string16& message_text, |
| 86 bool is_reload, | 86 bool is_reload, |
| 87 const DialogClosedCallback& callback) { | 87 const DialogClosedCallback& callback) { |
| 88 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) { | 88 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) { |
| 89 printf("CONFIRM NAVIGATION: %s\n", UTF16ToUTF8(message_text).c_str()); | 89 printf("CONFIRM NAVIGATION: %s\n", UTF16ToUTF8(message_text).c_str()); |
| 90 WebKitTestRunnerHost* controller = | 90 WebKitTestController* controller = WebKitTestController::Get(); |
| 91 WebKitTestRunnerHost::FromRenderViewHost( | |
| 92 web_contents->GetRenderViewHost()); | |
| 93 callback.Run( | 91 callback.Run( |
| 94 !controller->should_stay_on_page_after_handling_before_unload(), | 92 !controller->should_stay_on_page_after_handling_before_unload(), |
| 95 string16()); | 93 string16()); |
| 96 return; | 94 return; |
| 97 } | 95 } |
| 98 | 96 |
| 99 if (!dialog_request_callback_.is_null()) { | 97 if (!dialog_request_callback_.is_null()) { |
| 100 dialog_request_callback_.Run(); | 98 dialog_request_callback_.Run(); |
| 101 callback.Run(true, string16()); | 99 callback.Run(true, string16()); |
| 102 dialog_request_callback_.Reset(); | 100 dialog_request_callback_.Reset(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 void ShellJavaScriptDialogCreator::DialogClosed(ShellJavaScriptDialog* dialog) { | 143 void ShellJavaScriptDialogCreator::DialogClosed(ShellJavaScriptDialog* dialog) { |
| 146 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(TOOLKIT_GTK) | 144 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(TOOLKIT_GTK) |
| 147 DCHECK_EQ(dialog, dialog_.get()); | 145 DCHECK_EQ(dialog, dialog_.get()); |
| 148 dialog_.reset(); | 146 dialog_.reset(); |
| 149 #else | 147 #else |
| 150 // TODO: implement ShellJavaScriptDialog for other platforms, drop this #if | 148 // TODO: implement ShellJavaScriptDialog for other platforms, drop this #if |
| 151 #endif | 149 #endif |
| 152 } | 150 } |
| 153 | 151 |
| 154 } // namespace content | 152 } // namespace content |
| OLD | NEW |