Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/dom_ui/options/personal_options_handler.h" | 5 #include "chrome/browser/dom_ui/options/personal_options_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 if (type == NotificationType::BROWSER_THEME_CHANGED) | 147 if (type == NotificationType::BROWSER_THEME_CHANGED) |
| 148 ObserveThemeChanged(); | 148 ObserveThemeChanged(); |
| 149 else | 149 else |
| 150 OptionsPageUIHandler::Observe(type, source, details); | 150 OptionsPageUIHandler::Observe(type, source, details); |
| 151 } | 151 } |
| 152 | 152 |
| 153 void PersonalOptionsHandler::OnStateChanged() { | 153 void PersonalOptionsHandler::OnStateChanged() { |
| 154 string16 status_label; | 154 string16 status_label; |
| 155 string16 link_label; | 155 string16 link_label; |
| 156 ProfileSyncService* service = dom_ui_->GetProfile()->GetProfileSyncService(); | 156 ProfileSyncService* service = dom_ui_->GetProfile()->GetProfileSyncService(); |
| 157 DCHECK(service); | |
|
akalin
2011/01/14 00:26:37
I prefer these to be CHECK()s since you're derefer
| |
| 157 bool managed = service->IsManaged(); | 158 bool managed = service->IsManaged(); |
| 158 bool sync_setup_completed = service->HasSyncSetupCompleted(); | 159 bool sync_setup_completed = service->HasSyncSetupCompleted(); |
| 159 bool status_has_error = sync_ui_util::GetStatusLabels(service, | 160 bool status_has_error = sync_ui_util::GetStatusLabels(service, |
| 160 &status_label, &link_label) == sync_ui_util::SYNC_ERROR; | 161 &status_label, &link_label) == sync_ui_util::SYNC_ERROR; |
| 161 | 162 |
| 162 string16 start_stop_button_label; | 163 string16 start_stop_button_label; |
| 163 bool is_start_stop_button_visible = false; | 164 bool is_start_stop_button_visible = false; |
| 164 bool is_start_stop_button_enabled = false; | 165 bool is_start_stop_button_enabled = false; |
| 165 if (sync_setup_completed) { | 166 if (sync_setup_completed) { |
| 166 start_stop_button_label = | 167 start_stop_button_label = |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 268 void PersonalOptionsHandler::ShowSyncLoginDialog(const ListValue* args) { | 269 void PersonalOptionsHandler::ShowSyncLoginDialog(const ListValue* args) { |
| 269 #if defined(OS_CHROMEOS) | 270 #if defined(OS_CHROMEOS) |
| 270 std::string email = chromeos::UserManager::Get()->logged_in_user().email(); | 271 std::string email = chromeos::UserManager::Get()->logged_in_user().email(); |
| 271 string16 message = l10n_util::GetStringFUTF16( | 272 string16 message = l10n_util::GetStringFUTF16( |
| 272 IDS_SYNC_LOGIN_INTRODUCTION, | 273 IDS_SYNC_LOGIN_INTRODUCTION, |
| 273 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | 274 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
| 274 dom_ui_->GetProfile()->GetBrowserSignin()->RequestSignin( | 275 dom_ui_->GetProfile()->GetBrowserSignin()->RequestSignin( |
| 275 dom_ui_->tab_contents(), UTF8ToUTF16(email), message, this); | 276 dom_ui_->tab_contents(), UTF8ToUTF16(email), message, this); |
| 276 #else | 277 #else |
| 277 ProfileSyncService* service = dom_ui_->GetProfile()->GetProfileSyncService(); | 278 ProfileSyncService* service = dom_ui_->GetProfile()->GetProfileSyncService(); |
| 279 DCHECK(service); | |
| 278 service->ShowLoginDialog(NULL); | 280 service->ShowLoginDialog(NULL); |
| 279 ProfileSyncService::SyncEvent(ProfileSyncService::START_FROM_OPTIONS); | 281 ProfileSyncService::SyncEvent(ProfileSyncService::START_FROM_OPTIONS); |
| 280 #endif | 282 #endif |
| 281 } | 283 } |
| 282 | 284 |
| 283 void PersonalOptionsHandler::ThemesReset(const ListValue* args) { | 285 void PersonalOptionsHandler::ThemesReset(const ListValue* args) { |
| 284 UserMetricsRecordAction(UserMetricsAction("Options_ThemesReset")); | 286 UserMetricsRecordAction(UserMetricsAction("Options_ThemesReset")); |
| 285 dom_ui_->GetProfile()->ClearTheme(); | 287 dom_ui_->GetProfile()->ClearTheme(); |
| 286 } | 288 } |
| 287 | 289 |
| 288 #if defined(TOOLKIT_GTK) | 290 #if defined(TOOLKIT_GTK) |
| 289 void PersonalOptionsHandler::ThemesSetGTK(const ListValue* args) { | 291 void PersonalOptionsHandler::ThemesSetGTK(const ListValue* args) { |
| 290 UserMetricsRecordAction(UserMetricsAction("Options_GtkThemeSet")); | 292 UserMetricsRecordAction(UserMetricsAction("Options_GtkThemeSet")); |
| 291 dom_ui_->GetProfile()->SetNativeTheme(); | 293 dom_ui_->GetProfile()->SetNativeTheme(); |
| 292 } | 294 } |
| 293 #endif | 295 #endif |
| 294 | 296 |
| 295 void PersonalOptionsHandler::OnLoginSuccess() { | 297 void PersonalOptionsHandler::OnLoginSuccess() { |
| 296 OnStateChanged(); | 298 OnStateChanged(); |
| 297 } | 299 } |
| 298 | 300 |
| 299 void PersonalOptionsHandler::OnLoginFailure( | 301 void PersonalOptionsHandler::OnLoginFailure( |
| 300 const GoogleServiceAuthError& error) { | 302 const GoogleServiceAuthError& error) { |
| 301 OnStateChanged(); | 303 OnStateChanged(); |
| 302 } | 304 } |
| OLD | NEW |