summaryrefslogtreecommitdiffstats
path: root/chrome/browser/search_engines/search_host_to_urls_map.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/search_engines/search_host_to_urls_map.cc')
-rw-r--r--chrome/browser/search_engines/search_host_to_urls_map.cc45
1 files changed, 24 insertions, 21 deletions
diff --git a/chrome/browser/search_engines/search_host_to_urls_map.cc b/chrome/browser/search_engines/search_host_to_urls_map.cc
index 57e1564..878d108 100644
--- a/chrome/browser/search_engines/search_host_to_urls_map.cc
+++ b/chrome/browser/search_engines/search_host_to_urls_map.cc
@@ -16,18 +16,14 @@ SearchHostToURLsMap::~SearchHostToURLsMap() {
}
void SearchHostToURLsMap::Init(
- const std::vector<const TemplateURL*>& template_urls,
+ const TemplateURLService::TemplateURLVector& template_urls,
const SearchTermsData& search_terms_data) {
DCHECK(!initialized_);
-
- // Set as initialized here so Add doesn't assert.
- initialized_ = true;
-
- for (size_t i = 0; i < template_urls.size(); ++i)
- Add(template_urls[i], search_terms_data);
+ initialized_ = true; // Set here so Add doesn't assert.
+ Add(template_urls, search_terms_data);
}
-void SearchHostToURLsMap::Add(const TemplateURL* template_url,
+void SearchHostToURLsMap::Add(TemplateURL* template_url,
const SearchTermsData& search_terms_data) {
DCHECK(initialized_);
DCHECK(template_url);
@@ -40,7 +36,7 @@ void SearchHostToURLsMap::Add(const TemplateURL* template_url,
host_to_urls_map_[url.host()].insert(template_url);
}
-void SearchHostToURLsMap::Remove(const TemplateURL* template_url) {
+void SearchHostToURLsMap::Remove(TemplateURL* template_url) {
DCHECK(initialized_);
DCHECK(template_url);
@@ -64,7 +60,7 @@ void SearchHostToURLsMap::UpdateGoogleBaseURLs(
DCHECK(initialized_);
// Create a list of the the TemplateURLs to update.
- std::vector<const TemplateURL*> t_urls_using_base_url;
+ TemplateURLService::TemplateURLVector t_urls_using_base_url;
for (HostToURLsMap::iterator i(host_to_urls_map_.begin());
i != host_to_urls_map_.end(); ++i) {
for (TemplateURLSet::const_iterator j(i->second.begin());
@@ -75,15 +71,15 @@ void SearchHostToURLsMap::UpdateGoogleBaseURLs(
}
}
- for (size_t i = 0; i < t_urls_using_base_url.size(); ++i)
- RemoveByPointer(t_urls_using_base_url[i]);
+ for (TemplateURLService::TemplateURLVector::const_iterator i(
+ t_urls_using_base_url.begin()); i != t_urls_using_base_url.end(); ++i)
+ RemoveByPointer(*i);
- for (size_t i = 0; i < t_urls_using_base_url.size(); ++i)
- Add(t_urls_using_base_url[i], search_terms_data);
+ Add(t_urls_using_base_url, search_terms_data);
}
-const TemplateURL* SearchHostToURLsMap::GetTemplateURLForHost(
- const std::string& host) const {
+TemplateURL* SearchHostToURLsMap::GetTemplateURLForHost(
+ const std::string& host) {
DCHECK(initialized_);
HostToURLsMap::const_iterator iter = host_to_urls_map_.find(host);
@@ -92,18 +88,25 @@ const TemplateURL* SearchHostToURLsMap::GetTemplateURLForHost(
return *(iter->second.begin()); // Return the 1st element.
}
-const SearchHostToURLsMap::TemplateURLSet* SearchHostToURLsMap::GetURLsForHost(
- const std::string& host) const {
+SearchHostToURLsMap::TemplateURLSet* SearchHostToURLsMap::GetURLsForHost(
+ const std::string& host) {
DCHECK(initialized_);
- HostToURLsMap::const_iterator urls_for_host = host_to_urls_map_.find(host);
+ HostToURLsMap::iterator urls_for_host = host_to_urls_map_.find(host);
if (urls_for_host == host_to_urls_map_.end() || urls_for_host->second.empty())
return NULL;
return &urls_for_host->second;
}
-void SearchHostToURLsMap::RemoveByPointer(
- const TemplateURL* template_url) {
+void SearchHostToURLsMap::Add(
+ const TemplateURLService::TemplateURLVector& template_urls,
+ const SearchTermsData& search_terms_data) {
+ for (TemplateURLService::TemplateURLVector::const_iterator i(
+ template_urls.begin()); i != template_urls.end(); ++i)
+ Add(*i, search_terms_data);
+}
+
+void SearchHostToURLsMap::RemoveByPointer(TemplateURL* template_url) {
for (HostToURLsMap::iterator i = host_to_urls_map_.begin();
i != host_to_urls_map_.end(); ++i) {
TemplateURLSet::iterator url_set_iterator = i->second.find(template_url);