Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/ptr_util.h" | |
|
xiyuan
2016/04/27 16:00:57
nit: move this to cc file if WrapUnique is used th
Polina Bondarenko
2016/04/27 16:06:35
Sorry, removed, no need in this header.
| |
| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 static ArcAuthService* Get(); | 86 static ArcAuthService* Get(); |
| 83 | 87 |
| 84 // It is called from chrome/browser/prefs/browser_prefs.cc. | 88 // It is called from chrome/browser/prefs/browser_prefs.cc. |
| 85 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 89 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 86 | 90 |
| 87 static void DisableUIForTesting(); | 91 static void DisableUIForTesting(); |
| 88 | 92 |
| 89 // Checks if OptIn verification was disabled by switch in command line. | 93 // Checks if OptIn verification was disabled by switch in command line. |
| 90 static bool IsOptInVerificationDisabled(); | 94 static bool IsOptInVerificationDisabled(); |
| 91 | 95 |
| 96 static void EnableCheckAndroidManagementForTesting(); | |
| 97 | |
| 92 void OnPrimaryUserProfilePrepared(Profile* profile); | 98 void OnPrimaryUserProfilePrepared(Profile* profile); |
| 93 void Shutdown(); | 99 void Shutdown(); |
| 94 | 100 |
| 95 State state() const { return state_; } | 101 State state() const { return state_; } |
| 96 | 102 |
| 97 std::string GetAndResetAuthCode(); | 103 std::string GetAndResetAuthCode(); |
| 98 | 104 |
| 99 // Adds or removes observers. | 105 // Adds or removes observers. |
| 100 void AddObserver(Observer* observer); | 106 void AddObserver(Observer* observer); |
| 101 void RemoveObserver(Observer* observer); | 107 void RemoveObserver(Observer* observer); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 153 void ShowUI(UIPage page, const base::string16& status); | 159 void ShowUI(UIPage page, const base::string16& status); |
| 154 void CloseUI(); | 160 void CloseUI(); |
| 155 void SetUIPage(UIPage page, const base::string16& status); | 161 void SetUIPage(UIPage page, const base::string16& status); |
| 156 void SetState(State state); | 162 void SetState(State state); |
| 157 void ShutdownBridge(); | 163 void ShutdownBridge(); |
| 158 void ShutdownBridgeAndCloseUI(); | 164 void ShutdownBridgeAndCloseUI(); |
| 159 void ShutdownBridgeAndShowUI(UIPage page, const base::string16& status); | 165 void ShutdownBridgeAndShowUI(UIPage page, const base::string16& status); |
| 160 void OnOptInPreferenceChanged(); | 166 void OnOptInPreferenceChanged(); |
| 161 void StartUI(); | 167 void StartUI(); |
| 162 void OnPrepareContextFailed(); | 168 void OnPrepareContextFailed(); |
| 169 void StartAndroidManagementClient(); | |
| 170 void CheckAndroidManagement(); | |
| 171 void OnAndroidManagementChecked( | |
| 172 policy::AndroidManagementClient::Result result); | |
| 163 | 173 |
| 164 // Unowned pointer. Keeps current profile. | 174 // Unowned pointer. Keeps current profile. |
| 165 Profile* profile_ = nullptr; | 175 Profile* profile_ = nullptr; |
| 166 // Owned by content::BrowserContent. Used to isolate cookies for auth server | 176 // Owned by content::BrowserContent. Used to isolate cookies for auth server |
| 167 // communication and shared with Arc OptIn UI platform app. | 177 // communication and shared with Arc OptIn UI platform app. |
| 168 content::StoragePartition* storage_partition_ = nullptr; | 178 content::StoragePartition* storage_partition_ = nullptr; |
| 169 | 179 |
| 170 // Registrar used to monitor ARC enabled state. | 180 // Registrar used to monitor ARC enabled state. |
| 171 PrefChangeRegistrar pref_change_registrar_; | 181 PrefChangeRegistrar pref_change_registrar_; |
| 172 | 182 |
| 173 mojo::Binding<AuthHost> binding_; | 183 mojo::Binding<AuthHost> binding_; |
| 174 State state_ = State::STOPPED; | 184 State state_ = State::STOPPED; |
| 175 base::ObserverList<Observer> observer_list_; | 185 base::ObserverList<Observer> observer_list_; |
| 176 std::unique_ptr<GaiaAuthFetcher> merger_fetcher_; | 186 std::unique_ptr<GaiaAuthFetcher> merger_fetcher_; |
| 177 std::unique_ptr<UbertokenFetcher> ubertoken_fethcher_; | 187 std::unique_ptr<UbertokenFetcher> ubertoken_fethcher_; |
| 178 std::unique_ptr<ArcAppLauncher> playstore_launcher_; | 188 std::unique_ptr<ArcAppLauncher> playstore_launcher_; |
| 179 std::string auth_code_; | 189 std::string auth_code_; |
| 180 GetAuthCodeCallback auth_callback_; | 190 GetAuthCodeCallback auth_callback_; |
| 181 bool initial_opt_in_ = false; | 191 bool initial_opt_in_ = false; |
| 182 bool context_prepared_ = false; | 192 bool context_prepared_ = false; |
| 183 UIPage ui_page_ = UIPage::NO_PAGE; | 193 UIPage ui_page_ = UIPage::NO_PAGE; |
| 184 base::string16 ui_page_status_; | 194 base::string16 ui_page_status_; |
| 185 | 195 |
| 196 ProfileOAuth2TokenService* token_service_; | |
| 197 std::string account_id_; | |
| 198 std::unique_ptr<policy::AndroidManagementClient> android_management_client_; | |
| 199 | |
| 200 base::WeakPtrFactory<ArcAuthService> weak_ptr_factory_; | |
| 201 | |
| 186 DISALLOW_COPY_AND_ASSIGN(ArcAuthService); | 202 DISALLOW_COPY_AND_ASSIGN(ArcAuthService); |
| 187 }; | 203 }; |
| 188 | 204 |
| 189 std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state); | 205 std::ostream& operator<<(std::ostream& os, const ArcAuthService::State& state); |
| 190 | 206 |
| 191 } // namespace arc | 207 } // namespace arc |
| 192 | 208 |
| 193 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ | 209 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_ |
| OLD | NEW |