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

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

Issue 2490093002: Migrate opt-in auth flow to re-auth flow. (Closed)
Patch Set: rebase 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/arc/arc_auth_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 // FETCHING_CODE -> ACTIVE: when the auth token is successfully fetched. 98 // FETCHING_CODE -> ACTIVE: when the auth token is successfully fetched.
99 // 99 //
100 // In the second (or later) boot case: 100 // In the second (or later) boot case:
101 // STOPPED -> ACTIVE: when arc.enabled preference is checked that it is 101 // STOPPED -> ACTIVE: when arc.enabled preference is checked that it is
102 // true. Practically, this is when the primary Profile gets ready. 102 // true. Practically, this is when the primary Profile gets ready.
103 enum class State { 103 enum class State {
104 NOT_INITIALIZED, 104 NOT_INITIALIZED,
105 STOPPED, 105 STOPPED,
106 SHOWING_TERMS_OF_SERVICE, 106 SHOWING_TERMS_OF_SERVICE,
107 CHECKING_ANDROID_MANAGEMENT, 107 CHECKING_ANDROID_MANAGEMENT,
108 FETCHING_CODE,
109 ACTIVE, 108 ACTIVE,
110 }; 109 };
111 110
112 class Observer { 111 class Observer {
113 public: 112 public:
114 virtual ~Observer() = default; 113 virtual ~Observer() = default;
115 114
116 // Called to notify that ARC bridge is shut down. 115 // Called to notify that ARC bridge is shut down.
117 virtual void OnShutdownBridge() {} 116 virtual void OnShutdownBridge() {}
118 117
(...skipping 27 matching lines...) Expand all
146 bool IsAllowed() const; 145 bool IsAllowed() const;
147 146
148 void OnPrimaryUserProfilePrepared(Profile* profile); 147 void OnPrimaryUserProfilePrepared(Profile* profile);
149 void Shutdown(); 148 void Shutdown();
150 149
151 Profile* profile() { return profile_; } 150 Profile* profile() { return profile_; }
152 const Profile* profile() const { return profile_; } 151 const Profile* profile() const { return profile_; }
153 152
154 State state() const { return state_; } 153 State state() const { return state_; }
155 154
156 std::string GetAndResetAuthCode();
157
158 // Adds or removes observers. 155 // Adds or removes observers.
159 void AddObserver(Observer* observer); 156 void AddObserver(Observer* observer);
160 void RemoveObserver(Observer* observer); 157 void RemoveObserver(Observer* observer);
161 158
162 // ArcBridgeService::Observer: 159 // ArcBridgeService::Observer:
163 void OnBridgeStopped(ArcBridgeService::StopReason reason) override; 160 void OnBridgeStopped(ArcBridgeService::StopReason reason) override;
164 161
165 // InstanceHolder<mojom::AuthInstance>::Observer: 162 // InstanceHolder<mojom::AuthInstance>::Observer:
166 void OnInstanceReady() override; 163 void OnInstanceReady() override;
167 164
(...skipping 12 matching lines...) Expand all
180 void GetAuthCodeAndAccountTypeDeprecated( 177 void GetAuthCodeAndAccountTypeDeprecated(
181 const GetAuthCodeAndAccountTypeDeprecatedCallback& callback) override; 178 const GetAuthCodeAndAccountTypeDeprecatedCallback& callback) override;
182 // Callback is called with a bool that indicates the management status of the 179 // Callback is called with a bool that indicates the management status of the
183 // user. 180 // user.
184 void GetIsAccountManagedDeprecated( 181 void GetIsAccountManagedDeprecated(
185 const GetIsAccountManagedDeprecatedCallback& callback) override; 182 const GetIsAccountManagedDeprecatedCallback& callback) override;
186 183
187 void OnSignInFailedInternal(ProvisioningResult result); 184 void OnSignInFailedInternal(ProvisioningResult result);
188 185
189 // Called from Arc support platform app to set auth code and start arc. 186 // Called from Arc support platform app to set auth code and start arc.
190 void SetAuthCodeAndStartArc(const std::string& auth_code); 187 void OnAuthCodeObtained(const std::string& auth_code);
191 188
192 // Called from Arc support platform app when user cancels signing. 189 // Called from Arc support platform app when user cancels signing.
193 void CancelAuthCode(); 190 void CancelAuthCode();
194 191
195 bool IsArcManaged() const; 192 bool IsArcManaged() const;
196 bool IsArcEnabled() const; 193 bool IsArcEnabled() const;
197 194
198 // This requires Arc to be allowed (|IsAllowed|)for current profile. 195 // This requires Arc to be allowed (|IsAllowed|)for current profile.
199 void EnableArc(); 196 void EnableArc();
200 void DisableArc(); 197 void DisableArc();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 void RemoveArcData(); 241 void RemoveArcData();
245 242
246 // Returns current page that has to be shown in OptIn UI. 243 // Returns current page that has to be shown in OptIn UI.
247 ArcSupportHost::UIPage ui_page() const { return ui_page_; } 244 ArcSupportHost::UIPage ui_page() const { return ui_page_; }
248 245
249 // Returns current page status, relevant to the specific page. 246 // Returns current page status, relevant to the specific page.
250 const base::string16& ui_page_status() const { return ui_page_status_; } 247 const base::string16& ui_page_status() const { return ui_page_status_; }
251 248
252 ArcSupportHost* support_host() { return support_host_.get(); } 249 ArcSupportHost* support_host() { return support_host_.get(); }
253 250
251 void StartArc();
252
254 private: 253 private:
255 using AccountInfoCallback = base::Callback<void(mojom::AccountInfoPtr)>; 254 using AccountInfoCallback = base::Callback<void(mojom::AccountInfoPtr)>;
256 class AccountInfoNotifier; 255 class AccountInfoNotifier;
257 256
258 void StartArc();
259 // TODO(hidehiko): move UI methods/fields to ArcSupportHost. 257 // TODO(hidehiko): move UI methods/fields to ArcSupportHost.
260 void ShowUI(ArcSupportHost::UIPage page, const base::string16& status); 258 void ShowUI(ArcSupportHost::UIPage page, const base::string16& status);
261 void CloseUI(); 259 void CloseUI();
262 void SetUIPage(ArcSupportHost::UIPage page, const base::string16& status); 260 void SetUIPage(ArcSupportHost::UIPage page, const base::string16& status);
263 void SetState(State state); 261 void SetState(State state);
264 void ShutdownBridge(); 262 void ShutdownBridge();
265 void ShutdownBridgeAndCloseUI(); 263 void ShutdownBridgeAndCloseUI();
266 void ShutdownBridgeAndShowUI(ArcSupportHost::UIPage page, 264 void ShutdownBridgeAndShowUI(ArcSupportHost::UIPage page,
267 const base::string16& status); 265 const base::string16& status);
268 void OnOptInPreferenceChanged(); 266 void OnOptInPreferenceChanged();
(...skipping 24 matching lines...) Expand all
293 // Unowned pointer. Keeps current profile. 291 // Unowned pointer. Keeps current profile.
294 Profile* profile_ = nullptr; 292 Profile* profile_ = nullptr;
295 293
296 // Registrar used to monitor ARC enabled state. 294 // Registrar used to monitor ARC enabled state.
297 PrefChangeRegistrar pref_change_registrar_; 295 PrefChangeRegistrar pref_change_registrar_;
298 296
299 mojo::Binding<AuthHost> binding_; 297 mojo::Binding<AuthHost> binding_;
300 State state_ = State::NOT_INITIALIZED; 298 State state_ = State::NOT_INITIALIZED;
301 base::ObserverList<Observer> observer_list_; 299 base::ObserverList<Observer> observer_list_;
302 std::unique_ptr<ArcAppLauncher> playstore_launcher_; 300 std::unique_ptr<ArcAppLauncher> playstore_launcher_;
303 std::string auth_code_;
304 ArcSupportHost::UIPage ui_page_ = ArcSupportHost::UIPage::NO_PAGE; 301 ArcSupportHost::UIPage ui_page_ = ArcSupportHost::UIPage::NO_PAGE;
305 base::string16 ui_page_status_; 302 base::string16 ui_page_status_;
306 bool clear_required_ = false; 303 bool clear_required_ = false;
307 bool reenable_arc_ = false; 304 bool reenable_arc_ = false;
308 base::OneShotTimer arc_sign_in_timer_; 305 base::OneShotTimer arc_sign_in_timer_;
309 306
310 // Notifies the correct callback whenever the auth_code is ready. 307 // Notifies the correct callback whenever the auth_code is ready.
311 std::unique_ptr<AccountInfoNotifier> account_info_notifier_; 308 std::unique_ptr<AccountInfoNotifier> account_info_notifier_;
312 309
313 // Temporarily keeps the ArcSupportHost instance. 310 // Temporarily keeps the ArcSupportHost instance.
(...skipping 14 matching lines...) Expand all
328 325
329 DISALLOW_COPY_AND_ASSIGN(ArcAuthService); 326 DISALLOW_COPY_AND_ASSIGN(ArcAuthService);
330 }; 327 };
331 328
332 // Outputs the stringified |state| to |os|. This is only for logging purposes. 329 // Outputs the stringified |state| to |os|. This is only for logging purposes.
333 std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state); 330 std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state);
334 331
335 } // namespace arc 332 } // namespace arc
336 333
337 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ 334 #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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698