| 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 "components/url_formatter/url_formatter.h" | |
| 11 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
| 12 #include "content/shell/browser/blink_test_controller.h" | 11 #include "content/shell/browser/blink_test_controller.h" |
| 13 #include "content/shell/browser/shell_javascript_dialog.h" | 12 #include "content/shell/browser/shell_javascript_dialog.h" |
| 14 #include "content/shell/common/shell_switches.h" | 13 #include "content/shell/common/shell_switches.h" |
| 14 #include "net/base/net_util.h" |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 | 17 |
| 18 ShellJavaScriptDialogManager::ShellJavaScriptDialogManager() { | 18 ShellJavaScriptDialogManager::ShellJavaScriptDialogManager() { |
| 19 } | 19 } |
| 20 | 20 |
| 21 ShellJavaScriptDialogManager::~ShellJavaScriptDialogManager() { | 21 ShellJavaScriptDialogManager::~ShellJavaScriptDialogManager() { |
| 22 } | 22 } |
| 23 | 23 |
| 24 void ShellJavaScriptDialogManager::RunJavaScriptDialog( | 24 void ShellJavaScriptDialogManager::RunJavaScriptDialog( |
| (...skipping 14 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 #if defined(OS_MACOSX) || defined(OS_WIN) | 40 #if defined(OS_MACOSX) || defined(OS_WIN) |
| 41 *did_suppress_message = false; | 41 *did_suppress_message = false; |
| 42 | 42 |
| 43 if (dialog_) { | 43 if (dialog_) { |
| 44 // One dialog at a time, please. | 44 // One dialog at a time, please. |
| 45 *did_suppress_message = true; | 45 *did_suppress_message = true; |
| 46 return; | 46 return; |
| 47 } | 47 } |
| 48 | 48 |
| 49 base::string16 new_message_text = | 49 base::string16 new_message_text = net::FormatUrl(origin_url, accept_lang) + |
| 50 url_formatter::FormatUrl(origin_url, accept_lang) + | 50 base::ASCIIToUTF16("\n\n") + |
| 51 base::ASCIIToUTF16("\n\n") + message_text; | 51 message_text; |
| 52 gfx::NativeWindow parent_window = web_contents->GetTopLevelNativeWindow(); | 52 gfx::NativeWindow parent_window = web_contents->GetTopLevelNativeWindow(); |
| 53 | 53 |
| 54 dialog_.reset(new ShellJavaScriptDialog(this, | 54 dialog_.reset(new ShellJavaScriptDialog(this, |
| 55 parent_window, | 55 parent_window, |
| 56 javascript_message_type, | 56 javascript_message_type, |
| 57 new_message_text, | 57 new_message_text, |
| 58 default_prompt_text, | 58 default_prompt_text, |
| 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 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 void ShellJavaScriptDialogManager::DialogClosed(ShellJavaScriptDialog* dialog) { | 120 void ShellJavaScriptDialogManager::DialogClosed(ShellJavaScriptDialog* dialog) { |
| 121 #if defined(OS_MACOSX) || defined(OS_WIN) | 121 #if defined(OS_MACOSX) || defined(OS_WIN) |
| 122 DCHECK_EQ(dialog, dialog_.get()); | 122 DCHECK_EQ(dialog, dialog_.get()); |
| 123 dialog_.reset(); | 123 dialog_.reset(); |
| 124 #else | 124 #else |
| 125 // TODO: implement ShellJavaScriptDialog for other platforms, drop this #if | 125 // TODO: implement ShellJavaScriptDialog for other platforms, drop this #if |
| 126 #endif | 126 #endif |
| 127 } | 127 } |
| 128 | 128 |
| 129 } // namespace content | 129 } // namespace content |
| OLD | NEW |