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

Unified Diff: chrome/browser/policy/user_policy_controller.h

Issue 6312121: Add initial device policy infrastructure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix race condition and tests. Created 9 years, 11 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
« no previous file with comments | « chrome/browser/policy/profile_policy_context.cc ('k') | chrome/browser/policy/user_policy_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_
« no previous file with comments | « chrome/browser/policy/profile_policy_context.cc ('k') | chrome/browser/policy/user_policy_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698