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> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "chrome/browser/profiles/profile_window.h" | 22 #include "chrome/browser/profiles/profile_window.h" |
23 #include "chrome/browser/signin/chrome_signin_helper.h" | 23 #include "chrome/browser/signin/chrome_signin_helper.h" |
24 #include "chrome/browser/signin/signin_error_controller_factory.h" | 24 #include "chrome/browser/signin/signin_error_controller_factory.h" |
25 #include "chrome/browser/signin/signin_manager_factory.h" | 25 #include "chrome/browser/signin/signin_manager_factory.h" |
26 #include "chrome/browser/signin/signin_promo.h" | 26 #include "chrome/browser/signin/signin_promo.h" |
27 #include "chrome/browser/signin/signin_ui_util.h" | 27 #include "chrome/browser/signin/signin_ui_util.h" |
28 #include "chrome/browser/sync/profile_sync_service_factory.h" | 28 #include "chrome/browser/sync/profile_sync_service_factory.h" |
29 #include "chrome/browser/sync/sync_ui_util.h" | 29 #include "chrome/browser/sync/sync_ui_util.h" |
30 #include "chrome/browser/ui/browser_finder.h" | 30 #include "chrome/browser/ui/browser_finder.h" |
31 #include "chrome/browser/ui/browser_window.h" | 31 #include "chrome/browser/ui/browser_window.h" |
| 32 #include "chrome/browser/ui/chrome_pages.h" |
32 #include "chrome/browser/ui/singleton_tabs.h" | 33 #include "chrome/browser/ui/singleton_tabs.h" |
33 #include "chrome/browser/ui/user_manager.h" | 34 #include "chrome/browser/ui/user_manager.h" |
34 #include "chrome/browser/ui/webui/profile_helper.h" | 35 #include "chrome/browser/ui/webui/profile_helper.h" |
35 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 36 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
36 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 37 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
37 #include "chrome/common/chrome_switches.h" | 38 #include "chrome/common/chrome_switches.h" |
| 39 #include "chrome/common/url_constants.h" |
38 #include "chrome/grit/generated_resources.h" | 40 #include "chrome/grit/generated_resources.h" |
39 #include "components/autofill/core/common/autofill_constants.h" | 41 #include "components/autofill/core/common/autofill_constants.h" |
40 #include "components/autofill/core/common/autofill_pref_names.h" | 42 #include "components/autofill/core/common/autofill_pref_names.h" |
41 #include "components/browser_sync/profile_sync_service.h" | 43 #include "components/browser_sync/profile_sync_service.h" |
42 #include "components/prefs/pref_service.h" | 44 #include "components/prefs/pref_service.h" |
43 #include "components/signin/core/browser/signin_error_controller.h" | 45 #include "components/signin/core/browser/signin_error_controller.h" |
44 #include "components/signin/core/browser/signin_header_helper.h" | 46 #include "components/signin/core/browser/signin_header_helper.h" |
45 #include "components/signin/core/browser/signin_metrics.h" | 47 #include "components/signin/core/browser/signin_metrics.h" |
46 #include "components/signin/core/common/profile_management_switches.h" | 48 #include "components/signin/core/common/profile_management_switches.h" |
47 #include "components/signin/core/common/signin_pref_names.h" | 49 #include "components/signin/core/common/signin_pref_names.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 PeopleHandler::~PeopleHandler() { | 191 PeopleHandler::~PeopleHandler() { |
190 // Early exit if running unit tests (no actual WebUI is attached). | 192 // Early exit if running unit tests (no actual WebUI is attached). |
191 if (!web_ui()) | 193 if (!web_ui()) |
192 return; | 194 return; |
193 | 195 |
194 // This case is hit when the user performs a back navigation. | 196 // This case is hit when the user performs a back navigation. |
195 CloseSyncSetup(); | 197 CloseSyncSetup(); |
196 } | 198 } |
197 | 199 |
198 void PeopleHandler::RegisterMessages() { | 200 void PeopleHandler::RegisterMessages() { |
| 201 InitializeSyncBlocker(); |
199 web_ui()->RegisterMessageCallback( | 202 web_ui()->RegisterMessageCallback( |
200 "SyncSetupDidClosePage", | 203 "SyncSetupDidClosePage", |
201 base::Bind(&PeopleHandler::OnDidClosePage, base::Unretained(this))); | 204 base::Bind(&PeopleHandler::OnDidClosePage, base::Unretained(this))); |
202 web_ui()->RegisterMessageCallback( | 205 web_ui()->RegisterMessageCallback( |
203 "SyncSetupSetDatatypes", | 206 "SyncSetupSetDatatypes", |
204 base::Bind(&PeopleHandler::HandleSetDatatypes, base::Unretained(this))); | 207 base::Bind(&PeopleHandler::HandleSetDatatypes, base::Unretained(this))); |
205 web_ui()->RegisterMessageCallback( | 208 web_ui()->RegisterMessageCallback( |
206 "SyncSetupSetEncryption", | 209 "SyncSetupSetEncryption", |
207 base::Bind(&PeopleHandler::HandleSetEncryption, base::Unretained(this))); | 210 base::Bind(&PeopleHandler::HandleSetEncryption, base::Unretained(this))); |
208 web_ui()->RegisterMessageCallback( | 211 web_ui()->RegisterMessageCallback( |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 sync_blocker_.reset(); | 621 sync_blocker_.reset(); |
619 | 622 |
620 configuring_sync_ = false; | 623 configuring_sync_ = false; |
621 } | 624 } |
622 | 625 |
623 void PeopleHandler::OpenSyncSetup() { | 626 void PeopleHandler::OpenSyncSetup() { |
624 // Notify services that login UI is now active. | 627 // Notify services that login UI is now active. |
625 GetLoginUIService()->SetLoginUI(this); | 628 GetLoginUIService()->SetLoginUI(this); |
626 | 629 |
627 ProfileSyncService* service = GetSyncService(); | 630 ProfileSyncService* service = GetSyncService(); |
628 if (service) | 631 if (service && !sync_blocker_) |
629 sync_blocker_ = service->GetSetupInProgressHandle(); | 632 sync_blocker_ = service->GetSetupInProgressHandle(); |
630 | 633 |
631 // There are several different UI flows that can bring the user here: | 634 // There are several different UI flows that can bring the user here: |
632 // 1) Signin promo. | 635 // 1) Signin promo. |
633 // 2) Normal signin through settings page (IsAuthenticated() is false). | 636 // 2) Normal signin through settings page (IsAuthenticated() is false). |
634 // 3) Previously working credentials have expired. | 637 // 3) Previously working credentials have expired. |
635 // 4) User is signed in, but has stopped sync via the google dashboard, and | 638 // 4) User is signed in, but has stopped sync via the google dashboard, and |
636 // signout is prohibited by policy so we need to force a re-auth. | 639 // signout is prohibited by policy so we need to force a re-auth. |
637 // 5) User clicks [Advanced Settings] button on options page while already | 640 // 5) User clicks [Advanced Settings] button on options page while already |
638 // logged in. | 641 // logged in. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 } | 682 } |
680 return; | 683 return; |
681 } | 684 } |
682 | 685 |
683 // User is already logged in. They must have brought up the config wizard | 686 // User is already logged in. They must have brought up the config wizard |
684 // via the "Advanced..." button or through One-Click signin (cases 4-6), or | 687 // via the "Advanced..." button or through One-Click signin (cases 4-6), or |
685 // they are re-enabling sync after having disabled it (case 7). | 688 // they are re-enabling sync after having disabled it (case 7). |
686 PushSyncPrefs(); | 689 PushSyncPrefs(); |
687 } | 690 } |
688 | 691 |
| 692 void PeopleHandler::InitializeSyncBlocker() { |
| 693 if (!web_ui()) |
| 694 return; |
| 695 WebContents* web_contents = web_ui()->GetWebContents(); |
| 696 if (web_contents) { |
| 697 ProfileSyncService* service = GetSyncService(); |
| 698 const GURL current_url = web_contents->GetVisibleURL(); |
| 699 if (service && |
| 700 current_url == chrome::GetSettingsUrl(chrome::kSyncSetupSubPage)) { |
| 701 sync_blocker_ = service->GetSetupInProgressHandle(); |
| 702 } |
| 703 } |
| 704 } |
| 705 |
689 void PeopleHandler::FocusUI() { | 706 void PeopleHandler::FocusUI() { |
690 WebContents* web_contents = web_ui()->GetWebContents(); | 707 WebContents* web_contents = web_ui()->GetWebContents(); |
691 web_contents->GetDelegate()->ActivateContents(web_contents); | 708 web_contents->GetDelegate()->ActivateContents(web_contents); |
692 } | 709 } |
693 | 710 |
694 void PeopleHandler::CloseUI() { | 711 void PeopleHandler::CloseUI() { |
695 CloseSyncSetup(); | 712 CloseSyncSetup(); |
696 FireWebUIListener("page-status-changed", base::Value(kDonePageStatus)); | 713 FireWebUIListener("page-status-changed", base::Value(kDonePageStatus)); |
697 } | 714 } |
698 | 715 |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 base::FilePath profile_file_path = profile_->GetPath(); | 922 base::FilePath profile_file_path = profile_->GetPath(); |
906 ProfileMetrics::LogProfileSyncSignIn(profile_file_path); | 923 ProfileMetrics::LogProfileSyncSignIn(profile_file_path); |
907 | 924 |
908 // We're done configuring, so notify ProfileSyncService that it is OK to | 925 // We're done configuring, so notify ProfileSyncService that it is OK to |
909 // start syncing. | 926 // start syncing. |
910 sync_blocker_.reset(); | 927 sync_blocker_.reset(); |
911 service->SetFirstSetupComplete(); | 928 service->SetFirstSetupComplete(); |
912 } | 929 } |
913 | 930 |
914 } // namespace settings | 931 } // namespace settings |
OLD | NEW |