| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/personal_options_handler.h" | 5 #include "chrome/browser/ui/webui/options/personal_options_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
| 14 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
| 15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 16 #include "base/value_conversions.h" | 16 #include "base/value_conversions.h" |
| 17 #include "base/values.h" | 17 #include "base/values.h" |
| 18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
| 19 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
| 20 #include "chrome/browser/google/google_util.h" | 20 #include "chrome/browser/google/google_util.h" |
| 21 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chrome/browser/profiles/profile_info_cache.h" | 22 #include "chrome/browser/profiles/profile_info_cache.h" |
| 23 #include "chrome/browser/profiles/profile_info_util.h" | 23 #include "chrome/browser/profiles/profile_info_util.h" |
| 24 #include "chrome/browser/profiles/profile_manager.h" | 24 #include "chrome/browser/profiles/profile_manager.h" |
| 25 #include "chrome/browser/sync/profile_sync_service.h" | 25 #include "chrome/browser/sync/profile_sync_service.h" |
| 26 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 26 #include "chrome/browser/sync/sync_setup_flow.h" | 27 #include "chrome/browser/sync/sync_setup_flow.h" |
| 27 #include "chrome/browser/sync/sync_ui_util.h" | 28 #include "chrome/browser/sync/sync_ui_util.h" |
| 28 #include "chrome/browser/themes/theme_service.h" | 29 #include "chrome/browser/themes/theme_service.h" |
| 29 #include "chrome/browser/themes/theme_service_factory.h" | 30 #include "chrome/browser/themes/theme_service_factory.h" |
| 30 #include "chrome/browser/ui/webui/web_ui_util.h" | 31 #include "chrome/browser/ui/webui/web_ui_util.h" |
| 31 #include "chrome/common/chrome_notification_types.h" | 32 #include "chrome/common/chrome_notification_types.h" |
| 32 #include "chrome/common/chrome_paths.h" | 33 #include "chrome/common/chrome_paths.h" |
| 33 #include "chrome/common/chrome_switches.h" | 34 #include "chrome/common/chrome_switches.h" |
| 34 #include "chrome/common/net/gaia/google_service_auth_error.h" | 35 #include "chrome/common/net/gaia/google_service_auth_error.h" |
| 35 #include "chrome/common/url_constants.h" | 36 #include "chrome/common/url_constants.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 58 PersonalOptionsHandler::PersonalOptionsHandler() { | 59 PersonalOptionsHandler::PersonalOptionsHandler() { |
| 59 multiprofile_ = ProfileManager::IsMultipleProfilesEnabled(); | 60 multiprofile_ = ProfileManager::IsMultipleProfilesEnabled(); |
| 60 #if defined(OS_CHROMEOS) | 61 #if defined(OS_CHROMEOS) |
| 61 registrar_.Add(this, | 62 registrar_.Add(this, |
| 62 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, | 63 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, |
| 63 content::NotificationService::AllSources()); | 64 content::NotificationService::AllSources()); |
| 64 #endif | 65 #endif |
| 65 } | 66 } |
| 66 | 67 |
| 67 PersonalOptionsHandler::~PersonalOptionsHandler() { | 68 PersonalOptionsHandler::~PersonalOptionsHandler() { |
| 68 ProfileSyncService* sync_service = | 69 ProfileSyncService* sync_service(ProfileSyncServiceFactory:: |
| 69 Profile::FromWebUI(web_ui())->GetProfileSyncService(); | 70 GetInstance()->GetForProfile(Profile::FromWebUI(web_ui()))); |
| 70 if (sync_service) | 71 if (sync_service) |
| 71 sync_service->RemoveObserver(this); | 72 sync_service->RemoveObserver(this); |
| 72 } | 73 } |
| 73 | 74 |
| 74 void PersonalOptionsHandler::GetLocalizedValues( | 75 void PersonalOptionsHandler::GetLocalizedValues( |
| 75 DictionaryValue* localized_strings) { | 76 DictionaryValue* localized_strings) { |
| 76 DCHECK(localized_strings); | 77 DCHECK(localized_strings); |
| 77 | 78 |
| 78 RegisterTitle(localized_strings, "personalPage", | 79 RegisterTitle(localized_strings, "personalPage", |
| 79 IDS_OPTIONS_CONTENT_TAB_LABEL); | 80 IDS_OPTIONS_CONTENT_TAB_LABEL); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 UpdateAccountPicture(); | 245 UpdateAccountPicture(); |
| 245 #endif | 246 #endif |
| 246 } else { | 247 } else { |
| 247 OptionsPageUIHandler::Observe(type, source, details); | 248 OptionsPageUIHandler::Observe(type, source, details); |
| 248 } | 249 } |
| 249 } | 250 } |
| 250 | 251 |
| 251 void PersonalOptionsHandler::OnStateChanged() { | 252 void PersonalOptionsHandler::OnStateChanged() { |
| 252 string16 status_label; | 253 string16 status_label; |
| 253 string16 link_label; | 254 string16 link_label; |
| 254 ProfileSyncService* service = | 255 ProfileSyncService* service(ProfileSyncServiceFactory:: |
| 255 Profile::FromWebUI(web_ui())->GetProfileSyncService(); | 256 GetInstance()->GetForProfile(Profile::FromWebUI(web_ui()))); |
| 256 DCHECK(service); | 257 DCHECK(service); |
| 257 bool managed = service->IsManaged(); | 258 bool managed = service->IsManaged(); |
| 258 bool sync_setup_completed = service->HasSyncSetupCompleted(); | 259 bool sync_setup_completed = service->HasSyncSetupCompleted(); |
| 259 bool status_has_error = sync_ui_util::GetStatusLabels( | 260 bool status_has_error = sync_ui_util::GetStatusLabels( |
| 260 service, sync_ui_util::WITH_HTML, &status_label, &link_label) == | 261 service, sync_ui_util::WITH_HTML, &status_label, &link_label) == |
| 261 sync_ui_util::SYNC_ERROR; | 262 sync_ui_util::SYNC_ERROR; |
| 262 | 263 |
| 263 string16 start_stop_button_label; | 264 string16 start_stop_button_label; |
| 264 bool is_start_stop_button_visible = false; | 265 bool is_start_stop_button_visible = false; |
| 265 bool is_start_stop_button_enabled = false; | 266 bool is_start_stop_button_enabled = false; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 Profile* profile = Profile::FromWebUI(web_ui()); | 363 Profile* profile = Profile::FromWebUI(web_ui()); |
| 363 | 364 |
| 364 // Listen for theme installation. | 365 // Listen for theme installation. |
| 365 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | 366 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
| 366 content::Source<ThemeService>( | 367 content::Source<ThemeService>( |
| 367 ThemeServiceFactory::GetForProfile(profile))); | 368 ThemeServiceFactory::GetForProfile(profile))); |
| 368 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, | 369 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, |
| 369 content::NotificationService::AllSources()); | 370 content::NotificationService::AllSources()); |
| 370 ObserveThemeChanged(); | 371 ObserveThemeChanged(); |
| 371 | 372 |
| 372 ProfileSyncService* sync_service = profile->GetProfileSyncService(); | 373 ProfileSyncService* sync_service(ProfileSyncServiceFactory:: |
| 374 GetInstance()->GetForProfile(profile)); |
| 373 if (sync_service) { | 375 if (sync_service) { |
| 374 sync_service->AddObserver(this); | 376 sync_service->AddObserver(this); |
| 375 OnStateChanged(); | 377 OnStateChanged(); |
| 376 } else { | 378 } else { |
| 377 web_ui()->CallJavascriptFunction("options.PersonalOptions.hideSyncSection"); | 379 web_ui()->CallJavascriptFunction("options.PersonalOptions.hideSyncSection"); |
| 378 } | 380 } |
| 379 } | 381 } |
| 380 | 382 |
| 381 void PersonalOptionsHandler::ThemesReset(const ListValue* args) { | 383 void PersonalOptionsHandler::ThemesReset(const ListValue* args) { |
| 382 content::RecordAction(UserMetricsAction("Options_ThemesReset")); | 384 content::RecordAction(UserMetricsAction("Options_ThemesReset")); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 profile_info_list.Append(profile_value); | 436 profile_info_list.Append(profile_value); |
| 435 } | 437 } |
| 436 | 438 |
| 437 web_ui()->CallJavascriptFunction("PersonalOptions.setProfilesInfo", | 439 web_ui()->CallJavascriptFunction("PersonalOptions.setProfilesInfo", |
| 438 profile_info_list); | 440 profile_info_list); |
| 439 } | 441 } |
| 440 | 442 |
| 441 void PersonalOptionsHandler::CreateProfile(const ListValue* args) { | 443 void PersonalOptionsHandler::CreateProfile(const ListValue* args) { |
| 442 ProfileManager::CreateMultiProfileAsync(); | 444 ProfileManager::CreateMultiProfileAsync(); |
| 443 } | 445 } |
| OLD | NEW |