Chromium Code Reviews| Index: chrome/browser/ui/app_list/app_list_view_delegate.cc |
| diff --git a/chrome/browser/ui/app_list/app_list_view_delegate.cc b/chrome/browser/ui/app_list/app_list_view_delegate.cc |
| index 897dca3ae4002b8e5a7913fda80b6aa49ff0a38f..e0aec05048d268053ca0b349a0c36c9a6a5970b9 100644 |
| --- a/chrome/browser/ui/app_list/app_list_view_delegate.cc |
| +++ b/chrome/browser/ui/app_list/app_list_view_delegate.cc |
| @@ -20,6 +20,7 @@ |
| #include "chrome/browser/profiles/profile_manager.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/ui/app_list/app_list_controller_delegate.h" |
| #include "chrome/browser/ui/app_list/app_list_service.h" |
| #include "chrome/browser/ui/app_list/app_list_syncable_service.h" |
| @@ -37,6 +38,7 @@ |
| #include "chrome/common/chrome_switches.h" |
| #include "chrome/common/extensions/extension_constants.h" |
| #include "chrome/common/url_constants.h" |
| +#include "components/search_engines/template_url_prepopulate_data.h" |
| #include "components/signin/core/browser/signin_manager.h" |
| #include "content/public/browser/browser_thread.h" |
| #include "content/public/browser/notification_service.h" |
| @@ -160,6 +162,7 @@ AppListViewDelegate::AppListViewDelegate(AppListControllerDelegate* controller) |
| profile_(NULL), |
| model_(NULL), |
| is_voice_query_(false), |
| + template_url_service_observer_(this), |
| scoped_observer_(this) { |
| // TODO(vadimt): Remove ScopedTracker below once crbug.com/431326 is fixed. |
| tracked_objects::ScopedTracker tracking_profile( |
| @@ -288,6 +291,9 @@ void AppListViewDelegate::SetProfile(Profile* new_profile) { |
| tracked_objects::ScopedTracker tracking_profile3( |
| FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| "431326 AppListViewDelegate::SetProfile3")); |
| + template_url_service_observer_.RemoveAll(); |
| + template_url_service_observer_.Add( |
| + TemplateURLServiceFactory::GetForProfile(profile_)); |
| model_ = |
| app_list::AppListSyncableServiceFactory::GetForProfile(profile_)->model(); |
| @@ -299,6 +305,7 @@ void AppListViewDelegate::SetProfile(Profile* new_profile) { |
| SetUpSearchUI(); |
| SetUpProfileSwitcher(); |
| SetUpCustomLauncherPages(); |
| + OnTemplateURLServiceChanged(); |
| // TODO(vadimt): Remove ScopedTracker below once crbug.com/431326 is fixed. |
| tracked_objects::ScopedTracker tracking_profile4( |
| @@ -783,6 +790,24 @@ void AppListViewDelegate::RemoveObserver( |
| observers_.RemoveObserver(observer); |
| } |
| +void AppListViewDelegate::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; |
| + |
| + model_->SetSearchEngineIsGoogle(is_google); |
| + |
| + app_list::StartPageService* start_page_service = |
| + app_list::StartPageService::Get(profile_); |
| + if (start_page_service) |
|
Matt Giuca
2015/02/17 00:23:34
Do you know when the SPS gets created? I'm worried
calamity
2015/02/17 06:16:37
Hmm. I guess that's the most resilient thing to do
|
| + start_page_service->set_doodle_enabled(is_google); |
| +} |
| + |
| void AppListViewDelegate::Observe(int type, |
| const content::NotificationSource& source, |
| const content::NotificationDetails& details) { |