| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/settings/people_handler.h" | 5 #include "chrome/browser/ui/webui/settings/people_handler.h" |
| 6 | 6 |
| 7 #include <string> |
| 8 |
| 7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 10 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 11 #include "base/i18n/time_formatting.h" | 13 #include "base/i18n/time_formatting.h" |
| 12 #include "base/json/json_reader.h" | 14 #include "base/json/json_reader.h" |
| 13 #include "base/json/json_writer.h" | 15 #include "base/json/json_writer.h" |
| 14 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
| 15 #include "base/prefs/pref_service.h" | 17 #include "base/prefs/pref_service.h" |
| 16 #include "base/values.h" | 18 #include "base/values.h" |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 // blank setup overlay on this page by showing the "done" page. This can | 596 // blank setup overlay on this page by showing the "done" page. This can |
| 595 // happen if the user navigates to chrome://settings/syncSetup in more than | 597 // happen if the user navigates to chrome://settings/syncSetup in more than |
| 596 // one tab. See crbug.com/261566. | 598 // one tab. See crbug.com/261566. |
| 597 // Note: The following block will transfer focus to the existing wizard. | 599 // Note: The following block will transfer focus to the existing wizard. |
| 598 if (IsExistingWizardPresent() && !IsActiveLogin()) | 600 if (IsExistingWizardPresent() && !IsActiveLogin()) |
| 599 CloseUI(); | 601 CloseUI(); |
| 600 | 602 |
| 601 // If a setup wizard is present on this page or another, bring it to focus. | 603 // If a setup wizard is present on this page or another, bring it to focus. |
| 602 // Otherwise, display a new one on this page. | 604 // Otherwise, display a new one on this page. |
| 603 if (!FocusExistingWizardIfPresent()) | 605 if (!FocusExistingWizardIfPresent()) |
| 604 OpenSyncSetup(args); | 606 OpenSyncSetup(nullptr); |
| 605 } | 607 } |
| 606 | 608 |
| 607 #if defined(OS_CHROMEOS) | 609 #if defined(OS_CHROMEOS) |
| 608 // On ChromeOS, we need to sign out the user session to fix an auth error, so | 610 // On ChromeOS, we need to sign out the user session to fix an auth error, so |
| 609 // the user goes through the real signin flow to generate a new auth token. | 611 // the user goes through the real signin flow to generate a new auth token. |
| 610 void PeopleHandler::HandleDoSignOutOnAuthError(const base::ListValue* args) { | 612 void PeopleHandler::HandleDoSignOutOnAuthError(const base::ListValue* args) { |
| 611 DVLOG(1) << "Signing out the user to fix a sync error."; | 613 DVLOG(1) << "Signing out the user to fix a sync error."; |
| 612 chrome::AttemptUserExit(); | 614 chrome::AttemptUserExit(); |
| 613 } | 615 } |
| 614 #endif | 616 #endif |
| 615 | 617 |
| 616 #if !defined(OS_CHROMEOS) | 618 #if !defined(OS_CHROMEOS) |
| 617 void PeopleHandler::HandleStartSignin(const base::ListValue* args) { | 619 void PeopleHandler::HandleStartSignin(const base::ListValue* args) { |
| 618 // Should only be called if the user is not already signed in. | 620 // Should only be called if the user is not already signed in. |
| 619 DCHECK(!SigninManagerFactory::GetForProfile(profile_)->IsAuthenticated()); | 621 DCHECK(!SigninManagerFactory::GetForProfile(profile_)->IsAuthenticated()); |
| 620 OpenSyncSetup(args); | 622 OpenSyncSetup(nullptr); |
| 621 } | 623 } |
| 622 | 624 |
| 623 void PeopleHandler::HandleStopSyncing(const base::ListValue* args) { | 625 void PeopleHandler::HandleStopSyncing(const base::ListValue* args) { |
| 624 if (GetSyncService()) | 626 if (GetSyncService()) |
| 625 ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS); | 627 ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS); |
| 626 SigninManagerFactory::GetForProfile(profile_) | 628 SigninManagerFactory::GetForProfile(profile_) |
| 627 ->SignOut(signin_metrics::USER_CLICKED_SIGNOUT_SETTINGS); | 629 ->SignOut(signin_metrics::USER_CLICKED_SIGNOUT_SETTINGS); |
| 628 | 630 |
| 629 bool delete_profile = false; | 631 bool delete_profile = false; |
| 630 if (args->GetBoolean(0, &delete_profile) && delete_profile) { | 632 if (args->GetBoolean(0, &delete_profile) && delete_profile) { |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 992 void PeopleHandler::UpdateSyncState() { | 994 void PeopleHandler::UpdateSyncState() { |
| 993 web_ui()->CallJavascriptFunction("settings.SyncPrivateApi.sendSyncStatus", | 995 web_ui()->CallJavascriptFunction("settings.SyncPrivateApi.sendSyncStatus", |
| 994 *GetSyncStateDictionary()); | 996 *GetSyncStateDictionary()); |
| 995 } | 997 } |
| 996 | 998 |
| 997 void PeopleHandler::OnSigninAllowedPrefChange() { | 999 void PeopleHandler::OnSigninAllowedPrefChange() { |
| 998 UpdateSyncState(); | 1000 UpdateSyncState(); |
| 999 } | 1001 } |
| 1000 | 1002 |
| 1001 } // namespace settings | 1003 } // namespace settings |
| OLD | NEW |