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

Side by Side Diff: chrome/browser/ui/app_list/app_list_view_delegate.cc

Issue 1983773002: Cache SearchEngineType of TemplateURL (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@refactor-extracting-terms-from-template-url
Patch Set: Fix typo Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/app_list/app_list_view_delegate.h" 5 #include "chrome/browser/ui/app_list/app_list_view_delegate.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 25 matching lines...) Expand all
36 #include "chrome/browser/ui/apps/chrome_app_delegate.h" 36 #include "chrome/browser/ui/apps/chrome_app_delegate.h"
37 #include "chrome/browser/ui/browser_finder.h" 37 #include "chrome/browser/ui/browser_finder.h"
38 #include "chrome/browser/ui/chrome_pages.h" 38 #include "chrome/browser/ui/chrome_pages.h"
39 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" 39 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
40 #include "chrome/browser/web_applications/web_app.h" 40 #include "chrome/browser/web_applications/web_app.h"
41 #include "chrome/common/chrome_switches.h" 41 #include "chrome/common/chrome_switches.h"
42 #include "chrome/common/extensions/extension_constants.h" 42 #include "chrome/common/extensions/extension_constants.h"
43 #include "chrome/common/pref_names.h" 43 #include "chrome/common/pref_names.h"
44 #include "chrome/common/url_constants.h" 44 #include "chrome/common/url_constants.h"
45 #include "components/prefs/pref_service.h" 45 #include "components/prefs/pref_service.h"
46 #include "components/search_engines/template_url_prepopulate_data.h"
47 #include "components/signin/core/browser/signin_manager.h" 46 #include "components/signin/core/browser/signin_manager.h"
48 #include "components/user_prefs/user_prefs.h" 47 #include "components/user_prefs/user_prefs.h"
49 #include "content/public/browser/browser_thread.h" 48 #include "content/public/browser/browser_thread.h"
50 #include "content/public/browser/notification_service.h" 49 #include "content/public/browser/notification_service.h"
51 #include "content/public/browser/page_navigator.h" 50 #include "content/public/browser/page_navigator.h"
52 #include "content/public/browser/render_view_host.h" 51 #include "content/public/browser/render_view_host.h"
53 #include "content/public/browser/render_widget_host.h" 52 #include "content/public/browser/render_widget_host.h"
54 #include "content/public/browser/render_widget_host_view.h" 53 #include "content/public/browser/render_widget_host_view.h"
55 #include "content/public/browser/speech_recognition_session_preamble.h" 54 #include "content/public/browser/speech_recognition_session_preamble.h"
56 #include "content/public/browser/user_metrics.h" 55 #include "content/public/browser/user_metrics.h"
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 821
823 void AppListViewDelegate::OnTemplateURLServiceChanged() { 822 void AppListViewDelegate::OnTemplateURLServiceChanged() {
824 if (!app_list::switches::IsExperimentalAppListEnabled()) 823 if (!app_list::switches::IsExperimentalAppListEnabled())
825 return; 824 return;
826 825
827 TemplateURLService* template_url_service = 826 TemplateURLService* template_url_service =
828 TemplateURLServiceFactory::GetForProfile(profile_); 827 TemplateURLServiceFactory::GetForProfile(profile_);
829 const TemplateURL* default_provider = 828 const TemplateURL* default_provider =
830 template_url_service->GetDefaultSearchProvider(); 829 template_url_service->GetDefaultSearchProvider();
831 bool is_google = 830 bool is_google =
832 TemplateURLPrepopulateData::GetEngineType( 831 default_provider->GetEngineType(
833 *default_provider, template_url_service->search_terms_data()) == 832 template_url_service->search_terms_data()) ==
834 SEARCH_ENGINE_GOOGLE; 833 SEARCH_ENGINE_GOOGLE;
835 834
836 model_->SetSearchEngineIsGoogle(is_google); 835 model_->SetSearchEngineIsGoogle(is_google);
837 836
838 app_list::StartPageService* start_page_service = 837 app_list::StartPageService* start_page_service =
839 app_list::StartPageService::Get(profile_); 838 app_list::StartPageService::Get(profile_);
840 if (start_page_service) 839 if (start_page_service)
841 start_page_service->set_search_engine_is_google(is_google); 840 start_page_service->set_search_engine_is_google(is_google);
842 } 841 }
843 842
844 void AppListViewDelegate::Observe(int type, 843 void AppListViewDelegate::Observe(int type,
845 const content::NotificationSource& source, 844 const content::NotificationSource& source,
846 const content::NotificationDetails& details) { 845 const content::NotificationDetails& details) {
847 DCHECK_EQ(chrome::NOTIFICATION_APP_TERMINATING, type); 846 DCHECK_EQ(chrome::NOTIFICATION_APP_TERMINATING, type);
848 847
849 FOR_EACH_OBSERVER(app_list::AppListViewDelegateObserver, observers_, 848 FOR_EACH_OBSERVER(app_list::AppListViewDelegateObserver, observers_,
850 OnShutdown()); 849 OnShutdown());
851 850
852 SetProfile(nullptr); // Ensures launcher page web contents are torn down. 851 SetProfile(nullptr); // Ensures launcher page web contents are torn down.
853 852
854 // SigninManagerFactory is not a leaky singleton (unlike this class), and 853 // SigninManagerFactory is not a leaky singleton (unlike this class), and
855 // its destructor will check that it has no remaining observers. 854 // its destructor will check that it has no remaining observers.
856 scoped_observer_.RemoveAll(); 855 scoped_observer_.RemoveAll();
857 SigninManagerFactory::GetInstance()->RemoveObserver(this); 856 SigninManagerFactory::GetInstance()->RemoveObserver(this);
858 } 857 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698