| 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 14 matching lines...) Expand all Loading... |
| 25 void ShellJavaScriptDialogCreator::RunJavaScriptDialog( | 25 void ShellJavaScriptDialogCreator::RunJavaScriptDialog( |
| 26 WebContents* web_contents, | 26 WebContents* web_contents, |
| 27 const GURL& origin_url, | 27 const GURL& origin_url, |
| 28 const std::string& accept_lang, | 28 const std::string& accept_lang, |
| 29 JavaScriptMessageType javascript_message_type, | 29 JavaScriptMessageType javascript_message_type, |
| 30 const string16& message_text, | 30 const string16& message_text, |
| 31 const string16& default_prompt_text, | 31 const string16& default_prompt_text, |
| 32 const DialogClosedCallback& callback, | 32 const DialogClosedCallback& callback, |
| 33 bool* did_suppress_message) { | 33 bool* did_suppress_message) { |
| 34 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) { | 34 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) { |
| 35 WebKitTestResultPrinter& printer = WebKitTestController::Get()->printer(); | 35 WebKitTestResultPrinter* printer = WebKitTestController::Get()->printer(); |
| 36 if (javascript_message_type == JAVASCRIPT_MESSAGE_TYPE_ALERT) { | 36 if (javascript_message_type == JAVASCRIPT_MESSAGE_TYPE_ALERT) { |
| 37 printer.AddMessage(std::string("ALERT: ") + UTF16ToUTF8(message_text)); | 37 printer->AddMessage(std::string("ALERT: ") + UTF16ToUTF8(message_text)); |
| 38 } else if (javascript_message_type == JAVASCRIPT_MESSAGE_TYPE_CONFIRM) { | 38 } else if (javascript_message_type == JAVASCRIPT_MESSAGE_TYPE_CONFIRM) { |
| 39 printer.AddMessage(std::string("CONFIRM: ") + UTF16ToUTF8(message_text)); | 39 printer->AddMessage(std::string("CONFIRM: ") + UTF16ToUTF8(message_text)); |
| 40 } else { // JAVASCRIPT_MESSAGE_TYPE_PROMPT | 40 } else { // JAVASCRIPT_MESSAGE_TYPE_PROMPT |
| 41 printer.AddMessage(std::string("PROMPT: ") + UTF16ToUTF8(message_text) + | 41 printer->AddMessage(std::string("PROMPT: ") + UTF16ToUTF8(message_text) + |
| 42 "default text: " + UTF16ToUTF8(default_prompt_text)); | 42 "default text: " + UTF16ToUTF8(default_prompt_text)); |
| 43 } | 43 } |
| 44 callback.Run(true, string16()); | 44 callback.Run(true, string16()); |
| 45 return; | 45 return; |
| 46 } | 46 } |
| 47 | 47 |
| 48 if (!dialog_request_callback_.is_null()) { | 48 if (!dialog_request_callback_.is_null()) { |
| 49 dialog_request_callback_.Run(); | 49 dialog_request_callback_.Run(); |
| 50 callback.Run(true, string16()); | 50 callback.Run(true, string16()); |
| 51 dialog_request_callback_.Reset(); | 51 dialog_request_callback_.Reset(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 79 return; | 79 return; |
| 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 WebKitTestResultPrinter& printer = WebKitTestController::Get()->printer(); | 89 WebKitTestResultPrinter* printer = WebKitTestController::Get()->printer(); |
| 90 printer.AddMessage( | 90 printer->AddMessage( |
| 91 std::string("CONFIRM NAVIGATION: ") + UTF16ToUTF8(message_text)); | 91 std::string("CONFIRM NAVIGATION: ") + UTF16ToUTF8(message_text)); |
| 92 WebKitTestController* controller = WebKitTestController::Get(); | 92 WebKitTestController* controller = WebKitTestController::Get(); |
| 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(); |
| (...skipping 44 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 |