summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit.cc2
-rw-r--r--chrome/browser/autocomplete/autocomplete_match.cc2
-rw-r--r--chrome/browser/autocomplete/autocomplete_match.h4
-rw-r--r--chrome/browser/autocomplete/keyword_provider.cc2
-rw-r--r--chrome/browser/autocomplete/search_provider.cc18
-rw-r--r--chrome/browser/autocomplete/search_provider.h8
-rw-r--r--chrome/browser/automation/testing_automation_provider.cc8
-rw-r--r--chrome/browser/importer/profile_writer.cc2
-rw-r--r--chrome/browser/protector/base_setting_change.h2
-rw-r--r--chrome/browser/protector/default_search_provider_change.cc10
-rw-r--r--chrome/browser/protector/default_search_provider_change_browsertest.cc7
-rw-r--r--chrome/browser/search_engines/search_host_to_urls_map.cc45
-rw-r--r--chrome/browser/search_engines/search_host_to_urls_map.h23
-rw-r--r--chrome/browser/search_engines/search_host_to_urls_map_unittest.cc2
-rw-r--r--chrome/browser/search_engines/search_provider_install_data.cc4
-rw-r--r--chrome/browser/search_engines/search_provider_install_data.h2
-rw-r--r--chrome/browser/search_engines/template_url.cc4
-rw-r--r--chrome/browser/search_engines/template_url.h15
-rw-r--r--chrome/browser/search_engines/template_url_fetcher.cc2
-rw-r--r--chrome/browser/search_engines/template_url_service.cc207
-rw-r--r--chrome/browser/search_engines/template_url_service.h79
-rw-r--r--chrome/browser/search_engines/template_url_service_sync_unittest.cc13
-rw-r--r--chrome/browser/search_engines/template_url_service_unittest.cc14
-rw-r--r--chrome/browser/search_engines/util.cc4
-rw-r--r--chrome/browser/search_engines/util.h2
-rw-r--r--chrome/browser/sync/test/integration/search_engines_helper.cc13
-rw-r--r--chrome/browser/sync/test/integration/two_client_search_engines_sync_test.cc3
-rw-r--r--chrome/browser/ui/browser.cc2
-rw-r--r--chrome/browser/ui/browser.h2
-rw-r--r--chrome/browser/ui/browser_window.h2
-rw-r--r--chrome/browser/ui/cocoa/browser/edit_search_engine_cocoa_controller.h6
-rw-r--r--chrome/browser/ui/cocoa/browser/edit_search_engine_cocoa_controller.mm2
-rw-r--r--chrome/browser/ui/cocoa/browser_window_cocoa.h2
-rw-r--r--chrome/browser/ui/cocoa/browser_window_cocoa.mm2
-rw-r--r--chrome/browser/ui/gtk/browser_window_gtk.cc2
-rw-r--r--chrome/browser/ui/gtk/browser_window_gtk.h2
-rw-r--r--chrome/browser/ui/gtk/edit_search_engine_dialog.cc2
-rw-r--r--chrome/browser/ui/gtk/edit_search_engine_dialog.h4
-rw-r--r--chrome/browser/ui/panels/panel.cc2
-rw-r--r--chrome/browser/ui/panels/panel.h2
-rw-r--r--chrome/browser/ui/search_engines/edit_search_engine_controller.cc4
-rw-r--r--chrome/browser/ui/search_engines/edit_search_engine_controller.h8
-rw-r--r--chrome/browser/ui/search_engines/keyword_editor_controller.cc4
-rw-r--r--chrome/browser/ui/search_engines/keyword_editor_controller.h6
-rw-r--r--chrome/browser/ui/search_engines/keyword_editor_controller_unittest.cc2
-rw-r--r--chrome/browser/ui/search_engines/search_engine_tab_helper.cc2
-rw-r--r--chrome/browser/ui/search_engines/search_engine_tab_helper_delegate.h2
-rw-r--r--chrome/browser/ui/search_engines/template_url_table_model.cc18
-rw-r--r--chrome/browser/ui/search_engines/template_url_table_model.h2
-rw-r--r--chrome/browser/ui/views/browser_dialogs.h2
-rw-r--r--chrome/browser/ui/views/edit_search_engine_dialog.cc6
-rw-r--r--chrome/browser/ui/views/edit_search_engine_dialog.h4
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc2
-rw-r--r--chrome/browser/ui/views/frame/browser_view.h2
-rw-r--r--chrome/browser/ui/webui/options2/search_engine_manager_handler2.cc2
-rw-r--r--chrome/browser/ui/webui/options2/search_engine_manager_handler2.h2
-rw-r--r--chrome/browser/webdata/keyword_table.cc4
57 files changed, 300 insertions, 301 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit.cc b/chrome/browser/autocomplete/autocomplete_edit.cc
index fe47d30..c6773ff 100644
--- a/chrome/browser/autocomplete/autocomplete_edit.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit.cc
@@ -541,7 +541,7 @@ void AutocompleteEditModel::OpenMatch(const AutocompleteMatch& match,
content::Details<AutocompleteLog>(&log));
}
- const TemplateURL* template_url = match.GetTemplateURL();
+ TemplateURL* template_url = match.GetTemplateURL();
if (template_url) {
if (match.transition == content::PAGE_TRANSITION_KEYWORD) {
// The user is using a non-substituting keyword or is explicitly in
diff --git a/chrome/browser/autocomplete/autocomplete_match.cc b/chrome/browser/autocomplete/autocomplete_match.cc
index f3e3cc9..63cd210 100644
--- a/chrome/browser/autocomplete/autocomplete_match.cc
+++ b/chrome/browser/autocomplete/autocomplete_match.cc
@@ -302,7 +302,7 @@ string16 AutocompleteMatch::GetSubstitutingExplicitlyInvokedKeyword() const {
return (t_url && t_url->SupportsReplacement()) ? keyword : string16();
}
-const TemplateURL* AutocompleteMatch::GetTemplateURL() const {
+TemplateURL* AutocompleteMatch::GetTemplateURL() const {
return template_url;
}
diff --git a/chrome/browser/autocomplete/autocomplete_match.h b/chrome/browser/autocomplete/autocomplete_match.h
index a0260ae..dd53932 100644
--- a/chrome/browser/autocomplete/autocomplete_match.h
+++ b/chrome/browser/autocomplete/autocomplete_match.h
@@ -181,7 +181,7 @@ struct AutocompleteMatch {
string16 GetSubstitutingExplicitlyInvokedKeyword() const;
// Returns the TemplateURL associated with this match.
- const TemplateURL* GetTemplateURL() const;
+ TemplateURL* GetTemplateURL() const;
// The provider of this match, used to remember which provider the user had
// selected when the input changes. This may be NULL, in which case there is
@@ -256,7 +256,7 @@ struct AutocompleteMatch {
// Indicates the TemplateURL the match originated from. This is set for
// keywords as well as matches for the default search provider.
- const TemplateURL* template_url;
+ TemplateURL* template_url;
// True if the user has starred the destination URL.
bool starred;
diff --git a/chrome/browser/autocomplete/keyword_provider.cc b/chrome/browser/autocomplete/keyword_provider.cc
index 8c707b7..1a186a7 100644
--- a/chrome/browser/autocomplete/keyword_provider.cc
+++ b/chrome/browser/autocomplete/keyword_provider.cc
@@ -435,7 +435,7 @@ AutocompleteMatch KeywordProvider::CreateAutocompleteMatch(
int relevance) {
DCHECK(model);
// Get keyword data from data store.
- const TemplateURL* element = model->GetTemplateURLForKeyword(keyword);
+ TemplateURL* element = model->GetTemplateURLForKeyword(keyword);
DCHECK(element);
const bool supports_replacement = element->url_ref().SupportsReplacement();
diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc
index 35ebbfc..a8e45ee 100644
--- a/chrome/browser/autocomplete/search_provider.cc
+++ b/chrome/browser/autocomplete/search_provider.cc
@@ -220,7 +220,7 @@ void SearchProvider::Start(const AutocompleteInput& input,
match.contents.assign(l10n_util::GetStringUTF16(IDS_EMPTY_KEYWORD_VALUE));
match.contents_class.push_back(
ACMatchClassification(0, ACMatchClassification::NONE));
- match.template_url = &providers_.default_provider();
+ match.template_url = providers_.default_provider();
matches_.push_back(match);
}
Stop();
@@ -249,12 +249,12 @@ void SearchProvider::Run() {
if (providers_.valid_suggest_for_default_provider()) {
suggest_results_pending_++;
default_fetcher_.reset(CreateSuggestFetcher(kDefaultProviderURLFetcherID,
- providers_.default_provider().suggestions_url_ref(), input_.text()));
+ providers_.default_provider()->suggestions_url_ref(), input_.text()));
}
if (providers_.valid_suggest_for_keyword_provider()) {
suggest_results_pending_++;
keyword_fetcher_.reset(CreateSuggestFetcher(kKeywordProviderURLFetcherID,
- providers_.keyword_provider().suggestions_url_ref(),
+ providers_.keyword_provider()->suggestions_url_ref(),
keyword_input_text_));
}
// We should only get here if we have a suggest url for the keyword or default
@@ -341,11 +341,11 @@ void SearchProvider::DoHistoryQuery(bool minimal_changes) {
// database.
int num_matches = kMaxMatches * 5;
if (providers_.valid_default_provider()) {
- url_db->GetMostRecentKeywordSearchTerms(providers_.default_provider().id(),
+ url_db->GetMostRecentKeywordSearchTerms(providers_.default_provider()->id(),
input_.text(), num_matches, &default_history_results_);
}
if (providers_.valid_keyword_provider()) {
- url_db->GetMostRecentKeywordSearchTerms(providers_.keyword_provider().id(),
+ url_db->GetMostRecentKeywordSearchTerms(providers_.keyword_provider()->id(),
keyword_input_text_, num_matches, &keyword_history_results_);
}
}
@@ -841,9 +841,9 @@ void SearchProvider::AddMatchToMap(const string16& query_string,
MatchMap* map) {
AutocompleteMatch match(this, relevance, false, type);
std::vector<size_t> content_param_offsets;
- const TemplateURL& provider = is_keyword ?
+ TemplateURL* provider = is_keyword ?
providers_.keyword_provider() : providers_.default_provider();
- match.template_url = &provider;
+ match.template_url = provider;
match.contents.assign(query_string);
// We do intra-string highlighting for suggestions - the suggested segment
// will be highlighted, e.g. for input_text = "you" the suggestion may be
@@ -893,7 +893,7 @@ void SearchProvider::AddMatchToMap(const string16& query_string,
++search_start;
}
if (is_keyword) {
- match.keyword = providers_.keyword_provider().keyword();
+ match.keyword = providers_.keyword_provider()->keyword();
match.fill_into_edit.append(match.keyword + char16(' '));
search_start += match.keyword.length() + 1;
}
@@ -904,7 +904,7 @@ void SearchProvider::AddMatchToMap(const string16& query_string,
input_text))
match.inline_autocomplete_offset = search_start + input_text.length();
- const TemplateURLRef& search_url = provider.url_ref();
+ const TemplateURLRef& search_url = provider->url_ref();
DCHECK(search_url.SupportsReplacement());
match.destination_url = GURL(search_url.ReplaceSearchTerms(query_string,
accepted_suggestion, input_text));
diff --git a/chrome/browser/autocomplete/search_provider.h b/chrome/browser/autocomplete/search_provider.h
index d4ab56e..0914101 100644
--- a/chrome/browser/autocomplete/search_provider.h
+++ b/chrome/browser/autocomplete/search_provider.h
@@ -109,14 +109,14 @@ class SearchProvider : public AutocompleteProvider,
void Set(const TemplateURL* default_provider,
const TemplateURL* keyword_provider);
- const TemplateURL& default_provider() const {
+ TemplateURL* default_provider() {
DCHECK(valid_default_provider());
- return cached_default_provider_;
+ return &cached_default_provider_;
}
- const TemplateURL& keyword_provider() const {
+ TemplateURL* keyword_provider() {
DCHECK(valid_keyword_provider());
- return cached_keyword_provider_;
+ return &cached_keyword_provider_;
}
// Returns true if the default provider is valid.
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
index bed3cfe..7c9c736 100644
--- a/chrome/browser/automation/testing_automation_provider.cc
+++ b/chrome/browser/automation/testing_automation_provider.cc
@@ -3328,8 +3328,8 @@ void TestingAutomationProvider::AddOrEditSearchEngine(
scoped_ptr<KeywordEditorController> controller(
new KeywordEditorController(browser->profile()));
if (args->GetString("keyword", &keyword)) {
- const TemplateURL* template_url(
- url_model->GetTemplateURLForKeyword(UTF8ToUTF16(keyword)));
+ TemplateURL* template_url =
+ url_model->GetTemplateURLForKeyword(UTF8ToUTF16(keyword));
if (template_url == NULL) {
AutomationJSONReply(this, reply_message).SendError(
"No match for keyword: " + keyword);
@@ -3362,8 +3362,8 @@ void TestingAutomationProvider::PerformActionOnSearchEngine(
"One or more inputs invalid");
return;
}
- const TemplateURL* template_url(
- url_model->GetTemplateURLForKeyword(UTF8ToUTF16(keyword)));
+ TemplateURL* template_url =
+ url_model->GetTemplateURLForKeyword(UTF8ToUTF16(keyword));
if (template_url == NULL) {
AutomationJSONReply(this, reply_message).SendError(
"No match for keyword: " + keyword);
diff --git a/chrome/browser/importer/profile_writer.cc b/chrome/browser/importer/profile_writer.cc
index 2450e58..8519432 100644
--- a/chrome/browser/importer/profile_writer.cc
+++ b/chrome/browser/importer/profile_writer.cc
@@ -232,7 +232,7 @@ void ProfileWriter::AddFavicons(
SetImportedFavicons(favicons);
}
-typedef std::map<std::string, const TemplateURL*> HostPathMap;
+typedef std::map<std::string, TemplateURL*> HostPathMap;
// Returns the key for the map built by BuildHostPathMap. If url_string is not
// a valid URL, an empty string is returned, otherwise host+path is returned.
diff --git a/chrome/browser/protector/base_setting_change.h b/chrome/browser/protector/base_setting_change.h
index 14af703..d378af2 100644
--- a/chrome/browser/protector/base_setting_change.h
+++ b/chrome/browser/protector/base_setting_change.h
@@ -137,7 +137,7 @@ extern const size_t kHomepageChangeNamePriority;
// |backup| will be owned by the returned |BaseSettingChange| instance. |actual|
// is not owned and is safe to destroy after Protector::ShowChange has been
// called for the returned instance.
-BaseSettingChange* CreateDefaultSearchProviderChange(const TemplateURL* actual,
+BaseSettingChange* CreateDefaultSearchProviderChange(TemplateURL* actual,
TemplateURL* backup);
// Allocates and initializes BaseSettingChange implementation for session
diff --git a/chrome/browser/protector/default_search_provider_change.cc b/chrome/browser/protector/default_search_provider_change.cc
index dbd0027..a632f3f 100644
--- a/chrome/browser/protector/default_search_provider_change.cc
+++ b/chrome/browser/protector/default_search_provider_change.cc
@@ -82,7 +82,7 @@ class DefaultSearchProviderChange : public BaseSettingChange,
public TemplateURLServiceObserver,
public content::NotificationObserver {
public:
- DefaultSearchProviderChange(const TemplateURL* new_search_provider,
+ DefaultSearchProviderChange(TemplateURL* new_search_provider,
TemplateURL* backup_search_provider);
// BaseSettingChange overrides:
@@ -145,7 +145,7 @@ class DefaultSearchProviderChange : public BaseSettingChange,
// The default search at the moment the change was detected. Will be used to
// restore the new default search back if Apply is called. Will be set to
// |NULL| if removed from the TemplateURLService.
- const TemplateURL* new_search_provider_;
+ TemplateURL* new_search_provider_;
// Default search provider set by Init for the period until user makes a
// choice and either Apply or Discard is performed. Never is |NULL| during
// that period since the change will dismiss itself if this provider gets
@@ -160,7 +160,7 @@ class DefaultSearchProviderChange : public BaseSettingChange,
};
DefaultSearchProviderChange::DefaultSearchProviderChange(
- const TemplateURL* new_search_provider,
+ TemplateURL* new_search_provider,
TemplateURL* backup_search_provider)
: new_histogram_id_(GetSearchProviderHistogramID(new_search_provider)),
is_fallback_(false),
@@ -387,7 +387,7 @@ const TemplateURL* DefaultSearchProviderChange::SetDefaultSearchProvider(
scoped_ptr<TemplateURL>* search_provider) {
TemplateURLService* url_service = GetTemplateURLService();
TemplateURLService::TemplateURLVector urls = url_service->GetTemplateURLs();
- const TemplateURL* new_default_provider = NULL;
+ TemplateURL* new_default_provider = NULL;
// Check if this provider already exists and add it otherwise.
TemplateURLService::TemplateURLVector::const_iterator i =
@@ -432,7 +432,7 @@ TemplateURLService* DefaultSearchProviderChange::GetTemplateURLService() {
return url_service;
}
-BaseSettingChange* CreateDefaultSearchProviderChange(const TemplateURL* actual,
+BaseSettingChange* CreateDefaultSearchProviderChange(TemplateURL* actual,
TemplateURL* backup) {
return new DefaultSearchProviderChange(actual, backup);
}
diff --git a/chrome/browser/protector/default_search_provider_change_browsertest.cc b/chrome/browser/protector/default_search_provider_change_browsertest.cc
index f95ac0b..0709478 100644
--- a/chrome/browser/protector/default_search_provider_change_browsertest.cc
+++ b/chrome/browser/protector/default_search_provider_change_browsertest.cc
@@ -83,7 +83,7 @@ class DefaultSearchProviderChangeTest : public InProcessBrowserTest {
return new TemplateURL(browser()->profile(), data);
}
- const TemplateURL* FindTemplateURL(const std::string& search_url) {
+ TemplateURL* FindTemplateURL(const std::string& search_url) {
TemplateURLService::TemplateURLVector urls =
turl_service_->GetTemplateURLs();
for (TemplateURLService::TemplateURLVector::const_iterator
@@ -377,8 +377,7 @@ IN_PROC_BROWSER_TEST_F(DefaultSearchProviderChangeTest,
AddAndSetDefault(current_url);
- const TemplateURL* prepopulated_default =
- FindTemplateURL(prepopulated_url_->url());
+ TemplateURL* prepopulated_default = FindTemplateURL(prepopulated_url_->url());
// Prepopulated default search must exist, remove it.
ASSERT_TRUE(prepopulated_default);
turl_service_->Remove(prepopulated_default);
@@ -567,7 +566,7 @@ IN_PROC_BROWSER_TEST_F(DefaultSearchProviderChangeTest,
// same as the current search provider.
int prepopulated_histogram_id =
protector::GetSearchProviderHistogramID(prepopulated_url_.get());
- const TemplateURL* current_url = turl_service_->GetDefaultSearchProvider();
+ TemplateURL* current_url = turl_service_->GetDefaultSearchProvider();
// Verify that current search provider is same as the prepopulated default.
ASSERT_TRUE(current_url);
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);
diff --git a/chrome/browser/search_engines/search_host_to_urls_map.h b/chrome/browser/search_engines/search_host_to_urls_map.h
index cd21a87..cdd31a5 100644
--- a/chrome/browser/search_engines/search_host_to_urls_map.h
+++ b/chrome/browser/search_engines/search_host_to_urls_map.h
@@ -9,55 +9,56 @@
#include <map>
#include <set>
#include <string>
-#include <vector>
#include "base/basictypes.h"
-
-class SearchTermsData;
-class TemplateURL;
+#include "chrome/browser/search_engines/template_url_service.h"
// Holds the host to template url mappings for the search providers. WARNING:
// This class does not own any TemplateURLs passed to it and it is up to the
// caller to ensure the right lifetime of them.
class SearchHostToURLsMap {
public:
- typedef std::set<const TemplateURL*> TemplateURLSet;
+ typedef std::set<TemplateURL*> TemplateURLSet;
SearchHostToURLsMap();
~SearchHostToURLsMap();
// Initializes the map.
- void Init(const std::vector<const TemplateURL*>& template_urls,
+ void Init(const TemplateURLService::TemplateURLVector& template_urls,
const SearchTermsData& search_terms_data);
// Adds a new TemplateURL to the map. Since |template_url| is owned
// externally, Remove or RemoveAll should be called if it becomes invalid.
- void Add(const TemplateURL* template_url,
+ void Add(TemplateURL* template_url,
const SearchTermsData& search_terms_data);
// Removes the TemplateURL from the lookup.
- void Remove(const TemplateURL* template_url);
+ void Remove(TemplateURL* template_url);
// Updates all search providers which have a google base url.
void UpdateGoogleBaseURLs(const SearchTermsData& search_terms_data);
// Returns the first TemplateURL found with a URL using the specified |host|,
// or NULL if there are no such TemplateURLs
- const TemplateURL* GetTemplateURLForHost(const std::string& host) const;
+ TemplateURL* GetTemplateURLForHost(const std::string& host);
// Return the TemplateURLSet for the given the |host| or NULL if there are
// none.
- const TemplateURLSet* GetURLsForHost(const std::string& host) const;
+ TemplateURLSet* GetURLsForHost(const std::string& host);
private:
friend class SearchHostToURLsMapTest;
typedef std::map<std::string, TemplateURLSet> HostToURLsMap;
+ // Adds many URLs to the map.
+ void Add(const TemplateURLService::TemplateURLVector& template_urls,
+ const SearchTermsData& search_terms_data);
+
// Removes the given template_url using only the pointer instead of the value.
// This is useful when the value may have changed before being updated in the
// map. (Specifically when the GoogleBaseURLValue changes.)
- void RemoveByPointer(const TemplateURL* template_url);
+ void RemoveByPointer(TemplateURL* template_url);
// Maps from host to set of TemplateURLs whose search url host is host.
HostToURLsMap host_to_urls_map_;
diff --git a/chrome/browser/search_engines/search_host_to_urls_map_unittest.cc b/chrome/browser/search_engines/search_host_to_urls_map_unittest.cc
index edbec3d..2a0aec0 100644
--- a/chrome/browser/search_engines/search_host_to_urls_map_unittest.cc
+++ b/chrome/browser/search_engines/search_host_to_urls_map_unittest.cc
@@ -34,7 +34,7 @@ void SearchHostToURLsMapTest::SetUp() {
t_urls_[0].reset(new TemplateURL(NULL, data));
data.SetURL("http://" + host_ + "/path2");
t_urls_[1].reset(new TemplateURL(NULL, data));
- std::vector<const TemplateURL*> template_urls;
+ std::vector<TemplateURL*> template_urls;
template_urls.push_back(t_urls_[0].get());
template_urls.push_back(t_urls_[1].get());
diff --git a/chrome/browser/search_engines/search_provider_install_data.cc b/chrome/browser/search_engines/search_provider_install_data.cc
index c3af1aa..defd639 100644
--- a/chrome/browser/search_engines/search_provider_install_data.cc
+++ b/chrome/browser/search_engines/search_provider_install_data.cc
@@ -141,7 +141,7 @@ void GoogleURLObserver::Observe(int type,
// |requested_origin| should only be a security origin (no path, etc.).
// It is ok if |template_url| is NULL.
static bool IsSameOrigin(const GURL& requested_origin,
- const TemplateURL* template_url,
+ TemplateURL* template_url,
const SearchTermsData& search_terms_data) {
DCHECK(requested_origin == requested_origin.GetOrigin());
return requested_origin ==
@@ -237,7 +237,7 @@ void SearchProviderInstallData::OnWebDataServiceRequestDone(
return;
}
- const TemplateURL* default_search_provider = NULL;
+ TemplateURL* default_search_provider = NULL;
int new_resource_keyword_version = 0;
std::vector<TemplateURL*> extracted_template_urls;
GetSearchProvidersUsingKeywordResult(*result,
diff --git a/chrome/browser/search_engines/search_provider_install_data.h b/chrome/browser/search_engines/search_provider_install_data.h
index bd03fd6..246f5a3 100644
--- a/chrome/browser/search_engines/search_provider_install_data.h
+++ b/chrome/browser/search_engines/search_provider_install_data.h
@@ -97,7 +97,7 @@ class SearchProviderInstallData : public WebDataServiceConsumer,
scoped_ptr<SearchHostToURLsMap> provider_map_;
// The list of template urls that are owned by the class.
- ScopedVector<const TemplateURL> template_urls_;
+ ScopedVector<TemplateURL> template_urls_;
// The security origin for the default search provider.
std::string default_search_origin_;
diff --git a/chrome/browser/search_engines/template_url.cc b/chrome/browser/search_engines/template_url.cc
index b47696a..157fdc7 100644
--- a/chrome/browser/search_engines/template_url.cc
+++ b/chrome/browser/search_engines/template_url.cc
@@ -584,7 +584,7 @@ void TemplateURLData::SetKeyword(const string16& keyword) {
autogenerate_keyword_ = false;
}
-const string16& TemplateURLData::keyword(const TemplateURL* t_url) const {
+const string16& TemplateURLData::keyword(TemplateURL* t_url) const {
EnsureKeyword(t_url);
return keyword_;
}
@@ -597,7 +597,7 @@ void TemplateURLData::SetAutogenerateKeyword(bool autogenerate_keyword) {
}
}
-void TemplateURLData::EnsureKeyword(const TemplateURL* t_url) const {
+void TemplateURLData::EnsureKeyword(TemplateURL* t_url) const {
if (autogenerate_keyword_ && !keyword_generated_) {
// Generate a keyword and cache it.
keyword_ = base::i18n::ToLower(TemplateURLService::GenerateKeyword(
diff --git a/chrome/browser/search_engines/template_url.h b/chrome/browser/search_engines/template_url.h
index a0d703a..d81a5b3 100644
--- a/chrome/browser/search_engines/template_url.h
+++ b/chrome/browser/search_engines/template_url.h
@@ -244,7 +244,7 @@ struct TemplateURLData {
// The shortcut for this TemplateURL. May be empty.
void SetKeyword(const string16& keyword);
- const string16& keyword(const TemplateURL* t_url) const;
+ const string16& keyword(TemplateURL* t_url) const;
// TODO(pkasting): This should only be necessary until we eliminate keyword
// autogeneration.
const string16& raw_keyword() const { return keyword_; }
@@ -259,7 +259,7 @@ struct TemplateURLData {
// Ensures that the keyword is generated. Most consumers should not need this
// because it is done automatically. Use this method on the UI thread, so
// the keyword may be accessed on another thread.
- void EnsureKeyword(const TemplateURL* t_url) const;
+ void EnsureKeyword(TemplateURL* t_url) const;
// The raw URL for the TemplateURL, which may not be valid as-is (e.g. because
// it requires substitutions first). This must be non-empty.
@@ -376,11 +376,18 @@ class TemplateURL {
// displayed even if it is LTR and the UI is RTL.
string16 AdjustedShortNameForLocaleDirection() const;
- const string16& keyword() const { return data_.keyword(this); }
+ const string16& keyword() const {
+ // TODO(pkasting): See comment on EnsureKeyword() below.
+ return data_.keyword(const_cast<TemplateURL*>(this));
+ }
bool autogenerate_keyword() const {
return data_.autogenerate_keyword();
}
- void EnsureKeyword() const { data_.EnsureKeyword(this); }
+ void EnsureKeyword() const {
+ // TODO(pkasting): EnsureKeyword() will die soon so it's not worth jumping
+ // through hoops to fix this const_cast<>().
+ data_.EnsureKeyword(const_cast<TemplateURL*>(this));
+ }
const std::string& url() const { return data_.url(); }
const std::string& suggestions_url() const { return data_.suggestions_url; }
diff --git a/chrome/browser/search_engines/template_url_fetcher.cc b/chrome/browser/search_engines/template_url_fetcher.cc
index 575fef3..fade852 100644
--- a/chrome/browser/search_engines/template_url_fetcher.cc
+++ b/chrome/browser/search_engines/template_url_fetcher.cc
@@ -182,7 +182,7 @@ void TemplateURLFetcher::RequestDelegate::AddSearchProvider() {
DCHECK(model);
DCHECK(model->loaded());
- const TemplateURL* existing_url = NULL;
+ TemplateURL* existing_url = NULL;
if (model->CanReplaceKeyword(keyword_, GURL(template_url_->url()),
&existing_url)) {
if (existing_url)
diff --git a/chrome/browser/search_engines/template_url_service.cc b/chrome/browser/search_engines/template_url_service.cc
index edabfec..7bdbe87 100644
--- a/chrome/browser/search_engines/template_url_service.cc
+++ b/chrome/browser/search_engines/template_url_service.cc
@@ -80,6 +80,16 @@ bool TemplateURLsHaveSamePrefs(const TemplateURL* url1,
(url1->input_encodings() == url2->input_encodings());
}
+TemplateURL* FirstPotentialDefaultEngine(
+ const TemplateURLService::TemplateURLVector& template_urls) {
+ for (TemplateURLService::TemplateURLVector::const_iterator i(
+ template_urls.begin()); i != template_urls.end(); ++i) {
+ if (!(*i)->IsExtensionKeyword() && (*i)->SupportsReplacement())
+ return *i;
+ }
+ return NULL;
+}
+
} // namespace
@@ -106,7 +116,8 @@ class TemplateURLService::LessWithPrefix {
};
TemplateURLService::TemplateURLService(Profile* profile)
- : profile_(profile),
+ : provider_map_(new SearchHostToURLsMap),
+ profile_(profile),
loaded_(false),
load_failed_(false),
load_handle_(0),
@@ -123,7 +134,8 @@ TemplateURLService::TemplateURLService(Profile* profile)
TemplateURLService::TemplateURLService(const Initializer* initializers,
const int count)
- : profile_(NULL),
+ : provider_map_(new SearchHostToURLsMap),
+ profile_(NULL),
loaded_(false),
load_failed_(false),
load_handle_(0),
@@ -208,7 +220,7 @@ string16 TemplateURLService::CleanUserInputKeyword(const string16& keyword) {
}
// static
-GURL TemplateURLService::GenerateSearchURL(const TemplateURL* t_url) {
+GURL TemplateURLService::GenerateSearchURL(TemplateURL* t_url) {
DCHECK(t_url);
UIThreadSearchTermsData search_terms_data;
return GenerateSearchURLUsingTermsData(t_url, search_terms_data);
@@ -236,11 +248,11 @@ GURL TemplateURLService::GenerateSearchURLUsingTermsData(
bool TemplateURLService::CanReplaceKeyword(
const string16& keyword,
const GURL& url,
- const TemplateURL** template_url_to_replace) {
+ TemplateURL** template_url_to_replace) {
DCHECK(!keyword.empty()); // This should only be called for non-empty
// keywords. If we need to support empty kewords
// the code needs to change slightly.
- const TemplateURL* existing_url = GetTemplateURLForKeyword(keyword);
+ TemplateURL* existing_url = GetTemplateURLForKeyword(keyword);
if (template_url_to_replace)
*template_url_to_replace = existing_url;
if (existing_url) {
@@ -269,7 +281,7 @@ void TemplateURLService::FindMatchingKeywords(
DCHECK(matches->empty()); // The code for exact matches assumes this.
// Required for VS2010: http://connect.microsoft.com/VisualStudio/feedback/details/520043/error-converting-from-null-to-a-pointer-type-in-std-pair
- const TemplateURL* const kNullTemplateURL = NULL;
+ TemplateURL* const kNullTemplateURL = NULL;
// Find matching keyword range. Searches the element map for keywords
// beginning with |prefix| and stores the endpoints of the resulting set in
@@ -289,8 +301,8 @@ void TemplateURLService::FindMatchingKeywords(
}
}
-const TemplateURL* TemplateURLService::GetTemplateURLForKeyword(
- const string16& keyword) const {
+TemplateURL* TemplateURLService::GetTemplateURLForKeyword(
+ const string16& keyword) {
KeywordToTemplateMap::const_iterator elem(
keyword_to_template_map_.find(keyword));
if (elem != keyword_to_template_map_.end())
@@ -300,8 +312,8 @@ const TemplateURL* TemplateURLService::GetTemplateURLForKeyword(
initial_default_search_provider_.get() : NULL;
}
-const TemplateURL* TemplateURLService::GetTemplateURLForGUID(
- const std::string& sync_guid) const {
+TemplateURL* TemplateURLService::GetTemplateURLForGUID(
+ const std::string& sync_guid) {
GUIDToTemplateMap::const_iterator elem(
guid_to_template_map_.find(sync_guid));
if (elem != guid_to_template_map_.end())
@@ -311,9 +323,9 @@ const TemplateURL* TemplateURLService::GetTemplateURLForGUID(
initial_default_search_provider_.get() : NULL;
}
-const TemplateURL* TemplateURLService::GetTemplateURLForHost(
- const std::string& host) const {
- const TemplateURL* t_url = provider_map_.GetTemplateURLForHost(host);
+TemplateURL* TemplateURLService::GetTemplateURLForHost(
+ const std::string& host) {
+ TemplateURL* t_url = provider_map_->GetTemplateURLForHost(host);
if (t_url)
return t_url;
return (initial_default_search_provider_.get() &&
@@ -332,19 +344,18 @@ void TemplateURLService::AddAndSetProfile(TemplateURL* template_url,
Add(template_url);
}
-void TemplateURLService::AddWithOverrides(const TemplateURL* template_url,
+void TemplateURLService::AddWithOverrides(TemplateURL* template_url,
const string16& short_name,
const string16& keyword,
const std::string& url) {
DCHECK(!url.empty());
- TemplateURL* modifiable_url = const_cast<TemplateURL*>(template_url);
- modifiable_url->data_.short_name = short_name;
- modifiable_url->data_.SetKeyword(keyword);
- modifiable_url->SetURL(url);
- Add(modifiable_url);
+ template_url->data_.short_name = short_name;
+ template_url->data_.SetKeyword(keyword);
+ template_url->SetURL(url);
+ Add(template_url);
}
-void TemplateURLService::Remove(const TemplateURL* template_url) {
+void TemplateURLService::Remove(TemplateURL* template_url) {
RemoveNoNotify(template_url);
NotifyObservers();
}
@@ -408,7 +419,7 @@ void TemplateURLService::RegisterExtensionKeyword(const Extension* extension) {
void TemplateURLService::UnregisterExtensionKeyword(
const Extension* extension) {
if (loaded_) {
- const TemplateURL* url = GetTemplateURLForExtension(extension);
+ TemplateURL* url = GetTemplateURLForExtension(extension);
if (url)
Remove(url);
} else {
@@ -419,8 +430,8 @@ void TemplateURLService::UnregisterExtensionKeyword(
}
}
-const TemplateURL* TemplateURLService::GetTemplateURLForExtension(
- const Extension* extension) const {
+TemplateURL* TemplateURLService::GetTemplateURLForExtension(
+ const Extension* extension) {
for (TemplateURLVector::const_iterator i = template_urls_.begin();
i != template_urls_.end(); ++i) {
if ((*i)->IsExtensionKeyword() &&
@@ -431,15 +442,14 @@ const TemplateURL* TemplateURLService::GetTemplateURLForExtension(
return NULL;
}
-TemplateURLService::TemplateURLVector
- TemplateURLService::GetTemplateURLs() const {
+TemplateURLService::TemplateURLVector TemplateURLService::GetTemplateURLs() {
return template_urls_;
}
-void TemplateURLService::IncrementUsageCount(const TemplateURL* url) {
+void TemplateURLService::IncrementUsageCount(TemplateURL* url) {
DCHECK(url && std::find(template_urls_.begin(), template_urls_.end(), url) !=
template_urls_.end());
- ++const_cast<TemplateURL*>(url)->data_.usage_count;
+ ++url->data_.usage_count;
// Extension keywords are not persisted.
// TODO(mpcomplete): If we allow editing extension keywords, then those should
// be persisted to disk and synced.
@@ -447,7 +457,7 @@ void TemplateURLService::IncrementUsageCount(const TemplateURL* url) {
service_.get()->UpdateKeyword(*url);
}
-void TemplateURLService::ResetTemplateURL(const TemplateURL* url,
+void TemplateURLService::ResetTemplateURL(TemplateURL* url,
const string16& title,
const string16& keyword,
const std::string& search_url) {
@@ -462,7 +472,7 @@ void TemplateURLService::ResetTemplateURL(const TemplateURL* url,
}
data.safe_for_autoreplace = false;
data.last_modified = time_provider_();
- TemplateURL new_url(const_cast<TemplateURL*>(url)->profile(), data);
+ TemplateURL new_url(url->profile(), data);
UpdateNoNotify(url, new_url);
NotifyObservers();
}
@@ -472,7 +482,7 @@ bool TemplateURLService::CanMakeDefault(const TemplateURL* url) {
url->url_ref().SupportsReplacement() && !is_default_search_managed();
}
-void TemplateURLService::SetDefaultSearchProvider(const TemplateURL* url) {
+void TemplateURLService::SetDefaultSearchProvider(TemplateURL* url) {
DCHECK(!is_default_search_managed_);
// Extension keywords cannot be made default, as they are inherently async.
DCHECK(!url || !url->IsExtensionKeyword());
@@ -483,7 +493,7 @@ void TemplateURLService::SetDefaultSearchProvider(const TemplateURL* url) {
NotifyObservers();
}
-const TemplateURL* TemplateURLService::GetDefaultSearchProvider() {
+TemplateURL* TemplateURLService::GetDefaultSearchProvider() {
if (loaded_ && !load_failed_)
return default_search_provider_;
@@ -491,7 +501,7 @@ const TemplateURL* TemplateURLService::GetDefaultSearchProvider() {
return initial_default_search_provider_.get();
}
-const TemplateURL* TemplateURLService::FindNewDefaultSearchProvider() {
+TemplateURL* TemplateURLService::FindNewDefaultSearchProvider() {
// See if the prepopulated default still exists.
scoped_ptr<TemplateURL> prepopulated_default(
TemplateURLPrepopulateData::GetPrepopulatedDefaultSearch(profile_));
@@ -502,12 +512,7 @@ const TemplateURL* TemplateURLService::FindNewDefaultSearchProvider() {
}
// If not, use the first non-extension keyword of the templates that supports
// search term replacement.
- for (TemplateURLVector::const_iterator i(template_urls_.begin());
- i != template_urls_.end(); ++i) {
- if (!(*i)->IsExtensionKeyword() && (*i)->SupportsReplacement())
- return *i;
- }
- return NULL;
+ return FirstPotentialDefaultEngine(template_urls_);
}
void TemplateURLService::AddObserver(TemplateURLServiceObserver* observer) {
@@ -554,8 +559,8 @@ void TemplateURLService::OnWebDataServiceRequestDone(
initial_default_search_provider_.reset();
is_default_search_managed_ = false;
- std::vector<TemplateURL*> template_urls;
- const TemplateURL* default_search_provider = NULL;
+ TemplateURLVector template_urls;
+ TemplateURL* default_search_provider = NULL;
int new_resource_keyword_version = 0;
GetSearchProvidersUsingKeywordResult(*result, service_.get(), profile_,
&template_urls, &default_search_provider, &new_resource_keyword_version);
@@ -571,7 +576,7 @@ void TemplateURLService::OnWebDataServiceRequestDone(
// another program. No immediate action is performed because the default
// search may be changed below by Sync which effectively undoes the hijacking.
bool is_default_search_hijacked = false;
- const TemplateURL* hijacked_default_search_provider = NULL;
+ TemplateURL* hijacked_default_search_provider = NULL;
scoped_ptr<TemplateURL> backup_default_search_provider;
// No check is required if the default search is managed.
// |DidDefaultSearchProviderChange| must always be called because it will
@@ -605,9 +610,8 @@ void TemplateURLService::OnWebDataServiceRequestDone(
TemplateURLData data(default_from_prefs->data());
data.created_by_policy = true;
data.id = kInvalidTemplateURLID;
- TemplateURL* managed_default = new TemplateURL(profile_, data);
- AddNoNotify(managed_default, true);
- default_search_provider = managed_default;
+ default_search_provider = new TemplateURL(profile_, data);
+ AddNoNotify(default_search_provider, true);
}
}
// Note that this saves the default search provider to prefs.
@@ -618,19 +622,13 @@ void TemplateURLService::OnWebDataServiceRequestDone(
} else {
// If we had a managed default, replace it with the synced default if
// applicable, or the first provider of the list.
- const TemplateURL* synced_default = GetPendingSyncedDefaultSearchProvider();
+ TemplateURL* synced_default = GetPendingSyncedDefaultSearchProvider();
if (synced_default) {
default_search_provider = synced_default;
pending_synced_default_search_ = false;
} else if (database_specified_a_default &&
default_search_provider == NULL) {
- for (std::vector<TemplateURL*>::const_iterator i = template_urls.begin();
- i != template_urls.end(); ++i) {
- if (!(*i)->IsExtensionKeyword() && (*i)->SupportsReplacement()) {
- default_search_provider = *i;
- break;
- }
- }
+ default_search_provider = FirstPotentialDefaultEngine(template_urls);
}
// If the default search provider existed previously, then just
@@ -746,7 +744,7 @@ void TemplateURLService::Observe(int type,
DCHECK_EQ(std::string(prefs::kSyncedDefaultSearchProviderGUID),
*content::Details<std::string>(details).ptr());
PrefService* prefs = GetPrefs();
- const TemplateURL* new_default_search = GetTemplateURLForGUID(
+ TemplateURL* new_default_search = GetTemplateURLForGUID(
prefs->GetString(prefs::kSyncedDefaultSearchProviderGUID));
if (new_default_search && !is_default_search_managed_) {
if (new_default_search != GetDefaultSearchProvider()) {
@@ -805,13 +803,13 @@ SyncError TemplateURLService::ProcessSyncChanges(
std::string guid =
iter->sync_data().GetSpecifics().search_engine().sync_guid();
- const TemplateURL* existing_turl = GetTemplateURLForGUID(guid);
+ TemplateURL* existing_turl = GetTemplateURLForGUID(guid);
scoped_ptr<TemplateURL> turl(CreateTemplateURLFromTemplateURLAndSyncData(
profile_, existing_turl, iter->sync_data(), &new_changes));
if (!turl.get())
continue;
- const TemplateURL* existing_keyword_turl =
+ TemplateURL* existing_keyword_turl =
GetTemplateURLForKeyword(turl->keyword());
if (iter->change_type() == SyncChange::ACTION_DELETE && existing_turl) {
@@ -909,7 +907,7 @@ SyncError TemplateURLService::MergeDataAndStartSyncing(
for (SyncDataMap::const_iterator iter = sync_data_map.begin();
iter != sync_data_map.end(); ++iter) {
- const TemplateURL* local_turl = GetTemplateURLForGUID(iter->first);
+ TemplateURL* local_turl = GetTemplateURLForGUID(iter->first);
scoped_ptr<TemplateURL> sync_turl(
CreateTemplateURLFromTemplateURLAndSyncData(profile_, local_turl,
iter->second, &new_changes));
@@ -939,12 +937,11 @@ SyncError TemplateURLService::MergeDataAndStartSyncing(
// The search engine from the cloud has not been synced locally, but there
// might be a local search engine that is a duplicate that needs to be
// merged.
- const TemplateURL* dupe_turl = FindDuplicateOfSyncTemplateURL(*sync_turl);
+ TemplateURL* dupe_turl = FindDuplicateOfSyncTemplateURL(*sync_turl);
if (dupe_turl) {
// Merge duplicates and remove the processed local TURL from the map.
std::string old_guid = dupe_turl->sync_guid();
- MergeSyncAndLocalURLDuplicates(sync_turl.release(),
- const_cast<TemplateURL*>(dupe_turl),
+ MergeSyncAndLocalURLDuplicates(sync_turl.release(), dupe_turl,
&new_changes);
local_data_map.erase(old_guid);
} else {
@@ -1046,7 +1043,7 @@ SyncData TemplateURLService::CreateSyncDataFromTemplateURL(
// static
TemplateURL* TemplateURLService::CreateTemplateURLFromTemplateURLAndSyncData(
Profile* profile,
- const TemplateURL* existing_turl,
+ TemplateURL* existing_turl,
const SyncData& sync_data,
SyncChangeList* change_list) {
DCHECK(change_list);
@@ -1169,7 +1166,7 @@ void TemplateURLService::Init(const Initializer* initializers,
}
}
-void TemplateURLService::RemoveFromMaps(const TemplateURL* template_url) {
+void TemplateURLService::RemoveFromMaps(TemplateURL* template_url) {
if (!template_url->keyword().empty())
keyword_to_template_map_.erase(template_url->keyword());
@@ -1183,11 +1180,11 @@ void TemplateURLService::RemoveFromMaps(const TemplateURL* template_url) {
if (!template_url->sync_guid().empty())
guid_to_template_map_.erase(template_url->sync_guid());
if (loaded_)
- provider_map_.Remove(template_url);
+ provider_map_->Remove(template_url);
}
void TemplateURLService::RemoveFromKeywordMapByPointer(
- const TemplateURL* template_url) {
+ TemplateURL* template_url) {
DCHECK(template_url);
for (KeywordToTemplateMap::iterator i = keyword_to_template_map_.begin();
i != keyword_to_template_map_.end(); ++i) {
@@ -1200,7 +1197,7 @@ void TemplateURLService::RemoveFromKeywordMapByPointer(
}
}
-void TemplateURLService::AddToMaps(const TemplateURL* template_url) {
+void TemplateURLService::AddToMaps(TemplateURL* template_url) {
if (!template_url->keyword().empty())
keyword_to_template_map_[template_url->keyword()] = template_url;
@@ -1216,18 +1213,17 @@ void TemplateURLService::AddToMaps(const TemplateURL* template_url) {
guid_to_template_map_[template_url->sync_guid()] = template_url;
if (loaded_) {
UIThreadSearchTermsData search_terms_data;
- provider_map_.Add(template_url, search_terms_data);
+ provider_map_->Add(template_url, search_terms_data);
}
}
-void TemplateURLService::SetTemplateURLs(
- const std::vector<TemplateURL*>& urls) {
+void TemplateURLService::SetTemplateURLs(const TemplateURLVector& urls) {
// Add mappings for the new items.
// First, add the items that already have id's, so that the next_id_
// gets properly set.
- for (std::vector<TemplateURL*>::const_iterator i = urls.begin();
- i != urls.end(); ++i) {
+ for (TemplateURLVector::const_iterator i = urls.begin(); i != urls.end();
+ ++i) {
if ((*i)->id() != kInvalidTemplateURLID) {
next_id_ = std::max(next_id_, (*i)->id());
AddNoNotify(*i, false);
@@ -1235,8 +1231,8 @@ void TemplateURLService::SetTemplateURLs(
}
// Next add the new items that don't have id's.
- for (std::vector<TemplateURL*>::const_iterator i = urls.begin();
- i != urls.end(); ++i) {
+ for (TemplateURLVector::const_iterator i = urls.begin(); i != urls.end();
+ ++i) {
if ((*i)->id() == kInvalidTemplateURLID)
AddNoNotify(*i, true);
}
@@ -1246,7 +1242,7 @@ void TemplateURLService::ChangeToLoadedState() {
DCHECK(!loaded_);
UIThreadSearchTermsData search_terms_data;
- provider_map_.Init(template_urls_, search_terms_data);
+ provider_map_->Init(template_urls_, search_terms_data);
loaded_ = true;
}
@@ -1375,9 +1371,9 @@ bool TemplateURLService::LoadDefaultSearchProviderFromPrefs(
bool TemplateURLService::CanReplaceKeywordForHost(
const std::string& host,
- const TemplateURL** to_replace) {
+ TemplateURL** to_replace) {
DCHECK(!to_replace || !*to_replace);
- const TemplateURLSet* urls = provider_map_.GetURLsForHost(host);
+ const TemplateURLSet* urls = provider_map_->GetURLsForHost(host);
if (!urls)
return true;
for (TemplateURLSet::const_iterator i(urls->begin()); i != urls->end(); ++i) {
@@ -1395,7 +1391,7 @@ bool TemplateURLService::CanReplace(const TemplateURL* t_url) {
t_url->safe_for_autoreplace());
}
-void TemplateURLService::UpdateNoNotify(const TemplateURL* existing_turl,
+void TemplateURLService::UpdateNoNotify(TemplateURL* existing_turl,
const TemplateURL& new_values) {
DCHECK(loaded_);
DCHECK(existing_turl);
@@ -1413,13 +1409,12 @@ void TemplateURLService::UpdateNoNotify(const TemplateURL* existing_turl,
if (!existing_turl->sync_guid().empty())
guid_to_template_map_.erase(existing_turl->sync_guid());
- provider_map_.Remove(existing_turl);
+ provider_map_->Remove(existing_turl);
TemplateURLID previous_id = existing_turl->id();
- TemplateURL* modifiable_turl = const_cast<TemplateURL*>(existing_turl);
- *modifiable_turl = new_values;
- modifiable_turl->data_.id = previous_id;
+ *existing_turl = new_values;
+ existing_turl->data_.id = previous_id;
UIThreadSearchTermsData search_terms_data;
- provider_map_.Add(existing_turl, search_terms_data);
+ provider_map_->Add(existing_turl, search_terms_data);
const string16& keyword = existing_turl->keyword();
if (!keyword.empty())
@@ -1450,7 +1445,7 @@ void TemplateURLService::UpdateKeywordSearchTermsForURL(
}
const TemplateURLSet* urls_for_host =
- provider_map_.GetURLsForHost(row.url().host());
+ provider_map_->GetURLsForHost(row.url().host());
if (!urls_for_host)
return;
@@ -1562,7 +1557,7 @@ void TemplateURLService::GoogleBaseURLChanged() {
bool something_changed = false;
for (TemplateURLVector::iterator i(template_urls_.begin());
i != template_urls_.end(); ++i) {
- TemplateURL* t_url = const_cast<TemplateURL*>(*i);
+ TemplateURL* t_url = *i;
if (t_url->url_ref().HasGoogleBaseURLs() ||
t_url->suggestions_url_ref().HasGoogleBaseURLs()) {
something_changed = true;
@@ -1577,7 +1572,7 @@ void TemplateURLService::GoogleBaseURLChanged() {
if (something_changed && loaded_) {
UIThreadSearchTermsData search_terms_data;
- provider_map_.UpdateGoogleBaseURLs(search_terms_data);
+ provider_map_->UpdateGoogleBaseURLs(search_terms_data);
NotifyObservers();
}
}
@@ -1622,7 +1617,7 @@ void TemplateURLService::UpdateDefaultSearch() {
// default_search_provider_ can't be NULL otherwise
// TemplateURLsHaveSamePrefs would have returned true. Remove this now
// invalid value.
- const TemplateURL* old_default = default_search_provider_;
+ TemplateURL* old_default = default_search_provider_;
SetDefaultSearchProviderNoNotify(NULL);
RemoveNoNotify(old_default);
} else if (default_search_provider_) {
@@ -1660,14 +1655,14 @@ void TemplateURLService::UpdateDefaultSearch() {
// and set a likely default.
if ((default_search_provider_ != NULL) &&
default_search_provider_->created_by_policy()) {
- const TemplateURL* old_default = default_search_provider_;
+ TemplateURL* old_default = default_search_provider_;
default_search_provider_ = NULL;
RemoveNoNotify(old_default);
}
// The likely default should be from Sync if we were waiting on Sync.
// Otherwise, it should be FindNewDefaultSearchProvider.
- const TemplateURL* synced_default = GetPendingSyncedDefaultSearchProvider();
+ TemplateURL* synced_default = GetPendingSyncedDefaultSearchProvider();
if (synced_default)
pending_synced_default_search_ = false;
SetDefaultSearchProviderNoNotify(synced_default ? synced_default :
@@ -1676,8 +1671,7 @@ void TemplateURLService::UpdateDefaultSearch() {
NotifyObservers();
}
-void TemplateURLService::SetDefaultSearchProviderNoNotify(
- const TemplateURL* url) {
+void TemplateURLService::SetDefaultSearchProviderNoNotify(TemplateURL* url) {
if (url) {
DCHECK(std::find(template_urls_.begin(), template_urls_.end(), url) !=
template_urls_.end());
@@ -1688,10 +1682,9 @@ void TemplateURLService::SetDefaultSearchProviderNoNotify(
default_search_provider_ = url;
if (url) {
- TemplateURL* modifiable_url = const_cast<TemplateURL*>(url);
// Don't mark the url as edited, otherwise we won't be able to rev the
// template urls we ship with.
- modifiable_url->data_.show_in_default_list = true;
+ url->data_.show_in_default_list = true;
if (service_.get())
service_->UpdateKeyword(*url);
@@ -1755,7 +1748,7 @@ void TemplateURLService::AddNoNotify(TemplateURL* template_url,
}
}
-void TemplateURLService::RemoveNoNotify(const TemplateURL* template_url) {
+void TemplateURLService::RemoveNoNotify(TemplateURL* template_url) {
TemplateURLVector::iterator i =
std::find(template_urls_.begin(), template_urls_.end(), template_url);
if (i == template_urls_.end())
@@ -1811,12 +1804,12 @@ void TemplateURLService::NotifyObservers() {
// that were set by policy, unless it is the current default search provider
// and matches what is set by a managed preference.
void TemplateURLService::RemoveProvidersCreatedByPolicy(
- std::vector<TemplateURL*>* template_urls,
- const TemplateURL** default_search_provider,
- const TemplateURL* default_from_prefs) {
+ TemplateURLVector* template_urls,
+ TemplateURL** default_search_provider,
+ TemplateURL* default_from_prefs) {
DCHECK(template_urls);
DCHECK(default_search_provider);
- for (std::vector<TemplateURL*>::iterator i = template_urls->begin();
+ for (TemplateURLVector::iterator i = template_urls->begin();
i != template_urls->end(); ) {
TemplateURL* template_url = *i;
if (template_url->created_by_policy()) {
@@ -1852,17 +1845,17 @@ void TemplateURLService::RemoveProvidersCreatedByPolicy(
}
}
-void TemplateURLService::ResetTemplateURLGUID(const TemplateURL* url,
+void TemplateURLService::ResetTemplateURLGUID(TemplateURL* url,
const std::string& guid) {
DCHECK(!guid.empty());
TemplateURLData data(url->data());
data.sync_guid = guid;
- TemplateURL new_url(const_cast<TemplateURL*>(url)->profile(), data);
+ TemplateURL new_url(url->profile(), data);
UpdateNoNotify(url, new_url);
}
-string16 TemplateURLService::UniquifyKeyword(const TemplateURL& turl) const {
+string16 TemplateURLService::UniquifyKeyword(const TemplateURL& turl) {
// Already unique.
if (!GetTemplateURLForKeyword(turl.keyword()))
return turl.keyword();
@@ -1893,7 +1886,7 @@ bool TemplateURLService::ResolveSyncKeywordConflict(
DCHECK(sync_turl);
DCHECK(change_list);
- const TemplateURL* existing_turl =
+ TemplateURL* existing_turl =
GetTemplateURLForKeyword(sync_turl->keyword());
// If there is no conflict, or it's just conflicting with itself, return.
if (!existing_turl || existing_turl->sync_guid() == sync_turl->sync_guid())
@@ -1912,18 +1905,16 @@ bool TemplateURLService::ResolveSyncKeywordConflict(
string16 new_keyword = UniquifyKeyword(*existing_turl);
TemplateURLData data(existing_turl->data());
data.SetKeyword(new_keyword);
- TemplateURL new_turl(const_cast<TemplateURL*>(existing_turl)->profile(),
- data);
+ TemplateURL new_turl(existing_turl->profile(), data);
UpdateNoNotify(existing_turl, new_turl);
NotifyObservers();
}
return true;
}
-const TemplateURL* TemplateURLService::FindDuplicateOfSyncTemplateURL(
+TemplateURL* TemplateURLService::FindDuplicateOfSyncTemplateURL(
const TemplateURL& sync_turl) {
- const TemplateURL* existing_turl =
- GetTemplateURLForKeyword(sync_turl.keyword());
+ TemplateURL* existing_turl = GetTemplateURLForKeyword(sync_turl.keyword());
return existing_turl && (existing_turl->url() == sync_turl.url()) ?
existing_turl : NULL;
}
@@ -1975,14 +1966,14 @@ void TemplateURLService::SetDefaultSearchProviderIfNewlySynced(
prefs->GetString(prefs::kSyncedDefaultSearchProviderGUID) == guid) {
// Make sure this actually exists. We should not be calling this unless we
// really just added this TemplateURL.
- const TemplateURL* turl_from_sync = GetTemplateURLForGUID(guid);
+ TemplateURL* turl_from_sync = GetTemplateURLForGUID(guid);
if (turl_from_sync && turl_from_sync->SupportsReplacement())
SetDefaultSearchProvider(turl_from_sync);
pending_synced_default_search_ = false;
}
}
-const TemplateURL* TemplateURLService::GetPendingSyncedDefaultSearchProvider() {
+TemplateURL* TemplateURLService::GetPendingSyncedDefaultSearchProvider() {
PrefService* prefs = GetPrefs();
if (!prefs || !pending_synced_default_search_)
return NULL;
@@ -1993,9 +1984,9 @@ const TemplateURL* TemplateURLService::GetPendingSyncedDefaultSearchProvider() {
}
void TemplateURLService::PatchMissingSyncGUIDs(
- std::vector<TemplateURL*>* template_urls) {
+ TemplateURLVector* template_urls) {
DCHECK(template_urls);
- for (std::vector<TemplateURL*>::iterator i = template_urls->begin();
+ for (TemplateURLVector::iterator i = template_urls->begin();
i != template_urls->end(); ++i) {
TemplateURL* template_url = *i;
DCHECK(template_url);
diff --git a/chrome/browser/search_engines/template_url_service.h b/chrome/browser/search_engines/template_url_service.h
index 764df40..60618e204 100644
--- a/chrome/browser/search_engines/template_url_service.h
+++ b/chrome/browser/search_engines/template_url_service.h
@@ -17,7 +17,6 @@
#include "base/observer_list.h"
#include "chrome/browser/prefs/pref_change_registrar.h"
#include "chrome/browser/profiles/profile_keyed_service.h"
-#include "chrome/browser/search_engines/search_host_to_urls_map.h"
#include "chrome/browser/search_engines/template_url_id.h"
#include "chrome/browser/sync/api/sync_change.h"
#include "chrome/browser/sync/api/syncable_service.h"
@@ -66,7 +65,7 @@ class TemplateURLService : public WebDataServiceConsumer,
public SyncableService {
public:
typedef std::map<std::string, std::string> QueryTerms;
- typedef std::vector<const TemplateURL*> TemplateURLVector;
+ typedef std::vector<TemplateURL*> TemplateURLVector;
// Type for a static function pointer that acts as a time source.
typedef base::Time(TimeProvider)();
typedef std::map<std::string, SyncData> SyncDataMap;
@@ -97,7 +96,9 @@ class TemplateURLService : public WebDataServiceConsumer,
// Returns the search url for t_url. Returns an empty GURL if t_url has no
// url().
- static GURL GenerateSearchURL(const TemplateURL* t_url);
+ // NOTE: |t_url| is non-const in this version because of the need to access
+ // t_url->profile().
+ static GURL GenerateSearchURL(TemplateURL* t_url);
// Just like GenerateSearchURL except that it takes SearchTermsData to supply
// the data for some search terms. Most of the time GenerateSearchURL should
@@ -115,7 +116,7 @@ class TemplateURLService : public WebDataServiceConsumer,
// a TemplateURL for an existing TemplateURL that shares the same host.
bool CanReplaceKeyword(const string16& keyword,
const GURL& url,
- const TemplateURL** template_url_to_replace);
+ TemplateURL** template_url_to_replace);
// Returns (in |matches|) all keywords beginning with |prefix|, sorted
// shortest-first. If support_replacement_only is true, only keywords that
@@ -128,16 +129,16 @@ class TemplateURLService : public WebDataServiceConsumer,
// the keyword was not found.
// The caller should not try to delete the returned pointer; the data store
// retains ownership of it.
- const TemplateURL* GetTemplateURLForKeyword(const string16& keyword) const;
+ TemplateURL* GetTemplateURLForKeyword(const string16& keyword);
// Returns that TemplateURL with the specified GUID, or NULL if not found.
// The caller should not try to delete the returned pointer; the data store
// retains ownership of it.
- const TemplateURL* GetTemplateURLForGUID(const std::string& sync_guid) const;
+ TemplateURL* GetTemplateURLForGUID(const std::string& sync_guid);
// Returns the first TemplateURL found with a URL using the specified |host|,
// or NULL if there are no such TemplateURLs
- const TemplateURL* GetTemplateURLForHost(const std::string& host) const;
+ TemplateURL* GetTemplateURLForHost(const std::string& host);
// Takes ownership of |template_url| and adds it to this model.
void Add(TemplateURL* template_url);
@@ -145,14 +146,14 @@ class TemplateURLService : public WebDataServiceConsumer,
// Like Add(), but overwrites the |template_url|'s values with the provided
// ones.
void AddAndSetProfile(TemplateURL* template_url, Profile* profile);
- void AddWithOverrides(const TemplateURL* template_url,
+ void AddWithOverrides(TemplateURL* template_url,
const string16& short_name,
const string16& keyword,
const std::string& url);
// Removes the keyword from the model. This deletes the supplied TemplateURL.
// This fails if the supplied template_url is the default search provider.
- void Remove(const TemplateURL* template_url);
+ void Remove(TemplateURL* template_url);
// Removes all auto-generated keywords that were created on or after the
// date passed in.
@@ -182,20 +183,19 @@ class TemplateURLService : public WebDataServiceConsumer,
// Returns the TemplateURL associated with the keyword for this extension.
// This works by checking the extension ID, not the keyword, so it will work
// even if the user changed the keyword.
- const TemplateURL* GetTemplateURLForExtension(
- const Extension* extension) const;
+ TemplateURL* GetTemplateURLForExtension(const Extension* extension);
// Returns the set of URLs describing the keywords. The elements are owned
// by TemplateURLService and should not be deleted.
- TemplateURLVector GetTemplateURLs() const;
+ TemplateURLVector GetTemplateURLs();
// Increment the usage count of a keyword.
// Called when a URL is loaded that was generated from a keyword.
- void IncrementUsageCount(const TemplateURL* url);
+ void IncrementUsageCount(TemplateURL* url);
// Resets the title, keyword and search url of the specified TemplateURL.
// The TemplateURL is marked as not replaceable.
- void ResetTemplateURL(const TemplateURL* url,
+ void ResetTemplateURL(TemplateURL* url,
const string16& title,
const string16& keyword,
const std::string& search_url);
@@ -206,13 +206,13 @@ class TemplateURLService : public WebDataServiceConsumer,
// Set the default search provider. |url| may be null.
// This will assert if the default search is managed; the UI should not be
// invoking this method in that situation.
- void SetDefaultSearchProvider(const TemplateURL* url);
+ void SetDefaultSearchProvider(TemplateURL* url);
// Returns the default search provider. If the TemplateURLService hasn't been
// loaded, the default search provider is pulled from preferences.
//
// NOTE: At least in unittest mode, this may return NULL.
- const TemplateURL* GetDefaultSearchProvider();
+ TemplateURL* GetDefaultSearchProvider();
// Returns true if the default search is managed through group policy.
bool is_default_search_managed() const { return is_default_search_managed_; }
@@ -221,7 +221,7 @@ class TemplateURLService : public WebDataServiceConsumer,
// exists. If not, returns first URL in |template_urls_|, or NULL if that's
// empty. The returned object is owned by TemplateURLService and can be
// destroyed at any time so should be used right after the call.
- const TemplateURL* FindNewDefaultSearchProvider();
+ TemplateURL* FindNewDefaultSearchProvider();
// Observers used to listen for changes to the model.
// TemplateURLService does NOT delete the observers when deleted.
@@ -310,7 +310,7 @@ class TemplateURLService : public WebDataServiceConsumer,
// function returns NULL.
static TemplateURL* CreateTemplateURLFromTemplateURLAndSyncData(
Profile* profile,
- const TemplateURL* existing_turl,
+ TemplateURL* existing_turl,
const SyncData& sync_data,
SyncChangeList* change_list);
@@ -357,8 +357,8 @@ class TemplateURLService : public WebDataServiceConsumer,
friend class TemplateURLServiceTestUtil;
- typedef std::map<string16, const TemplateURL*> KeywordToTemplateMap;
- typedef std::map<std::string, const TemplateURL*> GUIDToTemplateMap;
+ typedef std::map<string16, TemplateURL*> KeywordToTemplateMap;
+ typedef std::map<std::string, TemplateURL*> GUIDToTemplateMap;
typedef std::list<std::string> PendingExtensionIDs;
// Helper functor for FindMatchingKeywords(), for finding the range of
@@ -367,18 +367,18 @@ class TemplateURLService : public WebDataServiceConsumer,
void Init(const Initializer* initializers, int num_initializers);
- void RemoveFromMaps(const TemplateURL* template_url);
+ void RemoveFromMaps(TemplateURL* template_url);
// Removes the supplied template_url from the keyword maps. This searches
// through all entries in the keyword map and does not generate the host or
// keyword. This is used when the cached content of the TemplateURL changes.
- void RemoveFromKeywordMapByPointer(const TemplateURL* template_url);
+ void RemoveFromKeywordMapByPointer(TemplateURL* template_url);
- void AddToMaps(const TemplateURL* template_url);
+ void AddToMaps(TemplateURL* template_url);
// Sets the keywords. This is used once the keywords have been loaded.
// This does NOT notify the delegate or the database.
- void SetTemplateURLs(const std::vector<TemplateURL*>& urls);
+ void SetTemplateURLs(const TemplateURLVector& urls);
// Transitions to the loaded state.
void ChangeToLoadedState();
@@ -405,7 +405,7 @@ class TemplateURLService : public WebDataServiceConsumer,
// specified host, or the only TemplateURLs matching the specified host can
// be replaced.
bool CanReplaceKeywordForHost(const std::string& host,
- const TemplateURL** to_replace);
+ TemplateURL** to_replace);
// Returns true if the TemplateURL is replaceable. This doesn't look at the
// uniqueness of the keyword or host and is intended to be called after those
@@ -418,7 +418,7 @@ class TemplateURLService : public WebDataServiceConsumer,
// Notifying observers is the responsibility of the caller.
// NOTE: This should not be called with an extension keyword as there are no
// updates needed in that case.
- void UpdateNoNotify(const TemplateURL* existing_turl,
+ void UpdateNoNotify(TemplateURL* existing_turl,
const TemplateURL& new_values);
// Returns the preferences we use.
@@ -452,7 +452,7 @@ class TemplateURLService : public WebDataServiceConsumer,
// Set the default search provider even if it is managed. |url| may be null.
// Caller is responsible for notifying observers.
- void SetDefaultSearchProviderNoNotify(const TemplateURL* url);
+ void SetDefaultSearchProviderNoNotify(TemplateURL* url);
// Adds a new TemplateURL to this model. TemplateURLService will own the
// reference, and delete it when the TemplateURL is removed.
@@ -465,7 +465,7 @@ class TemplateURLService : public WebDataServiceConsumer,
// Removes the keyword from the model. This deletes the supplied TemplateURL.
// This fails if the supplied template_url is the default search provider.
// Caller is responsible for notifying observers.
- void RemoveNoNotify(const TemplateURL* template_url);
+ void RemoveNoNotify(TemplateURL* template_url);
// Notify the observers that the model has changed. This is done only if the
// model is loaded.
@@ -476,20 +476,20 @@ class TemplateURLService : public WebDataServiceConsumer,
// Sets default_search_provider to NULL if it was one of them, unless it is
// the same as the current default from preferences and it is managed.
void RemoveProvidersCreatedByPolicy(
- std::vector<TemplateURL*>* template_urls,
- const TemplateURL** default_search_provider,
- const TemplateURL* default_from_prefs);
+ TemplateURLVector* template_urls,
+ TemplateURL** default_search_provider,
+ TemplateURL* default_from_prefs);
// Resets the sync GUID of the specified TemplateURL and persists the change
// to the database. This does not notify observers.
- void ResetTemplateURLGUID(const TemplateURL* url, const std::string& guid);
+ void ResetTemplateURLGUID(TemplateURL* url, const std::string& guid);
// Attempts to generate a unique keyword for |turl| based on its original
// keyword. If its keyword is already unique, that is returned. Otherwise, it
// tries to return the autogenerated keyword if that is unique to the Service,
// and finally it repeatedly appends special characters to the keyword until
// it is unique to the Service.
- string16 UniquifyKeyword(const TemplateURL& turl) const;
+ string16 UniquifyKeyword(const TemplateURL& turl);
// Given a TemplateURL from Sync (cloud), resolves any keyword conflicts by
// checking the local keywords and uniquifying either the cloud keyword or a
@@ -504,8 +504,7 @@ class TemplateURLService : public WebDataServiceConsumer,
// Returns a TemplateURL from the service that has the same keyword and search
// URL as |sync_turl|, if it exists.
- const TemplateURL* FindDuplicateOfSyncTemplateURL(
- const TemplateURL& sync_turl);
+ TemplateURL* FindDuplicateOfSyncTemplateURL(const TemplateURL& sync_turl);
// Given a TemplateURL from the cloud and a local matching duplicate found by
// FindDuplcateOfSyncTemplateURL, merges the two. If |sync_url| is newer, this
@@ -524,12 +523,12 @@ class TemplateURLService : public WebDataServiceConsumer,
// Retrieve the pending default search provider according to Sync. Returns
// NULL if there was no pending search provider from Sync.
- const TemplateURL* GetPendingSyncedDefaultSearchProvider();
+ TemplateURL* GetPendingSyncedDefaultSearchProvider();
// Goes through a vector of TemplateURLs and ensure that both the in-memory
// and database copies have valid sync_guids. This is to fix crbug.com/102038,
// where old entries were being pushed to Sync without a sync_guid.
- void PatchMissingSyncGUIDs(std::vector<TemplateURL*>* template_urls);
+ void PatchMissingSyncGUIDs(TemplateURLVector* template_urls);
content::NotificationRegistrar notification_registrar_;
PrefChangeRegistrar pref_change_registrar_;
@@ -545,7 +544,9 @@ class TemplateURLService : public WebDataServiceConsumer,
ObserverList<TemplateURLServiceObserver> model_observers_;
// Maps from host to set of TemplateURLs whose search url host is host.
- SearchHostToURLsMap provider_map_;
+ // NOTE: This is always non-NULL; we use a scoped_ptr<> to avoid circular
+ // header dependencies.
+ scoped_ptr<SearchHostToURLsMap> provider_map_;
// Used to obtain the WebDataService.
// When Load is invoked, if we haven't yet loaded, the WebDataService is
@@ -570,7 +571,7 @@ class TemplateURLService : public WebDataServiceConsumer,
// Once loaded, the default search provider. This is a pointer to a
// TemplateURL owned by template_urls_.
- const TemplateURL* default_search_provider_;
+ TemplateURL* default_search_provider_;
// The initial search provider extracted from preferences. This is only valid
// if we haven't been loaded or loading failed.
diff --git a/chrome/browser/search_engines/template_url_service_sync_unittest.cc b/chrome/browser/search_engines/template_url_service_sync_unittest.cc
index 7cec55b..451538e 100644
--- a/chrome/browser/search_engines/template_url_service_sync_unittest.cc
+++ b/chrome/browser/search_engines/template_url_service_sync_unittest.cc
@@ -410,7 +410,7 @@ TEST_F(TemplateURLServiceSyncTest, GetAllSyncDataNoManagedEngines) {
for (SyncDataList::const_iterator iter = all_sync_data.begin();
iter != all_sync_data.end(); ++iter) {
std::string guid = GetGUID(*iter);
- const TemplateURL* service_turl = model()->GetTemplateURLForGUID(guid);
+ TemplateURL* service_turl = model()->GetTemplateURLForGUID(guid);
scoped_ptr<TemplateURL> deserialized(Deserialize(*iter));
ASSERT_FALSE(service_turl->created_by_policy());
AssertEquals(*service_turl, *deserialized);
@@ -564,8 +564,7 @@ TEST_F(TemplateURLServiceSyncTest, MergeSyncAndLocalURLDuplicates) {
// The sync TemplateURL is newer. It should replace the original TemplateURL.
// Note that MergeSyncAndLocalURLDuplicates takes ownership of sync_turl.
model()->MergeSyncAndLocalURLDuplicates(sync_turl, original_turl, &changes);
- const TemplateURL* result =
- model()->GetTemplateURLForKeyword(ASCIIToUTF16("key1"));
+ TemplateURL* result = model()->GetTemplateURLForKeyword(ASCIIToUTF16("key1"));
ASSERT_TRUE(result);
EXPECT_EQ(9001, result->last_modified().ToTimeT());
EXPECT_EQ(0U, changes.size());
@@ -984,7 +983,7 @@ TEST_F(TemplateURLServiceSyncTest, ProcessTemplateURLChange) {
EXPECT_EQ("http://baidu.cn", GetURL(change.sync_data()));
// Change a keyword.
- const TemplateURL* existing_turl = model()->GetTemplateURLForGUID("key1");
+ TemplateURL* existing_turl = model()->GetTemplateURLForGUID("key1");
model()->ResetTemplateURL(existing_turl, existing_turl->short_name(),
ASCIIToUTF16("k"), existing_turl->url());
EXPECT_EQ(1U, processor()->change_list_size());
@@ -1133,10 +1132,10 @@ TEST_F(TemplateURLServiceSyncTest, MergeTwiceWithSameSyncData) {
// We should have updated the original TemplateURL with Sync's version.
// Keep a copy of it so we can compare it after we re-merge.
- const TemplateURL* key1_url = model()->GetTemplateURLForGUID("key1");
+ TemplateURL* key1_url = model()->GetTemplateURLForGUID("key1");
ASSERT_TRUE(key1_url);
- scoped_ptr<TemplateURL> updated_turl(new TemplateURL(
- const_cast<TemplateURL*>(key1_url)->profile(), key1_url->data()));
+ scoped_ptr<TemplateURL> updated_turl(new TemplateURL(key1_url->profile(),
+ key1_url->data()));
EXPECT_EQ(Time::FromTimeT(90), updated_turl->last_modified());
// Modify a single field of the initial data. This should not be updated in
diff --git a/chrome/browser/search_engines/template_url_service_unittest.cc b/chrome/browser/search_engines/template_url_service_unittest.cc
index 4bf0e23..d214f15 100644
--- a/chrome/browser/search_engines/template_url_service_unittest.cc
+++ b/chrome/browser/search_engines/template_url_service_unittest.cc
@@ -370,7 +370,7 @@ TEST_F(TemplateURLServiceTest, AddUpdateRemove) {
// Reload the model to verify it was actually saved to the database.
test_util_.ResetModel(true);
ASSERT_EQ(initial_count + 1, model()->GetTemplateURLs().size());
- const TemplateURL* loaded_url =
+ TemplateURL* loaded_url =
model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword"));
ASSERT_TRUE(loaded_url != NULL);
AssertEquals(*cloned_url, *loaded_url);
@@ -394,8 +394,7 @@ TEST_F(TemplateURLServiceTest, AddUpdateRemove) {
ASSERT_TRUE(model()->CanReplaceKeyword(ASCIIToUTF16("keyword"), GURL(),
NULL));
ASSERT_FALSE(model()->CanReplaceKeyword(ASCIIToUTF16("b"), GURL(), NULL));
- cloned_url.reset(new TemplateURL(
- const_cast<TemplateURL*>(loaded_url)->profile(), loaded_url->data()));
+ cloned_url.reset(new TemplateURL(loaded_url->profile(), loaded_url->data()));
test_util_.BlockTillServiceProcessesRequests();
test_util_.ResetModel(true);
ASSERT_EQ(initial_count + 1, model()->GetTemplateURLs().size());
@@ -1007,11 +1006,10 @@ TEST_F(TemplateURLServiceTest, LoadRetainsModifiedProvider) {
TEST_F(TemplateURLServiceTest, LoadSavesPrepopulatedDefaultSearchProvider) {
test_util_.VerifyLoad();
// Verify that the default search provider is set to something.
- const TemplateURL* default_search = model()->GetDefaultSearchProvider();
+ TemplateURL* default_search = model()->GetDefaultSearchProvider();
ASSERT_TRUE(default_search != NULL);
- scoped_ptr<TemplateURL> cloned_url(new TemplateURL(
- const_cast<TemplateURL*>(default_search)->profile(),
- default_search->data()));
+ scoped_ptr<TemplateURL> cloned_url(new TemplateURL(default_search->profile(),
+ default_search->data()));
// Wait for any saves to finish.
test_util_.BlockTillServiceProcessesRequests();
@@ -1086,7 +1084,7 @@ TEST_F(TemplateURLServiceTest, LoadUpdatesSearchURL) {
TEST_F(TemplateURLServiceTest, LoadEnsuresDefaultSearchProviderExists) {
// Force the model to load and make sure we have a default search provider.
test_util_.VerifyLoad();
- const TemplateURL* old_default = model()->GetDefaultSearchProvider();
+ TemplateURL* old_default = model()->GetDefaultSearchProvider();
EXPECT_TRUE(old_default);
// Now remove it.
diff --git a/chrome/browser/search_engines/util.cc b/chrome/browser/search_engines/util.cc
index 63d71a5..c8bd3c6 100644
--- a/chrome/browser/search_engines/util.cc
+++ b/chrome/browser/search_engines/util.cc
@@ -85,7 +85,7 @@ void MergeEnginesFromPrepopulateData(
Profile* profile,
WebDataService* service,
std::vector<TemplateURL*>* template_urls,
- const TemplateURL** default_search_provider) {
+ TemplateURL** default_search_provider) {
DCHECK(service == NULL || BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(template_urls);
DCHECK(default_search_provider);
@@ -176,7 +176,7 @@ void GetSearchProvidersUsingKeywordResult(
WebDataService* service,
Profile* profile,
std::vector<TemplateURL*>* template_urls,
- const TemplateURL** default_search_provider,
+ TemplateURL** default_search_provider,
int* new_resource_keyword_version) {
DCHECK(service == NULL || BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(template_urls);
diff --git a/chrome/browser/search_engines/util.h b/chrome/browser/search_engines/util.h
index bba6a9a..31b8fb2 100644
--- a/chrome/browser/search_engines/util.h
+++ b/chrome/browser/search_engines/util.h
@@ -37,7 +37,7 @@ void GetSearchProvidersUsingKeywordResult(
WebDataService* service,
Profile* profile,
std::vector<TemplateURL*>* template_urls,
- const TemplateURL** default_search_provider,
+ TemplateURL** default_search_provider,
int* new_resource_keyword_version);
// Returns true if the default search provider setting has been changed or
diff --git a/chrome/browser/sync/test/integration/search_engines_helper.cc b/chrome/browser/sync/test/integration/search_engines_helper.cc
index 1a9f4e0..f84c3b1 100644
--- a/chrome/browser/sync/test/integration/search_engines_helper.cc
+++ b/chrome/browser/sync/test/integration/search_engines_helper.cc
@@ -221,13 +221,13 @@ void EditSearchEngine(int profile_index,
const std::string& url) {
DCHECK(!url.empty());
TemplateURLService* service = GetServiceForProfile(profile_index);
- const TemplateURL* turl = service->GetTemplateURLForKeyword(keyword);
+ TemplateURL* turl = service->GetTemplateURLForKeyword(keyword);
EXPECT_TRUE(turl);
ASSERT_FALSE(new_keyword.empty());
service->ResetTemplateURL(turl, short_name, new_keyword, url);
// Make sure we do the same on the verifier.
if (test()->use_verifier()) {
- const TemplateURL* verifier_turl =
+ TemplateURL* verifier_turl =
GetVerifierService()->GetTemplateURLForKeyword(keyword);
EXPECT_TRUE(verifier_turl);
GetVerifierService()->ResetTemplateURL(verifier_turl, short_name,
@@ -238,12 +238,12 @@ void EditSearchEngine(int profile_index,
void DeleteSearchEngineBySeed(int profile_index, int seed) {
TemplateURLService* service = GetServiceForProfile(profile_index);
string16 keyword(CreateKeyword(seed));
- const TemplateURL* turl = service->GetTemplateURLForKeyword(keyword);
+ TemplateURL* turl = service->GetTemplateURLForKeyword(keyword);
EXPECT_TRUE(turl);
service->Remove(turl);
// Make sure we do the same on the verifier.
if (test()->use_verifier()) {
- const TemplateURL* verifier_turl =
+ TemplateURL* verifier_turl =
GetVerifierService()->GetTemplateURLForKeyword(keyword);
EXPECT_TRUE(verifier_turl);
GetVerifierService()->Remove(verifier_turl);
@@ -253,12 +253,11 @@ void DeleteSearchEngineBySeed(int profile_index, int seed) {
void ChangeDefaultSearchProvider(int profile_index, int seed) {
TemplateURLService* service = GetServiceForProfile(profile_index);
ASSERT_TRUE(service);
- const TemplateURL* turl =
- service->GetTemplateURLForKeyword(CreateKeyword(seed));
+ TemplateURL* turl = service->GetTemplateURLForKeyword(CreateKeyword(seed));
ASSERT_TRUE(turl);
service->SetDefaultSearchProvider(turl);
if (test()->use_verifier()) {
- const TemplateURL* verifier_turl =
+ TemplateURL* verifier_turl =
GetVerifierService()->GetTemplateURLForKeyword(CreateKeyword(seed));
ASSERT_TRUE(verifier_turl);
GetVerifierService()->SetDefaultSearchProvider(verifier_turl);
diff --git a/chrome/browser/sync/test/integration/two_client_search_engines_sync_test.cc b/chrome/browser/sync/test/integration/two_client_search_engines_sync_test.cc
index 83ec779..9251fcc 100644
--- a/chrome/browser/sync/test/integration/two_client_search_engines_sync_test.cc
+++ b/chrome/browser/sync/test/integration/two_client_search_engines_sync_test.cc
@@ -146,8 +146,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest, ConflictKeyword) {
search_engines_helper::AddSearchEngine(0, 0);
search_engines_helper::AddSearchEngine(1, 1);
TemplateURLService* service = search_engines_helper::GetServiceForProfile(1);
- const TemplateURL* turl =
- service->GetTemplateURLForKeyword(ASCIIToUTF16("test1"));
+ TemplateURL* turl = service->GetTemplateURLForKeyword(ASCIIToUTF16("test1"));
EXPECT_TRUE(turl);
service->ResetTemplateURL(turl, turl->short_name(), ASCIIToUTF16("test0"),
turl->url());
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index 469e47b..e08b210 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -4054,7 +4054,7 @@ void Browser::SwapTabContents(TabContentsWrapper* old_tab_contents,
///////////////////////////////////////////////////////////////////////////////
// Browser, SearchEngineTabHelperDelegate implementation:
-void Browser::ConfirmAddSearchProvider(const TemplateURL* template_url,
+void Browser::ConfirmAddSearchProvider(TemplateURL* template_url,
Profile* profile) {
window()->ConfirmAddSearchProvider(template_url, profile);
}
diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h
index 43dad16..8d0dfd5 100644
--- a/chrome/browser/ui/browser.h
+++ b/chrome/browser/ui/browser.h
@@ -1066,7 +1066,7 @@ class Browser : public TabHandlerDelegate,
TabContentsWrapper* new_tab_contents) OVERRIDE;
// Overridden from SearchEngineTabHelperDelegate:
- virtual void ConfirmAddSearchProvider(const TemplateURL* template_url,
+ virtual void ConfirmAddSearchProvider(TemplateURL* template_url,
Profile* profile) OVERRIDE;
// Overridden from ConstrainedWindowTabHelperDelegate:
diff --git a/chrome/browser/ui/browser_window.h b/chrome/browser/ui/browser_window.h
index 52e0794..a64196c8 100644
--- a/chrome/browser/ui/browser_window.h
+++ b/chrome/browser/ui/browser_window.h
@@ -191,7 +191,7 @@ class BrowserWindow : public BaseWindow {
// Shows a confirmation dialog box for adding a search engine described by
// |template_url|. Takes ownership of |template_url|.
- virtual void ConfirmAddSearchProvider(const TemplateURL* template_url,
+ virtual void ConfirmAddSearchProvider(TemplateURL* template_url,
Profile* profile) = 0;
// Shows or hides the bookmark bar depending on its current visibility.
diff --git a/chrome/browser/ui/cocoa/browser/edit_search_engine_cocoa_controller.h b/chrome/browser/ui/cocoa/browser/edit_search_engine_cocoa_controller.h
index 4ab711d..51f8d3d 100644
--- a/chrome/browser/ui/cocoa/browser/edit_search_engine_cocoa_controller.h
+++ b/chrome/browser/ui/cocoa/browser/edit_search_engine_cocoa_controller.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -32,13 +32,13 @@ class TemplateURL;
IBOutlet NSBox* fieldAndImageContainer_;
Profile* profile_; // weak
- const TemplateURL* templateURL_; // weak
+ TemplateURL* templateURL_; // weak
scoped_ptr<EditSearchEngineController> controller_;
}
- (id)initWithProfile:(Profile*)profile
delegate:(EditSearchEngineControllerDelegate*)delegate
- templateURL:(const TemplateURL*)url;
+ templateURL:(TemplateURL*)url;
- (IBAction)cancel:(id)sender;
- (IBAction)save:(id)sender;
diff --git a/chrome/browser/ui/cocoa/browser/edit_search_engine_cocoa_controller.mm b/chrome/browser/ui/cocoa/browser/edit_search_engine_cocoa_controller.mm
index e1c15db..5d2d2a6 100644
--- a/chrome/browser/ui/cocoa/browser/edit_search_engine_cocoa_controller.mm
+++ b/chrome/browser/ui/cocoa/browser/edit_search_engine_cocoa_controller.mm
@@ -32,7 +32,7 @@ void ShiftOriginY(NSView* view, CGFloat amount) {
- (id)initWithProfile:(Profile*)profile
delegate:(EditSearchEngineControllerDelegate*)delegate
- templateURL:(const TemplateURL*)url {
+ templateURL:(TemplateURL*)url {
DCHECK(profile);
NSString* nibpath = [base::mac::FrameworkBundle()
pathForResource:@"EditSearchEngine"
diff --git a/chrome/browser/ui/cocoa/browser_window_cocoa.h b/chrome/browser/ui/cocoa/browser_window_cocoa.h
index ef822e9..e47b7eb 100644
--- a/chrome/browser/ui/cocoa/browser_window_cocoa.h
+++ b/chrome/browser/ui/cocoa/browser_window_cocoa.h
@@ -83,7 +83,7 @@ class BrowserWindowCocoa : public BrowserWindow,
virtual bool IsToolbarVisible() const OVERRIDE;
virtual gfx::Rect GetRootWindowResizerRect() const OVERRIDE;
virtual bool IsPanel() const OVERRIDE;
- virtual void ConfirmAddSearchProvider(const TemplateURL* template_url,
+ virtual void ConfirmAddSearchProvider(TemplateURL* template_url,
Profile* profile) OVERRIDE;
virtual void ToggleBookmarkBar() OVERRIDE;
virtual void ShowAboutChromeDialog() OVERRIDE;
diff --git a/chrome/browser/ui/cocoa/browser_window_cocoa.mm b/chrome/browser/ui/cocoa/browser_window_cocoa.mm
index 7623fce..537fa99 100644
--- a/chrome/browser/ui/cocoa/browser_window_cocoa.mm
+++ b/chrome/browser/ui/cocoa/browser_window_cocoa.mm
@@ -315,7 +315,7 @@ bool BrowserWindowCocoa::IsFullscreenBubbleVisible() const {
}
void BrowserWindowCocoa::ConfirmAddSearchProvider(
- const TemplateURL* template_url,
+ TemplateURL* template_url,
Profile* profile) {
// The controller will release itself when the window closes.
EditSearchEngineCocoaController* editor =
diff --git a/chrome/browser/ui/gtk/browser_window_gtk.cc b/chrome/browser/ui/gtk/browser_window_gtk.cc
index c30674c..c7274f4 100644
--- a/chrome/browser/ui/gtk/browser_window_gtk.cc
+++ b/chrome/browser/ui/gtk/browser_window_gtk.cc
@@ -1018,7 +1018,7 @@ bool BrowserWindowGtk::IsPanel() const {
return false;
}
-void BrowserWindowGtk::ConfirmAddSearchProvider(const TemplateURL* template_url,
+void BrowserWindowGtk::ConfirmAddSearchProvider(TemplateURL* template_url,
Profile* profile) {
new EditSearchEngineDialog(window_, template_url, NULL, profile);
}
diff --git a/chrome/browser/ui/gtk/browser_window_gtk.h b/chrome/browser/ui/gtk/browser_window_gtk.h
index 43c8229..46efc31 100644
--- a/chrome/browser/ui/gtk/browser_window_gtk.h
+++ b/chrome/browser/ui/gtk/browser_window_gtk.h
@@ -117,7 +117,7 @@ class BrowserWindowGtk : public BrowserWindow,
virtual bool IsToolbarVisible() const OVERRIDE;
virtual gfx::Rect GetRootWindowResizerRect() const OVERRIDE;
virtual bool IsPanel() const OVERRIDE;
- virtual void ConfirmAddSearchProvider(const TemplateURL* template_url,
+ virtual void ConfirmAddSearchProvider(TemplateURL* template_url,
Profile* profile) OVERRIDE;
virtual void ToggleBookmarkBar() OVERRIDE;
virtual void ShowAboutChromeDialog() OVERRIDE;
diff --git a/chrome/browser/ui/gtk/edit_search_engine_dialog.cc b/chrome/browser/ui/gtk/edit_search_engine_dialog.cc
index 1cb853c8..0c11cb6 100644
--- a/chrome/browser/ui/gtk/edit_search_engine_dialog.cc
+++ b/chrome/browser/ui/gtk/edit_search_engine_dialog.cc
@@ -67,7 +67,7 @@ void SetWidgetStyle(GtkWidget* entry, GtkStyle* label_style,
EditSearchEngineDialog::EditSearchEngineDialog(
GtkWindow* parent_window,
- const TemplateURL* template_url,
+ TemplateURL* template_url,
EditSearchEngineControllerDelegate* delegate,
Profile* profile)
: controller_(new EditSearchEngineController(template_url, delegate,
diff --git a/chrome/browser/ui/gtk/edit_search_engine_dialog.h b/chrome/browser/ui/gtk/edit_search_engine_dialog.h
index e1fcbbc..d387598 100644
--- a/chrome/browser/ui/gtk/edit_search_engine_dialog.h
+++ b/chrome/browser/ui/gtk/edit_search_engine_dialog.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -22,7 +22,7 @@ class TemplateURL;
class EditSearchEngineDialog {
public:
EditSearchEngineDialog(GtkWindow* parent_window,
- const TemplateURL* template_url,
+ TemplateURL* template_url,
EditSearchEngineControllerDelegate* delegate,
Profile* profile);
~EditSearchEngineDialog();
diff --git a/chrome/browser/ui/panels/panel.cc b/chrome/browser/ui/panels/panel.cc
index bb92907..2d5cc59 100644
--- a/chrome/browser/ui/panels/panel.cc
+++ b/chrome/browser/ui/panels/panel.cc
@@ -458,7 +458,7 @@ void Panel::DisableInactiveFrame() {
NOTIMPLEMENTED();
}
-void Panel::ConfirmAddSearchProvider(const TemplateURL* template_url,
+void Panel::ConfirmAddSearchProvider(TemplateURL* template_url,
Profile* profile) {
NOTIMPLEMENTED();
}
diff --git a/chrome/browser/ui/panels/panel.h b/chrome/browser/ui/panels/panel.h
index a868189..bcc9335 100644
--- a/chrome/browser/ui/panels/panel.h
+++ b/chrome/browser/ui/panels/panel.h
@@ -136,7 +136,7 @@ class Panel : public BrowserWindow,
virtual gfx::Rect GetRootWindowResizerRect() const OVERRIDE;
virtual bool IsPanel() const OVERRIDE;
virtual void DisableInactiveFrame() OVERRIDE;
- virtual void ConfirmAddSearchProvider(const TemplateURL* template_url,
+ virtual void ConfirmAddSearchProvider(TemplateURL* template_url,
Profile* profile) OVERRIDE;
virtual void ToggleBookmarkBar() OVERRIDE;
virtual void ShowAboutChromeDialog() OVERRIDE;
diff --git a/chrome/browser/ui/search_engines/edit_search_engine_controller.cc b/chrome/browser/ui/search_engines/edit_search_engine_controller.cc
index ad9ec91..58562a3 100644
--- a/chrome/browser/ui/search_engines/edit_search_engine_controller.cc
+++ b/chrome/browser/ui/search_engines/edit_search_engine_controller.cc
@@ -17,7 +17,7 @@
using content::UserMetricsAction;
EditSearchEngineController::EditSearchEngineController(
- const TemplateURL* template_url,
+ TemplateURL* template_url,
EditSearchEngineControllerDelegate* edit_keyword_delegate,
Profile* profile)
: template_url_(template_url),
@@ -82,7 +82,7 @@ void EditSearchEngineController::AcceptAddOrEdit(
TemplateURLService* template_url_service =
TemplateURLServiceFactory::GetForProfile(profile_);
- const TemplateURL* existing =
+ TemplateURL* existing =
template_url_service->GetTemplateURLForKeyword(keyword_input);
if (existing && (!edit_keyword_delegate_ || existing != template_url_)) {
// An entry may have been added with the same keyword string while the
diff --git a/chrome/browser/ui/search_engines/edit_search_engine_controller.h b/chrome/browser/ui/search_engines/edit_search_engine_controller.h
index c6cf069..f5aff7f 100644
--- a/chrome/browser/ui/search_engines/edit_search_engine_controller.h
+++ b/chrome/browser/ui/search_engines/edit_search_engine_controller.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -21,7 +21,7 @@ class EditSearchEngineControllerDelegate {
// EditSearchEngineController's constructor, and may be NULL. A NULL value
// indicates a new TemplateURL should be created rather than modifying an
// existing TemplateURL.
- virtual void OnEditedKeyword(const TemplateURL* template_url,
+ virtual void OnEditedKeyword(TemplateURL* template_url,
const string16& title,
const string16& keyword,
const std::string& url) = 0;
@@ -36,7 +36,7 @@ class EditSearchEngineController {
public:
// The |template_url| and/or |edit_keyword_delegate| may be NULL.
EditSearchEngineController(
- const TemplateURL* template_url,
+ TemplateURL* template_url,
EditSearchEngineControllerDelegate* edit_keyword_delegate,
Profile* profile);
~EditSearchEngineController() {}
@@ -76,7 +76,7 @@ class EditSearchEngineController {
// The TemplateURL we're displaying information for. It may be NULL. If we
// have a keyword_editor_view, we assume that this TemplateURL is already in
// the TemplateURLService; if not, we assume it isn't.
- const TemplateURL* template_url_;
+ TemplateURL* template_url_;
// We may have been created by this, in which case we will call back to it on
// success to add/modify the entry. May be NULL.
diff --git a/chrome/browser/ui/search_engines/keyword_editor_controller.cc b/chrome/browser/ui/search_engines/keyword_editor_controller.cc
index 18899c8..6118b76 100644
--- a/chrome/browser/ui/search_engines/keyword_editor_controller.cc
+++ b/chrome/browser/ui/search_engines/keyword_editor_controller.cc
@@ -50,7 +50,7 @@ int KeywordEditorController::AddTemplateURL(const string16& title,
return new_index;
}
-void KeywordEditorController::ModifyTemplateURL(const TemplateURL* template_url,
+void KeywordEditorController::ModifyTemplateURL(TemplateURL* template_url,
const string16& title,
const string16& keyword,
const std::string& url) {
@@ -98,7 +98,7 @@ bool KeywordEditorController::loaded() const {
return url_model()->loaded();
}
-const TemplateURL* KeywordEditorController::GetTemplateURL(int index) const {
+TemplateURL* KeywordEditorController::GetTemplateURL(int index) {
return table_model_->GetTemplateURL(index);
}
diff --git a/chrome/browser/ui/search_engines/keyword_editor_controller.h b/chrome/browser/ui/search_engines/keyword_editor_controller.h
index 8b4e0e9..565c1d8 100644
--- a/chrome/browser/ui/search_engines/keyword_editor_controller.h
+++ b/chrome/browser/ui/search_engines/keyword_editor_controller.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -34,7 +34,7 @@ class KeywordEditorController {
// Invoked when the user modifies a TemplateURL. Updates the
// TemplateURLService and table model appropriately.
- void ModifyTemplateURL(const TemplateURL* template_url,
+ void ModifyTemplateURL(TemplateURL* template_url,
const string16& title,
const string16& keyword,
const std::string& url);
@@ -59,7 +59,7 @@ class KeywordEditorController {
bool loaded() const;
// Return the TemplateURL corresponding to the |index| in the model.
- const TemplateURL* GetTemplateURL(int index) const;
+ TemplateURL* GetTemplateURL(int index);
TemplateURLTableModel* table_model() {
return table_model_.get();
diff --git a/chrome/browser/ui/search_engines/keyword_editor_controller_unittest.cc b/chrome/browser/ui/search_engines/keyword_editor_controller_unittest.cc
index 7373089..276f00d 100644
--- a/chrome/browser/ui/search_engines/keyword_editor_controller_unittest.cc
+++ b/chrome/browser/ui/search_engines/keyword_editor_controller_unittest.cc
@@ -146,7 +146,7 @@ TEST_F(KeywordEditorControllerTest, Modify) {
ClearChangeCount();
// Modify the entry.
- const TemplateURL* turl = model_->GetTemplateURLs()[0];
+ TemplateURL* turl = model_->GetTemplateURLs()[0];
controller_->ModifyTemplateURL(turl, kA1, kB1, "http://c1");
// Make sure it was updated appropriately.
diff --git a/chrome/browser/ui/search_engines/search_engine_tab_helper.cc b/chrome/browser/ui/search_engines/search_engine_tab_helper.cc
index b10bfac..0a93c5b 100644
--- a/chrome/browser/ui/search_engines/search_engine_tab_helper.cc
+++ b/chrome/browser/ui/search_engines/search_engine_tab_helper.cc
@@ -157,7 +157,7 @@ void SearchEngineTabHelper::GenerateKeywordIfNecessary(
return;
}
- const TemplateURL* current_url;
+ TemplateURL* current_url;
GURL url = params.searchable_form_url;
if (!url_service->CanReplaceKeyword(keyword, url, &current_url))
return;
diff --git a/chrome/browser/ui/search_engines/search_engine_tab_helper_delegate.h b/chrome/browser/ui/search_engines/search_engine_tab_helper_delegate.h
index b6eaf3b2..4ab194b 100644
--- a/chrome/browser/ui/search_engines/search_engine_tab_helper_delegate.h
+++ b/chrome/browser/ui/search_engines/search_engine_tab_helper_delegate.h
@@ -19,7 +19,7 @@ class SearchEngineTabHelperDelegate {
public:
// Shows a confirmation dialog box for adding a search engine described by
// |template_url|. Takes ownership of |template_url|.
- virtual void ConfirmAddSearchProvider(const TemplateURL* template_url,
+ virtual void ConfirmAddSearchProvider(TemplateURL* template_url,
Profile* profile) = 0;
protected:
diff --git a/chrome/browser/ui/search_engines/template_url_table_model.cc b/chrome/browser/ui/search_engines/template_url_table_model.cc
index 256a9c1..8ba1e88 100644
--- a/chrome/browser/ui/search_engines/template_url_table_model.cc
+++ b/chrome/browser/ui/search_engines/template_url_table_model.cc
@@ -35,7 +35,7 @@ static SkBitmap* default_icon = NULL;
class ModelEntry {
public:
- ModelEntry(TemplateURLTableModel* model, const TemplateURL* template_url)
+ ModelEntry(TemplateURLTableModel* model, TemplateURL* template_url)
: template_url_(template_url),
load_state_(NOT_LOADED),
model_(model) {
@@ -45,7 +45,7 @@ class ModelEntry {
}
}
- const TemplateURL* template_url() {
+ TemplateURL* template_url() {
return template_url_;
}
@@ -108,7 +108,7 @@ class ModelEntry {
}
}
- const TemplateURL* template_url_;
+ TemplateURL* template_url_;
SkBitmap favicon_;
LoadState load_state_;
TemplateURLTableModel* model_;
@@ -145,7 +145,7 @@ void TemplateURLTableModel::Reload() {
// Keywords that can be made the default first.
for (TemplateURLService::TemplateURLVector::iterator i = urls.begin();
i != urls.end(); ++i) {
- const TemplateURL* template_url = *i;
+ TemplateURL* template_url = *i;
// NOTE: we don't use ShowInDefaultList here to avoid items bouncing around
// the lists while editing.
if (template_url->show_in_default_list())
@@ -157,7 +157,7 @@ void TemplateURLTableModel::Reload() {
// Then the rest.
for (TemplateURLService::TemplateURLVector::iterator i = urls.begin();
i != urls.end(); ++i) {
- const TemplateURL* template_url = *i;
+ TemplateURL* template_url = *i;
// NOTE: we don't use ShowInDefaultList here to avoid things bouncing
// the lists while editing.
if (!template_url->show_in_default_list() &&
@@ -233,7 +233,7 @@ void TemplateURLTableModel::Remove(int index) {
// Remove the observer while we modify the model, that way we don't need to
// worry about the model calling us back when we mutate it.
template_url_service_->RemoveObserver(this);
- const TemplateURL* template_url = GetTemplateURL(index);
+ TemplateURL* template_url = GetTemplateURL(index);
scoped_ptr<ModelEntry> entry(entries_[index]);
entries_.erase(entries_.begin() + index);
@@ -274,7 +274,7 @@ void TemplateURLTableModel::ModifyTemplateURL(int index,
const std::string& url) {
DCHECK(index >= 0 && index <= RowCount());
DCHECK(!url.empty());
- const TemplateURL* template_url = GetTemplateURL(index);
+ TemplateURL* template_url = GetTemplateURL(index);
// The default search provider should support replacement.
DCHECK(template_url_service_->GetDefaultSearchProvider() != template_url ||
template_url->SupportsReplacement());
@@ -292,7 +292,7 @@ void TemplateURLTableModel::ReloadIcon(int index) {
NotifyChanged(index);
}
-const TemplateURL* TemplateURLTableModel::GetTemplateURL(int index) {
+TemplateURL* TemplateURLTableModel::GetTemplateURL(int index) {
return entries_[index]->template_url();
}
@@ -329,7 +329,7 @@ int TemplateURLTableModel::MakeDefaultTemplateURL(int index) {
return -1;
}
- const TemplateURL* keyword = GetTemplateURL(index);
+ TemplateURL* keyword = GetTemplateURL(index);
const TemplateURL* current_default =
template_url_service_->GetDefaultSearchProvider();
if (current_default == keyword)
diff --git a/chrome/browser/ui/search_engines/template_url_table_model.h b/chrome/browser/ui/search_engines/template_url_table_model.h
index 702d7cb9..3ee549b 100644
--- a/chrome/browser/ui/search_engines/template_url_table_model.h
+++ b/chrome/browser/ui/search_engines/template_url_table_model.h
@@ -70,7 +70,7 @@ class TemplateURLTableModel : public ui::TableModel,
void ReloadIcon(int index);
// Returns the TemplateURL at the specified index.
- const TemplateURL* GetTemplateURL(int index);
+ TemplateURL* GetTemplateURL(int index);
// Returns the index of the TemplateURL, or -1 if it the TemplateURL is not
// found.
diff --git a/chrome/browser/ui/views/browser_dialogs.h b/chrome/browser/ui/views/browser_dialogs.h
index d29b3e7..97fb06a 100644
--- a/chrome/browser/ui/views/browser_dialogs.h
+++ b/chrome/browser/ui/views/browser_dialogs.h
@@ -85,7 +85,7 @@ void ShowLoginWizard(const std::string& start_screen, const gfx::Size& size);
// to be notified when the user is done editing, or NULL. If NULL, the dialog
// will update the model with the user's edits directly.
void EditSearchEngine(gfx::NativeWindow parent,
- const TemplateURL* template_url,
+ TemplateURL* template_url,
EditSearchEngineControllerDelegate* delegate,
Profile* profile);
diff --git a/chrome/browser/ui/views/edit_search_engine_dialog.cc b/chrome/browser/ui/views/edit_search_engine_dialog.cc
index 805deea..d962008 100644
--- a/chrome/browser/ui/views/edit_search_engine_dialog.cc
+++ b/chrome/browser/ui/views/edit_search_engine_dialog.cc
@@ -31,7 +31,7 @@ using views::Textfield;
namespace browser {
void EditSearchEngine(gfx::NativeWindow parent,
- const TemplateURL* template_url,
+ TemplateURL* template_url,
EditSearchEngineControllerDelegate* delegate,
Profile* profile) {
EditSearchEngineDialog::Show(parent, template_url, delegate, profile);
@@ -40,7 +40,7 @@ void EditSearchEngine(gfx::NativeWindow parent,
} // namespace browser
EditSearchEngineDialog::EditSearchEngineDialog(
- const TemplateURL* template_url,
+ TemplateURL* template_url,
EditSearchEngineControllerDelegate* delegate,
Profile* profile)
: controller_(new EditSearchEngineController(template_url,
@@ -54,7 +54,7 @@ EditSearchEngineDialog::~EditSearchEngineDialog() {
// static
void EditSearchEngineDialog::Show(gfx::NativeWindow parent,
- const TemplateURL* template_url,
+ TemplateURL* template_url,
EditSearchEngineControllerDelegate* delegate,
Profile* profile) {
EditSearchEngineDialog* contents =
diff --git a/chrome/browser/ui/views/edit_search_engine_dialog.h b/chrome/browser/ui/views/edit_search_engine_dialog.h
index 83b3994..eb40bda1 100644
--- a/chrome/browser/ui/views/edit_search_engine_dialog.h
+++ b/chrome/browser/ui/views/edit_search_engine_dialog.h
@@ -28,14 +28,14 @@ class EditSearchEngineDialog : public views::TextfieldController,
public views::DialogDelegateView {
public:
// The |template_url| and/or |delegate| may be NULL.
- EditSearchEngineDialog(const TemplateURL* template_url,
+ EditSearchEngineDialog(TemplateURL* template_url,
EditSearchEngineControllerDelegate* delegate,
Profile* profile);
virtual ~EditSearchEngineDialog();
// Shows the dialog to the user.
static void Show(gfx::NativeWindow parent,
- const TemplateURL* template_url,
+ TemplateURL* template_url,
EditSearchEngineControllerDelegate* delegate,
Profile* profile);
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index 5bbca22..68409c4 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -1043,7 +1043,7 @@ void BrowserView::DisableInactiveFrame() {
#endif // No tricks are needed to get the right behavior on Linux.
}
-void BrowserView::ConfirmAddSearchProvider(const TemplateURL* template_url,
+void BrowserView::ConfirmAddSearchProvider(TemplateURL* template_url,
Profile* profile) {
browser::EditSearchEngine(GetWidget()->GetNativeWindow(), template_url, NULL,
profile);
diff --git a/chrome/browser/ui/views/frame/browser_view.h b/chrome/browser/ui/views/frame/browser_view.h
index e634c89..cfd430c 100644
--- a/chrome/browser/ui/views/frame/browser_view.h
+++ b/chrome/browser/ui/views/frame/browser_view.h
@@ -262,7 +262,7 @@ class BrowserView : public BrowserWindow,
virtual bool IsPanel() const OVERRIDE;
virtual gfx::Rect GetRootWindowResizerRect() const OVERRIDE;
virtual void DisableInactiveFrame() OVERRIDE;
- virtual void ConfirmAddSearchProvider(const TemplateURL* template_url,
+ virtual void ConfirmAddSearchProvider(TemplateURL* template_url,
Profile* profile) OVERRIDE;
virtual void ToggleBookmarkBar() OVERRIDE;
virtual void ShowAboutChromeDialog() OVERRIDE;
diff --git a/chrome/browser/ui/webui/options2/search_engine_manager_handler2.cc b/chrome/browser/ui/webui/options2/search_engine_manager_handler2.cc
index d30b03a..38f03a3 100644
--- a/chrome/browser/ui/webui/options2/search_engine_manager_handler2.cc
+++ b/chrome/browser/ui/webui/options2/search_engine_manager_handler2.cc
@@ -249,7 +249,7 @@ void SearchEngineManagerHandler::EditSearchEngine(const ListValue* args) {
}
void SearchEngineManagerHandler::OnEditedKeyword(
- const TemplateURL* template_url,
+ TemplateURL* template_url,
const string16& title,
const string16& keyword,
const std::string& url) {
diff --git a/chrome/browser/ui/webui/options2/search_engine_manager_handler2.h b/chrome/browser/ui/webui/options2/search_engine_manager_handler2.h
index 42984a4..95af05ed 100644
--- a/chrome/browser/ui/webui/options2/search_engine_manager_handler2.h
+++ b/chrome/browser/ui/webui/options2/search_engine_manager_handler2.h
@@ -34,7 +34,7 @@ class SearchEngineManagerHandler : public OptionsPageUIHandler,
virtual void OnItemsRemoved(int start, int length) OVERRIDE;
// EditSearchEngineControllerDelegate implementation.
- virtual void OnEditedKeyword(const TemplateURL* template_url,
+ virtual void OnEditedKeyword(TemplateURL* template_url,
const string16& title,
const string16& keyword,
const std::string& url) OVERRIDE;
diff --git a/chrome/browser/webdata/keyword_table.cc b/chrome/browser/webdata/keyword_table.cc
index 4ecc860..8df072d 100644
--- a/chrome/browser/webdata/keyword_table.cc
+++ b/chrome/browser/webdata/keyword_table.cc
@@ -60,7 +60,9 @@ void BindURLToStatement(const TemplateURL& url,
const TemplateURLData& data = url.data();
s->BindInt64(id_column, data.id);
s->BindString16(starting_column, data.short_name);
- s->BindString16(starting_column + 1, data.keyword(&url));
+ // TODO(pkasting): See comment on TempalteURL::EnsureKeyword().
+ s->BindString16(starting_column + 1,
+ data.keyword(const_cast<TemplateURL*>(&url)));
s->BindString(starting_column + 2, data.favicon_url.is_valid() ?
history::HistoryDatabase::GURLToDatabaseURL(data.favicon_url) :
std::string());