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

Unified 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: Fixed comments, rebase. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/arc/arc_auth_service.h
diff --git a/chrome/browser/chromeos/arc/arc_auth_service.h b/chrome/browser/chromeos/arc/arc_auth_service.h
index d797dfa2f749c6d2e254fa2b651e6cc25df6899d..9175d1b5145842e0bf3906b6396b100132530726 100644
--- a/chrome/browser/chromeos/arc/arc_auth_service.h
+++ b/chrome/browser/chromeos/arc/arc_auth_service.h
@@ -6,9 +6,12 @@
#define CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_SERVICE_H_
#include <ostream>
+#include <string>
#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
+#include "chrome/browser/chromeos/policy/android_management_client.h"
#include "components/arc/arc_bridge_service.h"
#include "components/arc/arc_service.h"
#include "components/arc/common/auth.mojom.h"
@@ -16,12 +19,15 @@
#include "components/syncable_prefs/pref_service_syncable_observer.h"
#include "components/syncable_prefs/synced_pref_observer.h"
#include "google_apis/gaia/gaia_auth_consumer.h"
+#include "google_apis/gaia/oauth2_token_service.h"
#include "google_apis/gaia/ubertoken_fetcher.h"
#include "mojo/public/cpp/bindings/binding.h"
class ArcAppLauncher;
class GaiaAuthFetcher;
+class GoogleServiceAuthError;
class Profile;
+class ProfileOAuth2TokenService;
namespace content {
class StoragePartition;
@@ -44,6 +50,7 @@ class ArcAuthService : public ArcService,
public ArcBridgeService::Observer,
public UbertokenConsumer,
public GaiaAuthConsumer,
+ public OAuth2TokenService::Consumer,
public syncable_prefs::PrefServiceSyncableObserver,
public syncable_prefs::SyncedPrefObserver {
public:
@@ -89,6 +96,8 @@ class ArcAuthService : public ArcService,
// Checks if OptIn verification was disabled by switch in command line.
static bool IsOptInVerificationDisabled();
+ static void EnableCheckAndroidManagementForTesting(const char* access_token);
+
void OnPrimaryUserProfilePrepared(Profile* profile);
void Shutdown();
@@ -142,11 +151,17 @@ class ArcAuthService : public ArcService,
// syncable_prefs::SyncedPrefObserver
void OnSyncedPrefChanged(const std::string& path, bool from_sync) override;
+ // OAuth2TokenService::Consumer implementation:
+ void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
+ const std::string& access_token,
+ const base::Time& expiration_time) override;
+ void OnGetTokenFailure(const OAuth2TokenService::Request* request,
+ const GoogleServiceAuthError& error) override;
+
// Returns current page that has to be shown in OptIn UI.
UIPage ui_page() const { return ui_page_; }
// Returns current page status, relevant to the specific page.
const base::string16& ui_page_status() { return ui_page_status_; }
-
private:
void StartArc();
void PrepareContext();
@@ -160,6 +175,10 @@ class ArcAuthService : public ArcService,
void OnOptInPreferenceChanged();
void StartUI();
void OnPrepareContextFailed();
+ void StartAndroidManagementClient();
+ void CheckAndroidManagement();
+ void OnAndroidManagementChecked(
+ policy::AndroidManagementClient::Result result);
// Unowned pointer. Keeps current profile.
Profile* profile_ = nullptr;
@@ -183,6 +202,14 @@ class ArcAuthService : public ArcService,
UIPage ui_page_ = UIPage::NO_PAGE;
base::string16 ui_page_status_;
+ ProfileOAuth2TokenService* token_service_;
+ std::string account_id_;
+
+ std::unique_ptr<policy::AndroidManagementClient> android_management_client_;
+ std::unique_ptr<OAuth2TokenService::Request> token_request_;
+
+ base::WeakPtrFactory<ArcAuthService> weak_ptr_factory_;
+
DISALLOW_COPY_AND_ASSIGN(ArcAuthService);
};

Powered by Google App Engine
This is Rietveld 408576698