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

Side by Side Diff: chrome/browser/chromeos/arc/arc_auth_service.h

Issue 2474663003: arc: Shuffle ArcAuthService's interface (Closed)
Patch Set: Formatting Created 4 years, 1 month 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_
6 #define CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ 6 #define CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <ostream> 9 #include <ostream>
10 #include <string> 10 #include <string>
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 void AddObserver(Observer* observer); 126 void AddObserver(Observer* observer);
127 void RemoveObserver(Observer* observer); 127 void RemoveObserver(Observer* observer);
128 128
129 // ArcBridgeService::Observer: 129 // ArcBridgeService::Observer:
130 void OnBridgeStopped(ArcBridgeService::StopReason reason) override; 130 void OnBridgeStopped(ArcBridgeService::StopReason reason) override;
131 131
132 // InstanceHolder<mojom::AuthInstance>::Observer: 132 // InstanceHolder<mojom::AuthInstance>::Observer:
133 void OnInstanceReady() override; 133 void OnInstanceReady() override;
134 134
135 // AuthHost: 135 // AuthHost:
136 void OnSignInComplete() override;
137 void OnSignInFailed(mojom::ArcSignInFailureReason reason) override;
138 void RequestAccountInformation() override;
139
140 // Deprecated methods:
136 // For security reason this code can be used only once and exists for specific 141 // For security reason this code can be used only once and exists for specific
137 // period of time. 142 // period of time.
143 void GetAuthCodeDeprecated0(
144 const GetAuthCodeDeprecated0Callback& callback) override;
138 void GetAuthCodeDeprecated( 145 void GetAuthCodeDeprecated(
139 const GetAuthCodeDeprecatedCallback& callback) override; 146 const GetAuthCodeDeprecatedCallback& callback) override;
140 void GetAuthCode(const GetAuthCodeCallback& callback) override; 147 void GetAuthCodeAndAccountTypeDeprecated(
141 void GetAuthCodeAndAccountType( 148 const GetAuthCodeAndAccountTypeDeprecatedCallback& callback) override;
142 const GetAuthCodeAndAccountTypeCallback& callback) override;
143 void OnSignInComplete() override;
144 void OnSignInFailed(mojom::ArcSignInFailureReason reason) override;
145 // Callback is called with a bool that indicates the management status of the 149 // Callback is called with a bool that indicates the management status of the
146 // user. 150 // user.
147 void GetIsAccountManaged( 151 void GetIsAccountManagedDeprecated(
148 const GetIsAccountManagedCallback& callback) override; 152 const GetIsAccountManagedDeprecatedCallback& callback) override;
149 153
150 void OnSignInFailedInternal(ProvisioningResult result); 154 void OnSignInFailedInternal(ProvisioningResult result);
151 155
152 // Called from Arc support platform app to start LSO. 156 // Called from Arc support platform app to start LSO.
153 void StartLso(); 157 void StartLso();
154 158
155 // Called from Arc support platform app to set auth code and start arc. 159 // Called from Arc support platform app to set auth code and start arc.
156 void SetAuthCodeAndStartArc(const std::string& auth_code); 160 void SetAuthCodeAndStartArc(const std::string& auth_code);
157 161
158 // Called from Arc support platform app when user cancels signing. 162 // Called from Arc support platform app when user cancels signing.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 197
194 // Returns current page that has to be shown in OptIn UI. 198 // Returns current page that has to be shown in OptIn UI.
195 UIPage ui_page() const { return ui_page_; } 199 UIPage ui_page() const { return ui_page_; }
196 200
197 // Returns current page status, relevant to the specific page. 201 // Returns current page status, relevant to the specific page.
198 const base::string16& ui_page_status() const { return ui_page_status_; } 202 const base::string16& ui_page_status() const { return ui_page_status_; }
199 203
200 ArcSupportHost* support_host() { return support_host_.get(); } 204 ArcSupportHost* support_host() { return support_host_.get(); }
201 205
202 private: 206 private:
207 using AccountInformationCallback =
208 base::Callback<void(mojom::AccountInformationPtr)>;
209 class AccountInformationNotifier;
210
203 void StartArc(); 211 void StartArc();
204 // TODO: move UI methods/fields to ArcSupportHost. 212 // TODO(hidehiko): move UI methods/fields to ArcSupportHost.
205 void ShowUI(UIPage page, const base::string16& status); 213 void ShowUI(UIPage page, const base::string16& status);
206 void CloseUI(); 214 void CloseUI();
207 void SetUIPage(UIPage page, const base::string16& status); 215 void SetUIPage(UIPage page, const base::string16& status);
208 void SetState(State state); 216 void SetState(State state);
209 void ShutdownBridge(); 217 void ShutdownBridge();
210 void ShutdownBridgeAndCloseUI(); 218 void ShutdownBridgeAndCloseUI();
211 void ShutdownBridgeAndShowUI(UIPage page, const base::string16& status); 219 void ShutdownBridgeAndShowUI(UIPage page, const base::string16& status);
212 void OnOptInPreferenceChanged(); 220 void OnOptInPreferenceChanged();
213 void StartUI(); 221 void StartUI();
214 void StartAndroidManagementClient(); 222 void StartAndroidManagementClient();
215 void OnAndroidManagementPassed(); 223 void OnAndroidManagementPassed();
216 void OnArcDataRemoved(bool success); 224 void OnArcDataRemoved(bool success);
217 void OnArcSignInTimeout(); 225 void OnArcSignInTimeout();
218 bool IsAuthCodeRequest() const; 226 bool IsAuthCodeRequest() const;
219 void FetchAuthCode(); 227 void FetchAuthCode();
220 void PrepareContextForAuthCodeRequest(); 228 void PrepareContextForAuthCodeRequest();
229 void RequestAccountInformationInternal(
230 std::unique_ptr<AccountInformationNotifier> account_information_notifier);
231 void OnAccountInformationReady(
232 mojom::AccountInformationPtr account_information);
221 233
222 // Called when the Android management check is done in opt-in flow or 234 // Called when the Android management check is done in opt-in flow or
223 // re-auth flow. 235 // re-auth flow.
224 void OnAndroidManagementChecked( 236 void OnAndroidManagementChecked(
225 policy::AndroidManagementClient::Result result); 237 policy::AndroidManagementClient::Result result);
226 238
227 // Called when the background Android management check is done. It is 239 // Called when the background Android management check is done. It is
228 // triggered when the second or later ARC boot timing. 240 // triggered when the second or later ARC boot timing.
229 void OnBackgroundAndroidManagementChecked( 241 void OnBackgroundAndroidManagementChecked(
230 policy::AndroidManagementClient::Result result); 242 policy::AndroidManagementClient::Result result);
231 243
232 // Unowned pointer. Keeps current profile. 244 // Unowned pointer. Keeps current profile.
233 Profile* profile_ = nullptr; 245 Profile* profile_ = nullptr;
234 246
235 // Registrar used to monitor ARC enabled state. 247 // Registrar used to monitor ARC enabled state.
236 PrefChangeRegistrar pref_change_registrar_; 248 PrefChangeRegistrar pref_change_registrar_;
237 249
238 mojo::Binding<AuthHost> binding_; 250 mojo::Binding<AuthHost> binding_;
239 State state_ = State::NOT_INITIALIZED; 251 State state_ = State::NOT_INITIALIZED;
240 base::ObserverList<Observer> observer_list_; 252 base::ObserverList<Observer> observer_list_;
241 std::unique_ptr<ArcAppLauncher> playstore_launcher_; 253 std::unique_ptr<ArcAppLauncher> playstore_launcher_;
242 std::string auth_code_; 254 std::string auth_code_;
243 GetAuthCodeCallback auth_callback_;
244 GetAuthCodeAndAccountTypeCallback auth_account_callback_;
245 bool initial_opt_in_ = false; 255 bool initial_opt_in_ = false;
246 UIPage ui_page_ = UIPage::NO_PAGE; 256 UIPage ui_page_ = UIPage::NO_PAGE;
247 base::string16 ui_page_status_; 257 base::string16 ui_page_status_;
248 bool clear_required_ = false; 258 bool clear_required_ = false;
249 bool reenable_arc_ = false; 259 bool reenable_arc_ = false;
250 base::OneShotTimer arc_sign_in_timer_; 260 base::OneShotTimer arc_sign_in_timer_;
251 261
262 // Notifies the correct callback whenever the auth_code is ready.
263 std::unique_ptr<AccountInformationNotifier> account_information_notifier_;
264
252 // Temporarily keeps the ArcSupportHost instance. 265 // Temporarily keeps the ArcSupportHost instance.
253 // This should be moved to ArcSessionManager when the refactoring is 266 // This should be moved to ArcSessionManager when the refactoring is
254 // done. 267 // done.
255 std::unique_ptr<ArcSupportHost> support_host_; 268 std::unique_ptr<ArcSupportHost> support_host_;
256 269
257 std::unique_ptr<ArcAuthContext> context_; 270 std::unique_ptr<ArcAuthContext> context_;
258 std::unique_ptr<ArcAuthCodeFetcher> auth_code_fetcher_; 271 std::unique_ptr<ArcAuthCodeFetcher> auth_code_fetcher_;
259 std::unique_ptr<ArcAndroidManagementChecker> android_management_checker_; 272 std::unique_ptr<ArcAndroidManagementChecker> android_management_checker_;
260 273
261 base::Time sign_in_time_; 274 base::Time sign_in_time_;
262 275
263 base::WeakPtrFactory<ArcAuthService> weak_ptr_factory_; 276 base::WeakPtrFactory<ArcAuthService> weak_ptr_factory_;
264 277
265 DISALLOW_COPY_AND_ASSIGN(ArcAuthService); 278 DISALLOW_COPY_AND_ASSIGN(ArcAuthService);
266 }; 279 };
267 280
268 // Outputs the stringified |state| to |os|. This is only for logging purposes. 281 // Outputs the stringified |state| to |os|. This is only for logging purposes.
269 std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state); 282 std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state);
270 283
271 } // namespace arc 284 } // namespace arc
272 285
273 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ 286 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/arc/arc_auth_service.cc » ('j') | chrome/browser/chromeos/arc/arc_auth_service.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698