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

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 browser test for ArcAuthService. Created 4 years, 8 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"
11 #include "base/observer_list.h" 12 #include "base/observer_list.h"
13 #include "chrome/browser/chromeos/policy/android_management_client.h"
12 #include "components/arc/arc_bridge_service.h" 14 #include "components/arc/arc_bridge_service.h"
13 #include "components/arc/arc_service.h" 15 #include "components/arc/arc_service.h"
14 #include "components/arc/common/auth.mojom.h" 16 #include "components/arc/common/auth.mojom.h"
15 #include "components/prefs/pref_change_registrar.h" 17 #include "components/prefs/pref_change_registrar.h"
16 #include "components/syncable_prefs/pref_service_syncable_observer.h" 18 #include "components/syncable_prefs/pref_service_syncable_observer.h"
17 #include "components/syncable_prefs/synced_pref_observer.h" 19 #include "components/syncable_prefs/synced_pref_observer.h"
18 #include "google_apis/gaia/gaia_auth_consumer.h" 20 #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
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 static ArcAuthService* Get(); 83 static ArcAuthService* Get();
82 84
83 // It is called from chrome/browser/prefs/browser_prefs.cc. 85 // It is called from chrome/browser/prefs/browser_prefs.cc.
84 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 86 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
85 87
86 static void DisableUIForTesting(); 88 static void DisableUIForTesting();
87 89
88 // Checks if OptIn verification was disabled by switch in command line. 90 // Checks if OptIn verification was disabled by switch in command line.
89 static bool IsOptInVerificationDisabled(); 91 static bool IsOptInVerificationDisabled();
90 92
93 static void EnableCheckAndroidManagementForTesting();
94
91 void OnPrimaryUserProfilePrepared(Profile* profile); 95 void OnPrimaryUserProfilePrepared(Profile* profile);
92 void Shutdown(); 96 void Shutdown();
93 97
94 State state() const { return state_; } 98 State state() const { return state_; }
95 99
96 std::string GetAndResetAuthCode(); 100 std::string GetAndResetAuthCode();
97 101
98 // Adds or removes observers. 102 // Adds or removes observers.
99 void AddObserver(Observer* observer); 103 void AddObserver(Observer* observer);
100 void RemoveObserver(Observer* observer); 104 void RemoveObserver(Observer* observer);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 void OnIsSyncingChanged() override; 143 void OnIsSyncingChanged() override;
140 144
141 // syncable_prefs::SyncedPrefObserver 145 // syncable_prefs::SyncedPrefObserver
142 void OnSyncedPrefChanged(const std::string& path, bool from_sync) override; 146 void OnSyncedPrefChanged(const std::string& path, bool from_sync) override;
143 147
144 // Returns current page that has to be shown in OptIn UI. 148 // Returns current page that has to be shown in OptIn UI.
145 UIPage ui_page() const { return ui_page_; } 149 UIPage ui_page() const { return ui_page_; }
146 // Returns current page status, relevant to the specific page. 150 // Returns current page status, relevant to the specific page.
147 const base::string16& ui_page_status() { return ui_page_status_; } 151 const base::string16& ui_page_status() { return ui_page_status_; }
148 152
153 // Set auth_token only for testing when check Android management is enabled
154 // for testing.
155 void set_auth_token_for_testing(const std::string& auth_token) {
156 auth_token_ = auth_token;
157 }
158
149 private: 159 private:
150 void StartArc(); 160 void StartArc();
151 void PrepareContext(); 161 void PrepareContext();
152 void ShowUI(UIPage page, const base::string16& status); 162 void ShowUI(UIPage page, const base::string16& status);
153 void CloseUI(); 163 void CloseUI();
154 void SetUIPage(UIPage page, const base::string16& status); 164 void SetUIPage(UIPage page, const base::string16& status);
155 void SetState(State state); 165 void SetState(State state);
156 void ShutdownBridge(); 166 void ShutdownBridge();
157 void ShutdownBridgeAndCloseUI(); 167 void ShutdownBridgeAndCloseUI();
158 void ShutdownBridgeAndShowUI(UIPage page, const base::string16& status); 168 void ShutdownBridgeAndShowUI(UIPage page, const base::string16& status);
159 void OnOptInPreferenceChanged(); 169 void OnOptInPreferenceChanged();
160 void StartUI(); 170 void StartUI();
161 void OnPrepareContextFailed(); 171 void OnPrepareContextFailed();
172 void StartAndroidManagementClient();
173 void CheckAndroidManagement();
174 void OnAndroidManagementChecked(
175 policy::AndroidManagementClient::Result result);
162 176
163 // Unowned pointer. Keeps current profile. 177 // Unowned pointer. Keeps current profile.
164 Profile* profile_ = nullptr; 178 Profile* profile_ = nullptr;
165 // Owned by content::BrowserContent. Used to isolate cookies for auth server 179 // Owned by content::BrowserContent. Used to isolate cookies for auth server
166 // communication and shared with Arc OptIn UI platform app. 180 // communication and shared with Arc OptIn UI platform app.
167 content::StoragePartition* storage_partition_ = nullptr; 181 content::StoragePartition* storage_partition_ = nullptr;
168 182
169 // Registrar used to monitor ARC enabled state. 183 // Registrar used to monitor ARC enabled state.
170 PrefChangeRegistrar pref_change_registrar_; 184 PrefChangeRegistrar pref_change_registrar_;
171 185
172 mojo::Binding<AuthHost> binding_; 186 mojo::Binding<AuthHost> binding_;
173 State state_ = State::STOPPED; 187 State state_ = State::STOPPED;
174 base::ObserverList<Observer> observer_list_; 188 base::ObserverList<Observer> observer_list_;
175 std::unique_ptr<GaiaAuthFetcher> merger_fetcher_; 189 std::unique_ptr<GaiaAuthFetcher> merger_fetcher_;
176 std::unique_ptr<UbertokenFetcher> ubertoken_fethcher_; 190 std::unique_ptr<UbertokenFetcher> ubertoken_fethcher_;
177 std::string auth_code_; 191 std::string auth_code_;
178 GetAuthCodeCallback auth_callback_; 192 GetAuthCodeCallback auth_callback_;
179 bool initial_opt_in_ = false; 193 bool initial_opt_in_ = false;
180 bool context_prepared_ = false; 194 bool context_prepared_ = false;
181 UIPage ui_page_ = UIPage::NO_PAGE; 195 UIPage ui_page_ = UIPage::NO_PAGE;
182 base::string16 ui_page_status_; 196 base::string16 ui_page_status_;
197 std::string auth_token_;
198
199 std::unique_ptr<policy::AndroidManagementClient> android_management_client_;
183 200
184 DISALLOW_COPY_AND_ASSIGN(ArcAuthService); 201 DISALLOW_COPY_AND_ASSIGN(ArcAuthService);
185 }; 202 };
186 203
187 std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state); 204 std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state);
188 205
189 } // namespace arc 206 } // namespace arc
190 207
191 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ 208 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698