| OLD | NEW |
| 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 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 &BrowserOptionsHandler::HandleRefreshExtensionControlIndicators, | 806 &BrowserOptionsHandler::HandleRefreshExtensionControlIndicators, |
| 807 base::Unretained(this))); | 807 base::Unretained(this))); |
| 808 #endif // defined(OS_WIN) | 808 #endif // defined(OS_WIN) |
| 809 web_ui()->RegisterMessageCallback("metricsReportingCheckboxChanged", | 809 web_ui()->RegisterMessageCallback("metricsReportingCheckboxChanged", |
| 810 base::Bind(&BrowserOptionsHandler::HandleMetricsReportingChange, | 810 base::Bind(&BrowserOptionsHandler::HandleMetricsReportingChange, |
| 811 base::Unretained(this))); | 811 base::Unretained(this))); |
| 812 } | 812 } |
| 813 | 813 |
| 814 void BrowserOptionsHandler::Uninitialize() { | 814 void BrowserOptionsHandler::Uninitialize() { |
| 815 registrar_.RemoveAll(); | 815 registrar_.RemoveAll(); |
| 816 g_browser_process->profile_manager()-> |
| 817 GetProfileInfoCache().RemoveObserver(this); |
| 816 #if defined(OS_WIN) | 818 #if defined(OS_WIN) |
| 817 ExtensionRegistry::Get(Profile::FromWebUI(web_ui()))->RemoveObserver(this); | 819 ExtensionRegistry::Get(Profile::FromWebUI(web_ui()))->RemoveObserver(this); |
| 818 #endif | 820 #endif |
| 819 #if defined(OS_CHROMEOS) | 821 #if defined(OS_CHROMEOS) |
| 820 policy::ConsumerManagementService* consumer_management = | 822 policy::ConsumerManagementService* consumer_management = |
| 821 g_browser_process->platform_part()->browser_policy_connector_chromeos()-> | 823 g_browser_process->platform_part()->browser_policy_connector_chromeos()-> |
| 822 GetConsumerManagementService(); | 824 GetConsumerManagementService(); |
| 823 if (consumer_management) | 825 if (consumer_management) |
| 824 consumer_management->RemoveObserver(this); | 826 consumer_management->RemoveObserver(this); |
| 825 #endif | 827 #endif |
| (...skipping 30 matching lines...) Expand all Loading... |
| 856 if (zoom_level_prefs) { | 858 if (zoom_level_prefs) { |
| 857 default_zoom_level_subscription_ = | 859 default_zoom_level_subscription_ = |
| 858 zoom_level_prefs->RegisterDefaultZoomLevelCallback( | 860 zoom_level_prefs->RegisterDefaultZoomLevelCallback( |
| 859 base::Bind(&BrowserOptionsHandler::SetupPageZoomSelector, | 861 base::Bind(&BrowserOptionsHandler::SetupPageZoomSelector, |
| 860 base::Unretained(this))); | 862 base::Unretained(this))); |
| 861 } | 863 } |
| 862 | 864 |
| 863 g_browser_process->policy_service()->AddObserver( | 865 g_browser_process->policy_service()->AddObserver( |
| 864 policy::POLICY_DOMAIN_CHROME, this); | 866 policy::POLICY_DOMAIN_CHROME, this); |
| 865 | 867 |
| 868 g_browser_process->profile_manager()->GetProfileInfoCache().AddObserver(this); |
| 869 |
| 866 ProfileSyncService* sync_service( | 870 ProfileSyncService* sync_service( |
| 867 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile)); | 871 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile)); |
| 868 // TODO(blundell): Use a ScopedObserver to observe the PSS so that cleanup on | 872 // TODO(blundell): Use a ScopedObserver to observe the PSS so that cleanup on |
| 869 // destruction is automatic. | 873 // destruction is automatic. |
| 870 if (sync_service) | 874 if (sync_service) |
| 871 sync_service->AddObserver(this); | 875 sync_service->AddObserver(this); |
| 872 | 876 |
| 873 SigninManagerBase* signin_manager( | 877 SigninManagerBase* signin_manager( |
| 874 SigninManagerFactory::GetInstance()->GetForProfile(profile)); | 878 SigninManagerFactory::GetInstance()->GetForProfile(profile)); |
| 875 if (signin_manager) | 879 if (signin_manager) |
| 876 signin_observer_.Add(signin_manager); | 880 signin_observer_.Add(signin_manager); |
| 877 | 881 |
| 878 // Create our favicon data source. | 882 // Create our favicon data source. |
| 879 content::URLDataSource::Add( | 883 content::URLDataSource::Add( |
| 880 profile, new FaviconSource(profile, FaviconSource::FAVICON)); | 884 profile, new FaviconSource(profile, FaviconSource::FAVICON)); |
| 881 | 885 |
| 882 default_browser_policy_.Init( | 886 default_browser_policy_.Init( |
| 883 prefs::kDefaultBrowserSettingEnabled, | 887 prefs::kDefaultBrowserSettingEnabled, |
| 884 g_browser_process->local_state(), | 888 g_browser_process->local_state(), |
| 885 base::Bind(&BrowserOptionsHandler::UpdateDefaultBrowserState, | 889 base::Bind(&BrowserOptionsHandler::UpdateDefaultBrowserState, |
| 886 base::Unretained(this))); | 890 base::Unretained(this))); |
| 887 | 891 |
| 888 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, | |
| 889 content::NotificationService::AllSources()); | |
| 890 #if defined(OS_CHROMEOS) | 892 #if defined(OS_CHROMEOS) |
| 891 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, | 893 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, |
| 892 content::NotificationService::AllSources()); | 894 content::NotificationService::AllSources()); |
| 893 #endif | 895 #endif |
| 894 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | 896 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
| 895 content::Source<ThemeService>( | 897 content::Source<ThemeService>( |
| 896 ThemeServiceFactory::GetForProfile(profile))); | 898 ThemeServiceFactory::GetForProfile(profile))); |
| 897 registrar_.Add(this, chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED, | 899 registrar_.Add(this, chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED, |
| 898 content::Source<Profile>(profile)); | 900 content::Source<Profile>(profile)); |
| 899 AddTemplateUrlServiceObserver(); | 901 AddTemplateUrlServiceObserver(); |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2150 void BrowserOptionsHandler::OnPolicyUpdated(const policy::PolicyNamespace& ns, | 2170 void BrowserOptionsHandler::OnPolicyUpdated(const policy::PolicyNamespace& ns, |
| 2151 const policy::PolicyMap& previous, | 2171 const policy::PolicyMap& previous, |
| 2152 const policy::PolicyMap& current) { | 2172 const policy::PolicyMap& current) { |
| 2153 std::set<std::string> different_keys; | 2173 std::set<std::string> different_keys; |
| 2154 current.GetDifferingKeys(previous, &different_keys); | 2174 current.GetDifferingKeys(previous, &different_keys); |
| 2155 if (ContainsKey(different_keys, policy::key::kMetricsReportingEnabled)) | 2175 if (ContainsKey(different_keys, policy::key::kMetricsReportingEnabled)) |
| 2156 SetupMetricsReportingCheckbox(); | 2176 SetupMetricsReportingCheckbox(); |
| 2157 } | 2177 } |
| 2158 | 2178 |
| 2159 } // namespace options | 2179 } // namespace options |
| OLD | NEW |