| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/i18n/icu_string_conversions.h" | 7 #include "base/i18n/icu_string_conversions.h" |
| 8 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| (...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 } | 647 } |
| 648 | 648 |
| 649 bool TemplateURL::ShowInDefaultList() const { | 649 bool TemplateURL::ShowInDefaultList() const { |
| 650 return show_in_default_list() && url() && url()->SupportsReplacement(); | 650 return show_in_default_list() && url() && url()->SupportsReplacement(); |
| 651 } | 651 } |
| 652 | 652 |
| 653 void TemplateURL::SetFavIconURL(const GURL& url) { | 653 void TemplateURL::SetFavIconURL(const GURL& url) { |
| 654 for (std::vector<ImageRef>::iterator i = image_refs_.begin(); | 654 for (std::vector<ImageRef>::iterator i = image_refs_.begin(); |
| 655 i != image_refs_.end(); ++i) { | 655 i != image_refs_.end(); ++i) { |
| 656 if (i->type == "image/x-icon" && | 656 if (i->type == "image/x-icon" && |
| 657 i->width == kFavIconSize && i->height == kFavIconSize) { | 657 i->width == kFaviconSize && i->height == kFaviconSize) { |
| 658 if (!url.is_valid()) | 658 if (!url.is_valid()) |
| 659 image_refs_.erase(i); | 659 image_refs_.erase(i); |
| 660 else | 660 else |
| 661 i->url = url; | 661 i->url = url; |
| 662 return; | 662 return; |
| 663 } | 663 } |
| 664 } | 664 } |
| 665 // Don't have one yet, add it. | 665 // Don't have one yet, add it. |
| 666 if (url.is_valid()) { | 666 if (url.is_valid()) { |
| 667 add_image_ref( | 667 add_image_ref( |
| 668 TemplateURL::ImageRef("image/x-icon", kFavIconSize, | 668 TemplateURL::ImageRef("image/x-icon", kFaviconSize, |
| 669 kFavIconSize, url)); | 669 kFaviconSize, url)); |
| 670 } | 670 } |
| 671 } | 671 } |
| 672 | 672 |
| 673 GURL TemplateURL::GetFavIconURL() const { | 673 GURL TemplateURL::GetFavIconURL() const { |
| 674 for (std::vector<ImageRef>::const_iterator i = image_refs_.begin(); | 674 for (std::vector<ImageRef>::const_iterator i = image_refs_.begin(); |
| 675 i != image_refs_.end(); ++i) { | 675 i != image_refs_.end(); ++i) { |
| 676 if ((i->type == "image/x-icon" || i->type == "image/vnd.microsoft.icon") | 676 if ((i->type == "image/x-icon" || i->type == "image/vnd.microsoft.icon") |
| 677 && i->width == kFavIconSize && i->height == kFavIconSize) { | 677 && i->width == kFaviconSize && i->height == kFaviconSize) { |
| 678 return i->url; | 678 return i->url; |
| 679 } | 679 } |
| 680 } | 680 } |
| 681 return GURL(); | 681 return GURL(); |
| 682 } | 682 } |
| 683 | 683 |
| 684 void TemplateURL::InvalidateCachedValues() const { | 684 void TemplateURL::InvalidateCachedValues() const { |
| 685 url_.InvalidateCachedValues(); | 685 url_.InvalidateCachedValues(); |
| 686 suggestions_url_.InvalidateCachedValues(); | 686 suggestions_url_.InvalidateCachedValues(); |
| 687 if (autogenerate_keyword_) { | 687 if (autogenerate_keyword_) { |
| 688 keyword_.clear(); | 688 keyword_.clear(); |
| 689 keyword_generated_ = false; | 689 keyword_generated_ = false; |
| 690 } | 690 } |
| 691 } | 691 } |
| 692 | 692 |
| 693 std::string TemplateURL::GetExtensionId() const { | 693 std::string TemplateURL::GetExtensionId() const { |
| 694 DCHECK(IsExtensionKeyword()); | 694 DCHECK(IsExtensionKeyword()); |
| 695 return GURL(url_.url()).host(); | 695 return GURL(url_.url()).host(); |
| 696 } | 696 } |
| 697 | 697 |
| 698 bool TemplateURL::IsExtensionKeyword() const { | 698 bool TemplateURL::IsExtensionKeyword() const { |
| 699 return GURL(url_.url()).SchemeIs(chrome::kExtensionScheme); | 699 return GURL(url_.url()).SchemeIs(chrome::kExtensionScheme); |
| 700 } | 700 } |
| OLD | NEW |