Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(687)

Unified Diff: chrome/browser/ui/app_list/app_list_view_delegate.cc

Issue 907833002: Hide experimental app list Google logo and custom launcher page when search engine is not Google. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@update_app_list_bg_color
Patch Set: address comment, add service dependency Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 b95f5e706c5ced402ee5b768fdf25c2804fe8bd5..9820a1ccd3d28e878277d726fd62670412dd58da 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"
@@ -158,6 +160,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(
@@ -286,6 +289,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();
@@ -297,6 +303,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(
@@ -773,6 +780,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)
+ start_page_service->set_search_engine_is_google(is_google);
+}
+
void AppListViewDelegate::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
« no previous file with comments | « chrome/browser/ui/app_list/app_list_view_delegate.h ('k') | chrome/browser/ui/app_list/start_page_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698