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

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

Issue 1892873002: Add CheckAndroidManagement to ARC sign-in flow. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@check_android_management
Patch Set: Added OnShutdownBridge to observer. Created 4 years, 7 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
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 <ostream> 8 #include <ostream>
9 #include <string>
9 10
10 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h"
11 #include "base/observer_list.h" 13 #include "base/observer_list.h"
14 #include "chrome/browser/chromeos/policy/android_management_client.h"
12 #include "components/arc/arc_bridge_service.h" 15 #include "components/arc/arc_bridge_service.h"
13 #include "components/arc/arc_service.h" 16 #include "components/arc/arc_service.h"
14 #include "components/arc/common/auth.mojom.h" 17 #include "components/arc/common/auth.mojom.h"
15 #include "components/prefs/pref_change_registrar.h" 18 #include "components/prefs/pref_change_registrar.h"
16 #include "components/syncable_prefs/pref_service_syncable_observer.h" 19 #include "components/syncable_prefs/pref_service_syncable_observer.h"
17 #include "components/syncable_prefs/synced_pref_observer.h" 20 #include "components/syncable_prefs/synced_pref_observer.h"
18 #include "google_apis/gaia/gaia_auth_consumer.h"
19 #include "google_apis/gaia/ubertoken_fetcher.h" 21 #include "google_apis/gaia/ubertoken_fetcher.h"
20 #include "mojo/public/cpp/bindings/binding.h" 22 #include "mojo/public/cpp/bindings/binding.h"
21 23
22 class ArcAppLauncher; 24 class ArcAppLauncher;
23 class GaiaAuthFetcher; 25 class GaiaAuthFetcher;
24 class Profile; 26 class Profile;
27 class ProfileOAuth2TokenService;
25 28
26 namespace content { 29 namespace content {
27 class StoragePartition; 30 class StoragePartition;
28 } 31 }
29 32
30 namespace net { 33 namespace net {
31 class URLRequestContextGetter; 34 class URLRequestContextGetter;
32 } 35 }
33 36
34 namespace user_prefs { 37 namespace user_prefs {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 virtual ~Observer() = default; 70 virtual ~Observer() = default;
68 71
69 // Called whenever Opt-In state of the ARC has been changed. 72 // Called whenever Opt-In state of the ARC has been changed.
70 virtual void OnOptInChanged(State state) {} 73 virtual void OnOptInChanged(State state) {}
71 74
72 // Called to notify that OptIn UI needs to be closed. 75 // Called to notify that OptIn UI needs to be closed.
73 virtual void OnOptInUIClose() {} 76 virtual void OnOptInUIClose() {}
74 77
75 // Called to notify that OptIn UI needs to show specific page. 78 // Called to notify that OptIn UI needs to show specific page.
76 virtual void OnOptInUIShowPage(UIPage page, const base::string16& status) {} 79 virtual void OnOptInUIShowPage(UIPage page, const base::string16& status) {}
80
81 // Called to notify that ARC bridge is shutdown.
bartfab (slow) 2016/05/02 14:55:48 Nit: s/shutdown/shut down/
Polina Bondarenko 2016/05/03 13:41:54 Done.
82 virtual void OnShutdownBridge() {}
77 }; 83 };
78 84
79 explicit ArcAuthService(ArcBridgeService* bridge_service); 85 explicit ArcAuthService(ArcBridgeService* bridge_service);
80 ~ArcAuthService() override; 86 ~ArcAuthService() override;
81 87
82 static ArcAuthService* Get(); 88 static ArcAuthService* Get();
83 89
84 // It is called from chrome/browser/prefs/browser_prefs.cc. 90 // It is called from chrome/browser/prefs/browser_prefs.cc.
85 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 91 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
86 92
87 static void DisableUIForTesting(); 93 static void DisableUIForTesting();
88 94
89 // Checks if OptIn verification was disabled by switch in command line. 95 // Checks if OptIn verification was disabled by switch in command line.
90 static bool IsOptInVerificationDisabled(); 96 static bool IsOptInVerificationDisabled();
91 97
98 static void EnableCheckAndroidManagementForTesting();
99
92 void OnPrimaryUserProfilePrepared(Profile* profile); 100 void OnPrimaryUserProfilePrepared(Profile* profile);
93 void Shutdown(); 101 void Shutdown();
94 102
95 State state() const { return state_; } 103 State state() const { return state_; }
96 104
97 std::string GetAndResetAuthCode(); 105 std::string GetAndResetAuthCode();
98 106
99 // Adds or removes observers. 107 // Adds or removes observers.
100 void AddObserver(Observer* observer); 108 void AddObserver(Observer* observer);
101 void RemoveObserver(Observer* observer); 109 void RemoveObserver(Observer* observer);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 void ShowUI(UIPage page, const base::string16& status); 161 void ShowUI(UIPage page, const base::string16& status);
154 void CloseUI(); 162 void CloseUI();
155 void SetUIPage(UIPage page, const base::string16& status); 163 void SetUIPage(UIPage page, const base::string16& status);
156 void SetState(State state); 164 void SetState(State state);
157 void ShutdownBridge(); 165 void ShutdownBridge();
158 void ShutdownBridgeAndCloseUI(); 166 void ShutdownBridgeAndCloseUI();
159 void ShutdownBridgeAndShowUI(UIPage page, const base::string16& status); 167 void ShutdownBridgeAndShowUI(UIPage page, const base::string16& status);
160 void OnOptInPreferenceChanged(); 168 void OnOptInPreferenceChanged();
161 void StartUI(); 169 void StartUI();
162 void OnPrepareContextFailed(); 170 void OnPrepareContextFailed();
171 void StartAndroidManagementClient();
172 void CheckAndroidManagement();
173 void OnAndroidManagementChecked(
174 policy::AndroidManagementClient::Result result);
163 175
164 // Unowned pointer. Keeps current profile. 176 // Unowned pointer. Keeps current profile.
165 Profile* profile_ = nullptr; 177 Profile* profile_ = nullptr;
166 // Owned by content::BrowserContent. Used to isolate cookies for auth server 178 // Owned by content::BrowserContent. Used to isolate cookies for auth server
167 // communication and shared with Arc OptIn UI platform app. 179 // communication and shared with Arc OptIn UI platform app.
168 content::StoragePartition* storage_partition_ = nullptr; 180 content::StoragePartition* storage_partition_ = nullptr;
169 181
170 // Registrar used to monitor ARC enabled state. 182 // Registrar used to monitor ARC enabled state.
171 PrefChangeRegistrar pref_change_registrar_; 183 PrefChangeRegistrar pref_change_registrar_;
172 184
173 mojo::Binding<AuthHost> binding_; 185 mojo::Binding<AuthHost> binding_;
174 State state_ = State::STOPPED; 186 State state_ = State::STOPPED;
175 base::ObserverList<Observer> observer_list_; 187 base::ObserverList<Observer> observer_list_;
176 std::unique_ptr<GaiaAuthFetcher> merger_fetcher_; 188 std::unique_ptr<GaiaAuthFetcher> merger_fetcher_;
177 std::unique_ptr<UbertokenFetcher> ubertoken_fethcher_; 189 std::unique_ptr<UbertokenFetcher> ubertoken_fethcher_;
178 std::unique_ptr<ArcAppLauncher> playstore_launcher_; 190 std::unique_ptr<ArcAppLauncher> playstore_launcher_;
179 std::string auth_code_; 191 std::string auth_code_;
180 GetAuthCodeCallback auth_callback_; 192 GetAuthCodeCallback auth_callback_;
181 bool initial_opt_in_ = false; 193 bool initial_opt_in_ = false;
182 bool context_prepared_ = false; 194 bool context_prepared_ = false;
183 UIPage ui_page_ = UIPage::NO_PAGE; 195 UIPage ui_page_ = UIPage::NO_PAGE;
184 base::string16 ui_page_status_; 196 base::string16 ui_page_status_;
185 197
198 ProfileOAuth2TokenService* token_service_;
199 std::string account_id_;
200 std::unique_ptr<policy::AndroidManagementClient> android_management_client_;
bartfab (slow) 2016/05/02 14:55:48 Nit: #include <memory>
Polina Bondarenko 2016/05/03 13:41:54 Done.
201
202 base::WeakPtrFactory<ArcAuthService> weak_ptr_factory_;
203
186 DISALLOW_COPY_AND_ASSIGN(ArcAuthService); 204 DISALLOW_COPY_AND_ASSIGN(ArcAuthService);
187 }; 205 };
188 206
189 std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state); 207 std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state);
190 208
191 } // namespace arc 209 } // namespace arc
192 210
193 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ 211 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698