OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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.h" | 5 #include "chrome/browser/search_engines/template_url.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "base/i18n/icu_string_conversions.h" | 8 #include "base/i18n/icu_string_conversions.h" |
9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 } | 255 } |
256 } | 256 } |
257 | 257 |
258 // static | 258 // static |
259 void TemplateURLRef::SetGoogleBaseURL(std::string* google_base_url) { | 259 void TemplateURLRef::SetGoogleBaseURL(std::string* google_base_url) { |
260 UIThreadSearchTermsData::SetGoogleBaseURL(google_base_url); | 260 UIThreadSearchTermsData::SetGoogleBaseURL(google_base_url); |
261 } | 261 } |
262 | 262 |
263 std::string TemplateURLRef::ReplaceSearchTerms( | 263 std::string TemplateURLRef::ReplaceSearchTerms( |
264 const TemplateURL& host, | 264 const TemplateURL& host, |
265 const string16& terms, | 265 const std::wstring& terms, |
266 int accepted_suggestion, | 266 int accepted_suggestion, |
267 const string16& original_query_for_suggestion) const { | 267 const std::wstring& original_query_for_suggestion) const { |
268 UIThreadSearchTermsData search_terms_data; | 268 UIThreadSearchTermsData search_terms_data; |
269 return ReplaceSearchTermsUsingTermsData(host, | 269 return ReplaceSearchTermsUsingTermsData(host, |
270 terms, | 270 terms, |
271 accepted_suggestion, | 271 accepted_suggestion, |
272 original_query_for_suggestion, | 272 original_query_for_suggestion, |
273 search_terms_data); | 273 search_terms_data); |
274 } | 274 } |
275 | 275 |
276 std::string TemplateURLRef::ReplaceSearchTermsUsingTermsData( | 276 std::string TemplateURLRef::ReplaceSearchTermsUsingTermsData( |
277 const TemplateURL& host, | 277 const TemplateURL& host, |
278 const string16& terms, | 278 const std::wstring& terms, |
279 int accepted_suggestion, | 279 int accepted_suggestion, |
280 const string16& original_query_for_suggestion, | 280 const std::wstring& original_query_for_suggestion, |
281 const SearchTermsData& search_terms_data) const { | 281 const SearchTermsData& search_terms_data) const { |
282 ParseIfNecessaryUsingTermsData(search_terms_data); | 282 ParseIfNecessaryUsingTermsData(search_terms_data); |
283 if (!valid_) | 283 if (!valid_) |
284 return std::string(); | 284 return std::string(); |
285 | 285 |
286 if (replacements_.empty()) | 286 if (replacements_.empty()) |
287 return parsed_url_; | 287 return parsed_url_; |
288 | 288 |
289 // Determine if the search terms are in the query or before. We're escaping | 289 // Determine if the search terms are in the query or before. We're escaping |
290 // space as '+' in the former case and as '%20' in the latter case. | 290 // space as '+' in the former case and as '%20' in the latter case. |
291 bool is_in_query = true; | 291 bool is_in_query = true; |
292 for (Replacements::iterator i = replacements_.begin(); | 292 for (Replacements::iterator i = replacements_.begin(); |
293 i != replacements_.end(); ++i) { | 293 i != replacements_.end(); ++i) { |
294 if (i->type == SEARCH_TERMS) { | 294 if (i->type == SEARCH_TERMS) { |
295 string16::size_type query_start = parsed_url_.find('?'); | 295 std::wstring::size_type query_start = parsed_url_.find('?'); |
296 is_in_query = query_start != string16::npos && | 296 is_in_query = query_start != std::wstring::npos && |
297 (static_cast<string16::size_type>(i->index) > query_start); | 297 (static_cast<std::wstring::size_type>(i->index) > query_start); |
298 break; | 298 break; |
299 } | 299 } |
300 } | 300 } |
301 | 301 |
302 string16 encoded_terms; | 302 string16 encoded_terms; |
303 string16 encoded_original_query; | 303 string16 encoded_original_query; |
304 std::string input_encoding; | 304 std::string input_encoding; |
305 // If the search terms are in query - escape them respecting the encoding. | 305 // If the search terms are in query - escape them respecting the encoding. |
306 if (is_in_query) { | 306 if (is_in_query) { |
307 // Encode the search terms so that we know the encoding. | 307 // Encode the search terms so that we know the encoding. |
308 const std::vector<std::string>& encodings = host.input_encodings(); | 308 const std::vector<std::string>& encodings = host.input_encodings(); |
309 for (size_t i = 0; i < encodings.size(); ++i) { | 309 for (size_t i = 0; i < encodings.size(); ++i) { |
310 if (EscapeQueryParamValue(terms, | 310 if (EscapeQueryParamValue(WideToUTF16Hack(terms), |
311 encodings[i].c_str(), true, | 311 encodings[i].c_str(), true, |
312 &encoded_terms)) { | 312 &encoded_terms)) { |
313 if (!original_query_for_suggestion.empty()) { | 313 if (!original_query_for_suggestion.empty()) { |
314 EscapeQueryParamValue(original_query_for_suggestion, | 314 EscapeQueryParamValue(WideToUTF16Hack(original_query_for_suggestion), |
315 encodings[i].c_str(), | 315 encodings[i].c_str(), |
316 true, | 316 true, |
317 &encoded_original_query); | 317 &encoded_original_query); |
318 } | 318 } |
319 input_encoding = encodings[i]; | 319 input_encoding = encodings[i]; |
320 break; | 320 break; |
321 } | 321 } |
322 } | 322 } |
323 if (input_encoding.empty()) { | 323 if (input_encoding.empty()) { |
324 encoded_terms = EscapeQueryParamValueUTF8(terms, true); | 324 encoded_terms = WideToUTF16Hack( |
| 325 EscapeQueryParamValueUTF8(terms, true)); |
325 if (!original_query_for_suggestion.empty()) { | 326 if (!original_query_for_suggestion.empty()) { |
326 encoded_original_query = | 327 encoded_original_query = |
327 EscapeQueryParamValueUTF8(original_query_for_suggestion, true); | 328 WideToUTF16Hack(EscapeQueryParamValueUTF8( |
| 329 original_query_for_suggestion, true)); |
328 } | 330 } |
329 input_encoding = "UTF-8"; | 331 input_encoding = "UTF-8"; |
330 } | 332 } |
331 } else { | 333 } else { |
332 encoded_terms = UTF8ToUTF16(EscapePath(UTF16ToUTF8(terms))); | 334 encoded_terms = WideToUTF16Hack(UTF8ToWide(EscapePath(WideToUTF8(terms)))); |
333 input_encoding = "UTF-8"; | 335 input_encoding = "UTF-8"; |
334 } | 336 } |
335 | 337 |
336 std::string url = parsed_url_; | 338 std::string url = parsed_url_; |
337 | 339 |
338 // replacements_ is ordered in ascending order, as such we need to iterate | 340 // replacements_ is ordered in ascending order, as such we need to iterate |
339 // from the back. | 341 // from the back. |
340 for (Replacements::reverse_iterator i = replacements_.rbegin(); | 342 for (Replacements::reverse_iterator i = replacements_.rbegin(); |
341 i != replacements_.rend(); ++i) { | 343 i != replacements_.rend(); ++i) { |
342 switch (i->type) { | 344 switch (i->type) { |
(...skipping 21 matching lines...) Expand all Loading... |
364 url.insert(i->index, "oq=" + UTF16ToUTF8(encoded_original_query) + | 366 url.insert(i->index, "oq=" + UTF16ToUTF8(encoded_original_query) + |
365 "&"); | 367 "&"); |
366 break; | 368 break; |
367 | 369 |
368 case GOOGLE_RLZ: { | 370 case GOOGLE_RLZ: { |
369 // On platforms that don't have RLZ, we still want this branch | 371 // On platforms that don't have RLZ, we still want this branch |
370 // to happen so that we replace the RLZ template with the | 372 // to happen so that we replace the RLZ template with the |
371 // empty string. (If we don't handle this case, we hit a | 373 // empty string. (If we don't handle this case, we hit a |
372 // NOTREACHED below.) | 374 // NOTREACHED below.) |
373 #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) | 375 #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) |
374 string16 rlz_string = search_terms_data.GetRlzParameterValue(); | 376 std::wstring rlz_string = search_terms_data.GetRlzParameterValue(); |
375 if (!rlz_string.empty()) { | 377 if (!rlz_string.empty()) { |
376 rlz_string = L"rlz=" + rlz_string + L"&"; | 378 rlz_string = L"rlz=" + rlz_string + L"&"; |
377 url.insert(i->index, UTF16ToUTF8(rlz_string)); | 379 url.insert(i->index, WideToUTF8(rlz_string)); |
378 } | 380 } |
379 #endif | 381 #endif |
380 break; | 382 break; |
381 } | 383 } |
382 | 384 |
383 case GOOGLE_UNESCAPED_SEARCH_TERMS: { | 385 case GOOGLE_UNESCAPED_SEARCH_TERMS: { |
384 std::string unescaped_terms; | 386 std::string unescaped_terms; |
385 base::UTF16ToCodepage(terms, input_encoding.c_str(), | 387 base::WideToCodepage(terms, input_encoding.c_str(), |
386 base::OnStringConversionError::SKIP, | 388 base::OnStringConversionError::SKIP, |
387 &unescaped_terms); | 389 &unescaped_terms); |
388 url.insert(i->index, std::string(unescaped_terms.begin(), | 390 url.insert(i->index, std::string(unescaped_terms.begin(), |
389 unescaped_terms.end())); | 391 unescaped_terms.end())); |
390 break; | 392 break; |
391 } | 393 } |
392 | 394 |
393 case LANGUAGE: | 395 case LANGUAGE: |
394 url.insert(i->index, search_terms_data.GetApplicationLocale()); | 396 url.insert(i->index, search_terms_data.GetApplicationLocale()); |
395 break; | 397 break; |
396 | 398 |
397 case SEARCH_TERMS: | 399 case SEARCH_TERMS: |
(...skipping 24 matching lines...) Expand all Loading... |
422 UIThreadSearchTermsData search_terms_data; | 424 UIThreadSearchTermsData search_terms_data; |
423 return IsValidUsingTermsData(search_terms_data); | 425 return IsValidUsingTermsData(search_terms_data); |
424 } | 426 } |
425 | 427 |
426 bool TemplateURLRef::IsValidUsingTermsData( | 428 bool TemplateURLRef::IsValidUsingTermsData( |
427 const SearchTermsData& search_terms_data) const { | 429 const SearchTermsData& search_terms_data) const { |
428 ParseIfNecessaryUsingTermsData(search_terms_data); | 430 ParseIfNecessaryUsingTermsData(search_terms_data); |
429 return valid_; | 431 return valid_; |
430 } | 432 } |
431 | 433 |
432 string16 TemplateURLRef::DisplayURL() const { | 434 std::wstring TemplateURLRef::DisplayURL() const { |
433 ParseIfNecessary(); | 435 ParseIfNecessary(); |
434 if (!valid_ || replacements_.empty()) | 436 if (!valid_ || replacements_.empty()) |
435 return UTF8ToUTF16(url_); | 437 return UTF8ToWide(url_); |
436 | 438 |
437 string16 result = UTF8ToUTF16(url_); | 439 string16 result = UTF8ToUTF16(url_); |
438 ReplaceSubstringsAfterOffset(&result, 0, | 440 ReplaceSubstringsAfterOffset(&result, 0, |
439 ASCIIToUTF16(kSearchTermsParameterFull), | 441 ASCIIToUTF16(kSearchTermsParameterFull), |
440 ASCIIToUTF16(kDisplaySearchTerms)); | 442 ASCIIToUTF16(kDisplaySearchTerms)); |
441 | 443 |
442 ReplaceSubstringsAfterOffset( | 444 ReplaceSubstringsAfterOffset( |
443 &result, 0, | 445 &result, 0, |
444 ASCIIToUTF16(kGoogleUnescapedSearchTermsParameterFull), | 446 ASCIIToUTF16(kGoogleUnescapedSearchTermsParameterFull), |
445 ASCIIToUTF16(kDisplayUnescapedSearchTerms)); | 447 ASCIIToUTF16(kDisplayUnescapedSearchTerms)); |
446 | 448 |
447 return result; | 449 return UTF16ToWideHack(result); |
448 } | 450 } |
449 | 451 |
450 // static | 452 // static |
451 std::string TemplateURLRef::DisplayURLToURLRef( | 453 std::string TemplateURLRef::DisplayURLToURLRef( |
452 const string16& display_url) { | 454 const std::wstring& display_url) { |
453 string16 result = display_url; | 455 string16 result = WideToUTF16Hack(display_url); |
454 ReplaceSubstringsAfterOffset(&result, 0, ASCIIToUTF16(kDisplaySearchTerms), | 456 ReplaceSubstringsAfterOffset(&result, 0, ASCIIToUTF16(kDisplaySearchTerms), |
455 ASCIIToUTF16(kSearchTermsParameterFull)); | 457 ASCIIToUTF16(kSearchTermsParameterFull)); |
456 ReplaceSubstringsAfterOffset( | 458 ReplaceSubstringsAfterOffset( |
457 &result, 0, | 459 &result, 0, |
458 ASCIIToUTF16(kDisplayUnescapedSearchTerms), | 460 ASCIIToUTF16(kDisplayUnescapedSearchTerms), |
459 ASCIIToUTF16(kGoogleUnescapedSearchTermsParameterFull)); | 461 ASCIIToUTF16(kGoogleUnescapedSearchTermsParameterFull)); |
460 return UTF16ToUTF8(result); | 462 return UTF16ToUTF8(result); |
461 } | 463 } |
462 | 464 |
463 const std::string& TemplateURLRef::GetHost() const { | 465 const std::string& TemplateURLRef::GetHost() const { |
464 ParseIfNecessary(); | 466 ParseIfNecessary(); |
465 return host_; | 467 return host_; |
466 } | 468 } |
467 | 469 |
468 const std::string& TemplateURLRef::GetPath() const { | 470 const std::string& TemplateURLRef::GetPath() const { |
469 ParseIfNecessary(); | 471 ParseIfNecessary(); |
470 return path_; | 472 return path_; |
471 } | 473 } |
472 | 474 |
473 const std::string& TemplateURLRef::GetSearchTermKey() const { | 475 const std::string& TemplateURLRef::GetSearchTermKey() const { |
474 ParseIfNecessary(); | 476 ParseIfNecessary(); |
475 return search_term_key_; | 477 return search_term_key_; |
476 } | 478 } |
477 | 479 |
478 string16 TemplateURLRef::SearchTermToString16(const TemplateURL& host, | 480 std::wstring TemplateURLRef::SearchTermToWide(const TemplateURL& host, |
479 const std::string& term) const { | 481 const std::string& term) const { |
480 const std::vector<std::string>& encodings = host.input_encodings(); | 482 const std::vector<std::string>& encodings = host.input_encodings(); |
481 string16 result; | 483 std::wstring result; |
482 | 484 |
483 std::string unescaped = | 485 std::string unescaped = |
484 UnescapeURLComponent(term, UnescapeRule::REPLACE_PLUS_WITH_SPACE | | 486 UnescapeURLComponent(term, UnescapeRule::REPLACE_PLUS_WITH_SPACE | |
485 UnescapeRule::URL_SPECIAL_CHARS); | 487 UnescapeRule::URL_SPECIAL_CHARS); |
486 for (size_t i = 0; i < encodings.size(); ++i) { | 488 for (size_t i = 0; i < encodings.size(); ++i) { |
487 if (base::CodepageToUTF16(unescaped, encodings[i].c_str(), | 489 if (base::CodepageToWide(unescaped, encodings[i].c_str(), |
488 base::OnStringConversionError::FAIL, &result)) | 490 base::OnStringConversionError::FAIL, &result)) |
489 return result; | 491 return result; |
490 } | 492 } |
491 | 493 |
492 // Always fall back on UTF-8 if it works. | 494 // Always fall back on UTF-8 if it works. |
493 if (base::CodepageToUTF16(unescaped, base::kCodepageUTF8, | 495 if (base::CodepageToWide(unescaped, base::kCodepageUTF8, |
494 base::OnStringConversionError::FAIL, &result)) | 496 base::OnStringConversionError::FAIL, &result)) |
495 return result; | 497 return result; |
496 | 498 |
497 // When nothing worked, just use the escaped text. We have no idea what the | 499 // When nothing worked, just use the escaped text. We have no idea what the |
498 // encoding is. We need to substitute spaces for pluses ourselves since we're | 500 // encoding is. We need to substitute spaces for pluses ourselves since we're |
499 // not sending it through an unescaper. | 501 // not sending it through an unescaper. |
500 result = UTF8ToUTF16(term); | 502 result = UTF8ToWide(term); |
501 std::replace(result.begin(), result.end(), '+', ' '); | 503 std::replace(result.begin(), result.end(), '+', ' '); |
502 return result; | 504 return result; |
503 } | 505 } |
504 | 506 |
505 bool TemplateURLRef::HasGoogleBaseURLs() const { | 507 bool TemplateURLRef::HasGoogleBaseURLs() const { |
506 ParseIfNecessary(); | 508 ParseIfNecessary(); |
507 for (size_t i = 0; i < replacements_.size(); ++i) { | 509 for (size_t i = 0; i < replacements_.size(); ++i) { |
508 if ((replacements_[i].type == GOOGLE_BASE_URL) || | 510 if ((replacements_[i].type == GOOGLE_BASE_URL) || |
509 (replacements_[i].type == GOOGLE_BASE_SUGGEST_URL)) | 511 (replacements_[i].type == GOOGLE_BASE_SUGGEST_URL)) |
510 return true; | 512 return true; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 created_by_policy_(false), | 570 created_by_policy_(false), |
569 usage_count_(0), | 571 usage_count_(0), |
570 search_engine_type_(SEARCH_ENGINE_OTHER), | 572 search_engine_type_(SEARCH_ENGINE_OTHER), |
571 logo_id_(kNoSearchEngineLogo), | 573 logo_id_(kNoSearchEngineLogo), |
572 prepopulate_id_(0) { | 574 prepopulate_id_(0) { |
573 } | 575 } |
574 | 576 |
575 TemplateURL::~TemplateURL() { | 577 TemplateURL::~TemplateURL() { |
576 } | 578 } |
577 | 579 |
578 string16 TemplateURL::AdjustedShortNameForLocaleDirection() const { | 580 std::wstring TemplateURL::AdjustedShortNameForLocaleDirection() const { |
579 string16 bidi_safe_short_name = short_name_; | 581 std::wstring bidi_safe_short_name = short_name_; |
580 base::i18n::AdjustStringForLocaleDirection(&bidi_safe_short_name); | 582 base::i18n::AdjustStringForLocaleDirection(&bidi_safe_short_name); |
581 return bidi_safe_short_name; | 583 return bidi_safe_short_name; |
582 } | 584 } |
583 | 585 |
584 void TemplateURL::SetSuggestionsURL(const std::string& suggestions_url, | 586 void TemplateURL::SetSuggestionsURL(const std::string& suggestions_url, |
585 int index_offset, | 587 int index_offset, |
586 int page_offset) { | 588 int page_offset) { |
587 suggestions_url_.Set(suggestions_url, index_offset, page_offset); | 589 suggestions_url_.Set(suggestions_url, index_offset, page_offset); |
588 } | 590 } |
589 | 591 |
590 void TemplateURL::SetURL(const std::string& url, | 592 void TemplateURL::SetURL(const std::string& url, |
591 int index_offset, | 593 int index_offset, |
592 int page_offset) { | 594 int page_offset) { |
593 url_.Set(url, index_offset, page_offset); | 595 url_.Set(url, index_offset, page_offset); |
594 } | 596 } |
595 | 597 |
596 void TemplateURL::SetInstantURL(const std::string& url, | 598 void TemplateURL::SetInstantURL(const std::string& url, |
597 int index_offset, | 599 int index_offset, |
598 int page_offset) { | 600 int page_offset) { |
599 instant_url_.Set(url, index_offset, page_offset); | 601 instant_url_.Set(url, index_offset, page_offset); |
600 } | 602 } |
601 | 603 |
602 void TemplateURL::set_keyword(const string16& keyword) { | 604 void TemplateURL::set_keyword(const std::wstring& keyword) { |
603 // Case sensitive keyword matching is confusing. As such, we force all | 605 // Case sensitive keyword matching is confusing. As such, we force all |
604 // keywords to be lower case. | 606 // keywords to be lower case. |
605 keyword_ = l10n_util::ToLower(keyword); | 607 keyword_ = UTF16ToWide(l10n_util::ToLower(WideToUTF16(keyword))); |
606 autogenerate_keyword_ = false; | 608 autogenerate_keyword_ = false; |
607 } | 609 } |
608 | 610 |
609 string16 TemplateURL::keyword() const { | 611 const std::wstring& TemplateURL::keyword() const { |
610 EnsureKeyword(); | 612 EnsureKeyword(); |
611 return keyword_; | 613 return keyword_; |
612 } | 614 } |
613 | 615 |
614 void TemplateURL::EnsureKeyword() const { | 616 void TemplateURL::EnsureKeyword() const { |
615 if (autogenerate_keyword_ && !keyword_generated_) { | 617 if (autogenerate_keyword_ && !keyword_generated_) { |
616 // Generate a keyword and cache it. | 618 // Generate a keyword and cache it. |
617 keyword_ = TemplateURLModel::GenerateKeyword( | 619 keyword_ = TemplateURLModel::GenerateKeyword( |
618 TemplateURLModel::GenerateSearchURL(this).GetWithEmptyPath(), true); | 620 TemplateURLModel::GenerateSearchURL(this).GetWithEmptyPath(), true); |
619 keyword_generated_ = true; | 621 keyword_generated_ = true; |
620 } | 622 } |
621 } | 623 } |
622 | 624 |
623 bool TemplateURL::ShowInDefaultList() const { | 625 bool TemplateURL::ShowInDefaultList() const { |
624 return show_in_default_list() && url() && url()->SupportsReplacement(); | 626 return show_in_default_list() && url() && url()->SupportsReplacement(); |
625 } | 627 } |
626 | 628 |
627 void TemplateURL::SetFavIconURL(const GURL& url) { | 629 void TemplateURL::SetFavIconURL(const GURL& url) { |
628 for (std::vector<ImageRef>::iterator i = image_refs_.begin(); | 630 for (std::vector<ImageRef>::iterator i = image_refs_.begin(); |
629 i != image_refs_.end(); ++i) { | 631 i != image_refs_.end(); ++i) { |
630 if (i->type == "image/x-icon" && | 632 if (i->type == L"image/x-icon" && |
631 i->width == kFavIconSize && i->height == kFavIconSize) { | 633 i->width == kFavIconSize && i->height == kFavIconSize) { |
632 if (!url.is_valid()) | 634 if (!url.is_valid()) |
633 image_refs_.erase(i); | 635 image_refs_.erase(i); |
634 else | 636 else |
635 i->url = url; | 637 i->url = url; |
636 return; | 638 return; |
637 } | 639 } |
638 } | 640 } |
639 // Don't have one yet, add it. | 641 // Don't have one yet, add it. |
640 if (url.is_valid()) { | 642 if (url.is_valid()) { |
641 add_image_ref( | 643 add_image_ref( |
642 TemplateURL::ImageRef("image/x-icon", kFavIconSize, | 644 TemplateURL::ImageRef(L"image/x-icon", kFavIconSize, kFavIconSize, |
643 kFavIconSize, url)); | 645 url)); |
644 } | 646 } |
645 } | 647 } |
646 | 648 |
647 GURL TemplateURL::GetFavIconURL() const { | 649 GURL TemplateURL::GetFavIconURL() const { |
648 for (std::vector<ImageRef>::const_iterator i = image_refs_.begin(); | 650 for (std::vector<ImageRef>::const_iterator i = image_refs_.begin(); |
649 i != image_refs_.end(); ++i) { | 651 i != image_refs_.end(); ++i) { |
650 if ((i->type == "image/x-icon" || i->type == "image/vnd.microsoft.icon") | 652 if ((i->type == L"image/x-icon" || i->type == L"image/vnd.microsoft.icon") |
651 && i->width == kFavIconSize && i->height == kFavIconSize) { | 653 && i->width == kFavIconSize && i->height == kFavIconSize) { |
652 return i->url; | 654 return i->url; |
653 } | 655 } |
654 } | 656 } |
655 return GURL(); | 657 return GURL(); |
656 } | 658 } |
657 | 659 |
658 void TemplateURL::InvalidateCachedValues() const { | 660 void TemplateURL::InvalidateCachedValues() const { |
659 url_.InvalidateCachedValues(); | 661 url_.InvalidateCachedValues(); |
660 suggestions_url_.InvalidateCachedValues(); | 662 suggestions_url_.InvalidateCachedValues(); |
661 if (autogenerate_keyword_) { | 663 if (autogenerate_keyword_) { |
662 keyword_.clear(); | 664 keyword_.clear(); |
663 keyword_generated_ = false; | 665 keyword_generated_ = false; |
664 } | 666 } |
665 } | 667 } |
666 | 668 |
667 std::string TemplateURL::GetExtensionId() const { | 669 std::string TemplateURL::GetExtensionId() const { |
668 DCHECK(IsExtensionKeyword()); | 670 DCHECK(IsExtensionKeyword()); |
669 return GURL(url_.url()).host(); | 671 return GURL(url_.url()).host(); |
670 } | 672 } |
671 | 673 |
672 bool TemplateURL::IsExtensionKeyword() const { | 674 bool TemplateURL::IsExtensionKeyword() const { |
673 return GURL(url_.url()).SchemeIs(chrome::kExtensionScheme); | 675 return GURL(url_.url()).SchemeIs(chrome::kExtensionScheme); |
674 } | 676 } |
OLD | NEW |