summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit.cc15
-rw-r--r--chrome/browser/autocomplete/autocomplete_popup_model.cc13
-rw-r--r--chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc2
-rw-r--r--chrome/browser/autocomplete/autocomplete_unittest.cc10
-rw-r--r--chrome/browser/autocomplete/extension_app_provider.h2
-rw-r--r--chrome/browser/autocomplete/keyword_provider.cc19
-rw-r--r--chrome/browser/autocomplete/keyword_provider.h14
-rw-r--r--chrome/browser/autocomplete/keyword_provider_unittest.cc8
-rw-r--r--chrome/browser/autocomplete/search_provider.cc6
-rw-r--r--chrome/browser/autocomplete/search_provider_unittest.cc12
-rw-r--r--chrome/browser/automation/automation_provider_observers.cc10
-rw-r--r--chrome/browser/automation/automation_provider_observers.h8
-rw-r--r--chrome/browser/automation/testing_automation_provider.cc15
-rw-r--r--chrome/browser/automation/testing_automation_provider.h2
-rw-r--r--chrome/browser/browser_main.cc10
-rw-r--r--chrome/browser/browser_process_impl.h2
-rw-r--r--chrome/browser/browsing_data_remover.cc14
-rw-r--r--chrome/browser/browsing_data_remover.h2
-rw-r--r--chrome/browser/extensions/extension_devtools_bridge.h1
-rw-r--r--chrome/browser/extensions/extension_omnibox_apitest.cc15
-rw-r--r--chrome/browser/extensions/extension_service.cc15
-rw-r--r--chrome/browser/first_run/first_run.cc6
-rw-r--r--chrome/browser/history/url_database.cc2
-rw-r--r--chrome/browser/importer/external_process_importer_client.cc2
-rw-r--r--chrome/browser/importer/firefox_importer_utils.cc4
-rw-r--r--chrome/browser/importer/ie_importer.cc6
-rw-r--r--chrome/browser/importer/importer_host.cc16
-rw-r--r--chrome/browser/importer/importer_host.h6
-rw-r--r--chrome/browser/importer/importer_unittest.cc6
-rw-r--r--chrome/browser/importer/profile_writer.cc16
-rw-r--r--chrome/browser/importer/profile_writer.h2
-rw-r--r--chrome/browser/instant/instant_browsertest.cc13
-rw-r--r--chrome/browser/instant/instant_controller.cc9
-rw-r--r--chrome/browser/metrics/metrics_service.cc10
-rw-r--r--chrome/browser/metrics/metrics_service.h4
-rw-r--r--chrome/browser/omnibox_search_hint.cc6
-rw-r--r--chrome/browser/prefs/browser_prefs.cc4
-rw-r--r--chrome/browser/profiles/profile.cc4
-rw-r--r--chrome/browser/profiles/profile.h5
-rw-r--r--chrome/browser/profiles/profile_impl.cc13
-rw-r--r--chrome/browser/profiles/profile_impl.h2
-rw-r--r--chrome/browser/profiles/profile_keyed_service_factory.cc9
-rw-r--r--chrome/browser/profiles/profile_keyed_service_factory.h7
-rw-r--r--chrome/browser/rlz/rlz.cc7
-rw-r--r--chrome/browser/search_engines/search_host_to_urls_map.cc6
-rw-r--r--chrome/browser/search_engines/search_provider_install_data.cc6
-rw-r--r--chrome/browser/search_engines/search_provider_install_data_unittest.cc16
-rw-r--r--chrome/browser/search_engines/template_url.cc6
-rw-r--r--chrome/browser/search_engines/template_url.h6
-rw-r--r--chrome/browser/search_engines/template_url_fetcher.cc25
-rw-r--r--chrome/browser/search_engines/template_url_fetcher.h4
-rw-r--r--chrome/browser/search_engines/template_url_fetcher_callbacks.h6
-rw-r--r--chrome/browser/search_engines/template_url_fetcher_unittest.cc16
-rw-r--r--chrome/browser/search_engines/template_url_model_observer.h20
-rw-r--r--chrome/browser/search_engines/template_url_prepopulate_data.cc4
-rw-r--r--chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc6
-rw-r--r--chrome/browser/search_engines/template_url_scraper_unittest.cc30
-rw-r--r--chrome/browser/search_engines/template_url_service.cc (renamed from chrome/browser/search_engines/template_url_model.cc)163
-rw-r--r--chrome/browser/search_engines/template_url_service.h (renamed from chrome/browser/search_engines/template_url_model.h)78
-rw-r--r--chrome/browser/search_engines/template_url_service_factory.cc50
-rw-r--r--chrome/browser/search_engines/template_url_service_factory.h36
-rw-r--r--chrome/browser/search_engines/template_url_service_observer.h20
-rw-r--r--chrome/browser/search_engines/template_url_service_test_util.cc (renamed from chrome/browser/search_engines/template_url_model_test_util.cc)85
-rw-r--r--chrome/browser/search_engines/template_url_service_test_util.h (renamed from chrome/browser/search_engines/template_url_model_test_util.h)40
-rw-r--r--chrome/browser/search_engines/template_url_service_unittest.cc (renamed from chrome/browser/search_engines/template_url_model_unittest.cc)106
-rw-r--r--chrome/browser/search_engines/util.cc6
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu.cc6
-rw-r--r--chrome/browser/ui/browser.cc4
-rw-r--r--chrome/browser/ui/browser.h2
-rw-r--r--chrome/browser/ui/browser_init.cc6
-rw-r--r--chrome/browser/ui/browser_window.h4
-rw-r--r--chrome/browser/ui/cocoa/browser_test_helper.cc2
-rw-r--r--chrome/browser/ui/cocoa/first_run_dialog.mm8
-rw-r--r--chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm9
-rw-r--r--chrome/browser/ui/cocoa/search_engine_dialog_controller.h4
-rw-r--r--chrome/browser/ui/cocoa/search_engine_dialog_controller.mm23
-rw-r--r--chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm2
-rw-r--r--chrome/browser/ui/gtk/edit_search_engine_dialog.cc2
-rw-r--r--chrome/browser/ui/gtk/first_run_dialog.cc14
-rw-r--r--chrome/browser/ui/gtk/first_run_dialog.h10
-rw-r--r--chrome/browser/ui/gtk/location_bar_view_gtk.cc17
-rw-r--r--chrome/browser/ui/omnibox/location_bar_util.cc9
-rw-r--r--chrome/browser/ui/omnibox/omnibox_view_browsertest.cc31
-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.cc23
-rw-r--r--chrome/browser/ui/search_engines/edit_search_engine_controller.h6
-rw-r--r--chrome/browser/ui/search_engines/keyword_editor_controller.cc10
-rw-r--r--chrome/browser/ui/search_engines/keyword_editor_controller.h12
-rw-r--r--chrome/browser/ui/search_engines/keyword_editor_controller_unittest.cc17
-rw-r--r--chrome/browser/ui/search_engines/search_engine_tab_helper.cc23
-rw-r--r--chrome/browser/ui/search_engines/search_engine_tab_helper_delegate.h4
-rw-r--r--chrome/browser/ui/search_engines/template_url_fetcher_ui_callbacks.cc4
-rw-r--r--chrome/browser/ui/search_engines/template_url_fetcher_ui_callbacks.h2
-rw-r--r--chrome/browser/ui/search_engines/template_url_table_model.cc53
-rw-r--r--chrome/browser/ui/search_engines/template_url_table_model.h23
-rw-r--r--chrome/browser/ui/views/default_search_view.cc22
-rw-r--r--chrome/browser/ui/views/default_search_view.h8
-rw-r--r--chrome/browser/ui/views/edit_search_engine_dialog.h2
-rw-r--r--chrome/browser/ui/views/first_run_search_engine_view.cc18
-rw-r--r--chrome/browser/ui/views/first_run_search_engine_view.h14
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc4
-rw-r--r--chrome/browser/ui/views/frame/browser_view.h2
-rw-r--r--chrome/browser/ui/views/location_bar/keyword_hint_view.cc11
-rw-r--r--chrome/browser/ui/views/location_bar/location_bar_view.cc28
-rw-r--r--chrome/browser/ui/views/location_bar/location_bar_view.h17
-rw-r--r--chrome/browser/ui/views/location_bar/selected_keyword_view.cc11
-rw-r--r--chrome/browser/ui/views/omnibox/omnibox_view_win.cc2
-rw-r--r--chrome/browser/ui/webui/options/browser_options_handler.cc34
-rw-r--r--chrome/browser/ui/webui/options/browser_options_handler.h14
-rw-r--r--chrome/browser/ui/webui/options/search_engine_manager_handler.cc2
-rw-r--r--chrome/browser/webdata/web_data_service.h6
-rw-r--r--chrome/chrome_browser.gypi8
-rw-r--r--chrome/chrome_tests.gypi6
-rw-r--r--chrome/test/testing_profile.cc25
-rw-r--r--chrome/test/testing_profile.h22
-rw-r--r--content/common/notification_type.h6
117 files changed, 929 insertions, 756 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit.cc b/chrome/browser/autocomplete/autocomplete_edit.cc
index 0ac3f3d..eb6c6a7 100644
--- a/chrome/browser/autocomplete/autocomplete_edit.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit.cc
@@ -25,7 +25,8 @@
#include "chrome/browser/net/url_fixer_upper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/omnibox/omnibox_view.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
@@ -460,7 +461,8 @@ void AutocompleteEditModel::AcceptInput(WindowOpenDisposition disposition,
match.type == AutocompleteMatch::SEARCH_HISTORY ||
match.type == AutocompleteMatch::SEARCH_SUGGEST) {
const TemplateURL* default_provider =
- profile_->GetTemplateURLModel()->GetDefaultSearchProvider();
+ TemplateURLServiceFactory::GetForProfile(profile_)->
+ GetDefaultSearchProvider();
if (default_provider && default_provider->url() &&
default_provider->url()->HasGoogleBaseURLs()) {
GoogleURLTracker::GoogleURLSearchCommitted();
@@ -497,10 +499,11 @@ void AutocompleteEditModel::OpenMatch(const AutocompleteMatch& match,
Details<AutocompleteLog>(&log));
}
- TemplateURLModel* template_url_model = profile_->GetTemplateURLModel();
- if (template_url_model && !keyword.empty()) {
+ TemplateURLService* template_url_service =
+ TemplateURLServiceFactory::GetForProfile(profile_);
+ if (template_url_service && !keyword.empty()) {
const TemplateURL* const template_url =
- template_url_model->GetTemplateURLForKeyword(keyword);
+ template_url_service->GetTemplateURLForKeyword(keyword);
// Special case for extension keywords. Don't increment usage count for
// these.
@@ -523,7 +526,7 @@ void AutocompleteEditModel::OpenMatch(const AutocompleteMatch& match,
if (template_url) {
UserMetrics::RecordAction(UserMetricsAction("AcceptedKeyword"));
- template_url_model->IncrementUsageCount(template_url);
+ template_url_service->IncrementUsageCount(template_url);
}
// NOTE: We purposefully don't increment the usage count of the default
diff --git a/chrome/browser/autocomplete/autocomplete_popup_model.cc b/chrome/browser/autocomplete/autocomplete_popup_model.cc
index 11794f6..ea8492f 100644
--- a/chrome/browser/autocomplete/autocomplete_popup_model.cc
+++ b/chrome/browser/autocomplete/autocomplete_popup_model.cc
@@ -16,7 +16,8 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "ui/gfx/rect.h"
///////////////////////////////////////////////////////////////////////////////
@@ -143,20 +144,22 @@ bool AutocompletePopupModel::GetKeywordForMatch(const AutocompleteMatch& match,
bool AutocompletePopupModel::GetKeywordForText(const string16& text,
string16* keyword) const {
// Creates keyword_hint first in case |keyword| is a pointer to |text|.
- const string16 keyword_hint(TemplateURLModel::CleanUserInputKeyword(text));
+ const string16 keyword_hint(TemplateURLService::CleanUserInputKeyword(text));
// Assume we have no keyword until we find otherwise.
keyword->clear();
if (keyword_hint.empty())
return false;
- if (!profile_->GetTemplateURLModel())
+ TemplateURLService* url_service =
+ TemplateURLServiceFactory::GetForProfile(profile_);
+ if (!url_service)
return false;
- profile_->GetTemplateURLModel()->Load();
+ url_service->Load();
// Don't provide a hint if this keyword doesn't support replacement.
const TemplateURL* const template_url =
- profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(keyword_hint);
+ url_service->GetTemplateURLForKeyword(keyword_hint);
if (!TemplateURL::SupportsReplacement(template_url))
return false;
diff --git a/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc
index 7602046..55f335f 100644
--- a/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc
+++ b/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc
@@ -21,7 +21,7 @@
#include "chrome/browser/defaults.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/ui/gtk/gtk_theme_service.h"
#include "chrome/browser/ui/gtk/gtk_util.h"
#include "chrome/browser/ui/omnibox/omnibox_view.h"
diff --git a/chrome/browser/autocomplete/autocomplete_unittest.cc b/chrome/browser/autocomplete/autocomplete_unittest.cc
index 9d0f7c1..5b76bf1 100644
--- a/chrome/browser/autocomplete/autocomplete_unittest.cc
+++ b/chrome/browser/autocomplete/autocomplete_unittest.cc
@@ -12,7 +12,8 @@
#include "chrome/browser/autocomplete/keyword_provider.h"
#include "chrome/browser/autocomplete/search_provider.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/test/testing_browser_process.h"
#include "chrome/test/testing_browser_process_test.h"
#include "chrome/test/testing_profile.h"
@@ -164,12 +165,13 @@ void AutocompleteProviderTest::ResetControllerWithTestProviders(
void AutocompleteProviderTest::
ResetControllerWithTestProvidersWithKeywordAndSearchProviders() {
- profile_.CreateTemplateURLModel();
+ profile_.CreateTemplateURLService();
// Reset the default TemplateURL.
TemplateURL* default_t_url = new TemplateURL();
default_t_url->SetURL("http://defaultturl/{searchTerms}", 0, 0);
- TemplateURLModel* turl_model = profile_.GetTemplateURLModel();
+ TemplateURLService* turl_model =
+ TemplateURLServiceFactory::GetForProfile(&profile_);
turl_model->Add(default_t_url);
turl_model->SetDefaultSearchProvider(default_t_url);
TemplateURLID default_provider_id = default_t_url->id();
@@ -180,7 +182,7 @@ void AutocompleteProviderTest::
keyword_t_url->set_short_name(ASCIIToUTF16("k"));
keyword_t_url->set_keyword(ASCIIToUTF16("k"));
keyword_t_url->SetURL("http://keyword/{searchTerms}", 0, 0);
- profile_.GetTemplateURLModel()->Add(keyword_t_url);
+ turl_model->Add(keyword_t_url);
ASSERT_NE(0, keyword_t_url->id());
// Forget about any existing providers. The controller owns them and will
diff --git a/chrome/browser/autocomplete/extension_app_provider.h b/chrome/browser/autocomplete/extension_app_provider.h
index ade0123..54480d7 100644
--- a/chrome/browser/autocomplete/extension_app_provider.h
+++ b/chrome/browser/autocomplete/extension_app_provider.h
@@ -25,8 +25,6 @@
#include "content/common/notification_observer.h"
#include "content/common/notification_registrar.h"
-class TemplateURLModel;
-
class ExtensionAppProvider : public AutocompleteProvider,
public NotificationObserver {
public:
diff --git a/chrome/browser/autocomplete/keyword_provider.cc b/chrome/browser/autocomplete/keyword_provider.cc
index 69a64d8..693d824 100644
--- a/chrome/browser/autocomplete/keyword_provider.cc
+++ b/chrome/browser/autocomplete/keyword_provider.cc
@@ -14,7 +14,8 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "content/common/notification_details.h"
#include "content/common/notification_source.h"
#include "grit/generated_resources.h"
@@ -72,7 +73,7 @@ KeywordProvider::KeywordProvider(ACProviderListener* listener, Profile* profile)
}
KeywordProvider::KeywordProvider(ACProviderListener* listener,
- TemplateURLModel* model)
+ TemplateURLService* model)
: AutocompleteProvider(listener, NULL, "Keyword"),
model_(model),
current_input_id_(0) {
@@ -117,7 +118,7 @@ const TemplateURL* KeywordProvider::GetSubstitutingTemplateURLForInput(
// Make sure the model is loaded. This is cheap and quickly bails out if
// the model is already loaded.
- TemplateURLModel* model = profile->GetTemplateURLModel();
+ TemplateURLService* model = TemplateURLServiceFactory::GetForProfile(profile);
DCHECK(model);
model->Load();
@@ -160,7 +161,10 @@ void KeywordProvider::Start(const AutocompleteInput& input,
// Make sure the model is loaded. This is cheap and quickly bails out if
// the model is already loaded.
- TemplateURLModel* model = profile_ ? profile_->GetTemplateURLModel() : model_;
+ TemplateURLService* model =
+ profile_ ?
+ TemplateURLServiceFactory::GetForProfile(profile_) :
+ model_;
DCHECK(model);
model->Load();
@@ -282,7 +286,7 @@ bool KeywordProvider::ExtractKeywordFromInput(const AutocompleteInput& input,
string16 trimmed_input;
TrimWhitespace(input.text(), TRIM_TRAILING, &trimmed_input);
- *keyword = TemplateURLModel::CleanUserInputKeyword(
+ *keyword = TemplateURLService::CleanUserInputKeyword(
SplitKeywordFromInput(trimmed_input, true, remaining_input));
return !keyword->empty();
}
@@ -382,7 +386,7 @@ int KeywordProvider::CalculateRelevance(AutocompleteInput::Type type,
}
AutocompleteMatch KeywordProvider::CreateAutocompleteMatch(
- TemplateURLModel* model,
+ TemplateURLService* model,
const string16& keyword,
const AutocompleteInput& input,
size_t prefix_length,
@@ -450,7 +454,8 @@ AutocompleteMatch KeywordProvider::CreateAutocompleteMatch(
void KeywordProvider::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
- TemplateURLModel* model = profile_ ? profile_->GetTemplateURLModel() : model_;
+ TemplateURLService* model =
+ profile_ ? TemplateURLServiceFactory::GetForProfile(profile_) : model_;
const AutocompleteInput& input = extension_suggest_last_input_;
switch (type.value) {
diff --git a/chrome/browser/autocomplete/keyword_provider.h b/chrome/browser/autocomplete/keyword_provider.h
index abfc029..7e4518c 100644
--- a/chrome/browser/autocomplete/keyword_provider.h
+++ b/chrome/browser/autocomplete/keyword_provider.h
@@ -6,7 +6,7 @@
// is responsible for remembering/suggesting user "search keyword queries"
// (e.g. "imdb Godzilla") and then fixing them up into valid URLs. An
// instance of it gets created and managed by the autocomplete controller.
-// KeywordProvider uses a TemplateURLModel to find the set of keywords.
+// KeywordProvider uses a TemplateURLService to find the set of keywords.
//
// For more information on the autocomplete system in general, including how
// the autocomplete controller and autocomplete providers work, see
@@ -24,7 +24,7 @@
class Profile;
class TemplateURL;
-class TemplateURLModel;
+class TemplateURLService;
// Autocomplete provider for keyword input.
//
@@ -53,7 +53,7 @@ class KeywordProvider : public AutocompleteProvider,
public:
KeywordProvider(ACProviderListener* listener, Profile* profile);
// For testing.
- KeywordProvider(ACProviderListener* listener, TemplateURLModel* model);
+ KeywordProvider(ACProviderListener* listener, TemplateURLService* model);
// Returns the replacement string from the user input. The replacement
// string is the portion of the input that does not contain the keyword.
@@ -85,7 +85,7 @@ class KeywordProvider : public AutocompleteProvider,
// after the keyword are placed in |remaining_input|. Returns true if |input|
// is valid and has a keyword. This makes use of SplitKeywordFromInput to
// extract the keyword and remaining string, and uses
- // TemplateURLModel::CleanUserInputKeyword to remove unnecessary characters.
+ // TemplateURLService::CleanUserInputKeyword to remove unnecessary characters.
// In general use this instead of SplitKeywordFromInput.
// Leading whitespace in |*remaining_input| will be trimmed.
static bool ExtractKeywordFromInput(const AutocompleteInput& input,
@@ -122,7 +122,7 @@ class KeywordProvider : public AutocompleteProvider,
// Creates a fully marked-up AutocompleteMatch from the user's input.
// If |relevance| is negative, calculate a relevance based on heuristics.
AutocompleteMatch CreateAutocompleteMatch(
- TemplateURLModel* model,
+ TemplateURLService* model,
const string16& keyword,
const AutocompleteInput& input,
size_t prefix_length,
@@ -138,8 +138,8 @@ class KeywordProvider : public AutocompleteProvider,
const NotificationDetails& details);
// Model for the keywords. This is only non-null when testing, otherwise the
- // TemplateURLModel from the Profile is used.
- TemplateURLModel* model_;
+ // TemplateURLService from the Profile is used.
+ TemplateURLService* model_;
// Identifies the current input state. This is incremented each time the
// autocomplete edit's input changes in any way. It is used to tell whether
diff --git a/chrome/browser/autocomplete/keyword_provider_unittest.cc b/chrome/browser/autocomplete/keyword_provider_unittest.cc
index 511fbe7..f87af2c5 100644
--- a/chrome/browser/autocomplete/keyword_provider_unittest.cc
+++ b/chrome/browser/autocomplete/keyword_provider_unittest.cc
@@ -7,7 +7,7 @@
#include "chrome/browser/autocomplete/autocomplete_match.h"
#include "chrome/browser/autocomplete/keyword_provider.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/test/testing_browser_process.h"
#include "chrome/test/testing_browser_process_test.h"
#include "googleurl/src/gurl.h"
@@ -35,11 +35,11 @@ class KeywordProviderTest : public TestingBrowserProcessTest {
protected:
scoped_refptr<KeywordProvider> kw_provider_;
- scoped_ptr<TemplateURLModel> model_;
+ scoped_ptr<TemplateURLService> model_;
};
void KeywordProviderTest::SetUp() {
- static const TemplateURLModel::Initializer kTestKeywordData[] = {
+ static const TemplateURLService::Initializer kTestKeywordData[] = {
{ "aa", "aa.com?foo=%s", "aa" },
{ "aaaa", "http://aaaa/?aaaa=1&b=%s&c", "aaaa" },
{ "aaaaa", "%s", "aaaaa" },
@@ -49,7 +49,7 @@ void KeywordProviderTest::SetUp() {
{ "z", "%s=z", "z" },
};
- model_.reset(new TemplateURLModel(kTestKeywordData,
+ model_.reset(new TemplateURLService(kTestKeywordData,
arraysize(kTestKeywordData)));
kw_provider_ = new KeywordProvider(NULL, model_.get());
}
diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc
index 79f1b84..546a4a2 100644
--- a/chrome/browser/autocomplete/search_provider.cc
+++ b/chrome/browser/autocomplete/search_provider.cc
@@ -23,7 +23,8 @@
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/history/in_memory_database.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "content/common/json_value_serializer.h"
@@ -152,7 +153,8 @@ void SearchProvider::Start(const AutocompleteInput& input,
keyword_provider = NULL;
const TemplateURL* default_provider =
- profile_->GetTemplateURLModel()->GetDefaultSearchProvider();
+ TemplateURLServiceFactory::GetForProfile(profile_)->
+ GetDefaultSearchProvider();
if (!TemplateURL::SupportsReplacement(default_provider))
default_provider = NULL;
diff --git a/chrome/browser/autocomplete/search_provider_unittest.cc b/chrome/browser/autocomplete/search_provider_unittest.cc
index 681ffb2..4a1263e 100644
--- a/chrome/browser/autocomplete/search_provider_unittest.cc
+++ b/chrome/browser/autocomplete/search_provider_unittest.cc
@@ -11,7 +11,8 @@
#include "chrome/browser/history/history.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/testing_browser_process.h"
#include "chrome/test/testing_browser_process_test.h"
@@ -23,7 +24,7 @@
// The following environment is configured for these tests:
// . The TemplateURL default_t_url_ is set as the default provider.
-// . The TemplateURL keyword_t_url_ is added to the TemplateURLModel. This
+// . The TemplateURL keyword_t_url_ is added to the TemplateURLService. This
// TemplateURL has a valid suggest and search URL.
// . The URL created by using the search term term1_ with default_t_url_ is
// added to history.
@@ -102,9 +103,10 @@ void SearchProviderTest::SetUp() {
// We need both the history service and template url model loaded.
profile_.CreateHistoryService(true, false);
- profile_.CreateTemplateURLModel();
+ profile_.CreateTemplateURLService();
- TemplateURLModel* turl_model = profile_.GetTemplateURLModel();
+ TemplateURLService* turl_model =
+ TemplateURLServiceFactory::GetForProfile(&profile_);
// Reset the default TemplateURL.
default_t_url_ = new TemplateURL();
@@ -132,7 +134,7 @@ void SearchProviderTest::SetUp() {
keyword_t_url_->SetURL("http://keyword/{searchTerms}", 0, 0);
keyword_t_url_->SetSuggestionsURL("http://suggest_keyword/{searchTerms}", 0,
0);
- profile_.GetTemplateURLModel()->Add(keyword_t_url_);
+ turl_model->Add(keyword_t_url_);
ASSERT_NE(0, keyword_t_url_->id());
// Add a page and search term for keyword_t_url_.
diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc
index 87b49f09..3fad593 100644
--- a/chrome/browser/automation/automation_provider_observers.cc
+++ b/chrome/browser/automation/automation_provider_observers.cc
@@ -42,7 +42,8 @@
#include "chrome/browser/password_manager/password_store_change.h"
#include "chrome/browser/printing/print_job.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/sessions/tab_restore_service.h"
#include "chrome/browser/sessions/tab_restore_service_factory.h"
#include "chrome/browser/tab_contents/thumbnail_generator.h"
@@ -1560,10 +1561,11 @@ AutomationProviderSearchEngineObserver::AutomationProviderSearchEngineObserver(
AutomationProviderSearchEngineObserver::
~AutomationProviderSearchEngineObserver() {}
-void AutomationProviderSearchEngineObserver::OnTemplateURLModelChanged() {
+void AutomationProviderSearchEngineObserver::OnTemplateURLServiceChanged() {
if (provider_) {
- TemplateURLModel* url_model = provider_->profile()->GetTemplateURLModel();
- url_model->RemoveObserver(this);
+ TemplateURLService* url_service =
+ TemplateURLServiceFactory::GetForProfile(provider_->profile());
+ url_service->RemoveObserver(this);
AutomationJSONReply(provider_, reply_message_.release()).SendSuccess(NULL);
}
delete this;
diff --git a/chrome/browser/automation/automation_provider_observers.h b/chrome/browser/automation/automation_provider_observers.h
index e269dd7..7579496 100644
--- a/chrome/browser/automation/automation_provider_observers.h
+++ b/chrome/browser/automation/automation_provider_observers.h
@@ -32,7 +32,7 @@
#include "chrome/browser/importer/importer_progress_observer.h"
#include "chrome/browser/password_manager/password_store_change.h"
#include "chrome/browser/password_manager/password_store_consumer.h"
-#include "chrome/browser/search_engines/template_url_model_observer.h"
+#include "chrome/browser/search_engines/template_url_service_observer.h"
#include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/common/automation_constants.h"
#include "chrome/common/extensions/extension_constants.h"
@@ -989,17 +989,17 @@ class AutomationProviderDownloadModelChangedObserver
DISALLOW_COPY_AND_ASSIGN(AutomationProviderDownloadModelChangedObserver);
};
-// Allows automation provider to wait until TemplateURLModel has loaded
+// Allows automation provider to wait until TemplateURLService has loaded
// before looking up/returning search engine info.
class AutomationProviderSearchEngineObserver
- : public TemplateURLModelObserver {
+ : public TemplateURLServiceObserver {
public:
AutomationProviderSearchEngineObserver(
AutomationProvider* provider,
IPC::Message* reply_message);
virtual ~AutomationProviderSearchEngineObserver();
- virtual void OnTemplateURLModelChanged();
+ virtual void OnTemplateURLServiceChanged();
private:
base::WeakPtr<AutomationProvider> provider_;
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
index 67766a1..b3e0a3c 100644
--- a/chrome/browser/automation/testing_automation_provider.cc
+++ b/chrome/browser/automation/testing_automation_provider.cc
@@ -62,7 +62,8 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/sessions/session_service_factory.h"
#include "chrome/browser/tab_contents/confirm_infobar_delegate.h"
#include "chrome/browser/tab_contents/link_infobar_delegate.h"
@@ -2914,7 +2915,8 @@ void TestingAutomationProvider::LoadSearchEngineInfo(
Browser* browser,
DictionaryValue* args,
IPC::Message* reply_message) {
- TemplateURLModel* url_model(profile_->GetTemplateURLModel());
+ TemplateURLService* url_model =
+ TemplateURLServiceFactory::GetForProfile(profile_);
if (url_model->loaded()) {
AutomationJSONReply(this, reply_message).SendSuccess(NULL);
return;
@@ -2930,7 +2932,8 @@ void TestingAutomationProvider::GetSearchEngineInfo(
Browser* browser,
DictionaryValue* args,
IPC::Message* reply_message) {
- TemplateURLModel* url_model(profile_->GetTemplateURLModel());
+ TemplateURLService* url_model =
+ TemplateURLServiceFactory::GetForProfile(profile_);
scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
ListValue* search_engines = new ListValue;
std::vector<const TemplateURL*> template_urls = url_model->GetTemplateURLs();
@@ -2962,7 +2965,8 @@ void TestingAutomationProvider::AddOrEditSearchEngine(
Browser* browser,
DictionaryValue* args,
IPC::Message* reply_message) {
- TemplateURLModel* url_model(profile_->GetTemplateURLModel());
+ TemplateURLService* url_model =
+ TemplateURLServiceFactory::GetForProfile(profile_);
const TemplateURL* template_url;
string16 new_title;
string16 new_keyword;
@@ -3003,7 +3007,8 @@ void TestingAutomationProvider::PerformActionOnSearchEngine(
Browser* browser,
DictionaryValue* args,
IPC::Message* reply_message) {
- TemplateURLModel* url_model(profile_->GetTemplateURLModel());
+ TemplateURLService* url_model =
+ TemplateURLServiceFactory::GetForProfile(profile_);
std::string keyword;
std::string action;
if (!args->GetString("keyword", &keyword) ||
diff --git a/chrome/browser/automation/testing_automation_provider.h b/chrome/browser/automation/testing_automation_provider.h
index 558c885..60eb1f5 100644
--- a/chrome/browser/automation/testing_automation_provider.h
+++ b/chrome/browser/automation/testing_automation_provider.h
@@ -22,7 +22,7 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
class DictionaryValue;
-class TemplateURLModel;
+class TemplateURLService;
// This is an automation provider containing testing calls.
class TestingAutomationProvider : public AutomationProvider,
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc
index 9cf9f1a..fd65ad6 100644
--- a/chrome/browser/browser_main.cc
+++ b/chrome/browser/browser_main.cc
@@ -66,7 +66,8 @@
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/search_engines/search_engine_type.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/service/service_process_control.h"
#include "chrome/browser/shell_integration.h"
#include "chrome/browser/translate/translate_manager.h"
@@ -1913,8 +1914,10 @@ int BrowserMain(const MainFunctionParams& parameters) {
// selecting a search engine through the dialog reached from the first run
// bubble link.
if (record_search_engine) {
+ TemplateURLService* url_service =
+ TemplateURLServiceFactory::GetForProfile(profile);
const TemplateURL* default_search_engine =
- profile->GetTemplateURLModel()->GetDefaultSearchProvider();
+ url_service->GetDefaultSearchProvider();
// The default engine can be NULL if the administrator has disabled
// default search.
SearchEngineType search_engine_type =
@@ -1928,8 +1931,7 @@ int BrowserMain(const MainFunctionParams& parameters) {
SEARCH_ENGINE_MAX);
// If the selection has been randomized, also record the winner by slot.
if (master_prefs.randomize_search_engine_experiment) {
- size_t engine_pos = profile->GetTemplateURLModel()->
- GetSearchEngineDialogSlot();
+ size_t engine_pos = url_service->GetSearchEngineDialogSlot();
if (engine_pos < 4) {
std::string experiment_type = "Chrome.SearchSelectExperimentSlot";
// Nicer in UMA if slots are 1-based.
diff --git a/chrome/browser/browser_process_impl.h b/chrome/browser/browser_process_impl.h
index ad1a4e2..080a9f6 100644
--- a/chrome/browser/browser_process_impl.h
+++ b/chrome/browser/browser_process_impl.h
@@ -138,7 +138,7 @@ class BrowserProcessImpl : public BrowserProcess,
#if defined(OS_CHROMEOS)
void CreateWebSocketProxyThread();
#endif
- void CreateTemplateURLModel();
+ void CreateTemplateURLService();
void CreateProfileManager();
void CreateWebDataService();
void CreateLocalState();
diff --git a/chrome/browser/browsing_data_remover.cc b/chrome/browser/browsing_data_remover.cc
index ed9b014..74e294c9 100644
--- a/chrome/browser/browsing_data_remover.cc
+++ b/chrome/browser/browsing_data_remover.cc
@@ -23,7 +23,8 @@
#include "chrome/browser/plugin_data_remover.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/renderer_host/web_cache_manager.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/sessions/session_service.h"
#include "chrome/browser/sessions/session_service_factory.h"
#include "chrome/browser/sessions/tab_restore_service.h"
@@ -148,10 +149,11 @@ void BrowsingDataRemover::Remove(int remove_mask) {
}
// As part of history deletion we also delete the auto-generated keywords.
- TemplateURLModel* keywords_model = profile_->GetTemplateURLModel();
+ TemplateURLService* keywords_model =
+ TemplateURLServiceFactory::GetForProfile(profile_);
if (keywords_model && !keywords_model->loaded()) {
- registrar_.Add(this, NotificationType::TEMPLATE_URL_MODEL_LOADED,
- Source<TemplateURLModel>(keywords_model));
+ registrar_.Add(this, NotificationType::TEMPLATE_URL_SERVICE_LOADED,
+ Source<TemplateURLService>(keywords_model));
keywords_model->Load();
} else if (keywords_model) {
keywords_model->RemoveAutoGeneratedBetween(delete_begin_, delete_end_);
@@ -341,8 +343,8 @@ void BrowsingDataRemover::Observe(NotificationType type,
// TODO(brettw) bug 1139736: This should also observe session
// clearing (what about other things such as passwords, etc.?) and wait for
// them to complete before continuing.
- DCHECK(type == NotificationType::TEMPLATE_URL_MODEL_LOADED);
- TemplateURLModel* model = Source<TemplateURLModel>(source).ptr();
+ DCHECK(type == NotificationType::TEMPLATE_URL_SERVICE_LOADED);
+ TemplateURLService* model = Source<TemplateURLService>(source).ptr();
if (model->profile() == profile_->GetOriginalProfile()) {
registrar_.RemoveAll();
model->RemoveAutoGeneratedBetween(delete_begin_, delete_end_);
diff --git a/chrome/browser/browsing_data_remover.h b/chrome/browser/browsing_data_remover.h
index 06effca..428cb9b 100644
--- a/chrome/browser/browsing_data_remover.h
+++ b/chrome/browser/browsing_data_remover.h
@@ -110,7 +110,7 @@ class BrowsingDataRemover : public NotificationObserver,
friend class DeleteTask<BrowsingDataRemover>;
virtual ~BrowsingDataRemover();
- // NotificationObserver method. Callback when TemplateURLModel has finished
+ // NotificationObserver method. Callback when TemplateURLService has finished
// loading. Deletes the entries from the model, and if we're not waiting on
// anything else notifies observers and deletes this BrowsingDataRemover.
virtual void Observe(NotificationType type,
diff --git a/chrome/browser/extensions/extension_devtools_bridge.h b/chrome/browser/extensions/extension_devtools_bridge.h
index 50b249e..b80b162 100644
--- a/chrome/browser/extensions/extension_devtools_bridge.h
+++ b/chrome/browser/extensions/extension_devtools_bridge.h
@@ -42,7 +42,6 @@ class ExtensionDevToolsBridge : public DevToolsClientHost {
int tab_id_;
scoped_refptr<ExtensionDevToolsManager> extension_devtools_manager_;
- scoped_refptr<ExtensionMessageService> extension_message_service_;
// Profile that owns our tab
Profile* profile_;
diff --git a/chrome/browser/extensions/extension_omnibox_apitest.cc b/chrome/browser/extensions/extension_omnibox_apitest.cc
index 38bac82..f66c48e 100644
--- a/chrome/browser/extensions/extension_omnibox_apitest.cc
+++ b/chrome/browser/extensions/extension_omnibox_apitest.cc
@@ -13,7 +13,8 @@
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/omnibox/location_bar.h"
@@ -61,13 +62,13 @@ class OmniboxApiTest : public ExtensionApiTest {
autocomplete_controller();
}
- void WaitForTemplateURLModelToLoad() {
- TemplateURLModel* model =
- browser()->profile()->GetTemplateURLModel();
+ void WaitForTemplateURLServiceToLoad() {
+ TemplateURLService* model =
+ TemplateURLServiceFactory::GetForProfile(browser()->profile());
model->Load();
if (!model->loaded()) {
ui_test_utils::WaitForNotification(
- NotificationType::TEMPLATE_URL_MODEL_LOADED);
+ NotificationType::TEMPLATE_URL_SERVICE_LOADED);
}
}
@@ -91,9 +92,9 @@ IN_PROC_BROWSER_TEST_F(OmniboxApiTest, MAYBE_Basic) {
ASSERT_TRUE(test_server()->Start());
ASSERT_TRUE(RunExtensionTest("omnibox")) << message_;
- // The results depend on the TemplateURLModel being loaded. Make sure it is
+ // The results depend on the TemplateURLService being loaded. Make sure it is
// loaded so that the autocomplete results are consistent.
- WaitForTemplateURLModelToLoad();
+ WaitForTemplateURLServiceToLoad();
LocationBar* location_bar = GetLocationBar();
AutocompleteController* autocomplete_controller = GetAutocompleteController();
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index 2665c8c..a835f6a 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -51,7 +51,8 @@
#include "chrome/browser/net/chrome_url_request_context.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/browser/ui/webui/chrome_url_data_manager.h"
@@ -782,8 +783,10 @@ bool ExtensionService::UninstallExtension(
RecordPermissionMessagesHistogram(
extension, "Extensions.Permissions_Uninstall");
- if (profile_->GetTemplateURLModel())
- profile_->GetTemplateURLModel()->UnregisterExtensionKeyword(extension);
+ TemplateURLService* url_service =
+ TemplateURLServiceFactory::GetForProfile(profile_);
+ if (url_service)
+ url_service->UnregisterExtensionKeyword(extension);
// Unload before doing more cleanup to ensure that nothing is hanging on to
// any of these resources.
@@ -1216,8 +1219,10 @@ void ExtensionService::NotifyExtensionLoaded(const Extension* extension) {
ExtensionWebUI::RegisterChromeURLOverrides(
profile_, extension->GetChromeURLOverrides());
- if (profile_->GetTemplateURLModel())
- profile_->GetTemplateURLModel()->RegisterExtensionKeyword(extension);
+ TemplateURLService* url_service =
+ TemplateURLServiceFactory::GetForProfile(profile_);
+ if (url_service)
+ url_service->RegisterExtensionKeyword(extension);
// Load the icon for omnibox-enabled extensions so it will be ready to display
// in the URL bar.
diff --git a/chrome/browser/first_run/first_run.cc b/chrome/browser/first_run/first_run.cc
index 24ff8e9..51dd756 100644
--- a/chrome/browser/first_run/first_run.cc
+++ b/chrome/browser/first_run/first_run.cc
@@ -21,7 +21,8 @@
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/process_singleton.h"
#include "chrome/browser/profiles/profile_manager.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/shell_integration.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
@@ -567,7 +568,8 @@ void FirstRun::AutoImport(
ShellIntegration::SetAsDefaultBrowser();
// Don't display the minimal bubble if there is no default search provider.
- TemplateURLModel* search_engines_model = profile->GetTemplateURLModel();
+ TemplateURLService* search_engines_model =
+ TemplateURLServiceFactory::GetForProfile(profile);
if (search_engines_model &&
search_engines_model->GetDefaultSearchProvider()) {
FirstRun::SetShowFirstRunBubblePref(true);
diff --git a/chrome/browser/history/url_database.cc b/chrome/browser/history/url_database.cc
index cc9bf9e..f53829e 100644
--- a/chrome/browser/history/url_database.cc
+++ b/chrome/browser/history/url_database.cc
@@ -470,7 +470,7 @@ void URLDatabase::GetMostRecentKeywordSearchTerms(
int max_count,
std::vector<KeywordSearchTermVisit>* matches) {
// NOTE: the keyword_id can be zero if on first run the user does a query
- // before the TemplateURLModel has finished loading. As the chances of this
+ // before the TemplateURLService has finished loading. As the chances of this
// occurring are small, we ignore it.
if (!keyword_id)
return;
diff --git a/chrome/browser/importer/external_process_importer_client.cc b/chrome/browser/importer/external_process_importer_client.cc
index 858665f..1d3b7d3 100644
--- a/chrome/browser/importer/external_process_importer_client.cc
+++ b/chrome/browser/importer/external_process_importer_client.cc
@@ -10,7 +10,7 @@
#include "chrome/browser/importer/in_process_importer_bridge.h"
#include "chrome/browser/importer/profile_import_process_host.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
#include "content/browser/browser_thread.h"
#include "content/browser/renderer_host/resource_dispatcher_host.h"
diff --git a/chrome/browser/importer/firefox_importer_utils.cc b/chrome/browser/importer/firefox_importer_utils.cc
index e2e2626..c66580b 100644
--- a/chrome/browser/importer/firefox_importer_utils.cc
+++ b/chrome/browser/importer/firefox_importer_utils.cc
@@ -17,7 +17,7 @@
#include "base/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/search_engines/template_url_parser.h"
#include "chrome/browser/search_engines/template_url_prepopulate_data.h"
#include "googleurl/src/gurl.h"
@@ -218,7 +218,7 @@ void ParseSearchEnginesFromXMLFiles(const std::vector<FilePath>& xml_files,
// Give this a keyword to facilitate tab-to-search, if possible.
GURL gurl = GURL(url);
template_url->set_keyword(
- TemplateURLModel::GenerateKeyword(gurl, false));
+ TemplateURLService::GenerateKeyword(gurl, false));
template_url->set_logo_id(
TemplateURLPrepopulateData::GetSearchEngineLogo(gurl));
template_url->set_show_in_default_list(true);
diff --git a/chrome/browser/importer/ie_importer.cc b/chrome/browser/importer/ie_importer.cc
index eb242a7..cc1afd9 100644
--- a/chrome/browser/importer/ie_importer.cc
+++ b/chrome/browser/importer/ie_importer.cc
@@ -31,7 +31,7 @@
#include "chrome/browser/importer/importer_data_types.h"
#include "chrome/browser/password_manager/ie7_password.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/search_engines/template_url_prepopulate_data.h"
#include "chrome/common/time_format.h"
#include "chrome/common/url_constants.h"
@@ -405,8 +405,8 @@ void IEImporter::ImportSearchEngines() {
template_url->SetURL(url, 0, 0);
// Give this a keyword to facilitate tab-to-search, if possible.
GURL gurl = GURL(url);
- template_url->set_keyword(TemplateURLModel::GenerateKeyword(gurl,
- false));
+ template_url->set_keyword(TemplateURLService::GenerateKeyword(gurl,
+ false));
template_url->set_logo_id(
TemplateURLPrepopulateData::GetSearchEngineLogo(gurl));
template_url->set_show_in_default_list(true);
diff --git a/chrome/browser/importer/importer_host.cc b/chrome/browser/importer/importer_host.cc
index a012b8c..04e19a9 100644
--- a/chrome/browser/importer/importer_host.cc
+++ b/chrome/browser/importer/importer_host.cc
@@ -16,7 +16,8 @@
#include "chrome/browser/importer/toolbar_importer_utils.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/browser_list.h"
#include "content/browser/browser_thread.h"
#include "content/common/notification_source.h"
@@ -196,14 +197,15 @@ void ImporterHost::CheckForLoadedModels(uint16 items) {
installed_bookmark_observer_ = true;
}
- // Observes the TemplateURLModel if needed to import search engines from the
+ // Observes the TemplateURLService if needed to import search engines from the
// other browser. We also check to see if we're importing bookmarks because
// we can import bookmark keywords from Firefox as search engines.
if ((items & importer::SEARCH_ENGINES) || (items & importer::FAVORITES)) {
- if (!writer_->TemplateURLModelIsLoaded()) {
- TemplateURLModel* model = profile_->GetTemplateURLModel();
- registrar_.Add(this, NotificationType::TEMPLATE_URL_MODEL_LOADED,
- Source<TemplateURLModel>(model));
+ if (!writer_->TemplateURLServiceIsLoaded()) {
+ TemplateURLService* model =
+ TemplateURLServiceFactory::GetForProfile(profile_);
+ registrar_.Add(this, NotificationType::TEMPLATE_URL_SERVICE_LOADED,
+ Source<TemplateURLService>(model));
model->Load();
}
}
@@ -235,7 +237,7 @@ void ImporterHost::BookmarkModelChanged() {
void ImporterHost::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
- DCHECK(type == NotificationType::TEMPLATE_URL_MODEL_LOADED);
+ DCHECK(type == NotificationType::TEMPLATE_URL_SERVICE_LOADED);
registrar_.RemoveAll();
InvokeTaskIfDone();
}
diff --git a/chrome/browser/importer/importer_host.h b/chrome/browser/importer/importer_host.h
index 35f0fe1..d3426cf 100644
--- a/chrome/browser/importer/importer_host.h
+++ b/chrome/browser/importer/importer_host.h
@@ -93,7 +93,7 @@ class ImporterHost : public base::RefCountedThreadSafe<ImporterHost>,
uint16 items,
bool first_run);
- // Make sure BookmarkModel and TemplateURLModel are loaded before import
+ // Make sure BookmarkModel and TemplateURLService are loaded before import
// process starts, if bookmarks and/or search engines are among the items
// which are to be imported.
void CheckForLoadedModels(uint16 items);
@@ -119,7 +119,7 @@ class ImporterHost : public base::RefCountedThreadSafe<ImporterHost>,
// True if source profile is readable.
bool is_source_readable_;
- // Receives notification when the TemplateURLModel has loaded.
+ // Receives notification when the TemplateURLService has loaded.
NotificationRegistrar registrar_;
// Writes data from the importer back to the profile.
@@ -140,7 +140,7 @@ class ImporterHost : public base::RefCountedThreadSafe<ImporterHost>,
virtual void BookmarkModelChanged() OVERRIDE;
// NotificationObserver:
- // Called when TemplateURLModel has been loaded.
+ // Called when TemplateURLService has been loaded.
virtual void Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) OVERRIDE;
diff --git a/chrome/browser/importer/importer_unittest.cc b/chrome/browser/importer/importer_unittest.cc
index 066c5ba..388db80 100644
--- a/chrome/browser/importer/importer_unittest.cc
+++ b/chrome/browser/importer/importer_unittest.cc
@@ -211,7 +211,7 @@ class TestObserver : public ProfileWriter,
return true;
}
- virtual bool TemplateURLModelIsLoaded() const {
+ virtual bool TemplateURLServiceIsLoaded() const {
return true;
}
@@ -577,7 +577,7 @@ class FirefoxObserver : public ProfileWriter,
return true;
}
- virtual bool TemplateURLModelIsLoaded() const {
+ virtual bool TemplateURLServiceIsLoaded() const {
return true;
}
@@ -781,7 +781,7 @@ class Firefox3Observer : public ProfileWriter,
return true;
}
- virtual bool TemplateURLModelIsLoaded() const {
+ virtual bool TemplateURLServiceIsLoaded() const {
return true;
}
diff --git a/chrome/browser/importer/profile_writer.cc b/chrome/browser/importer/profile_writer.cc
index da63976..f0f7841 100644
--- a/chrome/browser/importer/profile_writer.cc
+++ b/chrome/browser/importer/profile_writer.cc
@@ -15,7 +15,8 @@
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/common/pref_names.h"
#include "content/common/notification_service.h"
@@ -79,8 +80,8 @@ bool ProfileWriter::BookmarkModelIsLoaded() const {
return profile_->GetBookmarkModel()->IsLoaded();
}
-bool ProfileWriter::TemplateURLModelIsLoaded() const {
- return profile_->GetTemplateURLModel()->loaded();
+bool ProfileWriter::TemplateURLServiceIsLoaded() const {
+ return TemplateURLServiceFactory::GetForProfile(profile_)->loaded();
}
void ProfileWriter::AddPasswordForm(const webkit_glue::PasswordForm& form) {
@@ -256,8 +257,8 @@ static std::string BuildHostPathKey(const TemplateURL* t_url,
}
// Builds a set that contains an entry of the host+path for each TemplateURL in
-// the TemplateURLModel that has a valid search url.
-static void BuildHostPathMap(const TemplateURLModel& model,
+// the TemplateURLService that has a valid search url.
+static void BuildHostPathMap(const TemplateURLService& model,
HostPathMap* host_path_map) {
std::vector<const TemplateURL*> template_urls = model.GetTemplateURLs();
for (size_t i = 0; i < template_urls.size(); ++i) {
@@ -281,7 +282,8 @@ static void BuildHostPathMap(const TemplateURLModel& model,
void ProfileWriter::AddKeywords(const std::vector<TemplateURL*>& template_urls,
int default_keyword_index,
bool unique_on_host_and_path) {
- TemplateURLModel* model = profile_->GetTemplateURLModel();
+ TemplateURLService* model =
+ TemplateURLServiceFactory::GetForProfile(profile_);
HostPathMap host_path_map;
if (unique_on_host_and_path)
BuildHostPathMap(*model, &host_path_map);
@@ -293,7 +295,7 @@ void ProfileWriter::AddKeywords(const std::vector<TemplateURL*>& template_urls,
default_keyword_index >= 0 &&
(i - template_urls.begin() == default_keyword_index);
- // TemplateURLModel requires keywords to be unique. If there is already a
+ // TemplateURLService requires keywords to be unique. If there is already a
// TemplateURL with this keyword, don't import it again.
const TemplateURL* turl_with_keyword =
model->GetTemplateURLForKeyword(t_url->keyword());
diff --git a/chrome/browser/importer/profile_writer.h b/chrome/browser/importer/profile_writer.h
index 2e2830b..b810033 100644
--- a/chrome/browser/importer/profile_writer.h
+++ b/chrome/browser/importer/profile_writer.h
@@ -50,7 +50,7 @@ class ProfileWriter : public base::RefCountedThreadSafe<ProfileWriter> {
// If the models haven't been loaded, the importer waits to run until they've
// completed.
virtual bool BookmarkModelIsLoaded() const;
- virtual bool TemplateURLModelIsLoaded() const;
+ virtual bool TemplateURLServiceIsLoaded() const;
// Helper methods for adding data to local stores.
virtual void AddPasswordForm(const webkit_glue::PasswordForm& form);
diff --git a/chrome/browser/instant/instant_browsertest.cc b/chrome/browser/instant/instant_browsertest.cc
index 705ef5d..b2d8187 100644
--- a/chrome/browser/instant/instant_browsertest.cc
+++ b/chrome/browser/instant/instant_browsertest.cc
@@ -12,7 +12,8 @@
#include "chrome/browser/instant/instant_loader_manager.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
@@ -43,18 +44,19 @@ class InstantTest : public InProcessBrowserTest {
}
void SetupInstantProvider(const std::string& page) {
- TemplateURLModel* model = browser()->profile()->GetTemplateURLModel();
+ TemplateURLService* model =
+ TemplateURLServiceFactory::GetForProfile(browser()->profile());
ASSERT_TRUE(model);
if (!model->loaded()) {
model->Load();
ui_test_utils::WaitForNotification(
- NotificationType::TEMPLATE_URL_MODEL_LOADED);
+ NotificationType::TEMPLATE_URL_SERVICE_LOADED);
}
ASSERT_TRUE(model->loaded());
- // TemplateURLModel takes ownership of this.
+ // TemplateURLService takes ownership of this.
TemplateURL* template_url = new TemplateURL();
std::string url = StringPrintf(
@@ -329,7 +331,8 @@ IN_PROC_BROWSER_TEST_F(InstantTest, OnChangeEvent) {
// Make sure the url that will get committed when we press enter matches that
// of the default search provider.
const TemplateURL* default_turl =
- browser()->profile()->GetTemplateURLModel()->GetDefaultSearchProvider();
+ TemplateURLServiceFactory::GetForProfile(browser()->profile())->
+ GetDefaultSearchProvider();
ASSERT_TRUE(default_turl);
ASSERT_TRUE(default_turl->url());
EXPECT_EQ(default_turl->url()->ReplaceSearchTerms(
diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc
index a6fe03a..592c0e3 100644
--- a/chrome/browser/instant/instant_controller.cc
+++ b/chrome/browser/instant/instant_controller.cc
@@ -17,7 +17,8 @@
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/common/chrome_switches.h"
@@ -365,7 +366,8 @@ void InstantController::OnAutocompleteGotFocus(
if (is_active_)
return;
- TemplateURLModel* model = tab_contents->profile()->GetTemplateURLModel();
+ TemplateURLService* model = TemplateURLServiceFactory::GetForProfile(
+ tab_contents->profile());
if (!model)
return;
@@ -728,7 +730,8 @@ const TemplateURL* InstantController::GetTemplateURL(
if (match.type == AutocompleteMatch::SEARCH_WHAT_YOU_TYPED ||
match.type == AutocompleteMatch::SEARCH_HISTORY ||
match.type == AutocompleteMatch::SEARCH_SUGGEST) {
- TemplateURLModel* model = tab_contents_->profile()->GetTemplateURLModel();
+ TemplateURLService* model = TemplateURLServiceFactory::GetForProfile(
+ tab_contents_->profile());
template_url = model ? model->GetDefaultSearchProvider() : NULL;
}
return template_url;
diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc
index 90b4c74..674f966 100644
--- a/chrome/browser/metrics/metrics_service.cc
+++ b/chrome/browser/metrics/metrics_service.cc
@@ -177,7 +177,7 @@
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/prefs/scoped_user_pref_update.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/common/child_process_logging.h"
#include "chrome/common/chrome_switches.h"
@@ -555,7 +555,7 @@ void MetricsService::SetUpNotifications(NotificationRegistrar* registrar,
NotificationService::AllSources());
registrar->Add(observer, NotificationType::CHILD_PROCESS_CRASHED,
NotificationService::AllSources());
- registrar->Add(observer, NotificationType::TEMPLATE_URL_MODEL_LOADED,
+ registrar->Add(observer, NotificationType::TEMPLATE_URL_SERVICE_LOADED,
NotificationService::AllSources());
registrar->Add(observer, NotificationType::OMNIBOX_OPENED_URL,
NotificationService::AllSources());
@@ -621,8 +621,8 @@ void MetricsService::Observe(NotificationType type,
LogChildProcessChange(type, source, details);
break;
- case NotificationType::TEMPLATE_URL_MODEL_LOADED:
- LogKeywords(Source<TemplateURLModel>(source).ptr());
+ case NotificationType::TEMPLATE_URL_SERVICE_LOADED:
+ LogKeywords(Source<TemplateURLService>(source).ptr());
break;
case NotificationType::OMNIBOX_OPENED_URL: {
@@ -1566,7 +1566,7 @@ void MetricsService::LogBookmarks(BookmarkModel* model) {
ScheduleNextStateSave();
}
-void MetricsService::LogKeywords(const TemplateURLModel* url_model) {
+void MetricsService::LogKeywords(const TemplateURLService* url_model) {
DCHECK(url_model);
PrefService* pref = g_browser_process->local_state();
diff --git a/chrome/browser/metrics/metrics_service.h b/chrome/browser/metrics/metrics_service.h
index fb79337..cb61682 100644
--- a/chrome/browser/metrics/metrics_service.h
+++ b/chrome/browser/metrics/metrics_service.h
@@ -33,7 +33,7 @@ class HistogramSynchronizer;
class MetricsLogBase;
class MetricsReportingScheduler;
class PrefService;
-class TemplateURLModel;
+class TemplateURLService;
namespace webkit {
namespace npapi {
@@ -307,7 +307,7 @@ class MetricsService : public NotificationObserver,
// Logs keywords specific metrics. Keyword metrics are recorded in the
// profile specific metrics.
- void LogKeywords(const TemplateURLModel* url_model);
+ void LogKeywords(const TemplateURLService* url_model);
// Saves plugin-related updates from the in-object buffer to Local State
// for retrieval next time we send a Profile log (generally next launch).
diff --git a/chrome/browser/omnibox_search_hint.cc b/chrome/browser/omnibox_search_hint.cc
index 102d9c4..b653519 100644
--- a/chrome/browser/omnibox_search_hint.cc
+++ b/chrome/browser/omnibox_search_hint.cc
@@ -15,7 +15,8 @@
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/tab_contents/confirm_infobar_delegate.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
@@ -176,7 +177,8 @@ void OmniboxSearchHint::Observe(NotificationType type,
return;
}
const TemplateURL* const default_provider =
- tab_->profile()->GetTemplateURLModel()->GetDefaultSearchProvider();
+ TemplateURLServiceFactory::GetForProfile(tab_->profile())->
+ GetDefaultSearchProvider();
if (!default_provider)
return;
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index cfdba39..14b6fbc 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -41,7 +41,7 @@
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/renderer_host/web_cache_manager.h"
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/search_engines/template_url_prepopulate_data.h"
#include "chrome/browser/sync/signin_manager.h"
#include "chrome/browser/tabs/pinned_tab_codec.h"
@@ -160,7 +160,7 @@ void RegisterUserPrefs(PrefService* user_prefs) {
#endif
BackgroundContentsService::RegisterUserPrefs(user_prefs);
SigninManager::RegisterUserPrefs(user_prefs);
- TemplateURLModel::RegisterUserPrefs(user_prefs);
+ TemplateURLService::RegisterUserPrefs(user_prefs);
InstantController::RegisterUserPrefs(user_prefs);
NetPrefObserver::RegisterPrefs(user_prefs);
// TODO(sfeuz): Remove registering of cloud policy refresh rate preference in
diff --git a/chrome/browser/profiles/profile.cc b/chrome/browser/profiles/profile.cc
index 0871cf9..ebce3f8 100644
--- a/chrome/browser/profiles/profile.cc
+++ b/chrome/browser/profiles/profile.cc
@@ -404,10 +404,6 @@ class OffTheRecordProfileImpl : public Profile,
return prefs_;
}
- virtual TemplateURLModel* GetTemplateURLModel() {
- return profile_->GetTemplateURLModel();
- }
-
virtual TemplateURLFetcher* GetTemplateURLFetcher() {
return profile_->GetTemplateURLFetcher();
}
diff --git a/chrome/browser/profiles/profile.h b/chrome/browser/profiles/profile.h
index 22c983b..fcb78cf 100644
--- a/chrome/browser/profiles/profile.h
+++ b/chrome/browser/profiles/profile.h
@@ -87,7 +87,6 @@ class SSLConfigServiceManager;
class SSLHostState;
class SpellCheckHost;
class TemplateURLFetcher;
-class TemplateURLModel;
class TokenService;
class TransportSecurityPersister;
class UserScriptMaster;
@@ -310,10 +309,6 @@ class Profile {
// time that this method is called.
virtual PrefService* GetOffTheRecordPrefs() = 0;
- // Returns the TemplateURLModel for this profile. This is owned by the
- // the Profile.
- virtual TemplateURLModel* GetTemplateURLModel() = 0;
-
// Returns the TemplateURLFetcher for this profile. This is owned by the
// profile.
virtual TemplateURLFetcher* GetTemplateURLFetcher() = 0;
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index 2d45b33..51b38f4 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -58,7 +58,7 @@
#include "chrome/browser/profiles/profile_dependency_manager.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/search_engines/template_url_fetcher.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/sessions/session_service_factory.h"
#include "chrome/browser/spellcheck_host.h"
#include "chrome/browser/sync/profile_sync_factory_impl.h"
@@ -602,11 +602,6 @@ ProfileImpl::~ProfileImpl() {
ProfileDependencyManager::GetInstance()->DestroyProfileServices(this);
- // TemplateURLModel schedules a task on the WebDataService from its
- // destructor. Delete it first to ensure the task gets scheduled before we
- // shut down the database.
- template_url_model_.reset();
-
// DownloadManager is lazily created, so check before accessing it.
if (download_manager_.get()) {
// The download manager queries the history system and should be shut down
@@ -1021,12 +1016,6 @@ HistoryService* ProfileImpl::GetHistoryServiceWithoutCreating() {
return history_service_.get();
}
-TemplateURLModel* ProfileImpl::GetTemplateURLModel() {
- if (!template_url_model_.get())
- template_url_model_.reset(new TemplateURLModel(this));
- return template_url_model_.get();
-}
-
TemplateURLFetcher* ProfileImpl::GetTemplateURLFetcher() {
if (!template_url_fetcher_.get())
template_url_fetcher_.reset(new TemplateURLFetcher(this));
diff --git a/chrome/browser/profiles/profile_impl.h b/chrome/browser/profiles/profile_impl.h
index 77977cc..84dceec 100644
--- a/chrome/browser/profiles/profile_impl.h
+++ b/chrome/browser/profiles/profile_impl.h
@@ -74,7 +74,6 @@ class ProfileImpl : public Profile,
virtual PasswordStore* GetPasswordStore(ServiceAccessType sat);
virtual PrefService* GetPrefs();
virtual PrefService* GetOffTheRecordPrefs();
- virtual TemplateURLModel* GetTemplateURLModel();
virtual TemplateURLFetcher* GetTemplateURLFetcher();
virtual DownloadManager* GetDownloadManager();
virtual PersonalDataManager* GetPersonalDataManager();
@@ -210,7 +209,6 @@ class ProfileImpl : public Profile,
scoped_ptr<prerender::PrerenderManager> prerender_manager_;
scoped_ptr<NetPrefObserver> net_pref_observer_;
scoped_ptr<TemplateURLFetcher> template_url_fetcher_;
- scoped_ptr<TemplateURLModel> template_url_model_;
scoped_ptr<BookmarkModel> bookmark_bar_model_;
scoped_refptr<PromoResourceService> promo_resource_service_;
scoped_refptr<ProtocolHandlerRegistry> protocol_handler_registry_;
diff --git a/chrome/browser/profiles/profile_keyed_service_factory.cc b/chrome/browser/profiles/profile_keyed_service_factory.cc
index 8293ab8..e13fbf5 100644
--- a/chrome/browser/profiles/profile_keyed_service_factory.cc
+++ b/chrome/browser/profiles/profile_keyed_service_factory.cc
@@ -13,13 +13,8 @@
void ProfileKeyedServiceFactory::SetTestingFactory(Profile* profile,
FactoryFunction factory) {
-#ifndef NDEBUG
- std::map<Profile*, FactoryFunction>::iterator it =
- factories_.find(profile);
- if (it != factories_.end()) {
- DCHECK(it->second == NULL) << "Can't change non-NULL testing factory";
- }
-#endif
+ ProfileShutdown(profile);
+ ProfileDestroyed(profile);
factories_[profile] = factory;
}
diff --git a/chrome/browser/profiles/profile_keyed_service_factory.h b/chrome/browser/profiles/profile_keyed_service_factory.h
index f87440c..f805db7 100644
--- a/chrome/browser/profiles/profile_keyed_service_factory.h
+++ b/chrome/browser/profiles/profile_keyed_service_factory.h
@@ -26,9 +26,10 @@ class ProfileKeyedServiceFactory {
// Associates |factory| with |profile| so that |factory| is used to create
// the ProfileKeyedService when requested.
//
- // |factory| can be NULL to signal that ProfileKeyedService should be
- // NULL. When |factory| is NULL, a second call to SetTestingFactory() is
- // allowed. (Otherwise, we'll DCHECK.)
+ // |factory| can be NULL to signal that ProfileKeyedService should be NULL. A
+ // second call to SetTestingFactory() is allowed. If the FactoryFunction is
+ // changed AND an instance of the PKSF already exists for |profile|, that
+ // service is destroyed.
void SetTestingFactory(Profile* profile, FactoryFunction factory);
// Associates |factory| with |profile| and immediately returns the created
diff --git a/chrome/browser/rlz/rlz.cc b/chrome/browser/rlz/rlz.cc
index 1f965a0..fc676e7f 100644
--- a/chrome/browser/rlz/rlz.cc
+++ b/chrome/browser/rlz/rlz.cc
@@ -26,7 +26,8 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/env_vars.h"
#include "chrome/installer/util/google_update_settings.h"
@@ -222,8 +223,8 @@ class DelayedInitTask : public Task {
Profile* profile = profile_manager->GetDefaultProfile(user_data_dir);
if (!profile)
return false;
- const TemplateURL* url_template =
- profile->GetTemplateURLModel()->GetDefaultSearchProvider();
+ const TemplateURL* url_template = TemplateURLServiceFactory::GetForProfile(
+ profile)->GetDefaultSearchProvider();
if (!url_template)
return false;
const TemplateURLRef* urlref = url_template->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 256f2f8..cb91724 100644
--- a/chrome/browser/search_engines/search_host_to_urls_map.cc
+++ b/chrome/browser/search_engines/search_host_to_urls_map.cc
@@ -7,7 +7,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/task.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
SearchHostToURLsMap::SearchHostToURLsMap()
: initialized_(false) {
@@ -33,7 +33,7 @@ void SearchHostToURLsMap::Add(const TemplateURL* template_url,
DCHECK(initialized_);
DCHECK(template_url);
- const GURL url(TemplateURLModel::GenerateSearchURLUsingTermsData(
+ const GURL url(TemplateURLService::GenerateSearchURLUsingTermsData(
template_url, search_terms_data));
if (!url.is_valid() || !url.has_host())
return;
@@ -45,7 +45,7 @@ void SearchHostToURLsMap::Remove(const TemplateURL* template_url) {
DCHECK(initialized_);
DCHECK(template_url);
- const GURL url(TemplateURLModel::GenerateSearchURL(template_url));
+ const GURL url(TemplateURLService::GenerateSearchURL(template_url));
if (!url.is_valid() || !url.has_host())
return;
diff --git a/chrome/browser/search_engines/search_provider_install_data.cc b/chrome/browser/search_engines/search_provider_install_data.cc
index f87177a..46616c8 100644
--- a/chrome/browser/search_engines/search_provider_install_data.cc
+++ b/chrome/browser/search_engines/search_provider_install_data.cc
@@ -13,7 +13,7 @@
#include "chrome/browser/search_engines/search_host_to_urls_map.h"
#include "chrome/browser/search_engines/search_terms_data.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/search_engines/util.h"
#include "chrome/browser/webdata/web_data_service.h"
#include "content/browser/browser_thread.h"
@@ -153,7 +153,7 @@ static bool IsSameOrigin(const GURL& requested_origin,
const SearchTermsData& search_terms_data) {
DCHECK(requested_origin == requested_origin.GetOrigin());
return template_url && requested_origin ==
- TemplateURLModel::GenerateSearchURLUsingTermsData(
+ TemplateURLService::GenerateSearchURLUsingTermsData(
template_url,
search_terms_data).GetOrigin();
}
@@ -276,7 +276,7 @@ void SearchProviderInstallData::SetDefault(const TemplateURL* template_url) {
}
IOThreadSearchTermsData search_terms_data(google_base_url_);
- const GURL url(TemplateURLModel::GenerateSearchURLUsingTermsData(
+ const GURL url(TemplateURLService::GenerateSearchURLUsingTermsData(
template_url, search_terms_data));
if (!url.is_valid() || !url.has_host()) {
default_search_origin_.clear();
diff --git a/chrome/browser/search_engines/search_provider_install_data_unittest.cc b/chrome/browser/search_engines/search_provider_install_data_unittest.cc
index f30271c..476c7f5 100644
--- a/chrome/browser/search_engines/search_provider_install_data_unittest.cc
+++ b/chrome/browser/search_engines/search_provider_install_data_unittest.cc
@@ -11,8 +11,8 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/search_engines/search_provider_install_data.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
-#include "chrome/browser/search_engines/template_url_model_test_util.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_test_util.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/testing_pref_service.h"
#include "chrome/test/testing_profile.h"
@@ -155,7 +155,7 @@ void TestGetInstallState::VerifyInstallState(
}
// Provides basic test set-up/tear-down functionality needed by all tests
-// that use TemplateURLModelTestUtil.
+// that use TemplateURLServiceTestUtil.
class SearchProviderInstallDataTest : public testing::Test {
public:
SearchProviderInstallDataTest()
@@ -212,7 +212,7 @@ class SearchProviderInstallDataTest : public testing::Test {
}
protected:
- TemplateURLModelTestUtil util_;
+ TemplateURLServiceTestUtil util_;
// Provides the search provider install state on the I/O thread. It must be
// deleted on the I/O thread, which is why it isn't a scoped_ptr.
@@ -230,7 +230,7 @@ TEST_F(SearchProviderInstallDataTest, GetInstallState) {
util_.model()->Add(t_url);
// Wait for the changes to be saved.
- TemplateURLModelTestUtil::BlockTillServiceProcessesRequests();
+ TemplateURLServiceTestUtil::BlockTillServiceProcessesRequests();
// Verify the search providers install state (with no default set).
scoped_refptr<TestGetInstallState> test_get_install_state(
@@ -285,7 +285,7 @@ TEST_F(SearchProviderInstallDataTest, GoogleBaseUrlChange) {
std::string google_host = "w.com";
util_.SetGoogleBaseURL("http://" + google_host + "/");
// Wait for the I/O thread to process the update notification.
- TemplateURLModelTestUtil::BlockTillIOThreadProcessesRequests();
+ TemplateURLServiceTestUtil::BlockTillIOThreadProcessesRequests();
TemplateURL* t_url = CreateTemplateURL("{google:baseURL}?q={searchTerms}",
"t");
@@ -296,7 +296,7 @@ TEST_F(SearchProviderInstallDataTest, GoogleBaseUrlChange) {
util_.model()->SetDefaultSearchProvider(default_url);
// Wait for the changes to be saved.
- TemplateURLModelTestUtil::BlockTillServiceProcessesRequests();
+ TemplateURLServiceTestUtil::BlockTillServiceProcessesRequests();
// Verify the search providers install state (with no default set).
test_get_install_state->set_search_provider_host(google_host);
@@ -306,7 +306,7 @@ TEST_F(SearchProviderInstallDataTest, GoogleBaseUrlChange) {
google_host = "foo.com";
util_.SetGoogleBaseURL("http://" + google_host + "/");
// Wait for the I/O thread to process the update notification.
- TemplateURLModelTestUtil::BlockTillIOThreadProcessesRequests();
+ TemplateURLServiceTestUtil::BlockTillIOThreadProcessesRequests();
// Verify that the change got picked up.
test_get_install_state->set_search_provider_host(google_host);
diff --git a/chrome/browser/search_engines/template_url.cc b/chrome/browser/search_engines/template_url.cc
index 452a179..6a5808b 100644
--- a/chrome/browser/search_engines/template_url.cc
+++ b/chrome/browser/search_engines/template_url.cc
@@ -13,7 +13,7 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/search_engines/search_engine_type.h"
#include "chrome/browser/search_engines/search_terms_data.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/common/url_constants.h"
#include "chrome/installer/util/google_update_settings.h"
#include "content/browser/user_metrics.h"
@@ -643,8 +643,8 @@ string16 TemplateURL::keyword() const {
void TemplateURL::EnsureKeyword() const {
if (autogenerate_keyword_ && !keyword_generated_) {
// Generate a keyword and cache it.
- keyword_ = TemplateURLModel::GenerateKeyword(
- TemplateURLModel::GenerateSearchURL(this).GetWithEmptyPath(), true);
+ keyword_ = TemplateURLService::GenerateKeyword(
+ TemplateURLService::GenerateSearchURL(this).GetWithEmptyPath(), true);
keyword_generated_ = true;
}
}
diff --git a/chrome/browser/search_engines/template_url.h b/chrome/browser/search_engines/template_url.h
index 46f9048..5fe6a96 100644
--- a/chrome/browser/search_engines/template_url.h
+++ b/chrome/browser/search_engines/template_url.h
@@ -138,7 +138,7 @@ class TemplateURLRef {
private:
friend class SearchHostToURLsMapTest;
friend class TemplateURL;
- friend class TemplateURLModelTestUtil;
+ friend class TemplateURLServiceTestUtil;
friend class TemplateURLTest;
FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseParameterKnown);
FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseParameterUnknown);
@@ -463,7 +463,7 @@ class TemplateURL {
int logo_id() const { return logo_id_; }
// Returns the unique identifier of this TemplateURL. The unique ID is set
- // by the TemplateURLModel when the TemplateURL is added to it.
+ // by the TemplateURLService when the TemplateURL is added to it.
TemplateURLID id() const { return id_; }
// If this TemplateURL comes from prepopulated data the prepopulate_id is > 0.
@@ -482,7 +482,7 @@ class TemplateURL {
friend class KeywordTable;
friend class KeywordTableTest;
friend class SearchHostToURLsMap;
- friend class TemplateURLModel;
+ friend class TemplateURLService;
// Invalidates cached values on this object and its child TemplateURLRefs.
void InvalidateCachedValues() const;
diff --git a/chrome/browser/search_engines/template_url_fetcher.cc b/chrome/browser/search_engines/template_url_fetcher.cc
index 3a4e949..caf594e 100644
--- a/chrome/browser/search_engines/template_url_fetcher.cc
+++ b/chrome/browser/search_engines/template_url_fetcher.cc
@@ -11,7 +11,8 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url.h"
#include "chrome/browser/search_engines/template_url_fetcher_callbacks.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/search_engines/template_url_parser.h"
#include "content/common/notification_observer.h"
#include "content/common/notification_registrar.h"
@@ -39,7 +40,7 @@ class TemplateURLFetcher::RequestDelegate : public URLFetcher::Delegate,
// URLFetcher::Delegate:
// If data contains a valid OSDD, a TemplateURL is created and added to
- // the TemplateURLModel.
+ // the TemplateURLService.
virtual void OnURLFetchComplete(const URLFetcher* source,
const GURL& url,
const net::URLRequestStatus& status,
@@ -89,14 +90,15 @@ TemplateURLFetcher::RequestDelegate::RequestDelegate(
favicon_url_(favicon_url),
provider_type_(provider_type),
callbacks_(callbacks) {
- TemplateURLModel* model = fetcher_->profile()->GetTemplateURLModel();
+ TemplateURLService* model = TemplateURLServiceFactory::GetForProfile(
+ fetcher_->profile());
DCHECK(model); // TemplateURLFetcher::ScheduleDownload verifies this.
if (!model->loaded()) {
// Start the model load and set-up waiting for it.
registrar_.Add(this,
- NotificationType::TEMPLATE_URL_MODEL_LOADED,
- Source<TemplateURLModel>(model));
+ NotificationType::TEMPLATE_URL_SERVICE_LOADED,
+ Source<TemplateURLService>(model));
model->Load();
}
@@ -108,7 +110,7 @@ void TemplateURLFetcher::RequestDelegate::Observe(
NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
- DCHECK(type == NotificationType::TEMPLATE_URL_MODEL_LOADED);
+ DCHECK(type == NotificationType::TEMPLATE_URL_SERVICE_LOADED);
if (!template_url_.get())
return;
@@ -145,7 +147,8 @@ void TemplateURLFetcher::RequestDelegate::OnURLFetchComplete(
}
// Wait for the model to be loaded before adding the provider.
- TemplateURLModel* model = fetcher_->profile()->GetTemplateURLModel();
+ TemplateURLService* model = TemplateURLServiceFactory::GetForProfile(
+ fetcher_->profile());
if (!model->loaded())
return;
AddSearchProvider();
@@ -160,12 +163,13 @@ void TemplateURLFetcher::RequestDelegate::AddSearchProvider() {
// it gives wrong result when OSDD is located on third party site that
// has nothing in common with search engine in OSDD.
GURL keyword_url(template_url_->url()->url());
- string16 new_keyword = TemplateURLModel::GenerateKeyword(
+ string16 new_keyword = TemplateURLService::GenerateKeyword(
keyword_url, false);
if (!new_keyword.empty())
keyword_ = new_keyword;
}
- TemplateURLModel* model = fetcher_->profile()->GetTemplateURLModel();
+ TemplateURLService* model = TemplateURLServiceFactory::GetForProfile(
+ fetcher_->profile());
const TemplateURL* existing_url;
if (keyword_.empty() ||
!model || !model->loaded() ||
@@ -281,7 +285,8 @@ void TemplateURLFetcher::ScheduleDownload(
if (provider_type == TemplateURLFetcher::AUTODETECTED_PROVIDER &&
keyword.empty())
return;
- TemplateURLModel* url_model = profile()->GetTemplateURLModel();
+ TemplateURLService* url_model =
+ TemplateURLServiceFactory::GetForProfile(profile());
if (!url_model)
return;
diff --git a/chrome/browser/search_engines/template_url_fetcher.h b/chrome/browser/search_engines/template_url_fetcher.h
index 9d62954..a47e097 100644
--- a/chrome/browser/search_engines/template_url_fetcher.h
+++ b/chrome/browser/search_engines/template_url_fetcher.h
@@ -17,7 +17,7 @@ class TemplateURLFetcherCallbacks;
// TemplateURLFetcher is responsible for downloading OpenSearch description
// documents, creating a TemplateURL from the OSDD, and adding the TemplateURL
-// to the TemplateURLModel. Downloading is done in the background.
+// to the TemplateURLService. Downloading is done in the background.
//
class TemplateURLFetcher {
public:
@@ -33,7 +33,7 @@ class TemplateURLFetcher {
// If TemplateURLFetcher is not already downloading the OSDD for osdd_url,
// it is downloaded. If successful and the result can be parsed, a TemplateURL
- // is added to the TemplateURLModel. Takes ownership of |callbacks|.
+ // is added to the TemplateURLService. Takes ownership of |callbacks|.
void ScheduleDownload(const string16& keyword,
const GURL& osdd_url,
const GURL& favicon_url,
diff --git a/chrome/browser/search_engines/template_url_fetcher_callbacks.h b/chrome/browser/search_engines/template_url_fetcher_callbacks.h
index 6a009cd..34e0059 100644
--- a/chrome/browser/search_engines/template_url_fetcher_callbacks.h
+++ b/chrome/browser/search_engines/template_url_fetcher_callbacks.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -8,7 +8,7 @@
class Profile;
class TemplateURL;
-class TemplateURLModel;
+class TemplateURLService;
// Callbacks for the TemplateURLFetcher.
class TemplateURLFetcherCallbacks {
@@ -20,7 +20,7 @@ class TemplateURLFetcherCallbacks {
// described by |template_url|. Takes ownership of |template_url|.
virtual void ConfirmSetDefaultSearchProvider(
TemplateURL* template_url,
- TemplateURLModel* template_url_model) = 0;
+ TemplateURLService* template_url_service) = 0;
// Performs the confirmation step for adding a search engine described by
// |template_url|. Takes ownership of |template_url|.
diff --git a/chrome/browser/search_engines/template_url_fetcher_unittest.cc b/chrome/browser/search_engines/template_url_fetcher_unittest.cc
index 87a27f3..bc010f6 100644
--- a/chrome/browser/search_engines/template_url_fetcher_unittest.cc
+++ b/chrome/browser/search_engines/template_url_fetcher_unittest.cc
@@ -10,8 +10,8 @@
#include "chrome/browser/search_engines/template_url.h"
#include "chrome/browser/search_engines/template_url_fetcher.h"
#include "chrome/browser/search_engines/template_url_fetcher_callbacks.h"
-#include "chrome/browser/search_engines/template_url_model.h"
-#include "chrome/browser/search_engines/template_url_model_test_util.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_test_util.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/test/testing_profile.h"
#include "googleurl/src/gurl.h"
@@ -31,7 +31,7 @@ class TemplateURLFetcherTestCallbacks : public TemplateURLFetcherCallbacks {
// TemplateURLFetcherCallbacks implementation.
virtual void ConfirmSetDefaultSearchProvider(
TemplateURL* template_url,
- TemplateURLModel* template_url_model);
+ TemplateURLService* template_url_service);
virtual void ConfirmAddSearchProvider(
TemplateURL* template_url,
Profile* profile);
@@ -70,7 +70,7 @@ class TemplateURLFetcherTest : public testing::Test {
// this class, these methods handle those calls for the test.)
virtual void ConfirmSetDefaultSearchProvider(
TemplateURL* template_url,
- TemplateURLModel* template_url_model);
+ TemplateURLService* template_url_service);
virtual void ConfirmAddSearchProvider(
TemplateURL* template_url,
Profile* profile);
@@ -85,7 +85,7 @@ class TemplateURLFetcherTest : public testing::Test {
// Waits for any downloads to finish.
void WaitForDownloadToFinish();
- TemplateURLModelTestUtil test_util_;
+ TemplateURLServiceTestUtil test_util_;
net::TestServer test_server_;
// The last TemplateURL to come from a callback.
@@ -114,8 +114,8 @@ TemplateURLFetcherTestCallbacks::~TemplateURLFetcherTestCallbacks() {
void TemplateURLFetcherTestCallbacks::ConfirmSetDefaultSearchProvider(
TemplateURL* template_url,
- TemplateURLModel* template_url_model) {
- test_->ConfirmSetDefaultSearchProvider(template_url, template_url_model);
+ TemplateURLService* template_url_service) {
+ test_->ConfirmSetDefaultSearchProvider(template_url, template_url_service);
}
void TemplateURLFetcherTestCallbacks::ConfirmAddSearchProvider(
@@ -142,7 +142,7 @@ void TemplateURLFetcherTest::DestroyedCallback(
void TemplateURLFetcherTest::ConfirmSetDefaultSearchProvider(
TemplateURL* template_url,
- TemplateURLModel* template_url_model) {
+ TemplateURLService* template_url_service) {
last_callback_template_url_.reset(template_url);
set_default_called_++;
}
diff --git a/chrome/browser/search_engines/template_url_model_observer.h b/chrome/browser/search_engines/template_url_model_observer.h
deleted file mode 100644
index 860c01e..0000000
--- a/chrome/browser/search_engines/template_url_model_observer.h
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright (c) 2010 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.
-
-#ifndef CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_MODEL_OBSERVER_H_
-#define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_MODEL_OBSERVER_H_
-#pragma once
-
-// TemplateURLModelObserver is notified whenever the set of TemplateURLs
-// are modified.
-class TemplateURLModelObserver {
- public:
- // Notification that the template url model has changed in some way.
- virtual void OnTemplateURLModelChanged() = 0;
-
- protected:
- virtual ~TemplateURLModelObserver() {}
-};
-
-#endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_MODEL_OBSERVER_H_
diff --git a/chrome/browser/search_engines/template_url_prepopulate_data.cc b/chrome/browser/search_engines/template_url_prepopulate_data.cc
index e19384e..b729d070 100644
--- a/chrome/browser/search_engines/template_url_prepopulate_data.cc
+++ b/chrome/browser/search_engines/template_url_prepopulate_data.cc
@@ -18,7 +18,7 @@
#include "chrome/browser/search_engines/search_engine_type.h"
#include "chrome/browser/search_engines/search_terms_data.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "googleurl/src/gurl.h"
@@ -3532,7 +3532,7 @@ static GURL GetOriginForSearchURL(const STR& url_string) {
turl.SetURL(url_utf8_string, 0, 0);
UIThreadSearchTermsData search_terms_data;
- url = TemplateURLModel::GenerateSearchURLUsingTermsData(
+ url = TemplateURLService::GenerateSearchURLUsingTermsData(
&turl, search_terms_data);
}
return url.GetOrigin();
diff --git a/chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc b/chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc
index 327420f..df803e0 100644
--- a/chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc
+++ b/chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc
@@ -9,7 +9,7 @@
#include "chrome/browser/search_engines/search_engine_type.h"
#include "chrome/browser/search_engines/search_terms_data.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/search_engines/template_url_prepopulate_data.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/testing_pref_service.h"
@@ -146,7 +146,7 @@ TEST_F(TemplateURLPrepopulateDataTest, SearchEngineFromOrigin) {
for (size_t turl_i = 0; turl_i < urls.size(); ++turl_i) {
GURL engine_url(urls[turl_i]->url()->url());
if (!engine_url.is_valid()) {
- engine_url = TemplateURLModel::GenerateSearchURLUsingTermsData(
+ engine_url = TemplateURLService::GenerateSearchURLUsingTermsData(
urls[turl_i], search_terms_data);
}
GURL origin = engine_url.GetOrigin();
@@ -162,7 +162,7 @@ TEST_F(TemplateURLPrepopulateDataTest, SearchEngineFromOrigin) {
TemplateURLPrepopulateData::GetEngineForOrigin(profile.GetPrefs(),
*it));
EXPECT_EQ(
- TemplateURLModel::GenerateSearchURLUsingTermsData(
+ TemplateURLService::GenerateSearchURLUsingTermsData(
found_url.get(), search_terms_data).GetOrigin(),
it->GetOrigin());
}
diff --git a/chrome/browser/search_engines/template_url_scraper_unittest.cc b/chrome/browser/search_engines/template_url_scraper_unittest.cc
index 0fbfacc..f6d5cc8 100644
--- a/chrome/browser/search_engines/template_url_scraper_unittest.cc
+++ b/chrome/browser/search_engines/template_url_scraper_unittest.cc
@@ -1,9 +1,10 @@
-// Copyright (c) 2011 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.
+// Copyright (c) 2011 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.
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/search_engines/template_url_prepopulate_data.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/test/in_process_browser_test.h"
@@ -24,11 +25,11 @@ class TemplateURLScraperTest : public InProcessBrowserTest {
DISALLOW_COPY_AND_ASSIGN(TemplateURLScraperTest);
};
-class TemplateURLModelLoader : public NotificationObserver {
+class TemplateURLServiceLoader : public NotificationObserver {
public:
- explicit TemplateURLModelLoader(TemplateURLModel* model) : model_(model) {
- registrar_.Add(this, NotificationType::TEMPLATE_URL_MODEL_LOADED,
- Source<TemplateURLModel>(model));
+ explicit TemplateURLServiceLoader(TemplateURLService* model) : model_(model) {
+ registrar_.Add(this, NotificationType::TEMPLATE_URL_SERVICE_LOADED,
+ Source<TemplateURLService>(model));
model_->Load();
ui_test_utils::RunMessageLoop();
}
@@ -36,8 +37,8 @@ class TemplateURLModelLoader : public NotificationObserver {
virtual void Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
- if (type == NotificationType::TEMPLATE_URL_MODEL_LOADED &&
- Source<TemplateURLModel>(source).ptr() == model_) {
+ if (type == NotificationType::TEMPLATE_URL_SERVICE_LOADED &&
+ Source<TemplateURLService>(source).ptr() == model_) {
MessageLoop::current()->Quit();
}
}
@@ -45,9 +46,9 @@ class TemplateURLModelLoader : public NotificationObserver {
private:
NotificationRegistrar registrar_;
- TemplateURLModel* model_;
+ TemplateURLService* model_;
- DISALLOW_COPY_AND_ASSIGN(TemplateURLModelLoader);
+ DISALLOW_COPY_AND_ASSIGN(TemplateURLServiceLoader);
};
} // namespace
@@ -56,8 +57,9 @@ class TemplateURLModelLoader : public NotificationObserver {
IN_PROC_BROWSER_TEST_F(TemplateURLScraperTest, ScrapeWithOnSubmit) {
host_resolver()->AddRule("*.foo.com", "localhost");
- TemplateURLModel* template_urls = browser()->profile()->GetTemplateURLModel();
- TemplateURLModelLoader loader(template_urls);
+ TemplateURLService* template_urls =
+ TemplateURLServiceFactory::GetInstance(browser()->profile());
+ TemplateURLServiceLoader loader(template_urls);
std::vector<const TemplateURL*> all_urls = template_urls->GetTemplateURLs();
diff --git a/chrome/browser/search_engines/template_url_model.cc b/chrome/browser/search_engines/template_url_service.cc
index f6c1db0..6ee102f 100644
--- a/chrome/browser/search_engines/template_url_model.cc
+++ b/chrome/browser/search_engines/template_url_service.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
#include "base/command_line.h"
#include "base/environment.h"
@@ -25,7 +25,7 @@
#include "chrome/browser/search_engines/search_host_to_urls_map.h"
#include "chrome/browser/search_engines/search_terms_data.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model_observer.h"
+#include "chrome/browser/search_engines/template_url_service_observer.h"
#include "chrome/browser/search_engines/template_url_prepopulate_data.h"
#include "chrome/browser/search_engines/util.h"
#include "chrome/common/chrome_switches.h"
@@ -73,7 +73,7 @@ bool TemplateURLsHaveSamePrefs(const TemplateURL* url1,
} // namespace
-class TemplateURLModel::LessWithPrefix {
+class TemplateURLService::LessWithPrefix {
public:
// We want to find the set of keywords that begin with a prefix. The STL
// algorithms will return the set of elements that are "equal to" the
@@ -95,7 +95,7 @@ class TemplateURLModel::LessWithPrefix {
}
};
-TemplateURLModel::TemplateURLModel(Profile* profile)
+TemplateURLService::TemplateURLService(Profile* profile)
: profile_(profile),
loaded_(false),
load_failed_(false),
@@ -107,8 +107,8 @@ TemplateURLModel::TemplateURLModel(Profile* profile)
Init(NULL, 0);
}
-TemplateURLModel::TemplateURLModel(const Initializer* initializers,
- const int count)
+TemplateURLService::TemplateURLService(const Initializer* initializers,
+ const int count)
: profile_(NULL),
loaded_(false),
load_failed_(false),
@@ -120,7 +120,7 @@ TemplateURLModel::TemplateURLModel(const Initializer* initializers,
Init(initializers, count);
}
-TemplateURLModel::~TemplateURLModel() {
+TemplateURLService::~TemplateURLService() {
if (load_handle_) {
DCHECK(service_.get());
service_->CancelRequest(load_handle_);
@@ -130,8 +130,8 @@ TemplateURLModel::~TemplateURLModel() {
}
// static
-string16 TemplateURLModel::GenerateKeyword(const GURL& url,
- bool autodetected) {
+string16 TemplateURLService::GenerateKeyword(const GURL& url,
+ bool autodetected) {
// Don't autogenerate keywords for referrers that are the result of a form
// submission (TODO: right now we approximate this by checking for the URL
// having a query, but we should replace this with a call to WebCore to see if
@@ -152,7 +152,7 @@ string16 TemplateURLModel::GenerateKeyword(const GURL& url,
}
// static
-string16 TemplateURLModel::CleanUserInputKeyword(const string16& keyword) {
+string16 TemplateURLService::CleanUserInputKeyword(const string16& keyword) {
// Remove the scheme.
string16 result(base::i18n::ToLower(keyword));
TrimWhitespace(result, TRIM_ALL, &result);
@@ -186,14 +186,14 @@ string16 TemplateURLModel::CleanUserInputKeyword(const string16& keyword) {
}
// static
-GURL TemplateURLModel::GenerateSearchURL(const TemplateURL* t_url) {
+GURL TemplateURLService::GenerateSearchURL(const TemplateURL* t_url) {
DCHECK(t_url);
UIThreadSearchTermsData search_terms_data;
return GenerateSearchURLUsingTermsData(t_url, search_terms_data);
}
// static
-GURL TemplateURLModel::GenerateSearchURLUsingTermsData(
+GURL TemplateURLService::GenerateSearchURLUsingTermsData(
const TemplateURL* t_url,
const SearchTermsData& search_terms_data) {
DCHECK(t_url);
@@ -212,7 +212,7 @@ GURL TemplateURLModel::GenerateSearchURLUsingTermsData(
string16(), search_terms_data));
}
-bool TemplateURLModel::CanReplaceKeyword(
+bool TemplateURLService::CanReplaceKeyword(
const string16& keyword,
const GURL& url,
const TemplateURL** template_url_to_replace) {
@@ -238,7 +238,7 @@ bool TemplateURLModel::CanReplaceKeyword(
return true;
}
-void TemplateURLModel::FindMatchingKeywords(
+void TemplateURLService::FindMatchingKeywords(
const string16& prefix,
bool support_replacement_only,
std::vector<string16>* matches) const {
@@ -276,30 +276,30 @@ void TemplateURLModel::FindMatchingKeywords(
}
}
-const TemplateURL* TemplateURLModel::GetTemplateURLForKeyword(
- const string16& keyword) const {
+const TemplateURL* TemplateURLService::GetTemplateURLForKeyword(
+ const string16& keyword) const {
KeywordToTemplateMap::const_iterator elem(
keyword_to_template_map_.find(keyword));
return (elem == keyword_to_template_map_.end()) ? NULL : elem->second;
}
-const TemplateURL* TemplateURLModel::GetTemplateURLForHost(
+const TemplateURL* TemplateURLService::GetTemplateURLForHost(
const std::string& host) const {
return provider_map_.GetTemplateURLForHost(host);
}
-void TemplateURLModel::Add(TemplateURL* template_url) {
+void TemplateURLService::Add(TemplateURL* template_url) {
AddNoNotify(template_url);
NotifyObservers();
}
-void TemplateURLModel::Remove(const TemplateURL* template_url) {
+void TemplateURLService::Remove(const TemplateURL* template_url) {
RemoveNoNotify(template_url);
NotifyObservers();
}
-void TemplateURLModel::RemoveAutoGeneratedBetween(Time created_after,
- Time created_before) {
+void TemplateURLService::RemoveAutoGeneratedBetween(Time created_after,
+ Time created_before) {
bool should_notify = false;
for (size_t i = 0; i < template_urls_.size();) {
if (template_urls_[i]->date_created() >= created_after &&
@@ -316,11 +316,11 @@ void TemplateURLModel::RemoveAutoGeneratedBetween(Time created_after,
NotifyObservers();
}
-void TemplateURLModel::RemoveAutoGeneratedSince(Time created_after) {
+void TemplateURLService::RemoveAutoGeneratedSince(Time created_after) {
RemoveAutoGeneratedBetween(created_after, Time());
}
-void TemplateURLModel::RegisterExtensionKeyword(const Extension* extension) {
+void TemplateURLService::RegisterExtensionKeyword(const Extension* extension) {
// TODO(mpcomplete): disable the keyword when the extension is disabled.
if (extension->omnibox_keyword().empty())
return;
@@ -354,13 +354,14 @@ void TemplateURLModel::RegisterExtensionKeyword(const Extension* extension) {
NotifyObservers();
}
-void TemplateURLModel::UnregisterExtensionKeyword(const Extension* extension) {
+void TemplateURLService::UnregisterExtensionKeyword(
+ const Extension* extension) {
const TemplateURL* url = GetTemplateURLForExtension(extension);
if (url)
Remove(url);
}
-const TemplateURL* TemplateURLModel::GetTemplateURLForExtension(
+const TemplateURL* TemplateURLService::GetTemplateURLForExtension(
const Extension* extension) const {
for (TemplateURLVector::const_iterator i = template_urls_.begin();
i != template_urls_.end(); ++i) {
@@ -371,11 +372,11 @@ const TemplateURL* TemplateURLModel::GetTemplateURLForExtension(
return NULL;
}
-std::vector<const TemplateURL*> TemplateURLModel::GetTemplateURLs() const {
+std::vector<const TemplateURL*> TemplateURLService::GetTemplateURLs() const {
return template_urls_;
}
-void TemplateURLModel::IncrementUsageCount(const TemplateURL* url) {
+void TemplateURLService::IncrementUsageCount(const TemplateURL* url) {
DCHECK(url && find(template_urls_.begin(), template_urls_.end(), url) !=
template_urls_.end());
const_cast<TemplateURL*>(url)->set_usage_count(url->usage_count() + 1);
@@ -383,10 +384,10 @@ void TemplateURLModel::IncrementUsageCount(const TemplateURL* url) {
service_.get()->UpdateKeyword(*url);
}
-void TemplateURLModel::ResetTemplateURL(const TemplateURL* url,
- const string16& title,
- const string16& keyword,
- const std::string& search_url) {
+void TemplateURLService::ResetTemplateURL(const TemplateURL* url,
+ const string16& title,
+ const string16& keyword,
+ const std::string& search_url) {
TemplateURL new_url(*url);
new_url.set_short_name(title);
new_url.set_keyword(keyword);
@@ -402,14 +403,14 @@ void TemplateURLModel::ResetTemplateURL(const TemplateURL* url,
NotifyObservers();
}
-bool TemplateURLModel::CanMakeDefault(const TemplateURL* url) {
+bool TemplateURLService::CanMakeDefault(const TemplateURL* url) {
return url != GetDefaultSearchProvider() &&
url->url() &&
url->url()->SupportsReplacement() &&
!is_default_search_managed();
}
-void TemplateURLModel::SetDefaultSearchProvider(const TemplateURL* url) {
+void TemplateURLService::SetDefaultSearchProvider(const TemplateURL* url) {
if (is_default_search_managed_) {
NOTREACHED();
return;
@@ -420,7 +421,7 @@ void TemplateURLModel::SetDefaultSearchProvider(const TemplateURL* url) {
NotifyObservers();
}
-const TemplateURL* TemplateURLModel::GetDefaultSearchProvider() {
+const TemplateURL* TemplateURLService::GetDefaultSearchProvider() {
if (loaded_ && !load_failed_)
return default_search_provider_;
@@ -428,15 +429,15 @@ const TemplateURL* TemplateURLModel::GetDefaultSearchProvider() {
return initial_default_search_provider_.get();
}
-void TemplateURLModel::AddObserver(TemplateURLModelObserver* observer) {
+void TemplateURLService::AddObserver(TemplateURLServiceObserver* observer) {
model_observers_.AddObserver(observer);
}
-void TemplateURLModel::RemoveObserver(TemplateURLModelObserver* observer) {
+void TemplateURLService::RemoveObserver(TemplateURLServiceObserver* observer) {
model_observers_.RemoveObserver(observer);
}
-void TemplateURLModel::Load() {
+void TemplateURLService::Load() {
if (loaded_ || load_handle_)
return;
@@ -451,7 +452,7 @@ void TemplateURLModel::Load() {
}
}
-void TemplateURLModel::OnWebDataServiceRequestDone(
+void TemplateURLService::OnWebDataServiceRequestDone(
WebDataService::Handle h,
const WDTypedResult* result) {
// Reset the load_handle so that we don't try and cancel the load in
@@ -561,11 +562,11 @@ void TemplateURLModel::OnWebDataServiceRequestDone(
NotifyLoaded();
}
-string16 TemplateURLModel::GetKeywordShortName(const string16& keyword,
- bool* is_extension_keyword) {
+string16 TemplateURLService::GetKeywordShortName(const string16& keyword,
+ bool* is_extension_keyword) {
const TemplateURL* template_url = GetTemplateURLForKeyword(keyword);
- // TODO(sky): Once LocationBarView adds a listener to the TemplateURLModel
+ // TODO(sky): Once LocationBarView adds a listener to the TemplateURLService
// to track changes to the model, this should become a DCHECK.
if (template_url) {
*is_extension_keyword = template_url->IsExtensionKeyword();
@@ -575,9 +576,9 @@ string16 TemplateURLModel::GetKeywordShortName(const string16& keyword,
return string16();
}
-void TemplateURLModel::Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details) {
+void TemplateURLService::Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
if (type == NotificationType::HISTORY_URL_VISITED) {
Details<history::URLVisitedDetails> visit_details(details);
if (!loaded())
@@ -600,7 +601,7 @@ void TemplateURLModel::Observe(NotificationType type,
}
// static
-void TemplateURLModel::RegisterUserPrefs(PrefService* prefs) {
+void TemplateURLService::RegisterUserPrefs(PrefService* prefs) {
prefs->RegisterBooleanPref(prefs::kDefaultSearchProviderEnabled,
true,
PrefService::UNSYNCABLE_PREF);
@@ -633,9 +634,9 @@ void TemplateURLModel::RegisterUserPrefs(PrefService* prefs) {
PrefService::UNSYNCABLE_PREF);
}
-void TemplateURLModel::SetKeywordSearchTermsForURL(const TemplateURL* t_url,
- const GURL& url,
- const string16& term) {
+void TemplateURLService::SetKeywordSearchTermsForURL(const TemplateURL* t_url,
+ const GURL& url,
+ const string16& term) {
HistoryService* history = profile_ ?
profile_->GetHistoryService(Profile::EXPLICIT_ACCESS) : NULL;
if (!history)
@@ -643,7 +644,7 @@ void TemplateURLModel::SetKeywordSearchTermsForURL(const TemplateURL* t_url,
history->SetKeywordSearchTermsForURL(url, t_url->id(), term);
}
-void TemplateURLModel::Init(const Initializer* initializers,
+void TemplateURLService::Init(const Initializer* initializers,
int num_initializers) {
// Register for notifications.
if (profile_) {
@@ -662,7 +663,7 @@ void TemplateURLModel::Init(const Initializer* initializers,
if (num_initializers > 0) {
// This path is only hit by test code and is used to simulate a loaded
- // TemplateURLModel.
+ // TemplateURLService.
ChangeToLoadedState();
// Add specific initializers, if any.
@@ -678,7 +679,8 @@ void TemplateURLModel::Init(const Initializer* initializers,
osd_url.replace(template_position, arraysize(kTemplateParameter) - 1,
kSearchTermParameter);
- // TemplateURLModel ends up owning the TemplateURL, don't try and free it.
+ // TemplateURLService ends up owning the TemplateURL, don't try and free
+ // it.
TemplateURL* template_url = new TemplateURL();
template_url->set_keyword(UTF8ToUTF16(initializers[i].keyword));
template_url->set_short_name(UTF8ToUTF16(initializers[i].content));
@@ -704,14 +706,14 @@ void TemplateURLModel::Init(const Initializer* initializers,
}
}
-void TemplateURLModel::RemoveFromMaps(const TemplateURL* template_url) {
+void TemplateURLService::RemoveFromMaps(const TemplateURL* template_url) {
if (!template_url->keyword().empty())
keyword_to_template_map_.erase(template_url->keyword());
if (loaded_)
provider_map_.Remove(template_url);
}
-void TemplateURLModel::RemoveFromKeywordMapByPointer(
+void TemplateURLService::RemoveFromKeywordMapByPointer(
const TemplateURL* template_url) {
DCHECK(template_url);
for (KeywordToTemplateMap::iterator i = keyword_to_template_map_.begin();
@@ -725,7 +727,7 @@ void TemplateURLModel::RemoveFromKeywordMapByPointer(
}
}
-void TemplateURLModel::AddToMaps(const TemplateURL* template_url) {
+void TemplateURLService::AddToMaps(const TemplateURL* template_url) {
if (!template_url->keyword().empty())
keyword_to_template_map_[template_url->keyword()] = template_url;
if (loaded_) {
@@ -734,7 +736,8 @@ void TemplateURLModel::AddToMaps(const TemplateURL* template_url) {
}
}
-void TemplateURLModel::SetTemplateURLs(const std::vector<TemplateURL*>& urls) {
+void TemplateURLService::SetTemplateURLs(
+ const std::vector<TemplateURL*>& urls) {
// Add mappings for the new items.
// First, add the items that already have id's, so that the next_id_
@@ -759,7 +762,7 @@ void TemplateURLModel::SetTemplateURLs(const std::vector<TemplateURL*>& urls) {
}
}
-void TemplateURLModel::ChangeToLoadedState() {
+void TemplateURLService::ChangeToLoadedState() {
DCHECK(!loaded_);
UIThreadSearchTermsData search_terms_data;
@@ -767,10 +770,10 @@ void TemplateURLModel::ChangeToLoadedState() {
loaded_ = true;
}
-void TemplateURLModel::NotifyLoaded() {
+void TemplateURLService::NotifyLoaded() {
NotificationService::current()->Notify(
- NotificationType::TEMPLATE_URL_MODEL_LOADED,
- Source<TemplateURLModel>(this),
+ NotificationType::TEMPLATE_URL_SERVICE_LOADED,
+ Source<TemplateURLService>(this),
NotificationService::NoDetails());
for (size_t i = 0; i < pending_extension_ids_.size(); ++i) {
@@ -782,7 +785,7 @@ void TemplateURLModel::NotifyLoaded() {
pending_extension_ids_.clear();
}
-void TemplateURLModel::SaveDefaultSearchProviderToPrefs(
+void TemplateURLService::SaveDefaultSearchProviderToPrefs(
const TemplateURL* t_url) {
PrefService* prefs = GetPrefs();
if (!prefs)
@@ -829,7 +832,7 @@ void TemplateURLModel::SaveDefaultSearchProviderToPrefs(
prefs->ScheduleSavePersistentPrefs();
}
-bool TemplateURLModel::LoadDefaultSearchProviderFromPrefs(
+bool TemplateURLService::LoadDefaultSearchProviderFromPrefs(
scoped_ptr<TemplateURL>* default_provider,
bool* is_managed) {
PrefService* prefs = GetPrefs();
@@ -891,7 +894,7 @@ bool TemplateURLModel::LoadDefaultSearchProviderFromPrefs(
return true;
}
-bool TemplateURLModel::CanReplaceKeywordForHost(
+bool TemplateURLService::CanReplaceKeywordForHost(
const std::string& host,
const TemplateURL** to_replace) {
const TemplateURLSet* urls = provider_map_.GetURLsForHost(host);
@@ -912,13 +915,13 @@ bool TemplateURLModel::CanReplaceKeywordForHost(
return !urls;
}
-bool TemplateURLModel::CanReplace(const TemplateURL* t_url) {
+bool TemplateURLService::CanReplace(const TemplateURL* t_url) {
return (t_url != default_search_provider_ && !t_url->show_in_default_list() &&
t_url->safe_for_autoreplace());
}
-void TemplateURLModel::UpdateNoNotify(const TemplateURL* existing_turl,
- const TemplateURL& new_values) {
+void TemplateURLService::UpdateNoNotify(const TemplateURL* existing_turl,
+ const TemplateURL& new_values) {
DCHECK(loaded_);
DCHECK(existing_turl);
DCHECK(find(template_urls_.begin(), template_urls_.end(), existing_turl) !=
@@ -941,11 +944,11 @@ void TemplateURLModel::UpdateNoNotify(const TemplateURL* existing_turl,
SetDefaultSearchProviderNoNotify(existing_turl);
}
-PrefService* TemplateURLModel::GetPrefs() {
+PrefService* TemplateURLService::GetPrefs() {
return profile_ ? profile_->GetPrefs() : NULL;
}
-void TemplateURLModel::UpdateKeywordSearchTermsForURL(
+void TemplateURLService::UpdateKeywordSearchTermsForURL(
const history::URLVisitedDetails& details) {
const history::URLRow& row = details.row;
if (!row.url().is_valid() ||
@@ -1005,7 +1008,7 @@ void TemplateURLModel::UpdateKeywordSearchTermsForURL(
}
}
-void TemplateURLModel::AddTabToSearchVisit(const TemplateURL& t_url) {
+void TemplateURLService::AddTabToSearchVisit(const TemplateURL& t_url) {
// Only add visits for entries the user hasn't modified. If the user modified
// the entry the keyword may no longer correspond to the host name. It may be
// possible to do something more sophisticated here, but it's so rare as to
@@ -1034,8 +1037,8 @@ void TemplateURLModel::AddTabToSearchVisit(const TemplateURL& t_url) {
}
// static
-bool TemplateURLModel::BuildQueryTerms(const GURL& url,
- QueryTerms* query_terms) {
+bool TemplateURLService::BuildQueryTerms(const GURL& url,
+ QueryTerms* query_terms) {
url_parse::Component query = url.parsed_for_possibly_invalid_spec().query;
url_parse::Component key, value;
size_t valid_term_count = 0;
@@ -1065,7 +1068,7 @@ bool TemplateURLModel::BuildQueryTerms(const GURL& url,
return (valid_term_count > 0);
}
-void TemplateURLModel::GoogleBaseURLChanged() {
+void TemplateURLService::GoogleBaseURLChanged() {
bool something_changed = false;
for (size_t i = 0; i < template_urls_.size(); ++i) {
const TemplateURL* t_url = template_urls_[i];
@@ -1087,7 +1090,7 @@ void TemplateURLModel::GoogleBaseURLChanged() {
}
}
-void TemplateURLModel::UpdateDefaultSearch() {
+void TemplateURLService::UpdateDefaultSearch() {
if (!loaded_) {
// Set |initial_default_search_provider_| from the preferences. We use this
// value for default search provider until the database has been loaded.
@@ -1172,7 +1175,7 @@ void TemplateURLModel::UpdateDefaultSearch() {
NotifyObservers();
}
-const TemplateURL* TemplateURLModel::FindNewDefaultSearchProvider() {
+const TemplateURL* TemplateURLService::FindNewDefaultSearchProvider() {
// See if the prepoluated default still exists.
scoped_ptr<TemplateURL> prepopulated_default(
TemplateURLPrepopulateData::GetPrepopulatedDefaultSearch(GetPrefs()));
@@ -1188,7 +1191,7 @@ const TemplateURL* TemplateURLModel::FindNewDefaultSearchProvider() {
return NULL;
}
-void TemplateURLModel::SetDefaultSearchProviderNoNotify(
+void TemplateURLService::SetDefaultSearchProviderNoNotify(
const TemplateURL* url) {
DCHECK(!url || find(template_urls_.begin(), template_urls_.end(), url) !=
template_urls_.end());
@@ -1222,7 +1225,7 @@ void TemplateURLModel::SetDefaultSearchProviderNoNotify(
service_->SetDefaultSearchProvider(url);
}
-void TemplateURLModel::AddNoNotify(TemplateURL* template_url) {
+void TemplateURLService::AddNoNotify(TemplateURL* template_url) {
DCHECK(template_url);
DCHECK(template_url->id() == 0);
DCHECK(find(template_urls_.begin(), template_urls_.end(), template_url) ==
@@ -1235,7 +1238,7 @@ void TemplateURLModel::AddNoNotify(TemplateURL* template_url) {
service_->AddKeyword(*template_url);
}
-void TemplateURLModel::RemoveNoNotify(const TemplateURL* template_url) {
+void TemplateURLService::RemoveNoNotify(const TemplateURL* template_url) {
TemplateURLVector::iterator i = find(template_urls_.begin(),
template_urls_.end(),
template_url);
@@ -1269,12 +1272,12 @@ void TemplateURLModel::RemoveNoNotify(const TemplateURL* template_url) {
delete template_url;
}
-void TemplateURLModel::NotifyObservers() {
+void TemplateURLService::NotifyObservers() {
if (!loaded_)
return;
- FOR_EACH_OBSERVER(TemplateURLModelObserver, model_observers_,
- OnTemplateURLModelChanged());
+ FOR_EACH_OBSERVER(TemplateURLServiceObserver, model_observers_,
+ OnTemplateURLServiceChanged());
}
// |template_urls| are the TemplateURLs loaded from the database.
@@ -1285,7 +1288,7 @@ void TemplateURLModel::NotifyObservers() {
// This function removes from the vector and the database all the TemplateURLs
// that were set by policy, unless it is the current default search provider
// and matches what is set by a managed preference.
-void TemplateURLModel::RemoveProvidersCreatedByPolicy(
+void TemplateURLService::RemoveProvidersCreatedByPolicy(
std::vector<TemplateURL*>* template_urls,
const TemplateURL** default_search_provider,
const TemplateURL* default_from_prefs) {
diff --git a/chrome/browser/search_engines/template_url_model.h b/chrome/browser/search_engines/template_url_service.h
index d25e57a..f5c6264 100644
--- a/chrome/browser/search_engines/template_url_model.h
+++ b/chrome/browser/search_engines/template_url_service.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_MODEL_H_
-#define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_MODEL_H_
+#ifndef CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_
+#define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_
#pragma once
#include <map>
@@ -14,6 +14,7 @@
#include "base/gtest_prod_util.h"
#include "base/memory/scoped_ptr.h"
#include "base/observer_list.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/webdata/web_data_service.h"
@@ -27,36 +28,37 @@ class Profile;
class PrefSetObserver;
class SearchHostToURLsMap;
class SearchTermsData;
-class TemplateURLModelObserver;
+class TemplateURLServiceObserver;
class TemplateURLRef;
namespace history {
struct URLVisitedDetails;
}
-// TemplateURLModel is the backend for keywords. It's used by
+// TemplateURLService is the backend for keywords. It's used by
// KeywordAutocomplete.
//
-// TemplateURLModel stores a vector of TemplateURLs. The TemplateURLs are
+// TemplateURLService stores a vector of TemplateURLs. The TemplateURLs are
// persisted to the database maintained by WebDataService. *ALL* mutations
-// to the TemplateURLs must funnel through TemplateURLModel. This allows
-// TemplateURLModel to notify listeners of changes as well as keep the
+// to the TemplateURLs must funnel through TemplateURLService. This allows
+// TemplateURLService to notify listeners of changes as well as keep the
// database in sync.
//
-// There is a TemplateURLModel per Profile.
+// There is a TemplateURLService per Profile.
//
-// TemplateURLModel does not load the vector of TemplateURLs in its
+// TemplateURLService does not load the vector of TemplateURLs in its
// constructor (except for testing). Use the Load method to trigger a load.
-// When TemplateURLModel has completed loading, observers are notified via
-// OnTemplateURLModelChanged as well as the TEMPLATE_URL_MODEL_LOADED
+// When TemplateURLService has completed loading, observers are notified via
+// OnTemplateURLServiceChanged as well as the TEMPLATE_URL_SERVICE_LOADED
// notification message.
//
-// TemplateURLModel takes ownership of any TemplateURL passed to it. If there
+// TemplateURLService takes ownership of any TemplateURL passed to it. If there
// is a WebDataService, deletion is handled by WebDataService, otherwise
-// TemplateURLModel handles deletion.
+// TemplateURLService handles deletion.
-class TemplateURLModel : public WebDataServiceConsumer,
- public NotificationObserver {
+class TemplateURLService : public WebDataServiceConsumer,
+ public ProfileKeyedService,
+ public NotificationObserver {
public:
typedef std::map<std::string, std::string> QueryTerms;
typedef std::vector<const TemplateURL*> TemplateURLVector;
@@ -69,10 +71,10 @@ class TemplateURLModel : public WebDataServiceConsumer,
const char* const content;
};
- explicit TemplateURLModel(Profile* profile);
+ explicit TemplateURLService(Profile* profile);
// The following is for testing.
- TemplateURLModel(const Initializer* initializers, const int count);
- virtual ~TemplateURLModel();
+ TemplateURLService(const Initializer* initializers, const int count);
+ virtual ~TemplateURLService();
// Generates a suitable keyword for the specified url. Returns an empty
// string if a keyword couldn't be generated. If |autodetected| is true, we
@@ -124,7 +126,7 @@ class TemplateURLModel : public WebDataServiceConsumer,
// or NULL if there are no such TemplateURLs
const TemplateURL* GetTemplateURLForHost(const std::string& host) const;
- // Adds a new TemplateURL to this model. TemplateURLModel will own the
+ // Adds a new TemplateURL to this model. TemplateURLService will own the
// reference, and delete it when the TemplateURL is removed.
void Add(TemplateURL* template_url);
@@ -157,7 +159,7 @@ class TemplateURLModel : public WebDataServiceConsumer,
const Extension* extension) const;
// Returns the set of URLs describing the keywords. The elements are owned
- // by TemplateURLModel and should not be deleted.
+ // by TemplateURLService and should not be deleted.
TemplateURLVector GetTemplateURLs() const;
// Increment the usage count of a keyword.
@@ -179,7 +181,7 @@ class TemplateURLModel : public WebDataServiceConsumer,
// invoking this method in that situation.
void SetDefaultSearchProvider(const TemplateURL* url);
- // Returns the default search provider. If the TemplateURLModel hasn't been
+ // 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.
@@ -189,14 +191,14 @@ class TemplateURLModel : public WebDataServiceConsumer,
bool is_default_search_managed() const { return is_default_search_managed_; }
// Observers used to listen for changes to the model.
- // TemplateURLModel does NOT delete the observers when deleted.
- void AddObserver(TemplateURLModelObserver* observer);
- void RemoveObserver(TemplateURLModelObserver* observer);
+ // TemplateURLService does NOT delete the observers when deleted.
+ void AddObserver(TemplateURLServiceObserver* observer);
+ void RemoveObserver(TemplateURLServiceObserver* observer);
// Loads the keywords. This has no effect if the keywords have already been
// loaded.
// Observers are notified when loading completes via the method
- // OnTemplateURLModelChanged.
+ // OnTemplateURLServiceChanged.
void Load();
// Whether or not the keywords have been loaded.
@@ -214,7 +216,7 @@ class TemplateURLModel : public WebDataServiceConsumer,
string16 GetKeywordShortName(const string16& keyword,
bool* is_extension_keyword);
- // NotificationObserver method. TemplateURLModel listens for three
+ // NotificationObserver method. TemplateURLService listens for three
// notification types:
// . NOTIFY_HISTORY_URL_VISITED: adds keyword search terms if the visit
// corresponds to a keyword.
@@ -248,15 +250,15 @@ class TemplateURLModel : public WebDataServiceConsumer,
const string16& term);
private:
- FRIEND_TEST_ALL_PREFIXES(TemplateURLModelTest, BuildQueryTerms);
- FRIEND_TEST_ALL_PREFIXES(TemplateURLModelTest, TestManagedDefaultSearch);
- FRIEND_TEST_ALL_PREFIXES(TemplateURLModelTest,
+ FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, BuildQueryTerms);
+ FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, TestManagedDefaultSearch);
+ FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest,
UpdateKeywordSearchTermsForURL);
- FRIEND_TEST_ALL_PREFIXES(TemplateURLModelTest,
+ FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest,
DontUpdateKeywordSearchForNonReplaceable);
- FRIEND_TEST_ALL_PREFIXES(TemplateURLModelTest, ChangeGoogleBaseValue);
- FRIEND_TEST_ALL_PREFIXES(TemplateURLModelTest, MergeDeletesUnusedProviders);
- friend class TemplateURLModelTestUtil;
+ FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, ChangeGoogleBaseValue);
+ FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, MergeDeletesUnusedProviders);
+ friend class TemplateURLServiceTestUtil;
typedef std::map<string16, const TemplateURL*> KeywordToTemplateMap;
@@ -282,7 +284,7 @@ class TemplateURLModel : public WebDataServiceConsumer,
// Transitions to the loaded state.
void ChangeToLoadedState();
- // If there is a notification service, sends TEMPLATE_URL_MODEL_LOADED
+ // If there is a notification service, sends TEMPLATE_URL_SERVICE_LOADED
// notification.
void NotifyLoaded();
@@ -356,7 +358,7 @@ class TemplateURLModel : public WebDataServiceConsumer,
// Caller is responsible for notifying observers.
void SetDefaultSearchProviderNoNotify(const TemplateURL* url);
- // Adds a new TemplateURL to this model. TemplateURLModel will own the
+ // Adds a new TemplateURL to this model. TemplateURLService will own the
// reference, and delete it when the TemplateURL is removed.
// Caller is responsible for notifying observers.
void AddNoNotify(TemplateURL* template_url);
@@ -386,7 +388,7 @@ class TemplateURLModel : public WebDataServiceConsumer,
TemplateURLVector template_urls_;
- ObserverList<TemplateURLModelObserver> model_observers_;
+ ObserverList<TemplateURLServiceObserver> model_observers_;
// Maps from host to set of TemplateURLs whose search url host is host.
SearchHostToURLsMap provider_map_;
@@ -438,7 +440,7 @@ class TemplateURLModel : public WebDataServiceConsumer,
// List of extension IDs waiting for Load to have keywords registered.
std::vector<std::string> pending_extension_ids_;
- DISALLOW_COPY_AND_ASSIGN(TemplateURLModel);
+ DISALLOW_COPY_AND_ASSIGN(TemplateURLService);
};
-#endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_MODEL_H_
+#endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_
diff --git a/chrome/browser/search_engines/template_url_service_factory.cc b/chrome/browser/search_engines/template_url_service_factory.cc
new file mode 100644
index 0000000..e344163
--- /dev/null
+++ b/chrome/browser/search_engines/template_url_service_factory.cc
@@ -0,0 +1,50 @@
+// Copyright (c) 2011 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.
+
+#include "chrome/browser/search_engines/template_url_service_factory.h"
+
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/profiles/profile_dependency_manager.h"
+
+TemplateURLService* TemplateURLServiceFactory::GetForProfile(Profile* profile) {
+ return static_cast<TemplateURLService*>(
+ GetInstance()->GetServiceForProfile(profile, true));
+}
+
+TemplateURLServiceFactory* TemplateURLServiceFactory::GetInstance() {
+ return Singleton<TemplateURLServiceFactory>::get();
+}
+
+TemplateURLServiceFactory::TemplateURLServiceFactory()
+ : ProfileKeyedServiceFactory(
+ ProfileDependencyManager::GetInstance()) {
+ // TODO(erg): For Shutdown() order, we need to:
+ // DependsOn(WebDataServiceFactory::GetInstance());
+ // DependsOn(HistoryService::GetInstance());
+ // DependsOn(ExtensionService::GetInstance());
+}
+
+TemplateURLServiceFactory::~TemplateURLServiceFactory() {}
+
+ProfileKeyedService* TemplateURLServiceFactory::BuildServiceInstanceFor(
+ Profile* profile) const {
+ return new TemplateURLService(profile);
+}
+
+bool TemplateURLServiceFactory::ServiceRedirectedInIncognito() {
+ return true;
+}
+
+void TemplateURLServiceFactory::ProfileShutdown(Profile* profile) {
+ // We shutdown AND destroy the TemplateURLService during this pass.
+ // TemplateURLService schedules a task on the WebDataService from its
+ // destructor. Delete it first to ensure the task gets scheduled before we
+ // shut down the database.
+ ProfileKeyedServiceFactory::ProfileShutdown(profile);
+ ProfileKeyedServiceFactory::ProfileDestroyed(profile);
+}
+
+void TemplateURLServiceFactory::ProfileDestroyed(Profile* profile) {
+ // Don't double delete.
+}
diff --git a/chrome/browser/search_engines/template_url_service_factory.h b/chrome/browser/search_engines/template_url_service_factory.h
new file mode 100644
index 0000000..703d586
--- /dev/null
+++ b/chrome/browser/search_engines/template_url_service_factory.h
@@ -0,0 +1,36 @@
+// Copyright (c) 2011 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.
+
+#ifndef CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_FACTORY_H_
+#define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_FACTORY_H_
+#pragma once
+
+#include "base/memory/singleton.h"
+#include "chrome/browser/profiles/profile_keyed_service_factory.h"
+
+class Profile;
+class TemplateURLService;
+
+// Singleton that owns all TemplateURLService and associates them with
+// Profiles.
+class TemplateURLServiceFactory : public ProfileKeyedServiceFactory {
+ public:
+ static TemplateURLService* GetForProfile(Profile* profile);
+
+ static TemplateURLServiceFactory* GetInstance();
+
+ private:
+ friend struct DefaultSingletonTraits<TemplateURLServiceFactory>;
+
+ TemplateURLServiceFactory();
+ virtual ~TemplateURLServiceFactory();
+
+ // ProfileKeyedServiceFactory:
+ virtual ProfileKeyedService* BuildServiceInstanceFor(Profile* profile) const;
+ virtual bool ServiceRedirectedInIncognito();
+ virtual void ProfileShutdown(Profile* profile);
+ virtual void ProfileDestroyed(Profile* profile);
+};
+
+#endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_FACTORY_H_
diff --git a/chrome/browser/search_engines/template_url_service_observer.h b/chrome/browser/search_engines/template_url_service_observer.h
new file mode 100644
index 0000000..30934f4
--- /dev/null
+++ b/chrome/browser/search_engines/template_url_service_observer.h
@@ -0,0 +1,20 @@
+// Copyright (c) 2011 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.
+
+#ifndef CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_OBSERVER_H_
+#define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_OBSERVER_H_
+#pragma once
+
+// TemplateURLServiceObserver is notified whenever the set of TemplateURLs
+// are modified.
+class TemplateURLServiceObserver {
+ public:
+ // Notification that the template url model has changed in some way.
+ virtual void OnTemplateURLServiceChanged() = 0;
+
+ protected:
+ virtual ~TemplateURLServiceObserver() {}
+};
+
+#endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_OBSERVER_H_
diff --git a/chrome/browser/search_engines/template_url_model_test_util.cc b/chrome/browser/search_engines/template_url_service_test_util.cc
index 26d2491..ff18139 100644
--- a/chrome/browser/search_engines/template_url_model_test_util.cc
+++ b/chrome/browser/search_engines/template_url_service_test_util.cc
@@ -2,14 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/search_engines/template_url_model_test_util.h"
+#include "chrome/browser/search_engines/template_url_service_test_util.h"
#include "base/message_loop.h"
#include "base/path_service.h"
#include "base/scoped_temp_dir.h"
#include "base/threading/thread.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/test/testing_profile.h"
#include "content/common/notification_service.h"
#include "content/common/notification_type.h"
@@ -47,9 +48,9 @@ static void WaitForThreadToProcessRequests(BrowserThread::ID identifier) {
} // namespace
// Subclass the TestingProfile so that it can return a WebDataService.
-class TemplateURLModelTestingProfile : public TestingProfile {
+class TemplateURLServiceTestingProfile : public TestingProfile {
public:
- TemplateURLModelTestingProfile()
+ TemplateURLServiceTestingProfile()
: TestingProfile(),
db_thread_(BrowserThread::DB),
io_thread_(BrowserThread::IO) {
@@ -77,12 +78,16 @@ class TemplateURLModelTestingProfile : public TestingProfile {
BrowserThread io_thread_;
};
-// Trivial subclass of TemplateURLModel that records the last invocation of
+// Trivial subclass of TemplateURLService that records the last invocation of
// SetKeywordSearchTermsForURL.
-class TestingTemplateURLModel : public TemplateURLModel {
+class TestingTemplateURLService : public TemplateURLService {
public:
- explicit TestingTemplateURLModel(Profile* profile)
- : TemplateURLModel(profile) {
+ static ProfileKeyedService* Build(Profile* profile) {
+ return new TestingTemplateURLService(profile);
+ }
+
+ explicit TestingTemplateURLService(Profile* profile)
+ : TemplateURLService(profile) {
}
string16 GetAndClearSearchTerm() {
@@ -101,10 +106,10 @@ class TestingTemplateURLModel : public TemplateURLModel {
private:
string16 search_term_;
- DISALLOW_COPY_AND_ASSIGN(TestingTemplateURLModel);
+ DISALLOW_COPY_AND_ASSIGN(TestingTemplateURLService);
};
-void TemplateURLModelTestingProfile::SetUp() {
+void TemplateURLServiceTestingProfile::SetUp() {
db_thread_.Start();
// Make unique temp directory.
@@ -115,14 +120,14 @@ void TemplateURLModelTestingProfile::SetUp() {
ASSERT_TRUE(service_->InitWithPath(path));
}
-void TemplateURLModelTestingProfile::TearDown() {
+void TemplateURLServiceTestingProfile::TearDown() {
// Clear the request context so it will get deleted. This should be done
// before shutting down the I/O thread to avoid memory leaks.
ResetRequestContext();
// Wait for the delete of the request context to happen.
if (io_thread_.IsRunning())
- TemplateURLModelTestUtil::BlockTillIOThreadProcessesRequests();
+ TemplateURLServiceTestUtil::BlockTillIOThreadProcessesRequests();
// The I/O thread must be shutdown before the DB thread.
io_thread_.Stop();
@@ -137,22 +142,24 @@ void TemplateURLModelTestingProfile::TearDown() {
db_thread_.Stop();
}
-TemplateURLModelTestUtil::TemplateURLModelTestUtil()
+TemplateURLServiceTestUtil::TemplateURLServiceTestUtil()
: ui_thread_(BrowserThread::UI, &message_loop_),
changed_count_(0) {
}
-TemplateURLModelTestUtil::~TemplateURLModelTestUtil() {
+TemplateURLServiceTestUtil::~TemplateURLServiceTestUtil() {
}
-void TemplateURLModelTestUtil::SetUp() {
- profile_.reset(new TemplateURLModelTestingProfile());
+void TemplateURLServiceTestUtil::SetUp() {
+ profile_.reset(new TemplateURLServiceTestingProfile());
profile_->SetUp();
- profile_->SetTemplateURLModel(new TestingTemplateURLModel(profile_.get()));
- profile_->GetTemplateURLModel()->AddObserver(this);
+ TemplateURLService* service = static_cast<TemplateURLService*>(
+ TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(
+ profile_.get(), TestingTemplateURLService::Build));
+ service->AddObserver(this);
}
-void TemplateURLModelTestUtil::TearDown() {
+void TemplateURLServiceTestUtil::TearDown() {
if (profile_.get()) {
profile_->TearDown();
profile_.reset();
@@ -163,27 +170,27 @@ void TemplateURLModelTestUtil::TearDown() {
message_loop_.RunAllPending();
}
-void TemplateURLModelTestUtil::OnTemplateURLModelChanged() {
+void TemplateURLServiceTestUtil::OnTemplateURLServiceChanged() {
changed_count_++;
}
-int TemplateURLModelTestUtil::GetObserverCount() {
+int TemplateURLServiceTestUtil::GetObserverCount() {
return changed_count_;
}
-void TemplateURLModelTestUtil::ResetObserverCount() {
+void TemplateURLServiceTestUtil::ResetObserverCount() {
changed_count_ = 0;
}
-void TemplateURLModelTestUtil::BlockTillServiceProcessesRequests() {
+void TemplateURLServiceTestUtil::BlockTillServiceProcessesRequests() {
WaitForThreadToProcessRequests(BrowserThread::DB);
}
-void TemplateURLModelTestUtil::BlockTillIOThreadProcessesRequests() {
+void TemplateURLServiceTestUtil::BlockTillIOThreadProcessesRequests() {
WaitForThreadToProcessRequests(BrowserThread::IO);
}
-void TemplateURLModelTestUtil::VerifyLoad() {
+void TemplateURLServiceTestUtil::VerifyLoad() {
ASSERT_FALSE(model()->loaded());
model()->Load();
BlockTillServiceProcessesRequests();
@@ -191,31 +198,33 @@ void TemplateURLModelTestUtil::VerifyLoad() {
ResetObserverCount();
}
-void TemplateURLModelTestUtil::ChangeModelToLoadState() {
+void TemplateURLServiceTestUtil::ChangeModelToLoadState() {
model()->ChangeToLoadedState();
// Initialize the web data service so that the database gets updated with
// any changes made.
model()->service_ = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
}
-void TemplateURLModelTestUtil::ClearModel() {
- profile_->SetTemplateURLModel(NULL);
+void TemplateURLServiceTestUtil::ClearModel() {
+ TemplateURLServiceFactory::GetInstance()->SetTestingFactory(
+ profile_.get(), NULL);
}
-void TemplateURLModelTestUtil::ResetModel(bool verify_load) {
- profile_->SetTemplateURLModel(new TestingTemplateURLModel(profile_.get()));
+void TemplateURLServiceTestUtil::ResetModel(bool verify_load) {
+ TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(
+ profile_.get(), TestingTemplateURLService::Build);
model()->AddObserver(this);
changed_count_ = 0;
if (verify_load)
VerifyLoad();
}
-string16 TemplateURLModelTestUtil::GetAndClearSearchTerm() {
+string16 TemplateURLServiceTestUtil::GetAndClearSearchTerm() {
return
- static_cast<TestingTemplateURLModel*>(model())->GetAndClearSearchTerm();
+ static_cast<TestingTemplateURLService*>(model())->GetAndClearSearchTerm();
}
-void TemplateURLModelTestUtil::SetGoogleBaseURL(
+void TemplateURLServiceTestUtil::SetGoogleBaseURL(
const std::string& base_url) const {
TemplateURLRef::SetGoogleBaseURL(new std::string(base_url));
NotificationService::current()->Notify(NotificationType::GOOGLE_URL_UPDATED,
@@ -223,18 +232,18 @@ void TemplateURLModelTestUtil::SetGoogleBaseURL(
NotificationService::NoDetails());
}
-WebDataService* TemplateURLModelTestUtil::GetWebDataService() {
+WebDataService* TemplateURLServiceTestUtil::GetWebDataService() {
return profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
}
-TemplateURLModel* TemplateURLModelTestUtil::model() const {
- return profile_->GetTemplateURLModel();
+TemplateURLService* TemplateURLServiceTestUtil::model() const {
+ return TemplateURLServiceFactory::GetForProfile(profile());
}
-TestingProfile* TemplateURLModelTestUtil::profile() const {
+TestingProfile* TemplateURLServiceTestUtil::profile() const {
return profile_.get();
}
-void TemplateURLModelTestUtil::StartIOThread() {
+void TemplateURLServiceTestUtil::StartIOThread() {
profile_->StartIOThread();
}
diff --git a/chrome/browser/search_engines/template_url_model_test_util.h b/chrome/browser/search_engines/template_url_service_test_util.h
index 430e5d7..4d119fc6 100644
--- a/chrome/browser/search_engines/template_url_model_test_util.h
+++ b/chrome/browser/search_engines/template_url_service_test_util.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_MODEL_TEST_UTIL_H_
-#define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_MODEL_TEST_UTIL_H_
+#ifndef CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_TEST_UTIL_H_
+#define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_TEST_UTIL_H_
#pragma once
#include <string>
@@ -13,22 +13,22 @@
#include "base/memory/scoped_ptr.h"
#include "base/message_loop.h"
#include "base/string16.h"
-#include "chrome/browser/search_engines/template_url_model_observer.h"
+#include "chrome/browser/search_engines/template_url_service_observer.h"
#include "content/browser/browser_thread.h"
-class TemplateURLModel;
-class TemplateURLModelTestingProfile;
-class TestingTemplateURLModel;
+class TemplateURLService;
+class TemplateURLServiceTestingProfile;
+class TestingTemplateURLService;
class TestingProfile;
class WebDataService;
-// Implements functionality to make it easier to test TemplateURLModel and
+// Implements functionality to make it easier to test TemplateURLService and
// make changes to it.
-class TemplateURLModelTestUtil : public TemplateURLModelObserver {
+class TemplateURLServiceTestUtil : public TemplateURLServiceObserver {
public:
- TemplateURLModelTestUtil();
+ TemplateURLServiceTestUtil();
- virtual ~TemplateURLModelTestUtil();
+ virtual ~TemplateURLServiceTestUtil();
// Sets up the data structures for this class (mirroring gtest standard
// methods).
@@ -38,8 +38,8 @@ class TemplateURLModelTestUtil : public TemplateURLModelObserver {
// methods).
void TearDown();
- // TemplateURLModelObserver implemementation.
- virtual void OnTemplateURLModelChanged();
+ // TemplateURLServiceObserver implemementation.
+ virtual void OnTemplateURLServiceChanged();
// Gets the observer count.
int GetObserverCount();
@@ -66,11 +66,11 @@ class TemplateURLModelTestUtil : public TemplateURLModelObserver {
// Deletes the current model (and doesn't create a new one).
void ClearModel();
- // Creates a new TemplateURLModel.
+ // Creates a new TemplateURLService.
void ResetModel(bool verify_load);
// Returns the search term from the last invocation of
- // TemplateURLModel::SetKeywordSearchTermsForURL and clears the search term.
+ // TemplateURLService::SetKeywordSearchTermsForURL and clears the search term.
string16 GetAndClearSearchTerm();
// Set the google base url.
@@ -79,8 +79,8 @@ class TemplateURLModelTestUtil : public TemplateURLModelObserver {
// Returns the WebDataService.
WebDataService* GetWebDataService();
- // Returns the TemplateURLModel.
- TemplateURLModel* model() const;
+ // Returns the TemplateURLService.
+ TemplateURLService* model() const;
// Returns the TestingProfile.
TestingProfile* profile() const;
@@ -93,11 +93,11 @@ class TemplateURLModelTestUtil : public TemplateURLModelObserver {
// Needed to make the DeleteOnUIThread trait of WebDataService work
// properly.
BrowserThread ui_thread_;
- scoped_ptr<TemplateURLModelTestingProfile> profile_;
- scoped_ptr<TestingTemplateURLModel> model_;
+ scoped_ptr<TemplateURLServiceTestingProfile> profile_;
+ scoped_ptr<TestingTemplateURLService> model_;
int changed_count_;
- DISALLOW_COPY_AND_ASSIGN(TemplateURLModelTestUtil);
+ DISALLOW_COPY_AND_ASSIGN(TemplateURLServiceTestUtil);
};
-#endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_MODEL_TEST_UTIL_H_
+#endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_TEST_UTIL_H_
diff --git a/chrome/browser/search_engines/template_url_model_unittest.cc b/chrome/browser/search_engines/template_url_service_unittest.cc
index 3fe45bc..fc18735 100644
--- a/chrome/browser/search_engines/template_url_model_unittest.cc
+++ b/chrome/browser/search_engines/template_url_service_unittest.cc
@@ -14,8 +14,8 @@
#include "chrome/browser/search_engines/search_host_to_urls_map.h"
#include "chrome/browser/search_engines/search_terms_data.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
-#include "chrome/browser/search_engines/template_url_model_test_util.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_test_util.h"
#include "chrome/browser/search_engines/template_url_prepopulate_data.h"
#include "chrome/browser/webdata/web_database.h"
#include "chrome/common/pref_names.h"
@@ -104,9 +104,9 @@ static TemplateURL* CreatePreloadedTemplateURL() {
return t_url;
}
-class TemplateURLModelTest : public testing::Test {
+class TemplateURLServiceTest : public testing::Test {
public:
- TemplateURLModelTest() {}
+ TemplateURLServiceTest() {}
virtual void SetUp() {
test_util_.SetUp();
@@ -254,7 +254,7 @@ class TemplateURLModelTest : public testing::Test {
// happens when a preloaded url that is not the default gets updated.
void TestLoadUpdatingPreloadedURL(size_t index_offset_from_default);
- // Helper methods to make calling TemplateURLModelTestUtil methods less
+ // Helper methods to make calling TemplateURLServiceTestUtil methods less
// visually noisy in the test code.
void VerifyObserverCount(int expected_changed_count) {
EXPECT_EQ(expected_changed_count, test_util_.GetObserverCount());
@@ -265,7 +265,7 @@ class TemplateURLModelTest : public testing::Test {
test_util_.ResetObserverCount();
}
void BlockTillServiceProcessesRequests() {
- TemplateURLModelTestUtil::BlockTillServiceProcessesRequests();
+ TemplateURLServiceTestUtil::BlockTillServiceProcessesRequests();
}
void VerifyLoad() { test_util_.VerifyLoad(); }
void ChangeModelToLoadState() { test_util_.ChangeModelToLoadState(); }
@@ -277,13 +277,13 @@ class TemplateURLModelTest : public testing::Test {
test_util_.SetGoogleBaseURL(base_url);
}
WebDataService* GetWebDataService() { return test_util_.GetWebDataService(); }
- TemplateURLModel* model() { return test_util_.model(); }
+ TemplateURLService* model() { return test_util_.model(); }
TestingProfile* profile() { return test_util_.profile(); }
protected:
- TemplateURLModelTestUtil test_util_;
+ TemplateURLServiceTestUtil test_util_;
- DISALLOW_COPY_AND_ASSIGN(TemplateURLModelTest);
+ DISALLOW_COPY_AND_ASSIGN(TemplateURLServiceTest);
};
void TestGenerateSearchURL::RunTest() {
@@ -309,9 +309,9 @@ void TestGenerateSearchURL::RunTest() {
t_url.SetURL(generate_url_cases[i].url, 0, 0);
std::string result = search_terms_data_ ?
- TemplateURLModel::GenerateSearchURLUsingTermsData(
+ TemplateURLService::GenerateSearchURLUsingTermsData(
&t_url, *search_terms_data_).spec() :
- TemplateURLModel::GenerateSearchURL(&t_url).spec();
+ TemplateURLService::GenerateSearchURL(&t_url).spec();
if (strcmp(generate_url_cases[i].expected, result.c_str())) {
LOG(ERROR) << generate_url_cases[i].test_name << " failed. Expected " <<
generate_url_cases[i].expected << " Actual " << result;
@@ -322,7 +322,7 @@ void TestGenerateSearchURL::RunTest() {
passed_ = everything_passed;
}
-TemplateURL* TemplateURLModelTest::CreateReplaceablePreloadedTemplateURL(
+TemplateURL* TemplateURLServiceTest::CreateReplaceablePreloadedTemplateURL(
size_t index_offset_from_default,
string16* prepopulated_display_url) {
TemplateURL* t_url = CreatePreloadedTemplateURL();
@@ -343,7 +343,7 @@ TemplateURL* TemplateURLModelTest::CreateReplaceablePreloadedTemplateURL(
return t_url;
}
-void TemplateURLModelTest::TestLoadUpdatingPreloadedURL(
+void TemplateURLServiceTest::TestLoadUpdatingPreloadedURL(
size_t index_offset_from_default) {
string16 prepopulated_url;
TemplateURL* t_url = CreateReplaceablePreloadedTemplateURL(
@@ -378,11 +378,11 @@ void TemplateURLModelTest::TestLoadUpdatingPreloadedURL(
ASSERT_EQ(prepopulated_url, keyword_url->url()->DisplayURL());
}
-TEST_F(TemplateURLModelTest, MAYBE_Load) {
+TEST_F(TemplateURLServiceTest, MAYBE_Load) {
VerifyLoad();
}
-TEST_F(TemplateURLModelTest, AddUpdateRemove) {
+TEST_F(TemplateURLServiceTest, AddUpdateRemove) {
// Add a new TemplateURL.
VerifyLoad();
const size_t initial_count = model()->GetTemplateURLs().size();
@@ -443,37 +443,37 @@ TEST_F(TemplateURLModelTest, AddUpdateRemove) {
EXPECT_TRUE(model()->GetTemplateURLForKeyword(ASCIIToUTF16("b")) == NULL);
}
-TEST_F(TemplateURLModelTest, GenerateKeyword) {
- ASSERT_EQ(string16(), TemplateURLModel::GenerateKeyword(GURL(), true));
+TEST_F(TemplateURLServiceTest, GenerateKeyword) {
+ ASSERT_EQ(string16(), TemplateURLService::GenerateKeyword(GURL(), true));
// Shouldn't generate keywords for https.
ASSERT_EQ(string16(),
- TemplateURLModel::GenerateKeyword(GURL("https://blah"), true));
+ TemplateURLService::GenerateKeyword(GURL("https://blah"), true));
ASSERT_EQ(ASCIIToUTF16("foo"),
- TemplateURLModel::GenerateKeyword(GURL("http://foo"), true));
+ TemplateURLService::GenerateKeyword(GURL("http://foo"), true));
// www. should be stripped.
ASSERT_EQ(ASCIIToUTF16("foo"),
- TemplateURLModel::GenerateKeyword(GURL("http://www.foo"), true));
+ TemplateURLService::GenerateKeyword(GURL("http://www.foo"), true));
// Shouldn't generate keywords with paths, if autodetected.
ASSERT_EQ(string16(),
- TemplateURLModel::GenerateKeyword(GURL("http://blah/foo"), true));
+ TemplateURLService::GenerateKeyword(GURL("http://blah/foo"), true));
ASSERT_EQ(ASCIIToUTF16("blah"),
- TemplateURLModel::GenerateKeyword(GURL("http://blah/foo"), false));
+ TemplateURLService::GenerateKeyword(GURL("http://blah/foo"), false));
// FTP shouldn't generate a keyword.
ASSERT_EQ(string16(),
- TemplateURLModel::GenerateKeyword(GURL("ftp://blah/"), true));
+ TemplateURLService::GenerateKeyword(GURL("ftp://blah/"), true));
// Make sure we don't get a trailing /
ASSERT_EQ(ASCIIToUTF16("blah"),
- TemplateURLModel::GenerateKeyword(GURL("http://blah/"), true));
+ TemplateURLService::GenerateKeyword(GURL("http://blah/"), true));
}
-TEST_F(TemplateURLModelTest, GenerateSearchURL) {
+TEST_F(TemplateURLServiceTest, GenerateSearchURL) {
scoped_refptr<TestGenerateSearchURL> test_generate_search_url(
new TestGenerateSearchURL(NULL));
test_generate_search_url->RunTest();
EXPECT_TRUE(test_generate_search_url->passed());
}
-TEST_F(TemplateURLModelTest, GenerateSearchURLUsingTermsData) {
+TEST_F(TemplateURLServiceTest, GenerateSearchURLUsingTermsData) {
// Run the test for GenerateSearchURLUsingTermsData on the "IO" thread and
// wait for it to finish.
TestSearchTermsData search_terms_data("http://google.com/");
@@ -485,11 +485,11 @@ TEST_F(TemplateURLModelTest, GenerateSearchURLUsingTermsData) {
FROM_HERE,
NewRunnableMethod(test_generate_search_url.get(),
&TestGenerateSearchURL::RunTest));
- TemplateURLModelTestUtil::BlockTillIOThreadProcessesRequests();
+ TemplateURLServiceTestUtil::BlockTillIOThreadProcessesRequests();
EXPECT_TRUE(test_generate_search_url->passed());
}
-TEST_F(TemplateURLModelTest, ClearBrowsingData_Keywords) {
+TEST_F(TemplateURLServiceTest, ClearBrowsingData_Keywords) {
Time now = Time::Now();
TimeDelta one_day = TimeDelta::FromDays(1);
Time month_ago = now - TimeDelta::FromDays(30);
@@ -549,7 +549,7 @@ TEST_F(TemplateURLModelTest, ClearBrowsingData_Keywords) {
EXPECT_EQ(2U, model()->GetTemplateURLs().size());
}
-TEST_F(TemplateURLModelTest, Reset) {
+TEST_F(TemplateURLServiceTest, Reset) {
// Add a new TemplateURL.
VerifyLoad();
const size_t initial_count = model()->GetTemplateURLs().size();
@@ -590,7 +590,7 @@ TEST_F(TemplateURLModelTest, Reset) {
AssertEquals(last_url, *read_url);
}
-TEST_F(TemplateURLModelTest, DefaultSearchProvider) {
+TEST_F(TemplateURLServiceTest, DefaultSearchProvider) {
// Add a new TemplateURL.
VerifyLoad();
const size_t initial_count = model()->GetTemplateURLs().size();
@@ -621,7 +621,7 @@ TEST_F(TemplateURLModelTest, DefaultSearchProvider) {
AssertEquals(cloned_url, *model()->GetDefaultSearchProvider());
}
-TEST_F(TemplateURLModelTest, TemplateURLWithNoKeyword) {
+TEST_F(TemplateURLServiceTest, TemplateURLWithNoKeyword) {
VerifyLoad();
const size_t initial_count = model()->GetTemplateURLs().size();
@@ -647,7 +647,7 @@ TEST_F(TemplateURLModelTest, TemplateURLWithNoKeyword) {
ASSERT_TRUE(found_keyword);
}
-TEST_F(TemplateURLModelTest, CantReplaceWithSameKeyword) {
+TEST_F(TemplateURLServiceTest, CantReplaceWithSameKeyword) {
ChangeModelToLoadState();
ASSERT_TRUE(model()->CanReplaceKeyword(ASCIIToUTF16("foo"), GURL(), NULL));
TemplateURL* t_url = AddKeywordWithDate("foo", false, "http://foo1",
@@ -666,7 +666,7 @@ TEST_F(TemplateURLModelTest, CantReplaceWithSameKeyword) {
GURL("http://foo2"), NULL));
}
-TEST_F(TemplateURLModelTest, CantReplaceWithSameHosts) {
+TEST_F(TemplateURLServiceTest, CantReplaceWithSameHosts) {
ChangeModelToLoadState();
ASSERT_TRUE(model()->CanReplaceKeyword(ASCIIToUTF16("foo"),
GURL("http://foo.com"), NULL));
@@ -686,7 +686,7 @@ TEST_F(TemplateURLModelTest, CantReplaceWithSameHosts) {
GURL("http://foo.com"), NULL));
}
-TEST_F(TemplateURLModelTest, HasDefaultSearchProvider) {
+TEST_F(TemplateURLServiceTest, HasDefaultSearchProvider) {
// We should have a default search provider even if we haven't loaded.
ASSERT_TRUE(model()->GetDefaultSearchProvider());
@@ -696,7 +696,7 @@ TEST_F(TemplateURLModelTest, HasDefaultSearchProvider) {
ASSERT_TRUE(model()->GetDefaultSearchProvider());
}
-TEST_F(TemplateURLModelTest, DefaultSearchProviderLoadedFromPrefs) {
+TEST_F(TemplateURLServiceTest, DefaultSearchProviderLoadedFromPrefs) {
VerifyLoad();
TemplateURL* template_url = new TemplateURL();
@@ -744,7 +744,7 @@ TEST_F(TemplateURLModelTest, DefaultSearchProviderLoadedFromPrefs) {
*model()->GetDefaultSearchProvider());
}
-TEST_F(TemplateURLModelTest, BuildQueryTerms) {
+TEST_F(TemplateURLServiceTest, BuildQueryTerms) {
struct TestData {
const std::string url;
const bool result;
@@ -770,9 +770,9 @@ TEST_F(TemplateURLModelTest, BuildQueryTerms) {
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) {
- TemplateURLModel::QueryTerms terms;
+ TemplateURLService::QueryTerms terms;
ASSERT_EQ(data[i].result,
- TemplateURLModel::BuildQueryTerms(GURL(data[i].url), &terms));
+ TemplateURLService::BuildQueryTerms(GURL(data[i].url), &terms));
if (data[i].result) {
std::vector<std::string> keys;
std::vector<std::string> values;
@@ -781,7 +781,7 @@ TEST_F(TemplateURLModelTest, BuildQueryTerms) {
ASSERT_TRUE(keys.size() == values.size());
ASSERT_EQ(keys.size(), terms.size());
for (size_t j = 0; j < keys.size(); ++j) {
- TemplateURLModel::QueryTerms::iterator term_iterator =
+ TemplateURLService::QueryTerms::iterator term_iterator =
terms.find(keys[j]);
ASSERT_TRUE(term_iterator != terms.end());
ASSERT_EQ(values[j], term_iterator->second);
@@ -790,7 +790,7 @@ TEST_F(TemplateURLModelTest, BuildQueryTerms) {
}
}
-TEST_F(TemplateURLModelTest, UpdateKeywordSearchTermsForURL) {
+TEST_F(TemplateURLServiceTest, UpdateKeywordSearchTermsForURL) {
struct TestData {
const std::string url;
const string16 term;
@@ -817,7 +817,7 @@ TEST_F(TemplateURLModelTest, UpdateKeywordSearchTermsForURL) {
}
}
-TEST_F(TemplateURLModelTest, DontUpdateKeywordSearchForNonReplaceable) {
+TEST_F(TemplateURLServiceTest, DontUpdateKeywordSearchForNonReplaceable) {
struct TestData {
const std::string url;
} data[] = {
@@ -839,7 +839,7 @@ TEST_F(TemplateURLModelTest, DontUpdateKeywordSearchForNonReplaceable) {
}
}
-TEST_F(TemplateURLModelTest, ChangeGoogleBaseValue) {
+TEST_F(TemplateURLServiceTest, ChangeGoogleBaseValue) {
// NOTE: Do not do a VerifyLoad() here as it will load the prepopulate data,
// which also has a {google:baseURL} keyword in it, which will confuse this
// test.
@@ -884,9 +884,9 @@ struct QueryHistoryCallbackImpl {
history::VisitVector visits;
};
-// Make sure TemplateURLModel generates a KEYWORD_GENERATED visit for
+// Make sure TemplateURLService generates a KEYWORD_GENERATED visit for
// KEYWORD visits.
-TEST_F(TemplateURLModelTest, GenerateVisitOnKeyword) {
+TEST_F(TemplateURLServiceTest, GenerateVisitOnKeyword) {
VerifyLoad();
profile()->CreateHistoryService(true, false);
@@ -927,7 +927,7 @@ TEST_F(TemplateURLModelTest, GenerateVisitOnKeyword) {
// Make sure that the load routine deletes prepopulated engines that no longer
// exist in the prepopulate data.
-TEST_F(TemplateURLModelTest, LoadDeletesUnusedProvider) {
+TEST_F(TemplateURLServiceTest, LoadDeletesUnusedProvider) {
// Create a preloaded template url. Add it to a loaded model and wait for the
// saves to finish.
TemplateURL* t_url = CreatePreloadedTemplateURL();
@@ -954,7 +954,7 @@ TEST_F(TemplateURLModelTest, LoadDeletesUnusedProvider) {
// Make sure that load routine doesn't delete prepopulated engines that no
// longer exist in the prepopulate data if it has been modified by the user.
-TEST_F(TemplateURLModelTest, LoadRetainsModifiedProvider) {
+TEST_F(TemplateURLServiceTest, LoadRetainsModifiedProvider) {
// Create a preloaded template url and add it to a loaded model.
TemplateURL* t_url = CreatePreloadedTemplateURL();
t_url->set_safe_for_autoreplace(false);
@@ -987,7 +987,7 @@ TEST_F(TemplateURLModelTest, LoadRetainsModifiedProvider) {
// Make sure that load routine doesn't delete
// prepopulated engines that no longer exist in the prepopulate data if
// it has been modified by the user.
-TEST_F(TemplateURLModelTest, LoadSavesPrepopulatedDefaultSearchProvider) {
+TEST_F(TemplateURLServiceTest, LoadSavesPrepopulatedDefaultSearchProvider) {
VerifyLoad();
// Verify that the default search provider is set to something.
ASSERT_TRUE(model()->GetDefaultSearchProvider() != NULL);
@@ -1006,7 +1006,7 @@ TEST_F(TemplateURLModelTest, LoadSavesPrepopulatedDefaultSearchProvider) {
// Make sure that the load routine doesn't delete
// prepopulated engines that no longer exist in the prepopulate data if
// it is the default search provider.
-TEST_F(TemplateURLModelTest, LoadRetainsDefaultProvider) {
+TEST_F(TemplateURLServiceTest, LoadRetainsDefaultProvider) {
// Set the default search provider to a preloaded template url which
// is not in the current set of preloaded template urls and save
// the result.
@@ -1049,20 +1049,20 @@ TEST_F(TemplateURLModelTest, LoadRetainsDefaultProvider) {
// Make sure that the load routine updates the url of a preexisting
// default search engine provider and that the result is saved correctly.
-TEST_F(TemplateURLModelTest, LoadUpdatesDefaultSearchURL) {
+TEST_F(TemplateURLServiceTest, LoadUpdatesDefaultSearchURL) {
TestLoadUpdatingPreloadedURL(0);
}
// Make sure that the load routine updates the url of a preexisting
// non-default search engine provider and that the result is saved correctly.
-TEST_F(TemplateURLModelTest, LoadUpdatesSearchURL) {
+TEST_F(TemplateURLServiceTest, LoadUpdatesSearchURL) {
TestLoadUpdatingPreloadedURL(1);
}
// Make sure that the load does update of auto-keywords correctly.
// This test basically verifies that no asserts or crashes occur
// during this operation.
-TEST_F(TemplateURLModelTest, LoadDoesAutoKeywordUpdate) {
+TEST_F(TemplateURLServiceTest, LoadDoesAutoKeywordUpdate) {
string16 prepopulated_url;
TemplateURL* t_url = CreateReplaceablePreloadedTemplateURL(
0, &prepopulated_url);
@@ -1084,7 +1084,7 @@ TEST_F(TemplateURLModelTest, LoadDoesAutoKeywordUpdate) {
// Simulates failing to load the webdb and makes sure the default search
// provider is valid.
-TEST_F(TemplateURLModelTest, FailedInit) {
+TEST_F(TemplateURLServiceTest, FailedInit) {
VerifyLoad();
test_util_.ClearModel();
@@ -1101,7 +1101,7 @@ TEST_F(TemplateURLModelTest, FailedInit) {
// Verifies that if the default search URL preference is managed, we report
// the default search as managed. Also check that we are getting the right
// values.
-TEST_F(TemplateURLModelTest, TestManagedDefaultSearch) {
+TEST_F(TemplateURLServiceTest, TestManagedDefaultSearch) {
VerifyLoad();
const size_t initial_count = model()->GetTemplateURLs().size();
test_util_.ResetObserverCount();
diff --git a/chrome/browser/search_engines/util.cc b/chrome/browser/search_engines/util.cc
index 9ccf423..2cbbe08 100644
--- a/chrome/browser/search_engines/util.cc
+++ b/chrome/browser/search_engines/util.cc
@@ -9,7 +9,8 @@
#include "base/logging.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/search_engines/template_url_prepopulate_data.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
@@ -21,7 +22,8 @@ string16 GetDefaultSearchEngineName(Profile* profile) {
return string16();
}
const TemplateURL* const default_provider =
- profile->GetTemplateURLModel()->GetDefaultSearchProvider();
+ TemplateURLServiceFactory::GetForProfile(profile)->
+ GetDefaultSearchProvider();
if (!default_provider) {
// TODO(cpu): bug 1187517. It is possible to have no default provider.
// returning an empty string is a stopgap measure for the crash
diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc
index 59993c2..71aa909 100644
--- a/chrome/browser/tab_contents/render_view_context_menu.cc
+++ b/chrome/browser/tab_contents/render_view_context_menu.cc
@@ -34,7 +34,8 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_io_data.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/spellcheck_host.h"
#include "chrome/browser/spellchecker_platform_engine.h"
#include "chrome/browser/translate/translate_manager.h"
@@ -720,7 +721,8 @@ void RenderViewContextMenu::AppendSearchProvider() {
}
} else {
const TemplateURL* const default_provider =
- profile_->GetTemplateURLModel()->GetDefaultSearchProvider();
+ TemplateURLServiceFactory::GetForProfile(profile_)->
+ GetDefaultSearchProvider();
if (!default_provider)
return;
menu_model_.AddItem(
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index 7ad7bc9..405003a 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -3483,9 +3483,9 @@ void Browser::OnInstallApplication(TabContentsWrapper* source,
void Browser::ConfirmSetDefaultSearchProvider(
TabContents* tab_contents,
TemplateURL* template_url,
- TemplateURLModel* template_url_model) {
+ TemplateURLService* template_url_service) {
window()->ConfirmSetDefaultSearchProvider(tab_contents, template_url,
- template_url_model);
+ template_url_service);
}
void Browser::ConfirmAddSearchProvider(const TemplateURL* template_url,
diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h
index 867e785..ddd8dd92 100644
--- a/chrome/browser/ui/browser.h
+++ b/chrome/browser/ui/browser.h
@@ -869,7 +869,7 @@ class Browser : public TabHandlerDelegate,
virtual void ConfirmSetDefaultSearchProvider(
TabContents* tab_contents,
TemplateURL* template_url,
- TemplateURLModel* template_url_model) OVERRIDE;
+ TemplateURLService* template_url_service) OVERRIDE;
virtual void ConfirmAddSearchProvider(const TemplateURL* template_url,
Profile* profile) OVERRIDE;
diff --git a/chrome/browser/ui/browser_init.cc b/chrome/browser/ui/browser_init.cc
index ec1c083..b31e670 100644
--- a/chrome/browser/ui/browser_init.cc
+++ b/chrome/browser/ui/browser_init.cc
@@ -39,7 +39,8 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_io_data.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/sessions/session_restore.h"
#include "chrome/browser/sessions/session_service.h"
#include "chrome/browser/sessions/session_service_factory.h"
@@ -1236,7 +1237,8 @@ std::vector<GURL> BrowserInit::GetURLsFromCommandLine(
if (param.value().size() > 2 &&
param.value()[0] == '?' && param.value()[1] == ' ') {
const TemplateURL* default_provider =
- profile->GetTemplateURLModel()->GetDefaultSearchProvider();
+ TemplateURLServiceFactory::GetForProfile(profile)->
+ GetDefaultSearchProvider();
if (default_provider && default_provider->url()) {
const TemplateURLRef* search_url = default_provider->url();
DCHECK(search_url->SupportsReplacement());
diff --git a/chrome/browser/ui/browser_window.h b/chrome/browser/ui/browser_window.h
index 8bb212d..74c67a3 100644
--- a/chrome/browser/ui/browser_window.h
+++ b/chrome/browser/ui/browser_window.h
@@ -24,7 +24,7 @@ class StatusBubble;
class TabContents;
class TabContentsWrapper;
class TemplateURL;
-class TemplateURLModel;
+class TemplateURLService;
#if !defined(OS_MACOSX)
class ToolbarView;
#endif
@@ -198,7 +198,7 @@ class BrowserWindow {
virtual void ConfirmSetDefaultSearchProvider(
TabContents* tab_contents,
TemplateURL* template_url,
- TemplateURLModel* template_url_model) {
+ TemplateURLService* template_url_service) {
// TODO(levin): Implement this for non-Windows platforms and make it pure.
// http://crbug.com/38475
}
diff --git a/chrome/browser/ui/cocoa/browser_test_helper.cc b/chrome/browser/ui/cocoa/browser_test_helper.cc
index 08cc8c2..bf6029e 100644
--- a/chrome/browser/ui/cocoa/browser_test_helper.cc
+++ b/chrome/browser/ui/cocoa/browser_test_helper.cc
@@ -18,7 +18,7 @@ BrowserTestHelper::BrowserTestHelper()
// this.
// http://crbug.com/39725
profile_->CreateAutocompleteClassifier();
- profile_->CreateTemplateURLModel();
+ profile_->CreateTemplateURLService();
browser_.reset(new Browser(Browser::TYPE_TABBED, profile_.get()));
}
diff --git a/chrome/browser/ui/cocoa/first_run_dialog.mm b/chrome/browser/ui/cocoa/first_run_dialog.mm
index 7747c0c..c1f1181 100644
--- a/chrome/browser/ui/cocoa/first_run_dialog.mm
+++ b/chrome/browser/ui/cocoa/first_run_dialog.mm
@@ -14,7 +14,8 @@
#include "chrome/browser/google/google_util.h"
#include "chrome/browser/platform_util.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#import "chrome/browser/ui/cocoa/search_engine_dialog_controller.h"
#include "chrome/common/url_constants.h"
#include "googleurl/src/gurl.h"
@@ -125,7 +126,8 @@ void ShowFirstRun(Profile* profile) {
// Set preference to show first run bubble and welcome page.
// Don't display the minimal bubble if there is no default search provider.
- TemplateURLModel* search_engines_model = profile->GetTemplateURLModel();
+ TemplateURLService* search_engines_model =
+ TemplateURLServiceFactory::GetForProfile(profile);
if (search_engines_model &&
search_engines_model->GetDefaultSearchProvider()) {
FirstRun::SetShowFirstRunBubblePref(true);
@@ -147,7 +149,7 @@ void ShowFirstRunDialog(Profile* profile,
bool randomize_search_engine_experiment) {
// If the default search is not managed via policy, ask the user to
// choose a default.
- TemplateURLModel* model = profile->GetTemplateURLModel();
+ TemplateURLService* model = TemplateURLServiceFactory::GetForProfile(profile);
if (!FirstRun::SearchEngineSelectorDisallowed() ||
(model && !model->is_default_search_managed())) {
ShowSearchEngineSelectionDialog(profile,
diff --git a/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm b/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm
index 0e5c77b..1721aef 100644
--- a/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm
+++ b/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm
@@ -20,7 +20,8 @@
#include "chrome/browser/instant/instant_controller.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/browser_list.h"
#import "chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.h"
#include "chrome/browser/ui/cocoa/event_utils.h"
@@ -462,8 +463,8 @@ NSPoint LocationBarViewMac::GetPageInfoBubblePoint() const {
}
NSImage* LocationBarViewMac::GetKeywordImage(const string16& keyword) {
- const TemplateURL* template_url =
- profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(keyword);
+ const TemplateURL* template_url = TemplateURLServiceFactory::GetForProfile(
+ profile_)->GetTemplateURLForKeyword(keyword);
if (template_url && template_url->IsExtensionKeyword()) {
const SkBitmap& bitmap = profile_->GetExtensionService()->
GetOmniboxIcon(template_url->GetExtensionId());
@@ -601,7 +602,7 @@ void LocationBarViewMac::Layout() {
string16 short_name;
bool is_extension_keyword = false;
if (!keyword.empty()) {
- short_name = profile_->GetTemplateURLModel()->
+ short_name = TemplateURLServiceFactory::GetForProfile(profile_)->
GetKeywordShortName(keyword, &is_extension_keyword);
}
diff --git a/chrome/browser/ui/cocoa/search_engine_dialog_controller.h b/chrome/browser/ui/cocoa/search_engine_dialog_controller.h
index d1abf54..41aea13 100644
--- a/chrome/browser/ui/cocoa/search_engine_dialog_controller.h
+++ b/chrome/browser/ui/cocoa/search_engine_dialog_controller.h
@@ -13,7 +13,7 @@
class Profile;
class SearchEngineDialogControllerBridge;
class TemplateURL;
-class TemplateURLModel;
+class TemplateURLService;
// Class that acts as a controller for the search engine choice dialog.
@interface SearchEngineDialogController : NSWindowController {
@@ -25,7 +25,7 @@ class TemplateURLModel;
bool randomize_;
// Owned by the profile_.
- TemplateURLModel* searchEnginesModel_;
+ TemplateURLService* searchEnginesModel_;
// Bridge to the C++ world.
scoped_refptr<SearchEngineDialogControllerBridge> bridge_;
diff --git a/chrome/browser/ui/cocoa/search_engine_dialog_controller.mm b/chrome/browser/ui/cocoa/search_engine_dialog_controller.mm
index 51b1684..83429f4 100644
--- a/chrome/browser/ui/cocoa/search_engine_dialog_controller.mm
+++ b/chrome/browser/ui/cocoa/search_engine_dialog_controller.mm
@@ -11,8 +11,9 @@
#include "base/time.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
-#include "chrome/browser/search_engines/template_url_model_observer.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
+#include "chrome/browser/search_engines/template_url_service_observer.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
#import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h"
@@ -33,7 +34,7 @@ const int kLogoLabelWidth = 170;
const int kLogoLabelHeight = 25;
@interface SearchEngineDialogController (Private)
-- (void)onTemplateURLModelChanged;
+- (void)onTemplateURLServiceChanged;
- (void)buildSearchEngineView;
- (NSView*)viewForSearchEngine:(const TemplateURL*)engine
atIndex:(size_t)index;
@@ -42,12 +43,12 @@ const int kLogoLabelHeight = 25;
class SearchEngineDialogControllerBridge :
public base::RefCounted<SearchEngineDialogControllerBridge>,
- public TemplateURLModelObserver {
+ public TemplateURLServiceObserver {
public:
SearchEngineDialogControllerBridge(SearchEngineDialogController* controller);
- // TemplateURLModelObserver
- virtual void OnTemplateURLModelChanged();
+ // TemplateURLServiceObserver
+ virtual void OnTemplateURLServiceChanged();
private:
SearchEngineDialogController* controller_;
@@ -57,8 +58,8 @@ SearchEngineDialogControllerBridge::SearchEngineDialogControllerBridge(
SearchEngineDialogController* controller) : controller_(controller) {
}
-void SearchEngineDialogControllerBridge::OnTemplateURLModelChanged() {
- [controller_ onTemplateURLModelChanged];
+void SearchEngineDialogControllerBridge::OnTemplateURLServiceChanged() {
+ [controller_ onTemplateURLServiceChanged];
MessageLoop::current()->QuitNow();
}
@@ -83,7 +84,7 @@ void SearchEngineDialogControllerBridge::OnTemplateURLModelChanged() {
}
- (IBAction)showWindow:(id)sender {
- searchEnginesModel_ = profile_->GetTemplateURLModel();
+ searchEnginesModel_ = TemplateURLServiceFactory::GetForProfile(profile_);
searchEnginesModel_->AddObserver(bridge_.get());
if (searchEnginesModel_->loaded()) {
@@ -91,14 +92,14 @@ void SearchEngineDialogControllerBridge::OnTemplateURLModelChanged() {
FROM_HERE,
NewRunnableMethod(
bridge_.get(),
- &SearchEngineDialogControllerBridge::OnTemplateURLModelChanged));
+ &SearchEngineDialogControllerBridge::OnTemplateURLServiceChanged));
} else {
searchEnginesModel_->Load();
}
MessageLoop::current()->Run();
}
-- (void)onTemplateURLModelChanged {
+- (void)onTemplateURLServiceChanged {
searchEnginesModel_->RemoveObserver(bridge_.get());
// Add the search engines in the search_engines_model_ to the buttons list.
diff --git a/chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm b/chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm
index 39f3320..062400e 100644
--- a/chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm
+++ b/chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm
@@ -19,7 +19,7 @@
#include "chrome/browser/net/url_fixer_upper.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
diff --git a/chrome/browser/ui/gtk/edit_search_engine_dialog.cc b/chrome/browser/ui/gtk/edit_search_engine_dialog.cc
index a45e148..663b7be 100644
--- a/chrome/browser/ui/gtk/edit_search_engine_dialog.cc
+++ b/chrome/browser/ui/gtk/edit_search_engine_dialog.cc
@@ -13,7 +13,7 @@
#include "chrome/browser/net/url_fixer_upper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/ui/gtk/gtk_util.h"
#include "chrome/browser/ui/search_engines/edit_search_engine_controller.h"
#include "googleurl/src/gurl.h"
diff --git a/chrome/browser/ui/gtk/first_run_dialog.cc b/chrome/browser/ui/gtk/first_run_dialog.cc
index 988de69..a071cbc 100644
--- a/chrome/browser/ui/gtk/first_run_dialog.cc
+++ b/chrome/browser/ui/gtk/first_run_dialog.cc
@@ -16,7 +16,8 @@
#include "chrome/browser/process_singleton.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/shell_integration.h"
#include "chrome/browser/ui/gtk/gtk_chrome_link_button.h"
#include "chrome/browser/ui/gtk/gtk_floating_container.h"
@@ -106,7 +107,8 @@ bool FirstRunDialog::Show(Profile* profile,
bool randomize_search_engine_order) {
// Figure out which dialogs we will show.
// If the default search is managed via policy, we won't ask.
- const TemplateURLModel* search_engines_model = profile->GetTemplateURLModel();
+ const TemplateURLService* search_engines_model =
+ TemplateURLServiceFactory::GetForProfile(profile);
bool show_search_engines_dialog =
!FirstRun::SearchEngineSelectorDisallowed() &&
search_engines_model &&
@@ -159,13 +161,13 @@ FirstRunDialog::FirstRunDialog(Profile* profile,
ShowReportingDialog();
return;
}
- search_engines_model_ = profile_->GetTemplateURLModel();
+ search_engines_model_ = TemplateURLServiceFactory::GetForProfile(profile_);
ShowSearchEngineWindow();
search_engines_model_->AddObserver(this);
if (search_engines_model_->loaded())
- OnTemplateURLModelChanged();
+ OnTemplateURLServiceChanged();
else
search_engines_model_->Load();
}
@@ -226,7 +228,7 @@ void FirstRunDialog::ShowSearchEngineWindow() {
gtk_util::SetLabelWidth(explanation, kExplanationWidth);
gtk_box_pack_start(GTK_BOX(bubble_area_box), explanation, FALSE, FALSE, 0);
- // We will fill this in after the TemplateURLModel has loaded.
+ // We will fill this in after the TemplateURLService has loaded.
// GtkHButtonBox because we want all children to have the same size.
search_engine_hbox_ = gtk_hbutton_box_new();
gtk_box_set_spacing(GTK_BOX(search_engine_hbox_), kSearchEngineSpacing);
@@ -298,7 +300,7 @@ void FirstRunDialog::ShowReportingDialog() {
gtk_widget_show_all(dialog_);
}
-void FirstRunDialog::OnTemplateURLModelChanged() {
+void FirstRunDialog::OnTemplateURLServiceChanged() {
// We only watch the search engine model change once, on load. Remove
// observer so we don't try to redraw if engines change under us.
search_engines_model_->RemoveObserver(this);
diff --git a/chrome/browser/ui/gtk/first_run_dialog.h b/chrome/browser/ui/gtk/first_run_dialog.h
index 0718ddf..4902b1b 100644
--- a/chrome/browser/ui/gtk/first_run_dialog.h
+++ b/chrome/browser/ui/gtk/first_run_dialog.h
@@ -10,18 +10,18 @@ typedef struct _GtkButton GtkButton;
typedef struct _GtkWidget GtkWidget;
#include "chrome/browser/first_run/first_run.h"
-#include "chrome/browser/search_engines/template_url_model_observer.h"
+#include "chrome/browser/search_engines/template_url_service_observer.h"
#include "ui/base/gtk/gtk_signal.h"
class TemplateURL;
-class TemplateURLModel;
+class TemplateURLService;
-class FirstRunDialog : public TemplateURLModelObserver {
+class FirstRunDialog : public TemplateURLServiceObserver {
public:
// Displays the first run UI for reporting opt-in, import data etc.
static bool Show(Profile* profile, bool randomize_search_engine_order);
- virtual void OnTemplateURLModelChanged();
+ virtual void OnTemplateURLServiceChanged();
private:
FirstRunDialog(Profile* profile,
@@ -63,7 +63,7 @@ class FirstRunDialog : public TemplateURLModelObserver {
Profile* profile_;
// Owned by the profile_.
- TemplateURLModel* search_engines_model_;
+ TemplateURLService* search_engines_model_;
// The search engine the user chose, or NULL if the user has not chosen a
// search engine.
diff --git a/chrome/browser/ui/gtk/location_bar_view_gtk.cc b/chrome/browser/ui/gtk/location_bar_view_gtk.cc
index b4d10fc..517c810 100644
--- a/chrome/browser/ui/gtk/location_bar_view_gtk.cc
+++ b/chrome/browser/ui/gtk/location_bar_view_gtk.cc
@@ -27,7 +27,8 @@
#include "chrome/browser/instant/instant_controller.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
@@ -946,11 +947,13 @@ void LocationBarViewGtk::SetKeywordLabel(const string16& keyword) {
return;
DCHECK(profile_);
- if (!profile_->GetTemplateURLModel())
+ TemplateURLService* template_url_service =
+ TemplateURLServiceFactory::GetForProfile(profile_);
+ if (!template_url_service)
return;
bool is_extension_keyword;
- const string16 short_name = profile_->GetTemplateURLModel()->
+ const string16 short_name = template_url_service->
GetKeywordShortName(keyword, &is_extension_keyword);
int message_id = is_extension_keyword ?
IDS_OMNIBOX_EXTENSION_KEYWORD_TEXT : IDS_OMNIBOX_KEYWORD_TEXT;
@@ -970,7 +973,7 @@ void LocationBarViewGtk::SetKeywordLabel(const string16& keyword) {
if (is_extension_keyword) {
const TemplateURL* template_url =
- profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(keyword);
+ template_url_service->GetTemplateURLForKeyword(keyword);
const SkBitmap& bitmap = profile_->GetExtensionService()->
GetOmniboxIcon(template_url->GetExtensionId());
GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&bitmap);
@@ -989,11 +992,13 @@ void LocationBarViewGtk::SetKeywordHintLabel(const string16& keyword) {
return;
DCHECK(profile_);
- if (!profile_->GetTemplateURLModel())
+ TemplateURLService* template_url_service =
+ TemplateURLServiceFactory::GetForProfile(profile_);
+ if (!template_url_service)
return;
bool is_extension_keyword;
- const string16 short_name = profile_->GetTemplateURLModel()->
+ const string16 short_name = template_url_service->
GetKeywordShortName(keyword, &is_extension_keyword);
int message_id = is_extension_keyword ?
IDS_OMNIBOX_EXTENSION_KEYWORD_HINT : IDS_OMNIBOX_KEYWORD_HINT;
diff --git a/chrome/browser/ui/omnibox/location_bar_util.cc b/chrome/browser/ui/omnibox/location_bar_util.cc
index 46da34c..bb18ca7 100644
--- a/chrome/browser/ui/omnibox/location_bar_util.cc
+++ b/chrome/browser/ui/omnibox/location_bar_util.cc
@@ -8,18 +8,19 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "ui/base/l10n/l10n_util.h"
namespace location_bar_util {
std::wstring GetKeywordName(Profile* profile, const std::wstring& keyword) {
// Make sure the TemplateURL still exists.
-// TODO(sky): Once LocationBarView adds a listener to the TemplateURLModel
+// TODO(sky): Once LocationBarView adds a listener to the TemplateURLService
// to track changes to the model, this should become a DCHECK.
const TemplateURL* template_url =
- profile->GetTemplateURLModel()->GetTemplateURLForKeyword(
- WideToUTF16Hack(keyword));
+ TemplateURLServiceFactory::GetForProfile(profile)->
+ GetTemplateURLForKeyword(WideToUTF16Hack(keyword));
if (template_url)
return UTF16ToWideHack(template_url->AdjustedShortNameForLocaleDirection());
return std::wstring();
diff --git a/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc b/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
index a9e7aad..c5e57c6 100644
--- a/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
+++ b/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
@@ -18,7 +18,8 @@
#include "chrome/browser/history/history.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/omnibox/location_bar.h"
@@ -142,7 +143,7 @@ const int kCtrlOrCmdMask = ui::EF_CONTROL_DOWN;
} // namespace
class OmniboxViewTest : public InProcessBrowserTest,
- public NotificationObserver {
+ public NotificationObserver {
protected:
OmniboxViewTest() {
set_show_window(true);
@@ -255,13 +256,14 @@ class OmniboxViewTest : public InProcessBrowserTest,
}
void SetupSearchEngine() {
- TemplateURLModel* model = browser()->profile()->GetTemplateURLModel();
+ TemplateURLService* model =
+ TemplateURLServiceFactory::GetForProfile(browser()->profile());
ASSERT_TRUE(model);
if (!model->loaded()) {
NotificationRegistrar registrar;
- registrar.Add(this, NotificationType::TEMPLATE_URL_MODEL_LOADED,
- Source<TemplateURLModel>(model));
+ registrar.Add(this, NotificationType::TEMPLATE_URL_SERVICE_LOADED,
+ Source<TemplateURLService>(model));
model->Load();
ui_test_utils::RunMessageLoop();
}
@@ -270,8 +272,8 @@ class OmniboxViewTest : public InProcessBrowserTest,
// Remove built-in template urls, like google.com, bing.com etc., as they
// may appear as autocomplete suggests and interfere with our tests.
model->SetDefaultSearchProvider(NULL);
- TemplateURLModel::TemplateURLVector builtins = model->GetTemplateURLs();
- for (TemplateURLModel::TemplateURLVector::const_iterator
+ TemplateURLService::TemplateURLVector builtins = model->GetTemplateURLs();
+ for (TemplateURLService::TemplateURLVector::const_iterator
i = builtins.begin(); i != builtins.end(); ++i)
model->Remove(*i);
@@ -347,7 +349,7 @@ class OmniboxViewTest : public InProcessBrowserTest,
switch (type.value) {
case NotificationType::TAB_PARENTED:
case NotificationType::TAB_CLOSED:
- case NotificationType::TEMPLATE_URL_MODEL_LOADED:
+ case NotificationType::TEMPLATE_URL_SERVICE_LOADED:
case NotificationType::AUTOCOMPLETE_CONTROLLER_RESULT_READY:
case NotificationType::HISTORY_LOADED:
case NotificationType::BOOKMARK_MODEL_LOADED:
@@ -862,15 +864,15 @@ class OmniboxViewTest : public InProcessBrowserTest,
AutocompletePopupModel* popup_model = omnibox_view->model()->popup_model();
ASSERT_TRUE(popup_model);
- TemplateURLModel* template_url_model =
- browser()->profile()->GetTemplateURLModel();
+ TemplateURLService* template_url_service =
+ TemplateURLServiceFactory::GetForProfile(browser()->profile());
// Add a non-default substituting keyword.
TemplateURL* template_url = new TemplateURL();
template_url->SetURL("http://abc.com/{searchTerms}", 0, 0);
template_url->set_keyword(UTF8ToUTF16(kSearchText));
template_url->set_short_name(UTF8ToUTF16("Search abc"));
- template_url_model->Add(template_url);
+ template_url_service->Add(template_url);
omnibox_view->SetUserText(string16());
@@ -890,12 +892,12 @@ class OmniboxViewTest : public InProcessBrowserTest,
ASSERT_FALSE(popup_model->IsOpen());
// Try a non-substituting keyword.
- template_url_model->Remove(template_url);
+ template_url_service->Remove(template_url);
template_url = new TemplateURL();
template_url->SetURL("http://abc.com/", 0, 0);
template_url->set_keyword(UTF8ToUTF16(kSearchText));
template_url->set_short_name(UTF8ToUTF16("abc"));
- template_url_model->Add(template_url);
+ template_url_service->Add(template_url);
// We always allow exact matches for non-substituting keywords.
ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchTextKeys));
@@ -910,7 +912,8 @@ class OmniboxViewTest : public InProcessBrowserTest,
void DeleteItemTest() {
// Disable the search provider, to make sure the popup contains only history
// items.
- TemplateURLModel* model = browser()->profile()->GetTemplateURLModel();
+ TemplateURLService* model =
+ TemplateURLServiceFactory::GetForProfile(browser()->profile());
model->SetDefaultSearchProvider(NULL);
ui_test_utils::NavigateToURL(browser(), GURL(chrome::kAboutBlankURL));
diff --git a/chrome/browser/ui/panels/panel.cc b/chrome/browser/ui/panels/panel.cc
index e386f4a..027a7a2 100644
--- a/chrome/browser/ui/panels/panel.cc
+++ b/chrome/browser/ui/panels/panel.cc
@@ -226,7 +226,7 @@ void Panel::DisableInactiveFrame() {
void Panel::ConfirmSetDefaultSearchProvider(
TabContents* tab_contents,
TemplateURL* template_url,
- TemplateURLModel* template_url_model) {
+ TemplateURLService* template_url_service) {
NOTIMPLEMENTED();
}
diff --git a/chrome/browser/ui/panels/panel.h b/chrome/browser/ui/panels/panel.h
index 94644ac..5f03785 100644
--- a/chrome/browser/ui/panels/panel.h
+++ b/chrome/browser/ui/panels/panel.h
@@ -76,7 +76,7 @@ class Panel : public BrowserWindow {
virtual void ConfirmSetDefaultSearchProvider(
TabContents* tab_contents,
TemplateURL* template_url,
- TemplateURLModel* template_url_model) OVERRIDE;
+ TemplateURLService* template_url_service) OVERRIDE;
virtual void ConfirmAddSearchProvider(const TemplateURL* template_url,
Profile* profile) OVERRIDE;
virtual void ToggleBookmarkBar() 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 f409fe6..a0c9b52 100644
--- a/chrome/browser/ui/search_engines/edit_search_engine_controller.cc
+++ b/chrome/browser/ui/search_engines/edit_search_engine_controller.cc
@@ -9,7 +9,8 @@
#include "chrome/browser/net/url_fixer_upper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "content/browser/user_metrics.h"
#include "googleurl/src/gurl.h"
@@ -43,7 +44,8 @@ bool EditSearchEngineController::IsURLValid(
// If this is the default search engine, there must be a search term
// placeholder.
if (template_url_ ==
- profile_->GetTemplateURLModel()->GetDefaultSearchProvider())
+ TemplateURLServiceFactory::GetForProfile(profile_)->
+ GetDefaultSearchProvider())
return false;
return GURL(url).is_valid();
}
@@ -61,8 +63,8 @@ bool EditSearchEngineController::IsKeywordValid(
if (keyword_input_trimmed.empty())
return false; // Do not allow empty keyword.
const TemplateURL* turl_with_keyword =
- profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(
- keyword_input_trimmed);
+ TemplateURLServiceFactory::GetForProfile(profile_)->
+ GetTemplateURLForKeyword(keyword_input_trimmed);
return (turl_with_keyword == NULL || turl_with_keyword == template_url_);
}
@@ -73,9 +75,10 @@ void EditSearchEngineController::AcceptAddOrEdit(
std::string url_string = GetFixedUpURL(url_input);
DCHECK(!url_string.empty());
- const TemplateURL* existing =
- profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(
- keyword_input);
+ TemplateURLService* template_url_service =
+ TemplateURLServiceFactory::GetForProfile(profile_);
+ const 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
@@ -92,15 +95,15 @@ void EditSearchEngineController::AcceptAddOrEdit(
// Confiming an entry we got from JS. We have a template_url_, but it
// hasn't yet been added to the model.
DCHECK(template_url_);
- // const_cast is ugly, but this is the same thing the TemplateURLModel
+ // const_cast is ugly, but this is the same thing the TemplateURLService
// does in a similar situation (updating an existing TemplateURL with
// data from a new one).
TemplateURL* modifiable_url = const_cast<TemplateURL*>(template_url_);
modifiable_url->set_short_name(title_input);
modifiable_url->set_keyword(keyword_input);
modifiable_url->SetURL(url_string, 0, 0);
- // TemplateURLModel takes ownership of template_url_.
- profile_->GetTemplateURLModel()->Add(modifiable_url);
+ // TemplateURLService takes ownership of template_url_.
+ template_url_service->Add(modifiable_url);
UserMetrics::RecordAction(UserMetricsAction("KeywordEditor_AddKeywordJS"));
} else {
// Adding or modifying an entry via the Delegate.
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 5d57c1d..c6cf069 100644
--- a/chrome/browser/ui/search_engines/edit_search_engine_controller.h
+++ b/chrome/browser/ui/search_engines/edit_search_engine_controller.h
@@ -61,7 +61,7 @@ class EditSearchEngineController {
const std::string& url_input);
// Deletes an unused TemplateURL, if its add was cancelled and it's not
- // already owned by the TemplateURLModel.
+ // already owned by the TemplateURLService.
void CleanUpCancelledAdd();
// Accessors.
@@ -75,14 +75,14 @@ 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 TemplateURLModel; if not, we assume it isn't.
+ // the TemplateURLService; if not, we assume it isn't.
const 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.
EditSearchEngineControllerDelegate* edit_keyword_delegate_;
- // Profile whose TemplateURLModel we're modifying.
+ // Profile whose TemplateURLService we're modifying.
Profile* profile_;
DISALLOW_COPY_AND_ASSIGN(EditSearchEngineController);
diff --git a/chrome/browser/ui/search_engines/keyword_editor_controller.cc b/chrome/browser/ui/search_engines/keyword_editor_controller.cc
index 293ad50..97752aa 100644
--- a/chrome/browser/ui/search_engines/keyword_editor_controller.cc
+++ b/chrome/browser/ui/search_engines/keyword_editor_controller.cc
@@ -8,14 +8,16 @@
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/search_engines/template_url_table_model.h"
#include "chrome/common/pref_names.h"
#include "content/browser/user_metrics.h"
KeywordEditorController::KeywordEditorController(Profile* profile)
: profile_(profile) {
- table_model_.reset(new TemplateURLTableModel(profile->GetTemplateURLModel()));
+ table_model_.reset(new TemplateURLTableModel(
+ TemplateURLServiceFactory::GetForProfile(profile)));
}
KeywordEditorController::~KeywordEditorController() {
@@ -106,6 +108,6 @@ const TemplateURL* KeywordEditorController::GetTemplateURL(int index) const {
return &table_model_->GetTemplateURL(index);
}
-TemplateURLModel* KeywordEditorController::url_model() const {
- return table_model_->template_url_model();
+TemplateURLService* KeywordEditorController::url_model() const {
+ return table_model_->template_url_service();
}
diff --git a/chrome/browser/ui/search_engines/keyword_editor_controller.h b/chrome/browser/ui/search_engines/keyword_editor_controller.h
index 10f2698..8b4e0e9 100644
--- a/chrome/browser/ui/search_engines/keyword_editor_controller.h
+++ b/chrome/browser/ui/search_engines/keyword_editor_controller.h
@@ -15,7 +15,7 @@
class PrefService;
class Profile;
class TemplateURL;
-class TemplateURLModel;
+class TemplateURLService;
class TemplateURLTableModel;
class KeywordEditorController {
@@ -26,14 +26,14 @@ class KeywordEditorController {
static void RegisterPrefs(PrefService* prefs);
// Invoked when the user succesfully fills out the add keyword dialog.
- // Propagates the change to the TemplateURLModel and updates the table model.
- // Returns the index of the added URL.
+ // Propagates the change to the TemplateURLService and updates the table
+ // model. Returns the index of the added URL.
int AddTemplateURL(const string16& title,
const string16& keyword,
const std::string& url);
- // Invoked when the user modifies a TemplateURL. Updates the TemplateURLModel
- // and table model appropriately.
+ // Invoked when the user modifies a TemplateURL. Updates the
+ // TemplateURLService and table model appropriately.
void ModifyTemplateURL(const TemplateURL* template_url,
const string16& title,
const string16& keyword,
@@ -65,7 +65,7 @@ class KeywordEditorController {
return table_model_.get();
}
- TemplateURLModel* url_model() const;
+ TemplateURLService* url_model() const;
private:
// The profile.
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 f1e9221..e650b65 100644
--- a/chrome/browser/ui/search_engines/keyword_editor_controller_unittest.cc
+++ b/chrome/browser/ui/search_engines/keyword_editor_controller_unittest.cc
@@ -6,7 +6,8 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/search_engines/keyword_editor_controller.h"
#include "chrome/browser/ui/search_engines/template_url_table_model.h"
#include "chrome/common/pref_names.h"
@@ -23,7 +24,7 @@ static const string16 kB(ASCIIToUTF16("b"));
static const string16 kB1(ASCIIToUTF16("b1"));
// Base class for keyword editor tests. Creates a profile containing an
-// empty TemplateURLModel.
+// empty TemplateURLService.
class KeywordEditorControllerTest : public testing::Test,
public ui::TableModelObserver {
public:
@@ -95,7 +96,7 @@ class KeywordEditorControllerTest : public testing::Test,
MessageLoopForUI message_loop_;
scoped_ptr<TestingProfile> profile_;
scoped_ptr<KeywordEditorController> controller_;
- TemplateURLModel* model_;
+ TemplateURLService* model_;
int model_changed_count_;
int items_changed_count_;
@@ -110,9 +111,9 @@ void KeywordEditorControllerTest::Init(bool simulate_load_failure) {
// the profile is.
controller_.reset();
profile_.reset(new TestingProfile());
- profile_->CreateTemplateURLModel();
+ profile_->CreateTemplateURLService();
- model_ = profile_->GetTemplateURLModel();
+ model_ = TemplateURLServiceFactory::GetForProfile(profile_.get());
if (simulate_load_failure)
model_->OnWebDataServiceRequestDone(0, NULL);
@@ -132,7 +133,7 @@ TEST_F(KeywordEditorControllerTest, Add) {
// Verify the TableModel has the new data.
ASSERT_EQ(1, table_model()->RowCount());
- // Verify the TemplateURLModel has the new entry.
+ // Verify the TemplateURLService has the new entry.
ASSERT_EQ(1U, model_->GetTemplateURLs().size());
// Verify the entry is what we added.
@@ -241,9 +242,9 @@ TEST_F(KeywordEditorControllerTest, MakeDefaultNoWebData) {
EXPECT_EQ(0, new_default);
}
-// Mutates the TemplateURLModel and make sure table model is updating
+// Mutates the TemplateURLService and make sure table model is updating
// appropriately.
-TEST_F(KeywordEditorControllerTest, MutateTemplateURLModel) {
+TEST_F(KeywordEditorControllerTest, MutateTemplateURLService) {
TemplateURL* turl = new TemplateURL();
turl->set_keyword(ASCIIToUTF16("a"));
turl->set_short_name(ASCIIToUTF16("b"));
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 64a6ac8..af32620 100644
--- a/chrome/browser/ui/search_engines/search_engine_tab_helper.cc
+++ b/chrome/browser/ui/search_engines/search_engine_tab_helper.cc
@@ -7,7 +7,8 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url.h"
#include "chrome/browser/search_engines/template_url_fetcher.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/search_engines/template_url_fetcher_ui_callbacks.h"
#include "chrome/common/render_messages.h"
#include "content/common/view_messages.h"
@@ -109,7 +110,7 @@ void SearchEngineTabHelper::OnPageHasOSDD(
if (!keyword_url.is_valid())
return;
- string16 keyword = TemplateURLModel::GenerateKeyword(
+ string16 keyword = TemplateURLService::GenerateKeyword(
keyword_url,
provider_type == TemplateURLFetcher::AUTODETECTED_PROVIDER);
@@ -150,23 +151,23 @@ void SearchEngineTabHelper::GenerateKeywordIfNecessary(
GURL keyword_url = previous_entry->user_typed_url().is_valid() ?
previous_entry->user_typed_url() : previous_entry->url();
string16 keyword =
- TemplateURLModel::GenerateKeyword(keyword_url, true); // autodetected
+ TemplateURLService::GenerateKeyword(keyword_url, true); // autodetected
if (keyword.empty())
return;
- TemplateURLModel* url_model =
- tab_contents()->profile()->GetTemplateURLModel();
- if (!url_model)
+ TemplateURLService* url_service =
+ TemplateURLServiceFactory::GetForProfile(tab_contents()->profile());
+ if (!url_service)
return;
- if (!url_model->loaded()) {
- url_model->Load();
+ if (!url_service->loaded()) {
+ url_service->Load();
return;
}
const TemplateURL* current_url;
GURL url = params.searchable_form_url;
- if (!url_model->CanReplaceKeyword(keyword, url, &current_url))
+ if (!url_service->CanReplaceKeyword(keyword, url, &current_url))
return;
if (current_url) {
@@ -175,7 +176,7 @@ void SearchEngineTabHelper::GenerateKeywordIfNecessary(
// document, don't regenerate.
return;
}
- url_model->Remove(current_url);
+ url_service->Remove(current_url);
}
TemplateURL* new_url = new TemplateURL();
new_url->set_keyword(keyword);
@@ -196,5 +197,5 @@ void SearchEngineTabHelper::GenerateKeywordIfNecessary(
new_url->SetFaviconURL(TemplateURL::GenerateFaviconURL(params.referrer));
}
new_url->set_safe_for_autoreplace(true);
- url_model->Add(new_url);
+ url_service->Add(new_url);
}
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 8c83ea1..1c5ddcf 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
@@ -9,7 +9,7 @@
class Profile;
class TabContents;
class TemplateURL;
-class TemplateURLModel;
+class TemplateURLService;
// Objects implement this interface to get notified about changes in the
// SearchEngineTabHelper and to provide necessary functionality.
@@ -20,7 +20,7 @@ class SearchEngineTabHelperDelegate {
virtual void ConfirmSetDefaultSearchProvider(
TabContents* tab_contents,
TemplateURL* template_url,
- TemplateURLModel* template_url_model) = 0;
+ TemplateURLService* template_url_service) = 0;
// Shows a confirmation dialog box for adding a search engine described by
// |template_url|. Takes ownership of |template_url|.
diff --git a/chrome/browser/ui/search_engines/template_url_fetcher_ui_callbacks.cc b/chrome/browser/ui/search_engines/template_url_fetcher_ui_callbacks.cc
index d90b09a..490f9d2 100644
--- a/chrome/browser/ui/search_engines/template_url_fetcher_ui_callbacks.cc
+++ b/chrome/browser/ui/search_engines/template_url_fetcher_ui_callbacks.cc
@@ -28,7 +28,7 @@ TemplateURLFetcherUICallbacks::~TemplateURLFetcherUICallbacks() {
void TemplateURLFetcherUICallbacks::ConfirmSetDefaultSearchProvider(
TemplateURL* template_url,
- TemplateURLModel* template_url_model) {
+ TemplateURLService* template_url_service) {
scoped_ptr<TemplateURL> owned_template_url(template_url);
if (!source_ || !source_->delegate() || !tab_contents_)
return;
@@ -36,7 +36,7 @@ void TemplateURLFetcherUICallbacks::ConfirmSetDefaultSearchProvider(
source_->delegate()->ConfirmSetDefaultSearchProvider(
tab_contents_,
owned_template_url.release(),
- template_url_model);
+ template_url_service);
}
void TemplateURLFetcherUICallbacks::ConfirmAddSearchProvider(
diff --git a/chrome/browser/ui/search_engines/template_url_fetcher_ui_callbacks.h b/chrome/browser/ui/search_engines/template_url_fetcher_ui_callbacks.h
index feebcc4..012d737 100644
--- a/chrome/browser/ui/search_engines/template_url_fetcher_ui_callbacks.h
+++ b/chrome/browser/ui/search_engines/template_url_fetcher_ui_callbacks.h
@@ -25,7 +25,7 @@ class TemplateURLFetcherUICallbacks : public TemplateURLFetcherCallbacks,
// TemplateURLFetcherCallback implementation.
virtual void ConfirmSetDefaultSearchProvider(
TemplateURL* template_url,
- TemplateURLModel* template_url_model);
+ TemplateURLService* template_url_service);
virtual void ConfirmAddSearchProvider(
TemplateURL* template_url,
Profile* profile);
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 3617ecc..aa10bb8 100644
--- a/chrome/browser/ui/search_engines/template_url_table_model.cc
+++ b/chrome/browser/ui/search_engines/template_url_table_model.cc
@@ -11,7 +11,7 @@
#include "chrome/browser/favicon/favicon_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
#include "grit/app_resources.h"
#include "grit/generated_resources.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -75,7 +75,7 @@ class ModelEntry {
void LoadFavicon() {
load_state_ = LOADED;
FaviconService* favicon_service =
- model_->template_url_model()->profile()->GetFaviconService(
+ model_->template_url_service()->profile()->GetFaviconService(
Profile::EXPLICIT_ACCESS);
if (!favicon_service)
return;
@@ -119,17 +119,17 @@ class ModelEntry {
// TemplateURLTableModel -----------------------------------------
TemplateURLTableModel::TemplateURLTableModel(
- TemplateURLModel* template_url_model)
+ TemplateURLService* template_url_service)
: observer_(NULL),
- template_url_model_(template_url_model) {
- DCHECK(template_url_model);
- template_url_model_->Load();
- template_url_model_->AddObserver(this);
+ template_url_service_(template_url_service) {
+ DCHECK(template_url_service);
+ template_url_service_->Load();
+ template_url_service_->AddObserver(this);
Reload();
}
TemplateURLTableModel::~TemplateURLTableModel() {
- template_url_model_->RemoveObserver(this);
+ template_url_service_->RemoveObserver(this);
STLDeleteElements(&entries_);
entries_.clear();
}
@@ -138,7 +138,8 @@ void TemplateURLTableModel::Reload() {
STLDeleteElements(&entries_);
entries_.clear();
- std::vector<const TemplateURL*> urls = template_url_model_->GetTemplateURLs();
+ std::vector<const TemplateURL*> urls =
+ template_url_service_->GetTemplateURLs();
// Keywords that can be made the default first.
for (std::vector<const TemplateURL*>::iterator i = urls.begin();
@@ -181,7 +182,7 @@ string16 TemplateURLTableModel::GetText(int row, int col_id) {
// since those should always be displayed LTR. Please refer to
// http://crbug.com/6726 for more information.
base::i18n::AdjustStringForLocaleDirection(&url_short_name);
- if (template_url_model_->GetDefaultSearchProvider() == &url) {
+ if (template_url_service_->GetDefaultSearchProvider() == &url) {
return l10n_util::GetStringFUTF16(
IDS_SEARCH_ENGINES_EDITOR_DEFAULT_ENGINE,
url_short_name);
@@ -237,7 +238,7 @@ int TemplateURLTableModel::GetGroupID(int row) {
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_model_->RemoveObserver(this);
+ template_url_service_->RemoveObserver(this);
const TemplateURL* template_url = &GetTemplateURL(index);
scoped_ptr<ModelEntry> entry(entries_[index]);
@@ -249,8 +250,8 @@ void TemplateURLTableModel::Remove(int index) {
// Make sure to remove from the table model first, otherwise the
// TemplateURL would be freed.
- template_url_model_->Remove(template_url);
- template_url_model_->AddObserver(this);
+ template_url_service_->Remove(template_url);
+ template_url_service_->AddObserver(this);
}
void TemplateURLTableModel::Add(int index, TemplateURL* template_url) {
@@ -259,9 +260,9 @@ void TemplateURLTableModel::Add(int index, TemplateURL* template_url) {
entries_.insert(entries_.begin() + index, entry);
if (observer_)
observer_->OnItemsAdded(index, 1);
- template_url_model_->RemoveObserver(this);
- template_url_model_->Add(template_url);
- template_url_model_->AddObserver(this);
+ template_url_service_->RemoveObserver(this);
+ template_url_service_->Add(template_url);
+ template_url_service_->AddObserver(this);
}
void TemplateURLTableModel::ModifyTemplateURL(int index,
@@ -270,16 +271,16 @@ void TemplateURLTableModel::ModifyTemplateURL(int index,
const std::string& url) {
DCHECK(index >= 0 && index <= RowCount());
const TemplateURL* template_url = &GetTemplateURL(index);
- template_url_model_->RemoveObserver(this);
- template_url_model_->ResetTemplateURL(template_url, title, keyword, url);
- if (template_url_model_->GetDefaultSearchProvider() == template_url &&
+ template_url_service_->RemoveObserver(this);
+ template_url_service_->ResetTemplateURL(template_url, title, keyword, url);
+ if (template_url_service_->GetDefaultSearchProvider() == template_url &&
!TemplateURL::SupportsReplacement(template_url)) {
// The entry was the default search provider, but the url has been modified
// so that it no longer supports replacement. Reset the default search
// provider so that it doesn't point to a bogus entry.
- template_url_model_->SetDefaultSearchProvider(NULL);
+ template_url_service_->SetDefaultSearchProvider(NULL);
}
- template_url_model_->AddObserver(this);
+ template_url_service_->AddObserver(this);
ReloadIcon(index); // Also calls NotifyChanged().
}
@@ -330,13 +331,13 @@ int TemplateURLTableModel::MakeDefaultTemplateURL(int index) {
const TemplateURL* keyword = &GetTemplateURL(index);
const TemplateURL* current_default =
- template_url_model_->GetDefaultSearchProvider();
+ template_url_service_->GetDefaultSearchProvider();
if (current_default == keyword)
return -1;
- template_url_model_->RemoveObserver(this);
- template_url_model_->SetDefaultSearchProvider(keyword);
- template_url_model_->AddObserver(this);
+ template_url_service_->RemoveObserver(this);
+ template_url_service_->SetDefaultSearchProvider(keyword);
+ template_url_service_->AddObserver(this);
// The formatting of the default engine is different; notify the table that
// both old and new entries have changed.
@@ -368,6 +369,6 @@ void TemplateURLTableModel::FaviconAvailable(ModelEntry* entry) {
NotifyChanged(static_cast<int>(i - entries_.begin()));
}
-void TemplateURLTableModel::OnTemplateURLModelChanged() {
+void TemplateURLTableModel::OnTemplateURLServiceChanged() {
Reload();
}
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 d99a5dd..19f01cd 100644
--- a/chrome/browser/ui/search_engines/template_url_table_model.h
+++ b/chrome/browser/ui/search_engines/template_url_table_model.h
@@ -11,13 +11,13 @@
#include "base/compiler_specific.h"
#include "base/string16.h"
-#include "chrome/browser/search_engines/template_url_model_observer.h"
+#include "chrome/browser/search_engines/template_url_service_observer.h"
#include "ui/base/models/table_model.h"
class ModelEntry;
class SkBitmap;
class TemplateURL;
-class TemplateURLModel;
+class TemplateURLService;
// TemplateURLTableModel is the TableModel implementation used by
// KeywordEditorView to show the keywords in a TableView.
@@ -31,14 +31,15 @@ class TemplateURLModel;
// appear first (grouped together) and are followed by generated keywords.
class TemplateURLTableModel : public ui::TableModel,
- TemplateURLModelObserver {
+ TemplateURLServiceObserver {
public:
- explicit TemplateURLTableModel(TemplateURLModel* template_url_model);
+ explicit TemplateURLTableModel(TemplateURLService* template_url_service);
virtual ~TemplateURLTableModel();
- // Reloads the entries from the TemplateURLModel. This should ONLY be invoked
- // if the TemplateURLModel wasn't initially loaded and has been loaded.
+ // Reloads the entries from the TemplateURLService. This should ONLY be
+ // invoked if the TemplateURLService wasn't initially loaded and has been
+ // loaded.
void Reload();
// ui::TableModel overrides.
@@ -84,7 +85,9 @@ class TemplateURLTableModel : public ui::TableModel,
// If there is an observer, it's notified the selected row has changed.
void NotifyChanged(int index);
- TemplateURLModel* template_url_model() const { return template_url_model_; }
+ TemplateURLService* template_url_service() const {
+ return template_url_service_;
+ }
// Returns the index of the last entry shown in the search engines group.
int last_search_engine_index() const { return last_search_engine_index_; }
@@ -95,8 +98,8 @@ class TemplateURLTableModel : public ui::TableModel,
// Notification that a model entry has fetched its icon.
void FaviconAvailable(ModelEntry* entry);
- // TemplateURLModelObserver notification.
- virtual void OnTemplateURLModelChanged();
+ // TemplateURLServiceObserver notification.
+ virtual void OnTemplateURLServiceChanged();
ui::TableModelObserver* observer_;
@@ -104,7 +107,7 @@ class TemplateURLTableModel : public ui::TableModel,
std::vector<ModelEntry*> entries_;
// The model we're displaying entries from.
- TemplateURLModel* template_url_model_;
+ TemplateURLService* template_url_service_;
// Index of the last search engine in entries_. This is used to determine the
// group boundaries.
diff --git a/chrome/browser/ui/views/default_search_view.cc b/chrome/browser/ui/views/default_search_view.cc
index 9ed9d7ef..1e0d72c 100644
--- a/chrome/browser/ui/views/default_search_view.cc
+++ b/chrome/browser/ui/views/default_search_view.cc
@@ -9,7 +9,7 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/search_engines/template_url_prepopulate_data.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "grit/generated_resources.h"
@@ -39,7 +39,7 @@ void GetShortNameAndLogoId(PrefService* prefs,
DCHECK(short_name);
DCHECK(logo_id);
- GURL url = TemplateURLModel::GenerateSearchURL(turl);
+ GURL url = TemplateURLService::GenerateSearchURL(turl);
scoped_ptr<TemplateURL> built_in_data(
TemplateURLPrepopulateData::GetEngineForOrigin(prefs, url));
@@ -110,15 +110,15 @@ views::NativeButton* CreateProviderChoiceButton(
// static
void DefaultSearchView::Show(TabContents* tab_contents,
TemplateURL* default_url,
- TemplateURLModel* template_url_model) {
+ TemplateURLService* template_url_service) {
scoped_ptr<TemplateURL> template_url(default_url);
- if (!template_url_model->CanMakeDefault(default_url) ||
+ if (!template_url_service->CanMakeDefault(default_url) ||
default_url->url()->GetHost().empty())
return;
// When the window closes, it will delete itself.
new DefaultSearchView(tab_contents, template_url.release(),
- template_url_model);
+ template_url_service);
}
DefaultSearchView::~DefaultSearchView() {
@@ -163,22 +163,22 @@ bool DefaultSearchView::Accept() {
// Check this again in case the default became managed while this dialog was
// displayed.
TemplateURL* set_as_default = proposed_turl_.get();
- if (!template_url_model_->CanMakeDefault(set_as_default))
+ if (!template_url_service_->CanMakeDefault(set_as_default))
return true;
- template_url_model_->Add(proposed_turl_.release());
- template_url_model_->SetDefaultSearchProvider(set_as_default);
+ template_url_service_->Add(proposed_turl_.release());
+ template_url_service_->SetDefaultSearchProvider(set_as_default);
return true;
}
DefaultSearchView::DefaultSearchView(TabContents* tab_contents,
TemplateURL* proposed_default_turl,
- TemplateURLModel* template_url_model)
+ TemplateURLService* template_url_service)
: background_image_(NULL),
default_provider_button_(NULL),
proposed_provider_button_(NULL),
proposed_turl_(proposed_default_turl),
- template_url_model_(template_url_model) {
+ template_url_service_(template_url_service) {
PrefService* prefs = tab_contents->profile()->GetPrefs();
SetupControls(prefs);
@@ -212,7 +212,7 @@ void DefaultSearchView::SetupControls(PrefService* prefs) {
std::wstring default_short_name;
int default_logo_id = kNoSearchEngineLogo;
GetShortNameAndLogoId(prefs,
- template_url_model_->GetDefaultSearchProvider(),
+ template_url_service_->GetDefaultSearchProvider(),
&default_short_name,
&default_logo_id);
diff --git a/chrome/browser/ui/views/default_search_view.h b/chrome/browser/ui/views/default_search_view.h
index 57c8e18..d7d65cf 100644
--- a/chrome/browser/ui/views/default_search_view.h
+++ b/chrome/browser/ui/views/default_search_view.h
@@ -19,7 +19,7 @@
class PrefService;
class TabContents;
class TemplateURL;
-class TemplateURLModel;
+class TemplateURLService;
namespace gfx {
class Canvas;
@@ -42,7 +42,7 @@ class DefaultSearchView
// Takes ownership of |proposed_default_turl|.
static void Show(TabContents* tab_contents,
TemplateURL* ,
- TemplateURLModel* template_url_model);
+ TemplateURLService* template_url_service);
virtual ~DefaultSearchView();
@@ -65,7 +65,7 @@ class DefaultSearchView
// Takes ownership of |proposed_default_turl|.
DefaultSearchView(TabContents* tab_contents,
TemplateURL* proposed_default_turl,
- TemplateURLModel* template_url_model);
+ TemplateURLService* template_url_service);
// Initializes the labels and controls in the view.
void SetupControls(PrefService* prefs);
@@ -82,7 +82,7 @@ class DefaultSearchView
// The proposed new default search engine.
scoped_ptr<TemplateURL> proposed_turl_;
- TemplateURLModel* template_url_model_;
+ TemplateURLService* template_url_service_;
DISALLOW_COPY_AND_ASSIGN(DefaultSearchView);
};
diff --git a/chrome/browser/ui/views/edit_search_engine_dialog.h b/chrome/browser/ui/views/edit_search_engine_dialog.h
index 12ae190..9d7ffcc 100644
--- a/chrome/browser/ui/views/edit_search_engine_dialog.h
+++ b/chrome/browser/ui/views/edit_search_engine_dialog.h
@@ -26,7 +26,7 @@ class EditSearchEngineController;
class EditSearchEngineControllerDelegate;
class Profile;
class TemplateURL;
-class TemplateURLModel;
+class TemplateURLService;
class EditSearchEngineDialog : public views::View,
public views::TextfieldController,
diff --git a/chrome/browser/ui/views/first_run_search_engine_view.cc b/chrome/browser/ui/views/first_run_search_engine_view.cc
index 50121f1..56238b2 100644
--- a/chrome/browser/ui/views/first_run_search_engine_view.cc
+++ b/chrome/browser/ui/views/first_run_search_engine_view.cc
@@ -17,7 +17,8 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/search_engine_type.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "grit/google_chrome_strings.h"
@@ -57,7 +58,7 @@ void ShowFirstRunDialog(Profile* profile,
bool randomize_search_engine_experiment) {
// If the default search is managed via policy, we don't ask the user to
// choose.
- TemplateURLModel* model = profile->GetTemplateURLModel();
+ TemplateURLService* model = TemplateURLServiceFactory::GetForProfile(profile);
if (FirstRun::SearchEngineSelectorDisallowed() || !model ||
model->is_default_search_managed()) {
return;
@@ -155,7 +156,7 @@ FirstRunSearchEngineView::FirstRunSearchEngineView(
SetVisible(false);
// Start loading the search engines for the given profile.
- search_engines_model_ = profile_->GetTemplateURLModel();
+ search_engines_model_ = TemplateURLServiceFactory::GetForProfile(profile_);
if (search_engines_model_) {
DCHECK(!search_engines_model_->loaded());
search_engines_model_->AddObserver(this);
@@ -173,12 +174,13 @@ FirstRunSearchEngineView::~FirstRunSearchEngineView() {
void FirstRunSearchEngineView::ButtonPressed(views::Button* sender,
const views::Event& event) {
SearchEngineChoice* choice = static_cast<SearchEngineChoice*>(sender);
- TemplateURLModel* template_url_model = profile_->GetTemplateURLModel();
- DCHECK(template_url_model);
- template_url_model->SetSearchEngineDialogSlot(choice->slot());
+ TemplateURLService* template_url_service =
+ TemplateURLServiceFactory::GetForProfile(profile_);
+ DCHECK(template_url_service);
+ template_url_service->SetSearchEngineDialogSlot(choice->slot());
const TemplateURL* default_search = choice->GetSearchEngine();
if (default_search)
- template_url_model->SetDefaultSearchProvider(default_search);
+ template_url_service->SetDefaultSearchProvider(default_search);
MessageLoop::current()->Quit();
}
@@ -193,7 +195,7 @@ void FirstRunSearchEngineView::OnPaint(gfx::Canvas* canvas) {
height() - background_image_->height());
}
-void FirstRunSearchEngineView::OnTemplateURLModelChanged() {
+void FirstRunSearchEngineView::OnTemplateURLServiceChanged() {
using views::ImageView;
// We only watch the search engine model change once, on load. Remove
diff --git a/chrome/browser/ui/views/first_run_search_engine_view.h b/chrome/browser/ui/views/first_run_search_engine_view.h
index eee914c..95252ff 100644
--- a/chrome/browser/ui/views/first_run_search_engine_view.h
+++ b/chrome/browser/ui/views/first_run_search_engine_view.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -8,7 +8,7 @@
#include <vector>
-#include "chrome/browser/search_engines/template_url_model_observer.h"
+#include "chrome/browser/search_engines/template_url_service_observer.h"
#include "ui/gfx/size.h"
#include "views/controls/button/native_button.h"
#include "views/view.h"
@@ -24,7 +24,7 @@ class Window;
class Profile;
class TemplateURL;
-class TemplateURLModel;
+class TemplateURLService;
// This class holds the logo and TemplateURL for a search engine and serves
// as its button in the search engine selection view.
@@ -80,7 +80,7 @@ class FirstRunSearchEngineView
: public views::View,
public views::ButtonListener,
public views::WindowDelegate,
- public TemplateURLModelObserver {
+ public TemplateURLServiceObserver {
public:
// |profile| allows us to get the set of imported search engines.
// |randomize| is true if logos are to be displayed in random order.
@@ -109,17 +109,17 @@ class FirstRunSearchEngineView
// Override from View so we can draw the gray background at dialog top.
virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
- // Overridden from TemplateURLModelObserver. When the search engines have
+ // Overridden from TemplateURLServiceObserver. When the search engines have
// loaded from the profile, we can populate the logos in the dialog box
// to present to the user.
- virtual void OnTemplateURLModelChanged() OVERRIDE;
+ virtual void OnTemplateURLServiceChanged() OVERRIDE;
private:
// Initializes the labels and controls in the view.
void SetupControls();
// Owned by the profile_.
- TemplateURLModel* search_engines_model_;
+ TemplateURLService* search_engines_model_;
// One for each search engine choice offered, either three or four.
std::vector<SearchEngineChoice*> search_engine_choices_;
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index 782450c..5cd474a7 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -988,9 +988,9 @@ void BrowserView::DisableInactiveFrame() {
void BrowserView::ConfirmSetDefaultSearchProvider(
TabContents* tab_contents,
TemplateURL* template_url,
- TemplateURLModel* template_url_model) {
+ TemplateURLService* template_url_service) {
#if defined(OS_WIN)
- DefaultSearchView::Show(tab_contents, template_url, template_url_model);
+ DefaultSearchView::Show(tab_contents, template_url, template_url_service);
#else
// TODO(levin): Implement for other platforms. Right now this is behind
// a command line flag which is off. http://crbug.com/38475
diff --git a/chrome/browser/ui/views/frame/browser_view.h b/chrome/browser/ui/views/frame/browser_view.h
index 86c7c6e..cf8e98e 100644
--- a/chrome/browser/ui/views/frame/browser_view.h
+++ b/chrome/browser/ui/views/frame/browser_view.h
@@ -290,7 +290,7 @@ class BrowserView : public BrowserBubbleHost,
virtual void ConfirmSetDefaultSearchProvider(
TabContents* tab_contents,
TemplateURL* template_url,
- TemplateURLModel* template_url_model) OVERRIDE;
+ TemplateURLService* template_url_service) OVERRIDE;
virtual void ConfirmAddSearchProvider(const TemplateURL* template_url,
Profile* profile) OVERRIDE;
virtual void ToggleBookmarkBar() OVERRIDE;
diff --git a/chrome/browser/ui/views/location_bar/keyword_hint_view.cc b/chrome/browser/ui/views/location_bar/keyword_hint_view.cc
index a9da4ac..6a588d8 100644
--- a/chrome/browser/ui/views/location_bar/keyword_hint_view.cc
+++ b/chrome/browser/ui/views/location_bar/keyword_hint_view.cc
@@ -8,7 +8,8 @@
#include "base/utf_string_conversions.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -53,13 +54,15 @@ void KeywordHintView::SetKeyword(const string16& keyword) {
if (keyword_.empty())
return;
DCHECK(profile_);
- if (!profile_->GetTemplateURLModel())
+ TemplateURLService* url_service =
+ TemplateURLServiceFactory::GetForProfile(profile_);
+ if (!url_service)
return;
std::vector<size_t> content_param_offsets;
bool is_extension_keyword;
- string16 short_name = profile_->GetTemplateURLModel()->
- GetKeywordShortName(keyword, &is_extension_keyword);
+ string16 short_name = url_service->GetKeywordShortName(keyword,
+ &is_extension_keyword);
int message_id = is_extension_keyword ?
IDS_OMNIBOX_EXTENSION_KEYWORD_HINT : IDS_OMNIBOX_KEYWORD_HINT;
const std::wstring keyword_hint =
diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc
index ad4f476..8a29a25 100644
--- a/chrome/browser/ui/views/location_bar/location_bar_view.cc
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc
@@ -21,7 +21,8 @@
#include "chrome/browser/instant/instant_controller.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/browser/ui/view_ids.h"
@@ -121,7 +122,7 @@ LocationBarView::LocationBarView(Profile* profile,
mode_(mode),
show_focus_rect_(false),
bubble_type_(FirstRun::MINIMAL_BUBBLE),
- template_url_model_(NULL),
+ template_url_service_(NULL),
animation_offset_(0) {
DCHECK(profile_);
set_id(VIEW_ID_LOCATION_BAR);
@@ -135,8 +136,8 @@ LocationBarView::LocationBarView(Profile* profile,
}
LocationBarView::~LocationBarView() {
- if (template_url_model_)
- template_url_model_->RemoveObserver(this);
+ if (template_url_service_)
+ template_url_service_->RemoveObserver(this);
}
void LocationBarView::Init() {
@@ -553,7 +554,8 @@ void LocationBarView::Layout() {
if (selected_keyword_view_->keyword() != keyword) {
selected_keyword_view_->SetKeyword(keyword);
const TemplateURL* template_url =
- profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(keyword);
+ TemplateURLServiceFactory::GetForProfile(profile_)->
+ GetTemplateURLForKeyword(keyword);
if (template_url && template_url->IsExtensionKeyword()) {
const SkBitmap& bitmap = profile_->GetExtensionService()->
GetOmniboxIcon(template_url->GetExtensionId());
@@ -1078,11 +1080,13 @@ bool LocationBarView::CanStartDragForView(View* sender,
void LocationBarView::ShowFirstRunBubble(FirstRun::BubbleType bubble_type) {
// Wait until search engines have loaded to show the first run bubble.
- if (!profile_->GetTemplateURLModel()->loaded()) {
+ TemplateURLService* url_service =
+ TemplateURLServiceFactory::GetForProfile(profile_);
+ if (!url_service->loaded()) {
bubble_type_ = bubble_type;
- template_url_model_ = profile_->GetTemplateURLModel();
- template_url_model_->AddObserver(this);
- template_url_model_->Load();
+ template_url_service_ = url_service;
+ template_url_service_->AddObserver(this);
+ template_url_service_->Load();
return;
}
ShowFirstRunBubbleInternal(bubble_type);
@@ -1193,9 +1197,9 @@ void LocationBarView::TestPageActionPressed(size_t index) {
NOTREACHED();
}
-void LocationBarView::OnTemplateURLModelChanged() {
- template_url_model_->RemoveObserver(this);
- template_url_model_ = NULL;
+void LocationBarView::OnTemplateURLServiceChanged() {
+ template_url_service_->RemoveObserver(this);
+ template_url_service_ = NULL;
// If the browser is no longer active, let's not show the info bubble, as this
// would make the browser the active window again.
if (location_entry_view_ && location_entry_view_->GetWidget()->IsActive())
diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.h b/chrome/browser/ui/views/location_bar/location_bar_view.h
index 072868e..0dcc85b 100644
--- a/chrome/browser/ui/views/location_bar/location_bar_view.h
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.h
@@ -15,7 +15,7 @@
#include "chrome/browser/extensions/extension_context_menu_model.h"
#include "chrome/browser/first_run/first_run.h"
#include "chrome/browser/prefs/pref_member.h"
-#include "chrome/browser/search_engines/template_url_model_observer.h"
+#include "chrome/browser/search_engines/template_url_service_observer.h"
#include "chrome/browser/ui/omnibox/location_bar.h"
#include "chrome/browser/ui/toolbar/toolbar_model.h"
#include "chrome/browser/ui/views/dropdown_bar_host.h"
@@ -45,7 +45,7 @@ class SelectedKeywordView;
class StarView;
class TabContents;
class TabContentsWrapper;
-class TemplateURLModel;
+class TemplateURLService;
namespace views {
class HorizontalPainter;
@@ -70,7 +70,7 @@ class LocationBarView : public LocationBar,
public views::DragController,
public AutocompleteEditController,
public DropdownBarHostDelegate,
- public TemplateURLModelObserver,
+ public TemplateURLServiceObserver,
public NotificationObserver {
public:
// The location bar view's class name.
@@ -262,8 +262,8 @@ class LocationBarView : public LocationBar,
virtual ExtensionAction* GetVisiblePageAction(size_t index) OVERRIDE;
virtual void TestPageActionPressed(size_t index) OVERRIDE;
- // Overridden from TemplateURLModelObserver
- virtual void OnTemplateURLModelChanged() OVERRIDE;
+ // Overridden from TemplateURLServiceObserver
+ virtual void OnTemplateURLServiceChanged() OVERRIDE;
// Overridden from NotificationObserver
virtual void Observe(NotificationType type,
@@ -415,10 +415,9 @@ class LocationBarView : public LocationBar,
// Whether bubble text is short or long.
FirstRun::BubbleType bubble_type_;
- // This is in case we're destroyed before the model loads. We store the model
- // because calling profile_->GetTemplateURLModel() in the destructor causes a
- // crash.
- TemplateURLModel* template_url_model_;
+ // This is in case we're destroyed before the model loads. We need to make
+ // Add/RemoveObserver calls.
+ TemplateURLService* template_url_service_;
// Tracks this preference to determine whether bookmark editing is allowed.
BooleanPrefMember edit_bookmarks_enabled_;
diff --git a/chrome/browser/ui/views/location_bar/selected_keyword_view.cc b/chrome/browser/ui/views/location_bar/selected_keyword_view.cc
index 6af5000..7b575e8 100644
--- a/chrome/browser/ui/views/location_bar/selected_keyword_view.cc
+++ b/chrome/browser/ui/views/location_bar/selected_keyword_view.cc
@@ -6,7 +6,8 @@
#include "base/logging.h"
#include "base/utf_string_conversions.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/omnibox/location_bar_util.h"
#include "chrome/browser/ui/views/location_bar/keyword_hint_view.h"
@@ -55,12 +56,14 @@ void SelectedKeywordView::SetKeyword(const string16& keyword) {
if (keyword.empty())
return;
DCHECK(profile_);
- if (!profile_->GetTemplateURLModel())
+ TemplateURLService* model =
+ TemplateURLServiceFactory::GetForProfile(profile_);
+ if (!model)
return;
bool is_extension_keyword;
- const string16 short_name = profile_->GetTemplateURLModel()->
- GetKeywordShortName(keyword, &is_extension_keyword);
+ const string16 short_name = model->GetKeywordShortName(keyword,
+ &is_extension_keyword);
int message_id = is_extension_keyword ?
IDS_OMNIBOX_EXTENSION_KEYWORD_TEXT : IDS_OMNIBOX_KEYWORD_TEXT;
full_label_.SetText(UTF16ToWide(
diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_win.cc b/chrome/browser/ui/views/omnibox/omnibox_view_win.cc
index 70f6443..25567e2 100644
--- a/chrome/browser/ui/views/omnibox/omnibox_view_win.cc
+++ b/chrome/browser/ui/views/omnibox/omnibox_view_win.cc
@@ -29,7 +29,7 @@
#include "chrome/browser/net/url_fixer_upper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/ui/views/location_bar/location_bar_view.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/browser/user_metrics.h"
diff --git a/chrome/browser/ui/webui/options/browser_options_handler.cc b/chrome/browser/ui/webui/options/browser_options_handler.cc
index 49733b1..6a31815 100644
--- a/chrome/browser/ui/webui/options/browser_options_handler.cc
+++ b/chrome/browser/ui/webui/options/browser_options_handler.cc
@@ -21,7 +21,8 @@
#include "chrome/browser/prefs/session_startup_pref.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/webui/favicon_source.h"
#include "chrome/browser/ui/webui/options/options_managed_banner_handler.h"
#include "chrome/common/pref_names.h"
@@ -36,7 +37,7 @@
#include "ui/base/l10n/l10n_util.h"
BrowserOptionsHandler::BrowserOptionsHandler()
- : template_url_model_(NULL), startup_custom_pages_table_model_(NULL) {
+ : template_url_service_(NULL), startup_custom_pages_table_model_(NULL) {
#if !defined(OS_MACOSX)
default_browser_worker_ = new ShellIntegration::DefaultBrowserWorker(this);
#endif
@@ -45,8 +46,8 @@ BrowserOptionsHandler::BrowserOptionsHandler()
BrowserOptionsHandler::~BrowserOptionsHandler() {
if (default_browser_worker_.get())
default_browser_worker_->ObserverDestroyed();
- if (template_url_model_)
- template_url_model_->RemoveObserver(this);
+ if (template_url_service_)
+ template_url_service_->RemoveObserver(this);
}
void BrowserOptionsHandler::GetLocalizedValues(
@@ -245,17 +246,17 @@ void BrowserOptionsHandler::SetDefaultBrowserUIString(int status_string_id) {
*status_string, *is_default, *can_be_default);
}
-void BrowserOptionsHandler::OnTemplateURLModelChanged() {
- if (!template_url_model_ || !template_url_model_->loaded())
+void BrowserOptionsHandler::OnTemplateURLServiceChanged() {
+ if (!template_url_service_ || !template_url_service_->loaded())
return;
const TemplateURL* default_url =
- template_url_model_->GetDefaultSearchProvider();
+ template_url_service_->GetDefaultSearchProvider();
int default_index = 0;
ListValue search_engines;
std::vector<const TemplateURL*> model_urls =
- template_url_model_->GetTemplateURLs();
+ template_url_service_->GetTemplateURLs();
for (size_t i = 0; i < model_urls.size(); ++i) {
if (!model_urls[i]->ShowInDefaultList())
continue;
@@ -270,7 +271,7 @@ void BrowserOptionsHandler::OnTemplateURLModelChanged() {
scoped_ptr<Value> default_value(Value::CreateIntegerValue(default_index));
scoped_ptr<Value> default_managed(Value::CreateBooleanValue(
- template_url_model_->is_default_search_managed()));
+ template_url_service_->is_default_search_managed()));
web_ui_->CallJavascriptFunction("BrowserOptions.updateSearchEngines",
search_engines, *default_value,
@@ -285,20 +286,21 @@ void BrowserOptionsHandler::SetDefaultSearchEngine(const ListValue* args) {
}
std::vector<const TemplateURL*> model_urls =
- template_url_model_->GetTemplateURLs();
+ template_url_service_->GetTemplateURLs();
if (selected_index >= 0 &&
selected_index < static_cast<int>(model_urls.size()))
- template_url_model_->SetDefaultSearchProvider(model_urls[selected_index]);
+ template_url_service_->SetDefaultSearchProvider(model_urls[selected_index]);
UserMetricsRecordAction(UserMetricsAction("Options_SearchEngineChanged"));
}
void BrowserOptionsHandler::UpdateSearchEngines() {
- template_url_model_ = web_ui_->GetProfile()->GetTemplateURLModel();
- if (template_url_model_) {
- template_url_model_->Load();
- template_url_model_->AddObserver(this);
- OnTemplateURLModelChanged();
+ template_url_service_ = TemplateURLServiceFactory::GetForProfile(
+ web_ui_->GetProfile());
+ if (template_url_service_) {
+ template_url_service_->Load();
+ template_url_service_->AddObserver(this);
+ OnTemplateURLServiceChanged();
}
}
diff --git a/chrome/browser/ui/webui/options/browser_options_handler.h b/chrome/browser/ui/webui/options/browser_options_handler.h
index e14a6a5..7264581 100644
--- a/chrome/browser/ui/webui/options/browser_options_handler.h
+++ b/chrome/browser/ui/webui/options/browser_options_handler.h
@@ -8,7 +8,7 @@
#include "chrome/browser/autocomplete/autocomplete_controller_delegate.h"
#include "chrome/browser/prefs/pref_member.h"
-#include "chrome/browser/search_engines/template_url_model_observer.h"
+#include "chrome/browser/search_engines/template_url_service_observer.h"
#include "chrome/browser/shell_integration.h"
#include "chrome/browser/ui/webui/options/options_ui.h"
#include "ui/base/models/table_model_observer.h"
@@ -16,13 +16,13 @@
class AutocompleteController;
class CustomHomePagesTableModel;
class OptionsManagedBannerHandler;
-class TemplateURLModel;
+class TemplateURLService;
// Chrome browser options page UI handler.
class BrowserOptionsHandler : public OptionsPageUIHandler,
public AutocompleteControllerDelegate,
public ShellIntegration::DefaultWebClientObserver,
- public TemplateURLModelObserver,
+ public TemplateURLServiceObserver,
public ui::TableModelObserver {
public:
BrowserOptionsHandler();
@@ -41,8 +41,8 @@ class BrowserOptionsHandler : public OptionsPageUIHandler,
virtual void SetDefaultWebClientUIState(
ShellIntegration::DefaultWebClientUIState state);
- // TemplateURLModelObserver implementation.
- virtual void OnTemplateURLModelChanged();
+ // TemplateURLServiceObserver implementation.
+ virtual void OnTemplateURLServiceChanged();
// ui::TableModelObserver implementation.
virtual void OnModelChanged();
@@ -112,11 +112,11 @@ class BrowserOptionsHandler : public OptionsPageUIHandler,
StringPrefMember homepage_;
BooleanPrefMember default_browser_policy_;
- TemplateURLModel* template_url_model_; // Weak.
+ TemplateURLService* template_url_service_; // Weak.
// TODO(stuartmorgan): Once there are no other clients of
// CustomHomePagesTableModel, consider changing it to something more like
- // TemplateURLModel.
+ // TemplateURLService.
scoped_ptr<CustomHomePagesTableModel> startup_custom_pages_table_model_;
scoped_ptr<OptionsManagedBannerHandler> banner_handler_;
diff --git a/chrome/browser/ui/webui/options/search_engine_manager_handler.cc b/chrome/browser/ui/webui/options/search_engine_manager_handler.cc
index 69f0b8d..0ba7a3b 100644
--- a/chrome/browser/ui/webui/options/search_engine_manager_handler.cc
+++ b/chrome/browser/ui/webui/options/search_engine_manager_handler.cc
@@ -10,7 +10,7 @@
#include "base/values.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/ui/search_engines/keyword_editor_controller.h"
#include "chrome/browser/ui/search_engines/template_url_table_model.h"
#include "chrome/common/url_constants.h"
diff --git a/chrome/browser/webdata/web_data_service.h b/chrome/browser/webdata/web_data_service.h
index aa494ef..f886ee4 100644
--- a/chrome/browser/webdata/web_data_service.h
+++ b/chrome/browser/webdata/web_data_service.h
@@ -299,7 +299,7 @@ class WebDataService
// done on the background thread.
//
// Many of the keyword related methods do not return a handle. This is because
- // the caller (TemplateURLModel) does not need to know when the request is
+ // the caller (TemplateURLService) does not need to know when the request is
// done.
void AddKeyword(const TemplateURL& url);
@@ -485,8 +485,8 @@ class WebDataService
#endif
protected:
- friend class TemplateURLModelTest;
- friend class TemplateURLModelTestingProfile;
+ friend class TemplateURLServiceTest;
+ friend class TemplateURLServiceTestingProfile;
friend class WebDataServiceTest;
friend class WebDataRequest;
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index bad8731..744e12a 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -1842,9 +1842,11 @@
'browser/search_engines/template_url_fetcher.h',
'browser/search_engines/template_url_fetcher_callbacks.h',
'browser/search_engines/template_url_id.h',
- 'browser/search_engines/template_url_model.cc',
- 'browser/search_engines/template_url_model.h',
- 'browser/search_engines/template_url_model_observer.h',
+ 'browser/search_engines/template_url_service.cc',
+ 'browser/search_engines/template_url_service.h',
+ 'browser/search_engines/template_url_service_factory.cc',
+ 'browser/search_engines/template_url_service_factory.h',
+ 'browser/search_engines/template_url_service_observer.h',
'browser/search_engines/template_url_parser.cc',
'browser/search_engines/template_url_parser.h',
'browser/search_engines/template_url_prepopulate_data.cc',
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index b6be89f..9cae015 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1562,9 +1562,9 @@
'browser/search_engines/search_host_to_urls_map_unittest.cc',
'browser/search_engines/search_provider_install_data_unittest.cc',
'browser/search_engines/template_url_fetcher_unittest.cc',
- 'browser/search_engines/template_url_model_test_util.cc',
- 'browser/search_engines/template_url_model_test_util.h',
- 'browser/search_engines/template_url_model_unittest.cc',
+ 'browser/search_engines/template_url_service_test_util.cc',
+ 'browser/search_engines/template_url_service_test_util.h',
+ 'browser/search_engines/template_url_service_unittest.cc',
'browser/search_engines/template_url_parser_unittest.cc',
'browser/search_engines/template_url_prepopulate_data_unittest.cc',
'browser/search_engines/template_url_scraper_unittest.cc',
diff --git a/chrome/test/testing_profile.cc b/chrome/test/testing_profile.cc
index 1b6cd7b..3d4d927 100644
--- a/chrome/test/testing_profile.cc
+++ b/chrome/test/testing_profile.cc
@@ -35,7 +35,8 @@
#include "chrome/browser/prerender/prerender_manager.h"
#include "chrome/browser/profiles/profile_dependency_manager.h"
#include "chrome/browser/search_engines/template_url_fetcher.h"
-#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/sessions/session_service_factory.h"
#include "chrome/browser/sessions/tab_restore_service_factory.h"
#include "chrome/browser/sync/profile_sync_service_mock.h"
@@ -163,6 +164,7 @@ TestingProfile::TestingProfile()
this, CreateTestDesktopNotificationService);
SessionServiceFactory::GetInstance()->SetTestingFactory(this, NULL);
TabRestoreServiceFactory::GetInstance()->SetTestingFactory(this, NULL);
+ TemplateURLServiceFactory::GetInstance()->SetTestingFactory(this, NULL);
}
TestingProfile::~TestingProfile() {
@@ -312,12 +314,13 @@ void TestingProfile::CreateTemplateURLFetcher() {
template_url_fetcher_.reset(new TemplateURLFetcher(this));
}
-void TestingProfile::CreateTemplateURLModel() {
- SetTemplateURLModel(new TemplateURLModel(this));
+static ProfileKeyedService* BuildTemplateURLService(Profile* profile) {
+ return new TemplateURLService(profile);
}
-void TestingProfile::SetTemplateURLModel(TemplateURLModel* model) {
- template_url_model_.reset(model);
+void TestingProfile::CreateTemplateURLService() {
+ TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(
+ this, BuildTemplateURLService);
}
ExtensionService* TestingProfile::CreateExtensionService(
@@ -356,13 +359,17 @@ TestingPrefService* TestingProfile::GetTestingPrefService() {
return testing_prefs_;
}
+TestingProfile* TestingProfile::AsTestingProfile() {
+ return this;
+}
+
std::string TestingProfile::GetProfileName() {
return std::string("testing_profile");
}
ProfileId TestingProfile::GetRuntimeId() {
- return reinterpret_cast<ProfileId>(this);
- }
+ return reinterpret_cast<ProfileId>(this);
+}
bool TestingProfile::IsOffTheRecord() {
return incognito_;
@@ -494,10 +501,6 @@ PrefService* TestingProfile::GetPrefs() {
return prefs_.get();
}
-TemplateURLModel* TestingProfile::GetTemplateURLModel() {
- return template_url_model_.get();
-}
-
TemplateURLFetcher* TestingProfile::GetTemplateURLFetcher() {
return template_url_fetcher_.get();
}
diff --git a/chrome/test/testing_profile.h b/chrome/test/testing_profile.h
index 2083bea..b461f5e5 100644
--- a/chrome/test/testing_profile.h
+++ b/chrome/test/testing_profile.h
@@ -44,7 +44,7 @@ class HostContentSettingsMap;
class PrefService;
class ProfileDependencyManager;
class ProfileSyncService;
-class TemplateURLModel;
+class TemplateURLService;
class TestingPrefService;
class ThemeService;
class WebKitContext;
@@ -112,16 +112,14 @@ class TestingProfile : public Profile {
// Blocks until TopSites finishes loading.
void BlockUntilTopSitesLoaded();
- // Creates a TemplateURLModel. If not invoked the TemplateURLModel is NULL.
- // Creates a TemplateURLFetcher. If not invoked, the TemplateURLFetcher is
- // NULL.
+ // Creates a TemplateURLService. If not invoked the TemplateURLService is
+ // NULL. Creates a TemplateURLFetcher. If not invoked, the
+ // TemplateURLFetcher is NULL.
void CreateTemplateURLFetcher();
- // Creates a TemplateURLModel. If not invoked, the TemplateURLModel is NULL.
- void CreateTemplateURLModel();
-
- // Sets the TemplateURLModel. Takes ownership of it.
- void SetTemplateURLModel(TemplateURLModel* model);
+ // Creates a TemplateURLService. If not invoked, the TemplateURLService is
+ // NULL.
+ void CreateTemplateURLService();
// Creates an ExtensionService initialized with the testing profile and
// returns it. The profile keeps its own copy of a scoped_refptr to the
@@ -133,6 +131,8 @@ class TestingProfile : public Profile {
TestingPrefService* GetTestingPrefService();
+ virtual TestingProfile* AsTestingProfile();
+
virtual std::string GetProfileName();
virtual ProfileId GetRuntimeId();
@@ -181,7 +181,6 @@ class TestingProfile : public Profile {
// TestingPrefService takes ownership of |prefs|.
void SetPrefService(PrefService* prefs);
virtual PrefService* GetPrefs();
- virtual TemplateURLModel* GetTemplateURLModel();
virtual TemplateURLFetcher* GetTemplateURLFetcher();
virtual history::TopSites* GetTopSites();
virtual history::TopSites* GetTopSitesWithoutCreating();
@@ -334,9 +333,6 @@ class TestingProfile : public Profile {
// invoked.
scoped_ptr<TemplateURLFetcher> template_url_fetcher_;
- // The TemplateURLModel. Only created if CreateTemplateURLModel is invoked.
- scoped_ptr<TemplateURLModel> template_url_model_;
-
scoped_ptr<NTPResourceCache> ntp_resource_cache_;
// Internally, this is a TestURLRequestContextGetter that creates a dummy
diff --git a/content/common/notification_type.h b/content/common/notification_type.h
index 0ca3f88..3eb00b4 100644
--- a/content/common/notification_type.h
+++ b/content/common/notification_type.h
@@ -730,10 +730,10 @@ class NotificationType {
// Non-history storage services --------------------------------------------
- // Notification that the TemplateURLModel has finished loading from the
- // database. The source is the TemplateURLModel, and the details are
+ // Notification that the TemplateURLService has finished loading from the
+ // database. The source is the TemplateURLService, and the details are
// NoDetails.
- TEMPLATE_URL_MODEL_LOADED,
+ TEMPLATE_URL_SERVICE_LOADED,
// Sent when a TemplateURL is removed from the model. The source is the
// Profile, and the details the id of the TemplateURL being removed.