Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(235)

Side by Side Diff: chrome/browser/sync/sync_setup_flow.h

Issue 9295044: Start moving signin code out of browser/sync. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleaned up unnecessary inclusions of signin_manager.h Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #ifndef CHROME_BROWSER_SYNC_SYNC_SETUP_FLOW_H_ 5 #ifndef CHROME_BROWSER_SYNC_SYNC_SETUP_FLOW_H_
6 #define CHROME_BROWSER_SYNC_SYNC_SETUP_FLOW_H_ 6 #define CHROME_BROWSER_SYNC_SYNC_SETUP_FLOW_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 virtual ~SyncSetupFlow(); 55 virtual ~SyncSetupFlow();
56 56
57 // Runs a flow from |start| to |end|, and does the work of actually showing 57 // Runs a flow from |start| to |end|, and does the work of actually showing
58 // the HTML dialog. |container| is kept up-to-date with the lifetime of the 58 // the HTML dialog. |container| is kept up-to-date with the lifetime of the
59 // flow (e.g it is emptied on dialog close). 59 // flow (e.g it is emptied on dialog close).
60 static SyncSetupFlow* Run(ProfileSyncService* service, 60 static SyncSetupFlow* Run(ProfileSyncService* service,
61 SyncSetupFlowContainer* container, 61 SyncSetupFlowContainer* container,
62 SyncSetupWizard::State start, 62 SyncSetupWizard::State start,
63 SyncSetupWizard::State end); 63 SyncSetupWizard::State end);
64 64
65 // Fills |args| with "user" and "error" arguments per our current state.
66 void GetArgsForGaiaLogin(DictionaryValue* args);
67
68 // Fills |args| for the configure screen (Choose Data Types/Encryption) 65 // Fills |args| for the configure screen (Choose Data Types/Encryption)
69 void GetArgsForConfigure(DictionaryValue* args); 66 void GetArgsForConfigure(DictionaryValue* args);
70 67
71 // Attaches the |handler| to this flow. Returns true if successful and false 68 // Attaches the |handler| to this flow. Returns true if successful and false
72 // if a handler has already been attached. 69 // if a handler has already been attached.
73 bool AttachSyncSetupHandler(SyncSetupFlowHandler* handler); 70 bool AttachSyncSetupHandler(SyncSetupFlowHandler* handler);
74 71
75 // Returns true if a handler is attached to this flow. 72 // Returns true if a handler is attached to this flow.
76 bool IsAttached() const; 73 bool IsAttached() const;
77 74
78 // Triggers a state machine transition to advance_state. 75 // Triggers a state machine transition to advance_state.
79 void Advance(SyncSetupWizard::State advance_state); 76 void Advance(SyncSetupWizard::State advance_state);
80 77
81 // Focuses the dialog. This is useful in cases where the dialog has been 78 // Focuses the dialog. This is useful in cases where the dialog has been
82 // obscured by a browser window. 79 // obscured by a browser window.
83 void Focus(); 80 void Focus();
84 81
85 void OnUserSubmittedAuth(const std::string& username,
86 const std::string& password,
87 const std::string& captcha,
88 const std::string& access_code);
89
90 void OnUserSubmittedOAuth(const std::string& oauth1_request_token);
91
92 void OnUserConfigured(const SyncConfiguration& configuration); 82 void OnUserConfigured(const SyncConfiguration& configuration);
93 83
94 // The 'passphrase' screen is used when the user is prompted to enter 84 // The 'passphrase' screen is used when the user is prompted to enter
95 // an existing passphrase. 85 // an existing passphrase.
96 void OnPassphraseEntry(const std::string& passphrase); 86 void OnPassphraseEntry(const std::string& passphrase);
97 87
98 // The user canceled the passphrase entry without supplying a passphrase. 88 // The user canceled the passphrase entry without supplying a passphrase.
99 void OnPassphraseCancel(); 89 void OnPassphraseCancel();
100 90
101 void OnDialogClosed(const std::string& json_retval); 91 void OnDialogClosed(const std::string& json_retval);
102 92
103 private: 93 private:
104 friend class ProfileSyncServiceForWizardTest; 94 friend class ProfileSyncServiceForWizardTest;
105 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, InitialStepLogin); 95 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, InitialStepLogin);
106 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, ChooseDataTypesSetsPrefs); 96 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, ChooseDataTypesSetsPrefs);
107 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, DialogCancelled); 97 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, DialogCancelled);
108 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, InvalidTransitions); 98 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, InvalidTransitions);
109 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, FullSuccessfulRunSetsPref); 99 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, FullSuccessfulRunSetsPref);
110 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, AbortedByPendingClear); 100 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, AbortedByPendingClear);
111 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, DiscreteRunGaiaLogin); 101 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, DiscreteRunGaiaLogin);
112 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, DiscreteRunChooseDataTypes); 102 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, DiscreteRunChooseDataTypes);
113 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, 103 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest,
114 DiscreteRunChooseDataTypesAbortedByPendingClear); 104 DiscreteRunChooseDataTypesAbortedByPendingClear);
115 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, EnterPassphraseRequired); 105 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, EnterPassphraseRequired);
116 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, NonFatalError); 106 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, EnterPassphrase);
107 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, FatalErrorDuringConfigure);
117 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, CrosAuthSetup); 108 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, CrosAuthSetup);
118 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, ShowErrorUIForPasswordTest); 109 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, ShowErrorUIForPasswordTest);
119 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, ShowErrorUIForPassphraseTest); 110 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, ShowErrorUIForPassphraseTest);
120 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardCrosTest, CrosAuthSetup); 111 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardCrosTest, CrosAuthSetup);
121 112
122 // Use static Run method to get an instance. 113 // Use static Run method to get an instance.
123 SyncSetupFlow(SyncSetupWizard::State start_state, 114 SyncSetupFlow(SyncSetupWizard::State start_state,
124 SyncSetupWizard::State end_state, 115 SyncSetupWizard::State end_state,
125 SyncSetupFlowContainer* container, 116 SyncSetupFlowContainer* container,
126 ProfileSyncService* service); 117 ProfileSyncService* service);
127 118
128 // Returns true if |this| should transition its state machine to |state| 119 // Returns true if |this| should transition its state machine to |state|
129 // based on |current_state_|, or false if that would be nonsense or is 120 // based on |current_state_|, or false if that would be nonsense or is
130 // a no-op. 121 // a no-op.
131 bool ShouldAdvance(SyncSetupWizard::State state); 122 bool ShouldAdvance(SyncSetupWizard::State state);
132 123
133 void ActivateState(SyncSetupWizard::State state); 124 void ActivateState(SyncSetupWizard::State state);
134 125
135 SyncSetupFlowContainer* container_; // Our container. Don't own this. 126 SyncSetupFlowContainer* container_; // Our container. Don't own this.
136 127
137 SyncSetupWizard::State current_state_; 128 SyncSetupWizard::State current_state_;
138 SyncSetupWizard::State end_state_; // The goal. 129 SyncSetupWizard::State end_state_; // The goal.
139 130
140 // Time that the GAIA_LOGIN step was received.
141 base::TimeTicks login_start_time_;
142
143 // The handler needed for the entire flow. Weak reference. 131 // The handler needed for the entire flow. Weak reference.
144 SyncSetupFlowHandler* flow_handler_; 132 SyncSetupFlowHandler* flow_handler_;
145 133
146 // We need this to propagate back all user settings changes. Weak reference. 134 // We need this to propagate back all user settings changes. Weak reference.
147 ProfileSyncService* service_; 135 ProfileSyncService* service_;
148 136
149 // Set to true if the user has tried creating an explicit passphrase, so we 137 // Set to true if the user has tried creating an explicit passphrase, so we
150 // can appropriately reflect this in the UI. 138 // can appropriately reflect this in the UI.
151 bool user_tried_creating_explicit_passphrase_; 139 bool user_tried_creating_explicit_passphrase_;
152 140
153 // Set to true if the user entered a passphrase, so we can appropriately 141 // Set to true if the user entered a passphrase, so we can appropriately
154 // reflect this in the UI. 142 // reflect this in the UI.
155 bool user_tried_setting_passphrase_; 143 bool user_tried_setting_passphrase_;
156 144
157 // Cache of the last name the client attempted to authenticate.
158 // TODO(atwilson): Move this out of here entirely and up into the UI layer.
159 std::string last_attempted_user_email_;
160
161 DISALLOW_COPY_AND_ASSIGN(SyncSetupFlow); 145 DISALLOW_COPY_AND_ASSIGN(SyncSetupFlow);
162 }; 146 };
163 147
164 // A really simple wrapper for a SyncSetupFlow so that we don't have to 148 // A really simple wrapper for a SyncSetupFlow so that we don't have to
165 // add any public methods to the public SyncSetupWizard interface to notify it 149 // add any public methods to the public SyncSetupWizard interface to notify it
166 // when the dialog closes. 150 // when the dialog closes.
167 class SyncSetupFlowContainer { 151 class SyncSetupFlowContainer {
168 public: 152 public:
169 SyncSetupFlowContainer() : flow_(NULL) { } 153 SyncSetupFlowContainer() : flow_(NULL) { }
170 void set_flow(SyncSetupFlow* flow) { 154 void set_flow(SyncSetupFlow* flow) {
171 DCHECK(!flow_ || !flow); 155 DCHECK(!flow_ || !flow);
172 flow_ = flow; 156 flow_ = flow;
173 } 157 }
174 158
175 SyncSetupFlow* get_flow() { return flow_; } 159 SyncSetupFlow* get_flow() { return flow_; }
176 private: 160 private:
177 SyncSetupFlow* flow_; 161 SyncSetupFlow* flow_;
178 162
179 DISALLOW_COPY_AND_ASSIGN(SyncSetupFlowContainer); 163 DISALLOW_COPY_AND_ASSIGN(SyncSetupFlowContainer);
180 }; 164 };
181 165
182 #endif // CHROME_BROWSER_SYNC_SYNC_SETUP_FLOW_H_ 166 #endif // CHROME_BROWSER_SYNC_SYNC_SETUP_FLOW_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service_mock.cc ('k') | chrome/browser/sync/sync_setup_flow.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698