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

Side by Side Diff: chrome/browser/search_engines/template_url_parser.cc

Issue 120983002: Update some uses of UTF conversions in chrome/browser 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 "chrome/browser/search_engines/template_url_parser.h" 5 #include "chrome/browser/search_engines/template_url_parser.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 238
239 // static 239 // static
240 void TemplateURLParsingContext::EndElementImpl(void* ctx, const xmlChar* name) { 240 void TemplateURLParsingContext::EndElementImpl(void* ctx, const xmlChar* name) {
241 TemplateURLParsingContext* context = 241 TemplateURLParsingContext* context =
242 reinterpret_cast<TemplateURLParsingContext*>(ctx); 242 reinterpret_cast<TemplateURLParsingContext*>(ctx);
243 switch (context->GetKnownType()) { 243 switch (context->GetKnownType()) {
244 case TemplateURLParsingContext::SHORT_NAME: 244 case TemplateURLParsingContext::SHORT_NAME:
245 context->data_.short_name = context->string_; 245 context->data_.short_name = context->string_;
246 break; 246 break;
247 case TemplateURLParsingContext::IMAGE: { 247 case TemplateURLParsingContext::IMAGE: {
248 GURL image_url(UTF16ToUTF8(context->string_)); 248 GURL image_url(base::UTF16ToUTF8(context->string_));
249 if (image_url.SchemeIs(chrome::kDataScheme)) { 249 if (image_url.SchemeIs(chrome::kDataScheme)) {
250 // TODO (jcampan): bug 1169256: when dealing with data URL, we need to 250 // TODO (jcampan): bug 1169256: when dealing with data URL, we need to
251 // decode the data URL in the renderer. For now, we'll just point to the 251 // decode the data URL in the renderer. For now, we'll just point to the
252 // favicon from the URL. 252 // favicon from the URL.
253 context->derive_image_from_url_ = true; 253 context->derive_image_from_url_ = true;
254 } else if (context->image_is_valid_for_favicon_ && image_url.is_valid() && 254 } else if (context->image_is_valid_for_favicon_ && image_url.is_valid() &&
255 (image_url.SchemeIs(content::kHttpScheme) || 255 (image_url.SchemeIs(content::kHttpScheme) ||
256 image_url.SchemeIs(content::kHttpsScheme))) { 256 image_url.SchemeIs(content::kHttpsScheme))) {
257 context->data_.favicon_url = image_url; 257 context->data_.favicon_url = image_url;
258 } 258 }
(...skipping 14 matching lines...) Expand all
273 } 273 }
274 context->string_.clear(); 274 context->string_.clear();
275 context->elements_.pop_back(); 275 context->elements_.pop_back();
276 } 276 }
277 277
278 // static 278 // static
279 void TemplateURLParsingContext::CharactersImpl(void* ctx, 279 void TemplateURLParsingContext::CharactersImpl(void* ctx,
280 const xmlChar* ch, 280 const xmlChar* ch,
281 int len) { 281 int len) {
282 reinterpret_cast<TemplateURLParsingContext*>(ctx)->string_ += 282 reinterpret_cast<TemplateURLParsingContext*>(ctx)->string_ +=
283 UTF8ToUTF16(std::string(reinterpret_cast<const char*>(ch), len)); 283 base::UTF8ToUTF16(std::string(reinterpret_cast<const char*>(ch), len));
284 } 284 }
285 285
286 TemplateURL* TemplateURLParsingContext::GetTemplateURL( 286 TemplateURL* TemplateURLParsingContext::GetTemplateURL(
287 Profile* profile, 287 Profile* profile,
288 bool show_in_default_list) { 288 bool show_in_default_list) {
289 // TODO(jcampan): Support engines that use POST; see http://crbug.com/18107 289 // TODO(jcampan): Support engines that use POST; see http://crbug.com/18107
290 if (method_ == TemplateURLParsingContext::POST || data_.short_name.empty() || 290 if (method_ == TemplateURLParsingContext::POST || data_.short_name.empty() ||
291 !IsHTTPRef(data_.url()) || !IsHTTPRef(data_.suggestions_url)) 291 !IsHTTPRef(data_.url()) || !IsHTTPRef(data_.suggestions_url))
292 return NULL; 292 return NULL;
293 if (suggestion_method_ == TemplateURLParsingContext::POST) 293 if (suggestion_method_ == TemplateURLParsingContext::POST)
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 memset(&sax_handler, 0, sizeof(sax_handler)); 487 memset(&sax_handler, 0, sizeof(sax_handler));
488 sax_handler.startElement = &TemplateURLParsingContext::StartElementImpl; 488 sax_handler.startElement = &TemplateURLParsingContext::StartElementImpl;
489 sax_handler.endElement = &TemplateURLParsingContext::EndElementImpl; 489 sax_handler.endElement = &TemplateURLParsingContext::EndElementImpl;
490 sax_handler.characters = &TemplateURLParsingContext::CharactersImpl; 490 sax_handler.characters = &TemplateURLParsingContext::CharactersImpl;
491 int error = xmlSAXUserParseMemory(&sax_handler, &context, data, 491 int error = xmlSAXUserParseMemory(&sax_handler, &context, data,
492 static_cast<int>(length)); 492 static_cast<int>(length));
493 xmlSubstituteEntitiesDefault(last_sub_entities_value); 493 xmlSubstituteEntitiesDefault(last_sub_entities_value);
494 494
495 return error ? NULL : context.GetTemplateURL(profile, show_in_default_list); 495 return error ? NULL : context.GetTemplateURL(profile, show_in_default_list);
496 } 496 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698