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" |
11 #include "content/public/browser/web_contents_view.h" | 11 #include "content/public/browser/web_contents_view.h" |
12 #include "content/shell/layout_test_controller_host.h" | |
13 #include "content/shell/shell_javascript_dialog.h" | 12 #include "content/shell/shell_javascript_dialog.h" |
14 #include "content/shell/shell_switches.h" | 13 #include "content/shell/shell_switches.h" |
| 14 #include "content/shell/webkit_test_runner_host.h" |
15 #include "net/base/net_util.h" | 15 #include "net/base/net_util.h" |
16 | 16 |
17 namespace content { | 17 namespace content { |
18 | 18 |
19 ShellJavaScriptDialogCreator::ShellJavaScriptDialogCreator() { | 19 ShellJavaScriptDialogCreator::ShellJavaScriptDialogCreator() { |
20 } | 20 } |
21 | 21 |
22 ShellJavaScriptDialogCreator::~ShellJavaScriptDialogCreator() { | 22 ShellJavaScriptDialogCreator::~ShellJavaScriptDialogCreator() { |
23 } | 23 } |
24 | 24 |
(...skipping 55 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 LayoutTestControllerHost* controller = | 90 WebKitTestRunnerHost* controller = |
91 LayoutTestControllerHost::FromRenderViewHost( | 91 WebKitTestRunnerHost::FromRenderViewHost( |
92 web_contents->GetRenderViewHost()); | 92 web_contents->GetRenderViewHost()); |
93 callback.Run( | 93 callback.Run( |
94 !controller->should_stay_on_page_after_handling_before_unload(), | 94 !controller->should_stay_on_page_after_handling_before_unload(), |
95 string16()); | 95 string16()); |
96 return; | 96 return; |
97 } | 97 } |
98 | 98 |
99 if (!dialog_request_callback_.is_null()) { | 99 if (!dialog_request_callback_.is_null()) { |
100 dialog_request_callback_.Run(); | 100 dialog_request_callback_.Run(); |
101 callback.Run(true, string16()); | 101 callback.Run(true, string16()); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 void ShellJavaScriptDialogCreator::DialogClosed(ShellJavaScriptDialog* dialog) { | 145 void ShellJavaScriptDialogCreator::DialogClosed(ShellJavaScriptDialog* dialog) { |
146 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(TOOLKIT_GTK) | 146 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(TOOLKIT_GTK) |
147 DCHECK_EQ(dialog, dialog_.get()); | 147 DCHECK_EQ(dialog, dialog_.get()); |
148 dialog_.reset(); | 148 dialog_.reset(); |
149 #else | 149 #else |
150 // TODO: implement ShellJavaScriptDialog for other platforms, drop this #if | 150 // TODO: implement ShellJavaScriptDialog for other platforms, drop this #if |
151 #endif | 151 #endif |
152 } | 152 } |
153 | 153 |
154 } // namespace content | 154 } // namespace content |
OLD | NEW |