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

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

Powered by Google App Engine
This is Rietveld 408576698