OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/sync/one_click_signin_sync_starter.h" | 5 #include "chrome/browser/ui/sync/one_click_signin_sync_starter.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/signin/signin_manager.h" | 9 #include "chrome/browser/signin/signin_manager.h" |
10 #include "chrome/browser/signin/signin_manager_factory.h" | 10 #include "chrome/browser/signin/signin_manager_factory.h" |
11 #include "chrome/browser/sync/profile_sync_service.h" | 11 #include "chrome/browser/sync/profile_sync_service.h" |
12 #include "chrome/browser/sync/profile_sync_service_factory.h" | 12 #include "chrome/browser/sync/profile_sync_service_factory.h" |
13 #include "chrome/browser/ui/sync/one_click_signin_histogram.h" | 13 #include "chrome/browser/ui/sync/one_click_signin_histogram.h" |
14 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 14 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
15 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 15 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
16 | 16 |
17 OneClickSigninSyncStarter::OneClickSigninSyncStarter( | 17 OneClickSigninSyncStarter::OneClickSigninSyncStarter( |
18 Profile* profile, | 18 Profile* profile, |
19 const std::string& session_index, | 19 const std::string& session_index, |
20 const std::string& email, | 20 const std::string& email, |
21 const std::string& password, | 21 const std::string& password, |
22 bool use_default_settings) | 22 StartSyncMode start_mode) |
23 : profile_(profile), | 23 : profile_(profile), |
24 signin_tracker_(profile, this), | 24 signin_tracker_(profile, this), |
25 use_default_settings_(use_default_settings) { | 25 start_mode_(start_mode) { |
26 DCHECK(profile_); | 26 DCHECK(profile_); |
27 | 27 |
28 int action = use_default_settings ? one_click_signin::HISTOGRAM_WITH_DEFAULTS | 28 int action = start_mode_ == SYNC_WITH_DEFAULT_SETTINGS |
29 : one_click_signin::HISTOGRAM_WITH_ADVANCED; | 29 ? one_click_signin::HISTOGRAM_WITH_DEFAULTS |
Peter Kasting
2012/05/24 22:25:18
Nit: Operators go before linebreaks (2 places)
Roger Tawa OOO till Jul 10th
2012/05/25 16:04:08
Done.
| |
30 : one_click_signin::HISTOGRAM_WITH_ADVANCED; | |
30 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse", action, | 31 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse", action, |
31 one_click_signin::HISTOGRAM_MAX); | 32 one_click_signin::HISTOGRAM_MAX); |
32 | 33 |
33 ProfileSyncService* profile_sync_service = | 34 ProfileSyncService* profile_sync_service = |
34 ProfileSyncServiceFactory::GetForProfile(profile_); | 35 ProfileSyncServiceFactory::GetForProfile(profile_); |
35 // Let the sync service know that setup is in progress so it doesn't start | 36 // Let the sync service know that setup is in progress so it doesn't start |
36 // syncing until the user has finished any configuration. | 37 // syncing until the user has finished any configuration. |
37 profile_sync_service->set_setup_in_progress(true); | 38 profile_sync_service->set_setup_in_progress(true); |
38 SigninManager* manager = SigninManagerFactory::GetForProfile(profile_); | 39 SigninManager* manager = SigninManagerFactory::GetForProfile(profile_); |
39 manager->StartSignInWithCredentials(session_index, email, password); | 40 manager->StartSignInWithCredentials(session_index, email, password); |
(...skipping 10 matching lines...) Expand all Loading... | |
50 ProfileSyncService* profile_sync_service = | 51 ProfileSyncService* profile_sync_service = |
51 ProfileSyncServiceFactory::GetForProfile(profile_); | 52 ProfileSyncServiceFactory::GetForProfile(profile_); |
52 profile_sync_service->set_setup_in_progress(false); | 53 profile_sync_service->set_setup_in_progress(false); |
53 delete this; | 54 delete this; |
54 } | 55 } |
55 | 56 |
56 void OneClickSigninSyncStarter::SigninSuccess() { | 57 void OneClickSigninSyncStarter::SigninSuccess() { |
57 ProfileSyncService* profile_sync_service = | 58 ProfileSyncService* profile_sync_service = |
58 ProfileSyncServiceFactory::GetForProfile(profile_); | 59 ProfileSyncServiceFactory::GetForProfile(profile_); |
59 | 60 |
60 if (use_default_settings_) { | 61 if (start_mode_ == SYNC_WITH_DEFAULT_SETTINGS) { |
61 // Just kick off the sync machine, no need to configure it first. | 62 // Just kick off the sync machine, no need to configure it first. |
62 profile_sync_service->SetSyncSetupCompleted(); | 63 profile_sync_service->SetSyncSetupCompleted(); |
63 profile_sync_service->set_setup_in_progress(false); | 64 profile_sync_service->set_setup_in_progress(false); |
64 profile_sync_service->UnsuppressAndStart(); | 65 profile_sync_service->UnsuppressAndStart(); |
65 } else { | 66 } else { |
66 // Give the user a chance to configure things. We don't clear the | 67 // Give the user a chance to configure things. We don't clear the |
67 // ProfileSyncService::setup_in_progress flag because we don't want sync | 68 // ProfileSyncService::setup_in_progress flag because we don't want sync |
68 // to start up until after the configure UI is displayed (the configure UI | 69 // to start up until after the configure UI is displayed (the configure UI |
69 // will clear the flag when the user is done setting up sync). | 70 // will clear the flag when the user is done setting up sync). |
70 LoginUIServiceFactory::GetForProfile(profile_)->ShowLoginUI(); | 71 LoginUIServiceFactory::GetForProfile(profile_)->ShowLoginUI(); |
71 } | 72 } |
72 | 73 |
73 delete this; | 74 delete this; |
74 } | 75 } |
OLD | NEW |