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

Side by Side Diff: content/browser/webui/web_ui_impl.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
« no previous file with comments | « content/browser/webui/web_ui_impl.h ('k') | content/browser/webui/web_ui_message_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/browser/webui/web_ui_impl.h" 5 #include "content/browser/webui/web_ui_impl.h"
6 6
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "content/browser/child_process_security_policy_impl.h" 10 #include "content/browser/child_process_security_policy_impl.h"
11 #include "content/browser/renderer_host/dip_util.h" 11 #include "content/browser/renderer_host/dip_util.h"
12 #include "content/browser/renderer_host/render_process_host_impl.h" 12 #include "content/browser/renderer_host/render_process_host_impl.h"
13 #include "content/browser/renderer_host/render_view_host_impl.h" 13 #include "content/browser/renderer_host/render_view_host_impl.h"
14 #include "content/browser/web_contents/web_contents_impl.h" 14 #include "content/browser/web_contents/web_contents_impl.h"
15 #include "content/browser/webui/web_ui_controller_factory_registry.h" 15 #include "content/browser/webui/web_ui_controller_factory_registry.h"
16 #include "content/common/view_messages.h" 16 #include "content/common/view_messages.h"
17 #include "content/public/browser/content_browser_client.h" 17 #include "content/public/browser/content_browser_client.h"
18 #include "content/public/browser/web_contents_delegate.h" 18 #include "content/public/browser/web_contents_delegate.h"
19 #include "content/public/browser/web_contents_view.h" 19 #include "content/public/browser/web_contents_view.h"
20 #include "content/public/browser/web_ui_controller.h" 20 #include "content/public/browser/web_ui_controller.h"
21 #include "content/public/browser/web_ui_message_handler.h" 21 #include "content/public/browser/web_ui_message_handler.h"
22 #include "content/public/common/bindings_policy.h" 22 #include "content/public/common/bindings_policy.h"
23 #include "content/public/common/content_client.h" 23 #include "content/public/common/content_client.h"
24 24
25 namespace content { 25 namespace content {
26 26
27 const WebUI::TypeID WebUI::kNoWebUI = NULL; 27 const WebUI::TypeID WebUI::kNoWebUI = NULL;
28 28
29 // static 29 // static
30 string16 WebUI::GetJavascriptCall( 30 base::string16 WebUI::GetJavascriptCall(
31 const std::string& function_name, 31 const std::string& function_name,
32 const std::vector<const Value*>& arg_list) { 32 const std::vector<const Value*>& arg_list) {
33 string16 parameters; 33 base::string16 parameters;
34 std::string json; 34 std::string json;
35 for (size_t i = 0; i < arg_list.size(); ++i) { 35 for (size_t i = 0; i < arg_list.size(); ++i) {
36 if (i > 0) 36 if (i > 0)
37 parameters += char16(','); 37 parameters += char16(',');
38 38
39 base::JSONWriter::Write(arg_list[i], &json); 39 base::JSONWriter::Write(arg_list[i], &json);
40 parameters += UTF8ToUTF16(json); 40 parameters += UTF8ToUTF16(json);
41 } 41 }
42 return ASCIIToUTF16(function_name) + 42 return ASCIIToUTF16(function_name) +
43 char16('(') + parameters + char16(')') + char16(';'); 43 char16('(') + parameters + char16(')') + char16(';');
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 } 99 }
100 100
101 WebContents* WebUIImpl::GetWebContents() const { 101 WebContents* WebUIImpl::GetWebContents() const {
102 return web_contents_; 102 return web_contents_;
103 } 103 }
104 104
105 ui::ScaleFactor WebUIImpl::GetDeviceScaleFactor() const { 105 ui::ScaleFactor WebUIImpl::GetDeviceScaleFactor() const {
106 return GetScaleFactorForView(web_contents_->GetRenderWidgetHostView()); 106 return GetScaleFactorForView(web_contents_->GetRenderWidgetHostView());
107 } 107 }
108 108
109 const string16& WebUIImpl::GetOverriddenTitle() const { 109 const base::string16& WebUIImpl::GetOverriddenTitle() const {
110 return overridden_title_; 110 return overridden_title_;
111 } 111 }
112 112
113 void WebUIImpl::OverrideTitle(const string16& title) { 113 void WebUIImpl::OverrideTitle(const base::string16& title) {
114 overridden_title_ = title; 114 overridden_title_ = title;
115 } 115 }
116 116
117 PageTransition WebUIImpl::GetLinkTransitionType() const { 117 PageTransition WebUIImpl::GetLinkTransitionType() const {
118 return link_transition_type_; 118 return link_transition_type_;
119 } 119 }
120 120
121 void WebUIImpl::SetLinkTransitionType(PageTransition type) { 121 void WebUIImpl::SetLinkTransitionType(PageTransition type) {
122 link_transition_type_ = type; 122 link_transition_type_ = type;
123 } 123 }
(...skipping 13 matching lines...) Expand all
137 WebUIController* WebUIImpl::GetController() const { 137 WebUIController* WebUIImpl::GetController() const {
138 return controller_.get(); 138 return controller_.get();
139 } 139 }
140 140
141 void WebUIImpl::SetController(WebUIController* controller) { 141 void WebUIImpl::SetController(WebUIController* controller) {
142 controller_.reset(controller); 142 controller_.reset(controller);
143 } 143 }
144 144
145 void WebUIImpl::CallJavascriptFunction(const std::string& function_name) { 145 void WebUIImpl::CallJavascriptFunction(const std::string& function_name) {
146 DCHECK(IsStringASCII(function_name)); 146 DCHECK(IsStringASCII(function_name));
147 string16 javascript = ASCIIToUTF16(function_name + "();"); 147 base::string16 javascript = ASCIIToUTF16(function_name + "();");
148 ExecuteJavascript(javascript); 148 ExecuteJavascript(javascript);
149 } 149 }
150 150
151 void WebUIImpl::CallJavascriptFunction(const std::string& function_name, 151 void WebUIImpl::CallJavascriptFunction(const std::string& function_name,
152 const Value& arg) { 152 const Value& arg) {
153 DCHECK(IsStringASCII(function_name)); 153 DCHECK(IsStringASCII(function_name));
154 std::vector<const Value*> args; 154 std::vector<const Value*> args;
155 args.push_back(&arg); 155 args.push_back(&arg);
156 ExecuteJavascript(GetJavascriptCall(function_name, args)); 156 ExecuteJavascript(GetJavascriptCall(function_name, args));
157 } 157 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 223
224 // WebUIImpl, protected: ------------------------------------------------------- 224 // WebUIImpl, protected: -------------------------------------------------------
225 225
226 void WebUIImpl::AddMessageHandler(WebUIMessageHandler* handler) { 226 void WebUIImpl::AddMessageHandler(WebUIMessageHandler* handler) {
227 DCHECK(!handler->web_ui()); 227 DCHECK(!handler->web_ui());
228 handler->set_web_ui(this); 228 handler->set_web_ui(this);
229 handler->RegisterMessages(); 229 handler->RegisterMessages();
230 handlers_.push_back(handler); 230 handlers_.push_back(handler);
231 } 231 }
232 232
233 void WebUIImpl::ExecuteJavascript(const string16& javascript) { 233 void WebUIImpl::ExecuteJavascript(const base::string16& javascript) {
234 static_cast<RenderViewHostImpl*>( 234 static_cast<RenderViewHostImpl*>(
235 web_contents_->GetRenderViewHost())->ExecuteJavascriptInWebFrame( 235 web_contents_->GetRenderViewHost())->ExecuteJavascriptInWebFrame(
236 ASCIIToUTF16(frame_xpath_), javascript); 236 ASCIIToUTF16(frame_xpath_), javascript);
237 } 237 }
238 238
239 } // namespace content 239 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/webui/web_ui_impl.h ('k') | content/browser/webui/web_ui_message_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698