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

Side by Side Diff: content/browser/webui/web_ui_impl.cc

Issue 121033002: Update uses of UTF conversions in content/ to use the base:: namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 months 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 (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"
(...skipping 19 matching lines...) Expand all
30 base::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 base::Value*>& arg_list) { 32 const std::vector<const base::Value*>& arg_list) {
33 base::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 += base::UTF8ToUTF16(json);
41 } 41 }
42 return ASCIIToUTF16(function_name) + 42 return base::ASCIIToUTF16(function_name) +
43 char16('(') + parameters + char16(')') + char16(';'); 43 char16('(') + parameters + char16(')') + char16(';');
44 } 44 }
45 45
46 WebUIImpl::WebUIImpl(WebContents* contents) 46 WebUIImpl::WebUIImpl(WebContents* contents)
47 : link_transition_type_(PAGE_TRANSITION_LINK), 47 : link_transition_type_(PAGE_TRANSITION_LINK),
48 bindings_(BINDINGS_POLICY_WEB_UI), 48 bindings_(BINDINGS_POLICY_WEB_UI),
49 web_contents_(contents) { 49 web_contents_(contents) {
50 DCHECK(contents); 50 DCHECK(contents);
51 } 51 }
52 52
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 base::string16 javascript = ASCIIToUTF16(function_name + "();"); 147 base::string16 javascript = base::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 base::Value& arg) { 152 const base::Value& arg) {
153 DCHECK(IsStringASCII(function_name)); 153 DCHECK(IsStringASCII(function_name));
154 std::vector<const base::Value*> args; 154 std::vector<const base::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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 base::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 base::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_data_source_unittest.cc ('k') | content/browser/webui/web_ui_message_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698