Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(476)

Side by Side Diff: content/shell/browser/shell_javascript_dialog_manager.cc

Issue 102593002: Convert string16 to base::string16 in content. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "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/browser/shell_javascript_dialog.h" 12 #include "content/shell/browser/shell_javascript_dialog.h"
13 #include "content/shell/browser/webkit_test_controller.h" 13 #include "content/shell/browser/webkit_test_controller.h"
14 #include "content/shell/common/shell_switches.h" 14 #include "content/shell/common/shell_switches.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 ShellJavaScriptDialogManager::ShellJavaScriptDialogManager() { 19 ShellJavaScriptDialogManager::ShellJavaScriptDialogManager() {
20 } 20 }
21 21
22 ShellJavaScriptDialogManager::~ShellJavaScriptDialogManager() { 22 ShellJavaScriptDialogManager::~ShellJavaScriptDialogManager() {
23 } 23 }
24 24
25 void ShellJavaScriptDialogManager::RunJavaScriptDialog( 25 void ShellJavaScriptDialogManager::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 base::string16& message_text,
31 const string16& default_prompt_text, 31 const base::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 callback.Run(true, string16()); 35 callback.Run(true, base::string16());
36 return; 36 return;
37 } 37 }
38 38
39 if (!dialog_request_callback_.is_null()) { 39 if (!dialog_request_callback_.is_null()) {
40 dialog_request_callback_.Run(); 40 dialog_request_callback_.Run();
41 callback.Run(true, string16()); 41 callback.Run(true, base::string16());
42 dialog_request_callback_.Reset(); 42 dialog_request_callback_.Reset();
43 return; 43 return;
44 } 44 }
45 45
46 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(TOOLKIT_GTK) 46 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(TOOLKIT_GTK)
47 *did_suppress_message = false; 47 *did_suppress_message = false;
48 48
49 if (dialog_) { 49 if (dialog_) {
50 // One dialog at a time, please. 50 // One dialog at a time, please.
51 *did_suppress_message = true; 51 *did_suppress_message = true;
52 return; 52 return;
53 } 53 }
54 54
55 string16 new_message_text = net::FormatUrl(origin_url, accept_lang) + 55 base::string16 new_message_text = net::FormatUrl(origin_url, accept_lang) +
56 ASCIIToUTF16("\n\n") + 56 ASCIIToUTF16("\n\n") +
57 message_text; 57 message_text;
58 gfx::NativeWindow parent_window = 58 gfx::NativeWindow parent_window =
59 web_contents->GetView()->GetTopLevelNativeWindow(); 59 web_contents->GetView()->GetTopLevelNativeWindow();
60 60
61 dialog_.reset(new ShellJavaScriptDialog(this, 61 dialog_.reset(new ShellJavaScriptDialog(this,
62 parent_window, 62 parent_window,
63 javascript_message_type, 63 javascript_message_type,
64 new_message_text, 64 new_message_text,
65 default_prompt_text, 65 default_prompt_text,
66 callback)); 66 callback));
67 #else 67 #else
68 // TODO: implement ShellJavaScriptDialog for other platforms, drop this #if 68 // TODO: implement ShellJavaScriptDialog for other platforms, drop this #if
69 *did_suppress_message = true; 69 *did_suppress_message = true;
70 return; 70 return;
71 #endif 71 #endif
72 } 72 }
73 73
74 void ShellJavaScriptDialogManager::RunBeforeUnloadDialog( 74 void ShellJavaScriptDialogManager::RunBeforeUnloadDialog(
75 WebContents* web_contents, 75 WebContents* web_contents,
76 const string16& message_text, 76 const base::string16& message_text,
77 bool is_reload, 77 bool is_reload,
78 const DialogClosedCallback& callback) { 78 const DialogClosedCallback& callback) {
79 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) { 79 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) {
80 callback.Run(true, string16()); 80 callback.Run(true, base::string16());
81 return; 81 return;
82 } 82 }
83 83
84 if (!dialog_request_callback_.is_null()) { 84 if (!dialog_request_callback_.is_null()) {
85 dialog_request_callback_.Run(); 85 dialog_request_callback_.Run();
86 callback.Run(true, string16()); 86 callback.Run(true, base::string16());
87 dialog_request_callback_.Reset(); 87 dialog_request_callback_.Reset();
88 return; 88 return;
89 } 89 }
90 90
91 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(TOOLKIT_GTK) 91 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(TOOLKIT_GTK)
92 if (dialog_) { 92 if (dialog_) {
93 // Seriously!? 93 // Seriously!?
94 callback.Run(true, string16()); 94 callback.Run(true, base::string16());
95 return; 95 return;
96 } 96 }
97 97
98 string16 new_message_text = 98 base::string16 new_message_text =
99 message_text + 99 message_text +
100 ASCIIToUTF16("\n\nIs it OK to leave/reload this page?"); 100 ASCIIToUTF16("\n\nIs it OK to leave/reload this page?");
101 101
102 gfx::NativeWindow parent_window = 102 gfx::NativeWindow parent_window =
103 web_contents->GetView()->GetTopLevelNativeWindow(); 103 web_contents->GetView()->GetTopLevelNativeWindow();
104 104
105 dialog_.reset(new ShellJavaScriptDialog(this, 105 dialog_.reset(new ShellJavaScriptDialog(this,
106 parent_window, 106 parent_window,
107 JAVASCRIPT_MESSAGE_TYPE_CONFIRM, 107 JAVASCRIPT_MESSAGE_TYPE_CONFIRM,
108 new_message_text, 108 new_message_text,
109 string16(), // default_prompt_text 109 base::string16(), // default
110 callback)); 110 callback));
111 #else 111 #else
112 // TODO: implement ShellJavaScriptDialog for other platforms, drop this #if 112 // TODO: implement ShellJavaScriptDialog for other platforms, drop this #if
113 callback.Run(true, string16()); 113 callback.Run(true, base::string16());
114 return; 114 return;
115 #endif 115 #endif
116 } 116 }
117 117
118 void ShellJavaScriptDialogManager::CancelActiveAndPendingDialogs( 118 void ShellJavaScriptDialogManager::CancelActiveAndPendingDialogs(
119 WebContents* web_contents) { 119 WebContents* web_contents) {
120 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(TOOLKIT_GTK) 120 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(TOOLKIT_GTK)
121 if (dialog_) { 121 if (dialog_) {
122 dialog_->Cancel(); 122 dialog_->Cancel();
123 dialog_.reset(); 123 dialog_.reset();
(...skipping 10 matching lines...) Expand all
134 void ShellJavaScriptDialogManager::DialogClosed(ShellJavaScriptDialog* dialog) { 134 void ShellJavaScriptDialogManager::DialogClosed(ShellJavaScriptDialog* dialog) {
135 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(TOOLKIT_GTK) 135 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(TOOLKIT_GTK)
136 DCHECK_EQ(dialog, dialog_.get()); 136 DCHECK_EQ(dialog, dialog_.get());
137 dialog_.reset(); 137 dialog_.reset();
138 #else 138 #else
139 // TODO: implement ShellJavaScriptDialog for other platforms, drop this #if 139 // TODO: implement ShellJavaScriptDialog for other platforms, drop this #if
140 #endif 140 #endif
141 } 141 }
142 142
143 } // namespace content 143 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/browser/shell_javascript_dialog_manager.h ('k') | content/shell/browser/shell_javascript_dialog_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698