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

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: clean up views code 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 789 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 &BrowserOptionsHandler::HandleRefreshExtensionControlIndicators, 800 &BrowserOptionsHandler::HandleRefreshExtensionControlIndicators,
801 base::Unretained(this))); 801 base::Unretained(this)));
802 #endif // defined(OS_WIN) 802 #endif // defined(OS_WIN)
803 web_ui()->RegisterMessageCallback("metricsReportingCheckboxChanged", 803 web_ui()->RegisterMessageCallback("metricsReportingCheckboxChanged",
804 base::Bind(&BrowserOptionsHandler::HandleMetricsReportingChange, 804 base::Bind(&BrowserOptionsHandler::HandleMetricsReportingChange,
805 base::Unretained(this))); 805 base::Unretained(this)));
806 } 806 }
807 807
808 void BrowserOptionsHandler::Uninitialize() { 808 void BrowserOptionsHandler::Uninitialize() {
809 registrar_.RemoveAll(); 809 registrar_.RemoveAll();
810 g_browser_process->profile_manager()->
811 GetProfileInfoCache().RemoveObserver(this);
810 #if defined(OS_WIN) 812 #if defined(OS_WIN)
811 ExtensionRegistry::Get(Profile::FromWebUI(web_ui()))->RemoveObserver(this); 813 ExtensionRegistry::Get(Profile::FromWebUI(web_ui()))->RemoveObserver(this);
812 #endif 814 #endif
813 #if defined(OS_CHROMEOS) 815 #if defined(OS_CHROMEOS)
814 policy::ConsumerManagementService* consumer_management = 816 policy::ConsumerManagementService* consumer_management =
815 g_browser_process->platform_part()->browser_policy_connector_chromeos()-> 817 g_browser_process->platform_part()->browser_policy_connector_chromeos()->
816 GetConsumerManagementService(); 818 GetConsumerManagementService();
817 if (consumer_management) 819 if (consumer_management)
818 consumer_management->RemoveObserver(this); 820 consumer_management->RemoveObserver(this);
819 #endif 821 #endif
(...skipping 30 matching lines...) Expand all
850 if (zoom_level_prefs) { 852 if (zoom_level_prefs) {
851 default_zoom_level_subscription_ = 853 default_zoom_level_subscription_ =
852 zoom_level_prefs->RegisterDefaultZoomLevelCallback( 854 zoom_level_prefs->RegisterDefaultZoomLevelCallback(
853 base::Bind(&BrowserOptionsHandler::SetupPageZoomSelector, 855 base::Bind(&BrowserOptionsHandler::SetupPageZoomSelector,
854 base::Unretained(this))); 856 base::Unretained(this)));
855 } 857 }
856 858
857 g_browser_process->policy_service()->AddObserver( 859 g_browser_process->policy_service()->AddObserver(
858 policy::POLICY_DOMAIN_CHROME, this); 860 policy::POLICY_DOMAIN_CHROME, this);
859 861
862 g_browser_process->profile_manager()->GetProfileInfoCache().AddObserver(this);
863
860 ProfileSyncService* sync_service( 864 ProfileSyncService* sync_service(
861 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile)); 865 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile));
862 // TODO(blundell): Use a ScopedObserver to observe the PSS so that cleanup on 866 // TODO(blundell): Use a ScopedObserver to observe the PSS so that cleanup on
863 // destruction is automatic. 867 // destruction is automatic.
864 if (sync_service) 868 if (sync_service)
865 sync_service->AddObserver(this); 869 sync_service->AddObserver(this);
866 870
867 SigninManagerBase* signin_manager( 871 SigninManagerBase* signin_manager(
868 SigninManagerFactory::GetInstance()->GetForProfile(profile)); 872 SigninManagerFactory::GetInstance()->GetForProfile(profile));
869 if (signin_manager) 873 if (signin_manager)
870 signin_observer_.Add(signin_manager); 874 signin_observer_.Add(signin_manager);
871 875
872 // Create our favicon data source. 876 // Create our favicon data source.
873 content::URLDataSource::Add( 877 content::URLDataSource::Add(
874 profile, new FaviconSource(profile, FaviconSource::FAVICON)); 878 profile, new FaviconSource(profile, FaviconSource::FAVICON));
875 879
876 default_browser_policy_.Init( 880 default_browser_policy_.Init(
877 prefs::kDefaultBrowserSettingEnabled, 881 prefs::kDefaultBrowserSettingEnabled,
878 g_browser_process->local_state(), 882 g_browser_process->local_state(),
879 base::Bind(&BrowserOptionsHandler::UpdateDefaultBrowserState, 883 base::Bind(&BrowserOptionsHandler::UpdateDefaultBrowserState,
880 base::Unretained(this))); 884 base::Unretained(this)));
881 885
882 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED,
883 content::NotificationService::AllSources());
884 #if defined(OS_CHROMEOS) 886 #if defined(OS_CHROMEOS)
885 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, 887 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED,
886 content::NotificationService::AllSources()); 888 content::NotificationService::AllSources());
887 #endif 889 #endif
888 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, 890 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
889 content::Source<ThemeService>( 891 content::Source<ThemeService>(
890 ThemeServiceFactory::GetForProfile(profile))); 892 ThemeServiceFactory::GetForProfile(profile)));
891 registrar_.Add(this, chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED, 893 registrar_.Add(this, chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED,
892 content::Source<Profile>(profile)); 894 content::Source<Profile>(profile));
893 AddTemplateUrlServiceObserver(); 895 AddTemplateUrlServiceObserver();
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
1269 1271
1270 switch (type) { 1272 switch (type) {
1271 case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: 1273 case chrome::NOTIFICATION_BROWSER_THEME_CHANGED:
1272 ObserveThemeChanged(); 1274 ObserveThemeChanged();
1273 break; 1275 break;
1274 #if defined(OS_CHROMEOS) 1276 #if defined(OS_CHROMEOS)
1275 case chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED: 1277 case chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED:
1276 UpdateAccountPicture(); 1278 UpdateAccountPicture();
1277 break; 1279 break;
1278 #endif 1280 #endif
1279 case chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED:
1280 SendProfilesInfo();
1281 break;
1282 case chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED: 1281 case chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED:
1283 // Update our sync/signin status display. 1282 // Update our sync/signin status display.
1284 OnStateChanged(); 1283 OnStateChanged();
1285 break; 1284 break;
1286 default: 1285 default:
1287 NOTREACHED(); 1286 NOTREACHED();
1288 } 1287 }
1289 } 1288 }
1290 1289
1290 void BrowserOptionsHandler::OnProfileAdded(const base::FilePath& profile_path) {
1291 SendProfilesInfo();
1292 }
1293
1294 void BrowserOptionsHandler::OnProfileWasRemoved(
1295 const base::FilePath& profile_path,
1296 const base::string16& profile_name) {
1297 SendProfilesInfo();
1298 }
1299
1300 void BrowserOptionsHandler::OnProfileNameChanged(
1301 const base::FilePath& profile_path,
1302 const base::string16& old_profile_name) {
1303 SendProfilesInfo();
1304 }
1305
1306 void BrowserOptionsHandler::OnProfileAvatarChanged(
1307 const base::FilePath& profile_path) {
1308 SendProfilesInfo();
1309 }
1310
1291 void BrowserOptionsHandler::ToggleAutoLaunch(const base::ListValue* args) { 1311 void BrowserOptionsHandler::ToggleAutoLaunch(const base::ListValue* args) {
1292 #if defined(OS_WIN) 1312 #if defined(OS_WIN)
1293 if (!auto_launch_trial::IsInAutoLaunchGroup()) 1313 if (!auto_launch_trial::IsInAutoLaunchGroup())
1294 return; 1314 return;
1295 1315
1296 bool enable; 1316 bool enable;
1297 CHECK_EQ(args->GetSize(), 1U); 1317 CHECK_EQ(args->GetSize(), 1U);
1298 CHECK(args->GetBoolean(0, &enable)); 1318 CHECK(args->GetBoolean(0, &enable));
1299 1319
1300 Profile* profile = Profile::FromWebUI(web_ui()); 1320 Profile* profile = Profile::FromWebUI(web_ui());
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
2122 void BrowserOptionsHandler::OnPolicyUpdated(const policy::PolicyNamespace& ns, 2142 void BrowserOptionsHandler::OnPolicyUpdated(const policy::PolicyNamespace& ns,
2123 const policy::PolicyMap& previous, 2143 const policy::PolicyMap& previous,
2124 const policy::PolicyMap& current) { 2144 const policy::PolicyMap& current) {
2125 std::set<std::string> different_keys; 2145 std::set<std::string> different_keys;
2126 current.GetDifferingKeys(previous, &different_keys); 2146 current.GetDifferingKeys(previous, &different_keys);
2127 if (ContainsKey(different_keys, policy::key::kMetricsReportingEnabled)) 2147 if (ContainsKey(different_keys, policy::key::kMetricsReportingEnabled))
2128 SetupMetricsReportingCheckbox(); 2148 SetupMetricsReportingCheckbox();
2129 } 2149 }
2130 2150
2131 } // namespace options 2151 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698