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

Side by Side Diff: chrome/browser/ui/webui/options/browser_options_handler.cc

Issue 895803003: [Profiles] Remove the NotificationService from the ProfileInfoCache (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: copy paste the right function 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 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/webui/options/browser_options_handler.h" 5 #include "chrome/browser/ui/webui/options/browser_options_handler.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 &BrowserOptionsHandler::HandleRefreshExtensionControlIndicators, 807 &BrowserOptionsHandler::HandleRefreshExtensionControlIndicators,
808 base::Unretained(this))); 808 base::Unretained(this)));
809 #endif // defined(OS_WIN) 809 #endif // defined(OS_WIN)
810 web_ui()->RegisterMessageCallback("metricsReportingCheckboxChanged", 810 web_ui()->RegisterMessageCallback("metricsReportingCheckboxChanged",
811 base::Bind(&BrowserOptionsHandler::HandleMetricsReportingChange, 811 base::Bind(&BrowserOptionsHandler::HandleMetricsReportingChange,
812 base::Unretained(this))); 812 base::Unretained(this)));
813 } 813 }
814 814
815 void BrowserOptionsHandler::Uninitialize() { 815 void BrowserOptionsHandler::Uninitialize() {
816 registrar_.RemoveAll(); 816 registrar_.RemoveAll();
817 g_browser_process->profile_manager()->
818 GetProfileInfoCache().RemoveObserver(this);
817 #if defined(OS_WIN) 819 #if defined(OS_WIN)
818 ExtensionRegistry::Get(Profile::FromWebUI(web_ui()))->RemoveObserver(this); 820 ExtensionRegistry::Get(Profile::FromWebUI(web_ui()))->RemoveObserver(this);
819 #endif 821 #endif
820 #if defined(OS_CHROMEOS) 822 #if defined(OS_CHROMEOS)
821 policy::ConsumerManagementService* consumer_management = 823 policy::ConsumerManagementService* consumer_management =
822 g_browser_process->platform_part()->browser_policy_connector_chromeos()-> 824 g_browser_process->platform_part()->browser_policy_connector_chromeos()->
823 GetConsumerManagementService(); 825 GetConsumerManagementService();
824 if (consumer_management) 826 if (consumer_management)
825 consumer_management->RemoveObserver(this); 827 consumer_management->RemoveObserver(this);
826 #endif 828 #endif
(...skipping 30 matching lines...) Expand all
857 if (zoom_level_prefs) { 859 if (zoom_level_prefs) {
858 default_zoom_level_subscription_ = 860 default_zoom_level_subscription_ =
859 zoom_level_prefs->RegisterDefaultZoomLevelCallback( 861 zoom_level_prefs->RegisterDefaultZoomLevelCallback(
860 base::Bind(&BrowserOptionsHandler::SetupPageZoomSelector, 862 base::Bind(&BrowserOptionsHandler::SetupPageZoomSelector,
861 base::Unretained(this))); 863 base::Unretained(this)));
862 } 864 }
863 865
864 g_browser_process->policy_service()->AddObserver( 866 g_browser_process->policy_service()->AddObserver(
865 policy::POLICY_DOMAIN_CHROME, this); 867 policy::POLICY_DOMAIN_CHROME, this);
866 868
869 g_browser_process->profile_manager()->GetProfileInfoCache().AddObserver(this);
870
867 ProfileSyncService* sync_service( 871 ProfileSyncService* sync_service(
868 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile)); 872 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile));
869 // TODO(blundell): Use a ScopedObserver to observe the PSS so that cleanup on 873 // TODO(blundell): Use a ScopedObserver to observe the PSS so that cleanup on
870 // destruction is automatic. 874 // destruction is automatic.
871 if (sync_service) 875 if (sync_service)
872 sync_service->AddObserver(this); 876 sync_service->AddObserver(this);
873 877
874 SigninManagerBase* signin_manager( 878 SigninManagerBase* signin_manager(
875 SigninManagerFactory::GetInstance()->GetForProfile(profile)); 879 SigninManagerFactory::GetInstance()->GetForProfile(profile));
876 if (signin_manager) 880 if (signin_manager)
877 signin_observer_.Add(signin_manager); 881 signin_observer_.Add(signin_manager);
878 882
879 // Create our favicon data source. 883 // Create our favicon data source.
880 content::URLDataSource::Add( 884 content::URLDataSource::Add(
881 profile, new FaviconSource(profile, FaviconSource::FAVICON)); 885 profile, new FaviconSource(profile, FaviconSource::FAVICON));
882 886
883 default_browser_policy_.Init( 887 default_browser_policy_.Init(
884 prefs::kDefaultBrowserSettingEnabled, 888 prefs::kDefaultBrowserSettingEnabled,
885 g_browser_process->local_state(), 889 g_browser_process->local_state(),
886 base::Bind(&BrowserOptionsHandler::UpdateDefaultBrowserState, 890 base::Bind(&BrowserOptionsHandler::UpdateDefaultBrowserState,
887 base::Unretained(this))); 891 base::Unretained(this)));
888 892
889 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED,
890 content::NotificationService::AllSources());
891 #if defined(OS_CHROMEOS) 893 #if defined(OS_CHROMEOS)
892 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, 894 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED,
893 content::NotificationService::AllSources()); 895 content::NotificationService::AllSources());
894 #endif 896 #endif
895 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, 897 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
896 content::Source<ThemeService>( 898 content::Source<ThemeService>(
897 ThemeServiceFactory::GetForProfile(profile))); 899 ThemeServiceFactory::GetForProfile(profile)));
898 registrar_.Add(this, chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED, 900 registrar_.Add(this, chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED,
899 content::Source<Profile>(profile)); 901 content::Source<Profile>(profile));
900 AddTemplateUrlServiceObserver(); 902 AddTemplateUrlServiceObserver();
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
1276 1278
1277 switch (type) { 1279 switch (type) {
1278 case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: 1280 case chrome::NOTIFICATION_BROWSER_THEME_CHANGED:
1279 ObserveThemeChanged(); 1281 ObserveThemeChanged();
1280 break; 1282 break;
1281 #if defined(OS_CHROMEOS) 1283 #if defined(OS_CHROMEOS)
1282 case chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED: 1284 case chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED:
1283 UpdateAccountPicture(); 1285 UpdateAccountPicture();
1284 break; 1286 break;
1285 #endif 1287 #endif
1286 case chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED:
1287 SendProfilesInfo();
1288 break;
1289 case chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED: 1288 case chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED:
1290 // Update our sync/signin status display. 1289 // Update our sync/signin status display.
1291 OnStateChanged(); 1290 OnStateChanged();
1292 break; 1291 break;
1293 default: 1292 default:
1294 NOTREACHED(); 1293 NOTREACHED();
1295 } 1294 }
1296 } 1295 }
1297 1296
1297 void BrowserOptionsHandler::OnProfileAdded(const base::FilePath& profile_path) {
1298 SendProfilesInfo();
1299 }
1300
1301 void BrowserOptionsHandler::OnProfileWasRemoved(
1302 const base::FilePath& profile_path,
1303 const base::string16& profile_name) {
1304 SendProfilesInfo();
1305 }
1306
1307 void BrowserOptionsHandler::OnProfileNameChanged(
1308 const base::FilePath& profile_path,
1309 const base::string16& old_profile_name) {
1310 SendProfilesInfo();
1311 }
1312
1313 void BrowserOptionsHandler::OnProfileAvatarChanged(
1314 const base::FilePath& profile_path) {
1315 SendProfilesInfo();
1316 }
1317
1298 void BrowserOptionsHandler::ToggleAutoLaunch(const base::ListValue* args) { 1318 void BrowserOptionsHandler::ToggleAutoLaunch(const base::ListValue* args) {
1299 #if defined(OS_WIN) 1319 #if defined(OS_WIN)
1300 if (!auto_launch_trial::IsInAutoLaunchGroup()) 1320 if (!auto_launch_trial::IsInAutoLaunchGroup())
1301 return; 1321 return;
1302 1322
1303 bool enable; 1323 bool enable;
1304 CHECK_EQ(args->GetSize(), 1U); 1324 CHECK_EQ(args->GetSize(), 1U);
1305 CHECK(args->GetBoolean(0, &enable)); 1325 CHECK(args->GetBoolean(0, &enable));
1306 1326
1307 Profile* profile = Profile::FromWebUI(web_ui()); 1327 Profile* profile = Profile::FromWebUI(web_ui());
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
2129 void BrowserOptionsHandler::OnPolicyUpdated(const policy::PolicyNamespace& ns, 2149 void BrowserOptionsHandler::OnPolicyUpdated(const policy::PolicyNamespace& ns,
2130 const policy::PolicyMap& previous, 2150 const policy::PolicyMap& previous,
2131 const policy::PolicyMap& current) { 2151 const policy::PolicyMap& current) {
2132 std::set<std::string> different_keys; 2152 std::set<std::string> different_keys;
2133 current.GetDifferingKeys(previous, &different_keys); 2153 current.GetDifferingKeys(previous, &different_keys);
2134 if (ContainsKey(different_keys, policy::key::kMetricsReportingEnabled)) 2154 if (ContainsKey(different_keys, policy::key::kMetricsReportingEnabled))
2135 SetupMetricsReportingCheckbox(); 2155 SetupMetricsReportingCheckbox();
2136 } 2156 }
2137 2157
2138 } // namespace options 2158 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698