| Index: chrome/browser/ui/app_list/start_page_service.cc
|
| diff --git a/chrome/browser/ui/app_list/start_page_service.cc b/chrome/browser/ui/app_list/start_page_service.cc
|
| index c65a3e03a34990a4c1c607e69e34715d0100894b..817a3ff260213ddf4bb9aa6d0b40f77ac447cbf4 100644
|
| --- a/chrome/browser/ui/app_list/start_page_service.cc
|
| +++ b/chrome/browser/ui/app_list/start_page_service.cc
|
| @@ -19,6 +19,7 @@
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/search/hotword_service.h"
|
| #include "chrome/browser/search/hotword_service_factory.h"
|
| +#include "chrome/browser/search_engines/template_url_service_factory.h"
|
| #include "chrome/browser/search_engines/ui_thread_search_terms_data.h"
|
| #include "chrome/browser/ui/app_list/speech_auth_helper.h"
|
| #include "chrome/browser/ui/app_list/speech_recognizer.h"
|
| @@ -30,6 +31,8 @@
|
| #include "chrome/common/chrome_switches.h"
|
| #include "chrome/common/pref_names.h"
|
| #include "chrome/common/url_constants.h"
|
| +#include "components/search_engines/template_url_prepopulate_data.h"
|
| +#include "components/search_engines/template_url_service.h"
|
| #include "components/ui/zoom/zoom_controller.h"
|
| #include "content/public/browser/browser_thread.h"
|
| #include "content/public/browser/notification_details.h"
|
| @@ -279,10 +282,20 @@ StartPageService::StartPageService(Profile* profile)
|
| if (app_list::switches::IsExperimentalAppListEnabled())
|
| LoadContents();
|
|
|
| + TemplateURLService* template_url_service =
|
| + TemplateURLServiceFactory::GetForProfile(profile_);
|
| + if (template_url_service)
|
| + template_url_service->AddObserver(this);
|
| +
|
| network_change_observer_.reset(new NetworkChangeObserver(this));
|
| }
|
|
|
| -StartPageService::~StartPageService() {}
|
| +StartPageService::~StartPageService() {
|
| + TemplateURLService* template_url_service =
|
| + TemplateURLServiceFactory::GetForProfile(profile_);
|
| + if (template_url_service)
|
| + template_url_service->RemoveObserver(this);
|
| +}
|
|
|
| void StartPageService::AddObserver(StartPageObserver* observer) {
|
| observers_.AddObserver(observer);
|
| @@ -494,6 +507,24 @@ void StartPageService::GetSpeechAuthParameters(std::string* auth_scope,
|
| }
|
| }
|
|
|
| +void StartPageService::OnTemplateURLServiceChanged() {
|
| + TemplateURLService* template_url_service =
|
| + TemplateURLServiceFactory::GetForProfile(profile_);
|
| + const TemplateURL* default_provider =
|
| + template_url_service->GetDefaultSearchProvider();
|
| + bool is_google =
|
| + TemplateURLPrepopulateData::GetEngineType(
|
| + *default_provider, template_url_service->search_terms_data()) ==
|
| + SEARCH_ENGINE_GOOGLE;
|
| +
|
| + contents_->GetWebUI()->CallJavascriptFunction(
|
| + "appList.startPage.onSearchEngineChanged",
|
| + base::FundamentalValue(is_google));
|
| +
|
| + if (is_google)
|
| + FetchDoodleJson();
|
| +}
|
| +
|
| void StartPageService::Shutdown() {
|
| UnloadContents();
|
| #if defined(OS_CHROMEOS)
|
| @@ -531,7 +562,7 @@ void StartPageService::WebUILoaded() {
|
| cb.Run();
|
| pending_webui_callbacks_.clear();
|
|
|
| - FetchDoodleJson();
|
| + OnTemplateURLServiceChanged();
|
| }
|
|
|
| void StartPageService::LoadContents() {
|
|
|