| Index: chrome/browser/policy/user_policy_controller.h
|
| diff --git a/chrome/browser/policy/user_policy_controller.h b/chrome/browser/policy/user_policy_controller.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..ce114767fcf1d2d57a54919db09d942fb105fb1c
|
| --- /dev/null
|
| +++ b/chrome/browser/policy/user_policy_controller.h
|
| @@ -0,0 +1,78 @@
|
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef CHROME_BROWSER_POLICY_USER_POLICY_CONTROLLER_H_
|
| +#define CHROME_BROWSER_POLICY_USER_POLICY_CONTROLLER_H_
|
| +#pragma once
|
| +
|
| +#include "base/file_path.h"
|
| +#include "base/ref_counted.h"
|
| +#include "base/weak_ptr.h"
|
| +#include "chrome/browser/policy/cloud_policy_controller.h"
|
| +#include "chrome/common/notification_observer.h"
|
| +#include "chrome/common/notification_registrar.h"
|
| +
|
| +class Profile;
|
| +
|
| +namespace policy {
|
| +
|
| +class DeviceManagementBackend;
|
| +
|
| +// A token provider implementation that provides a user device token for the
|
| +// user corresponding to a given profile.
|
| +class UserPolicyController : public CloudPolicyController,
|
| + public NotificationObserver {
|
| + public:
|
| + UserPolicyController(Profile* profile,
|
| + const FilePath& token_cache_file);
|
| + virtual ~UserPolicyController();
|
| +
|
| + // CloudPolicyController implementation:
|
| + virtual std::string GetDeviceToken();
|
| + virtual std::string GetDeviceID();
|
| + virtual bool GetCredentials(std::string* username,
|
| + std::string* auth_token);
|
| + virtual void OnTokenAvailable(const std::string& token);
|
| +
|
| + private:
|
| + class TokenCache;
|
| +
|
| + // Checks whether a new token should be fetched and if so, pokes the fetcher.
|
| + void CheckAndTriggerFetch();
|
| +
|
| + // Gets the current user.
|
| + std::string GetCurrentUser();
|
| +
|
| + // Called from the token cache when the token has been loaded.
|
| + void OnCacheLoaded(const std::string& token, const std::string& device_id);
|
| +
|
| + // NotificationObserver method overrides:
|
| + virtual void Observe(NotificationType type,
|
| + const NotificationSource& source,
|
| + const NotificationDetails& details);
|
| +
|
| + // The profile this provider is associated with.
|
| + Profile* profile_;
|
| +
|
| + // Keeps the on-disk copy of the token.
|
| + scoped_refptr<TokenCache> cache_;
|
| +
|
| + // The device ID we use.
|
| + std::string device_id_;
|
| +
|
| + // Current device token. Empty if not available.
|
| + std::string device_token_;
|
| +
|
| + // Registers the provider for notification of successful Gaia logins.
|
| + NotificationRegistrar registrar_;
|
| +
|
| + // Allows to construct weak ptrs.
|
| + base::WeakPtrFactory<UserPolicyController> weak_ptr_factory_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(UserPolicyController);
|
| +};
|
| +
|
| +} // namespace policy
|
| +
|
| +#endif // CHROME_BROWSER_POLICY_USER_POLICY_CONTROLLER_H_
|
|
|