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" |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
243 void PersonalOptionsHandler::OnStateChanged() { | 243 void PersonalOptionsHandler::OnStateChanged() { |
244 string16 status_label; | 244 string16 status_label; |
245 string16 link_label; | 245 string16 link_label; |
246 ProfileSyncService* service = | 246 ProfileSyncService* service = |
247 Profile::FromWebUI(web_ui_)->GetProfileSyncService(); | 247 Profile::FromWebUI(web_ui_)->GetProfileSyncService(); |
248 DCHECK(service); | 248 DCHECK(service); |
249 bool managed = service->IsManaged(); | 249 bool managed = service->IsManaged(); |
250 bool sync_setup_completed = service->HasSyncSetupCompleted(); | 250 bool sync_setup_completed = service->HasSyncSetupCompleted(); |
251 bool status_has_error = sync_ui_util::GetStatusLabels( | 251 bool status_has_error = sync_ui_util::GetStatusLabels( |
252 service, &status_label, &link_label) == sync_ui_util::SYNC_ERROR; | 252 service, &status_label, &link_label) == sync_ui_util::SYNC_ERROR; |
253 bool has_unrecoverable_error = service->unrecoverable_error_detected(); | |
James Hawkins
2011/10/25 17:50:41
No need for temp var.
binji
2011/10/25 18:14:33
Done.
| |
253 | 254 |
254 string16 start_stop_button_label; | 255 string16 start_stop_button_label; |
255 bool is_start_stop_button_visible = false; | 256 bool is_start_stop_button_visible = false; |
256 bool is_start_stop_button_enabled = false; | 257 bool is_start_stop_button_enabled = false; |
257 if (sync_setup_completed) { | 258 if (sync_setup_completed) { |
258 start_stop_button_label = | 259 start_stop_button_label = |
259 l10n_util::GetStringUTF16(IDS_SYNC_STOP_SYNCING_BUTTON_LABEL); | 260 l10n_util::GetStringUTF16(IDS_SYNC_STOP_SYNCING_BUTTON_LABEL); |
260 #if defined(OS_CHROMEOS) | 261 #if defined(OS_CHROMEOS) |
261 is_start_stop_button_visible = false; | 262 is_start_stop_button_visible = false; |
262 #else | 263 #else |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
302 *label); | 303 *label); |
303 | 304 |
304 enabled.reset(Value::CreateBooleanValue(!managed)); | 305 enabled.reset(Value::CreateBooleanValue(!managed)); |
305 web_ui_->CallJavascriptFunction("PersonalOptions.setSyncActionLinkEnabled", | 306 web_ui_->CallJavascriptFunction("PersonalOptions.setSyncActionLinkEnabled", |
306 *enabled); | 307 *enabled); |
307 | 308 |
308 visible.reset(Value::CreateBooleanValue(status_has_error)); | 309 visible.reset(Value::CreateBooleanValue(status_has_error)); |
309 web_ui_->CallJavascriptFunction("PersonalOptions.setSyncStatusErrorVisible", | 310 web_ui_->CallJavascriptFunction("PersonalOptions.setSyncStatusErrorVisible", |
310 *visible); | 311 *visible); |
311 | 312 |
313 enabled.reset(Value::CreateBooleanValue(!has_unrecoverable_error)); | |
314 web_ui_->CallJavascriptFunction( | |
315 "PersonalOptions.setCustomizeSyncButtonEnabled", | |
316 *enabled); | |
317 | |
312 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAutologin)) { | 318 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAutologin)) { |
313 visible.reset(Value::CreateBooleanValue( | 319 visible.reset(Value::CreateBooleanValue( |
314 service->AreCredentialsAvailable())); | 320 service->AreCredentialsAvailable())); |
315 web_ui_->CallJavascriptFunction("PersonalOptions.setAutoLoginVisible", | 321 web_ui_->CallJavascriptFunction("PersonalOptions.setAutoLoginVisible", |
316 *visible); | 322 *visible); |
317 } | 323 } |
318 | 324 |
319 // Set profile creation text and button if multi-profiles switch is on. | 325 // Set profile creation text and button if multi-profiles switch is on. |
320 visible.reset(Value::CreateBooleanValue(multiprofile_)); | 326 visible.reset(Value::CreateBooleanValue(multiprofile_)); |
321 web_ui_->CallJavascriptFunction("PersonalOptions.setProfilesSectionVisible", | 327 web_ui_->CallJavascriptFunction("PersonalOptions.setProfilesSectionVisible", |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
408 profile_info_list.Append(profile_value); | 414 profile_info_list.Append(profile_value); |
409 } | 415 } |
410 | 416 |
411 web_ui_->CallJavascriptFunction("PersonalOptions.setProfilesInfo", | 417 web_ui_->CallJavascriptFunction("PersonalOptions.setProfilesInfo", |
412 profile_info_list); | 418 profile_info_list); |
413 } | 419 } |
414 | 420 |
415 void PersonalOptionsHandler::CreateProfile(const ListValue* args) { | 421 void PersonalOptionsHandler::CreateProfile(const ListValue* args) { |
416 ProfileManager::CreateMultiProfileAsync(); | 422 ProfileManager::CreateMultiProfileAsync(); |
417 } | 423 } |
OLD | NEW |