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

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

Issue 198163004: Revert 257524 "Move IsStringASCII/UTF8 to base namespace." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 9 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 133
134 WebUIController* WebUIImpl::GetController() const { 134 WebUIController* WebUIImpl::GetController() const {
135 return controller_.get(); 135 return controller_.get();
136 } 136 }
137 137
138 void WebUIImpl::SetController(WebUIController* controller) { 138 void WebUIImpl::SetController(WebUIController* controller) {
139 controller_.reset(controller); 139 controller_.reset(controller);
140 } 140 }
141 141
142 void WebUIImpl::CallJavascriptFunction(const std::string& function_name) { 142 void WebUIImpl::CallJavascriptFunction(const std::string& function_name) {
143 DCHECK(base::IsStringASCII(function_name)); 143 DCHECK(IsStringASCII(function_name));
144 base::string16 javascript = base::ASCIIToUTF16(function_name + "();"); 144 base::string16 javascript = base::ASCIIToUTF16(function_name + "();");
145 ExecuteJavascript(javascript); 145 ExecuteJavascript(javascript);
146 } 146 }
147 147
148 void WebUIImpl::CallJavascriptFunction(const std::string& function_name, 148 void WebUIImpl::CallJavascriptFunction(const std::string& function_name,
149 const base::Value& arg) { 149 const base::Value& arg) {
150 DCHECK(base::IsStringASCII(function_name)); 150 DCHECK(IsStringASCII(function_name));
151 std::vector<const base::Value*> args; 151 std::vector<const base::Value*> args;
152 args.push_back(&arg); 152 args.push_back(&arg);
153 ExecuteJavascript(GetJavascriptCall(function_name, args)); 153 ExecuteJavascript(GetJavascriptCall(function_name, args));
154 } 154 }
155 155
156 void WebUIImpl::CallJavascriptFunction( 156 void WebUIImpl::CallJavascriptFunction(
157 const std::string& function_name, 157 const std::string& function_name,
158 const base::Value& arg1, const base::Value& arg2) { 158 const base::Value& arg1, const base::Value& arg2) {
159 DCHECK(base::IsStringASCII(function_name)); 159 DCHECK(IsStringASCII(function_name));
160 std::vector<const base::Value*> args; 160 std::vector<const base::Value*> args;
161 args.push_back(&arg1); 161 args.push_back(&arg1);
162 args.push_back(&arg2); 162 args.push_back(&arg2);
163 ExecuteJavascript(GetJavascriptCall(function_name, args)); 163 ExecuteJavascript(GetJavascriptCall(function_name, args));
164 } 164 }
165 165
166 void WebUIImpl::CallJavascriptFunction( 166 void WebUIImpl::CallJavascriptFunction(
167 const std::string& function_name, 167 const std::string& function_name,
168 const base::Value& arg1, const base::Value& arg2, const base::Value& arg3) { 168 const base::Value& arg1, const base::Value& arg2, const base::Value& arg3) {
169 DCHECK(base::IsStringASCII(function_name)); 169 DCHECK(IsStringASCII(function_name));
170 std::vector<const base::Value*> args; 170 std::vector<const base::Value*> args;
171 args.push_back(&arg1); 171 args.push_back(&arg1);
172 args.push_back(&arg2); 172 args.push_back(&arg2);
173 args.push_back(&arg3); 173 args.push_back(&arg3);
174 ExecuteJavascript(GetJavascriptCall(function_name, args)); 174 ExecuteJavascript(GetJavascriptCall(function_name, args));
175 } 175 }
176 176
177 void WebUIImpl::CallJavascriptFunction( 177 void WebUIImpl::CallJavascriptFunction(
178 const std::string& function_name, 178 const std::string& function_name,
179 const base::Value& arg1, 179 const base::Value& arg1,
180 const base::Value& arg2, 180 const base::Value& arg2,
181 const base::Value& arg3, 181 const base::Value& arg3,
182 const base::Value& arg4) { 182 const base::Value& arg4) {
183 DCHECK(base::IsStringASCII(function_name)); 183 DCHECK(IsStringASCII(function_name));
184 std::vector<const base::Value*> args; 184 std::vector<const base::Value*> args;
185 args.push_back(&arg1); 185 args.push_back(&arg1);
186 args.push_back(&arg2); 186 args.push_back(&arg2);
187 args.push_back(&arg3); 187 args.push_back(&arg3);
188 args.push_back(&arg4); 188 args.push_back(&arg4);
189 ExecuteJavascript(GetJavascriptCall(function_name, args)); 189 ExecuteJavascript(GetJavascriptCall(function_name, args));
190 } 190 }
191 191
192 void WebUIImpl::CallJavascriptFunction( 192 void WebUIImpl::CallJavascriptFunction(
193 const std::string& function_name, 193 const std::string& function_name,
194 const std::vector<const base::Value*>& args) { 194 const std::vector<const base::Value*>& args) {
195 DCHECK(base::IsStringASCII(function_name)); 195 DCHECK(IsStringASCII(function_name));
196 ExecuteJavascript(GetJavascriptCall(function_name, args)); 196 ExecuteJavascript(GetJavascriptCall(function_name, args));
197 } 197 }
198 198
199 void WebUIImpl::RegisterMessageCallback(const std::string &message, 199 void WebUIImpl::RegisterMessageCallback(const std::string &message,
200 const MessageCallback& callback) { 200 const MessageCallback& callback) {
201 message_callbacks_.insert(std::make_pair(message, callback)); 201 message_callbacks_.insert(std::make_pair(message, callback));
202 } 202 }
203 203
204 void WebUIImpl::ProcessWebUIMessage(const GURL& source_url, 204 void WebUIImpl::ProcessWebUIMessage(const GURL& source_url,
205 const std::string& message, 205 const std::string& message,
(...skipping 21 matching lines...) Expand all
227 handlers_.push_back(handler); 227 handlers_.push_back(handler);
228 } 228 }
229 229
230 void WebUIImpl::ExecuteJavascript(const base::string16& javascript) { 230 void WebUIImpl::ExecuteJavascript(const base::string16& javascript) {
231 static_cast<RenderViewHostImpl*>( 231 static_cast<RenderViewHostImpl*>(
232 web_contents_->GetRenderViewHost())->ExecuteJavascriptInWebFrame( 232 web_contents_->GetRenderViewHost())->ExecuteJavascriptInWebFrame(
233 base::ASCIIToUTF16(frame_xpath_), javascript); 233 base::ASCIIToUTF16(frame_xpath_), javascript);
234 } 234 }
235 235
236 } // namespace content 236 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698