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

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: Created 4 years, 7 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 769 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 825
827 void AppListViewDelegate::OnTemplateURLServiceChanged() { 826 void AppListViewDelegate::OnTemplateURLServiceChanged() {
828 if (!app_list::switches::IsExperimentalAppListEnabled()) 827 if (!app_list::switches::IsExperimentalAppListEnabled())
829 return; 828 return;
830 829
831 TemplateURLService* template_url_service = 830 TemplateURLService* template_url_service =
832 TemplateURLServiceFactory::GetForProfile(profile_); 831 TemplateURLServiceFactory::GetForProfile(profile_);
833 const TemplateURL* default_provider = 832 const TemplateURL* default_provider =
834 template_url_service->GetDefaultSearchProvider(); 833 template_url_service->GetDefaultSearchProvider();
835 bool is_google = 834 bool is_google =
836 TemplateURLPrepopulateData::GetEngineType( 835 default_provider->GetEngineType(
837 *default_provider, template_url_service->search_terms_data()) == 836 template_url_service->search_terms_data()) ==
838 SEARCH_ENGINE_GOOGLE; 837 SEARCH_ENGINE_GOOGLE;
839 838
840 model_->SetSearchEngineIsGoogle(is_google); 839 model_->SetSearchEngineIsGoogle(is_google);
841 840
842 app_list::StartPageService* start_page_service = 841 app_list::StartPageService* start_page_service =
843 app_list::StartPageService::Get(profile_); 842 app_list::StartPageService::Get(profile_);
844 if (start_page_service) 843 if (start_page_service)
845 start_page_service->set_search_engine_is_google(is_google); 844 start_page_service->set_search_engine_is_google(is_google);
846 } 845 }
847 846
848 void AppListViewDelegate::Observe(int type, 847 void AppListViewDelegate::Observe(int type,
849 const content::NotificationSource& source, 848 const content::NotificationSource& source,
850 const content::NotificationDetails& details) { 849 const content::NotificationDetails& details) {
851 switch (type) { 850 switch (type) {
852 case chrome::NOTIFICATION_APP_TERMINATING: 851 case chrome::NOTIFICATION_APP_TERMINATING:
853 FOR_EACH_OBSERVER( 852 FOR_EACH_OBSERVER(
854 app_list::AppListViewDelegateObserver, observers_, OnShutdown()); 853 app_list::AppListViewDelegateObserver, observers_, OnShutdown());
855 854
856 SetProfile(NULL); // Ensures launcher page web contents are torn down. 855 SetProfile(NULL); // Ensures launcher page web contents are torn down.
857 856
858 // SigninManagerFactory is not a leaky singleton (unlike this class), and 857 // SigninManagerFactory is not a leaky singleton (unlike this class), and
859 // its destructor will check that it has no remaining observers. 858 // its destructor will check that it has no remaining observers.
860 scoped_observer_.RemoveAll(); 859 scoped_observer_.RemoveAll();
861 SigninManagerFactory::GetInstance()->RemoveObserver(this); 860 SigninManagerFactory::GetInstance()->RemoveObserver(this);
862 break; 861 break;
863 default: 862 default:
864 NOTREACHED(); 863 NOTREACHED();
865 } 864 }
866 } 865 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698