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

Side by Side Diff: chrome/browser/policy/user_policy_identity_strategy.h

Issue 7298012: Consolidate data storage and notifications in the cloud policy subsystem (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years, 5 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_POLICY_USER_POLICY_IDENTITY_STRATEGY_H_
6 #define CHROME_BROWSER_POLICY_USER_POLICY_IDENTITY_STRATEGY_H_
7 #pragma once
8
9 #include <string>
10
11 #include "base/compiler_specific.h"
12 #include "base/file_path.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/weak_ptr.h"
15 #include "chrome/browser/policy/cloud_policy_identity_strategy.h"
16 #include "chrome/browser/policy/user_policy_token_cache.h"
17
18 namespace policy {
19
20 class DeviceManagementBackend;
21
22 // A token provider implementation that provides a user device token for the
23 // user corresponding to given credentials.
24 class UserPolicyIdentityStrategy : public CloudPolicyIdentityStrategy,
25 public UserPolicyTokenCache::Delegate {
26 public:
27 UserPolicyIdentityStrategy(const std::string& user_name,
28 const FilePath& token_cache_file);
29 virtual ~UserPolicyIdentityStrategy();
30
31 // Start loading the token cache.
32 void LoadTokenCache();
33
34 // Set a newly arriving auth_token and maybe trigger a fetch.
35 void SetAuthToken(const std::string& auth_token);
36
37 // CloudPolicyIdentityStrategy implementation:
38 virtual std::string GetDeviceToken() OVERRIDE;
39 virtual std::string GetDeviceID() OVERRIDE;
40 virtual std::string GetMachineID() OVERRIDE;
41 virtual std::string GetMachineModel() OVERRIDE;
42 virtual em::DeviceRegisterRequest_Type GetPolicyRegisterType() OVERRIDE;
43 virtual std::string GetPolicyType() OVERRIDE;
44 virtual bool GetCredentials(std::string* username,
45 std::string* auth_token) OVERRIDE;
46 virtual void OnDeviceTokenAvailable(const std::string& token) OVERRIDE;
47
48 private:
49 // Checks whether a new token should be fetched and if so, sends out a
50 // notification.
51 void CheckAndTriggerFetch();
52
53 // Gets the current user.
54 std::string GetCurrentUser();
55
56 // Called from the token cache when the token has been loaded.
57 virtual void OnTokenCacheLoaded(const std::string& token,
58 const std::string& device_id) OVERRIDE;
59
60 // Keeps the on-disk copy of the token.
61 scoped_refptr<UserPolicyTokenCache> cache_;
62
63 // false until cache_ reports being loaded for the first time, true
64 // afterwards.
65 bool cache_loaded_;
66
67 // The device ID we use.
68 std::string device_id_;
69
70 // Current device token. Empty if not available.
71 std::string device_token_;
72
73 // Current auth token. Empty if not available.
74 std::string auth_token_;
75
76 // Current user name. Empty if not available. This is set on creation and not
77 // changed afterwards.
78 std::string user_name_;
79
80 // Allows to construct weak ptrs.
81 base::WeakPtrFactory<UserPolicyTokenCache::Delegate> weak_ptr_factory_;
82
83 DISALLOW_COPY_AND_ASSIGN(UserPolicyIdentityStrategy);
84 };
85
86 } // namespace policy
87
88 #endif // CHROME_BROWSER_POLICY_USER_POLICY_IDENTITY_STRATEGY_H_
OLDNEW
« no previous file with comments | « chrome/browser/policy/testing_cloud_policy_subsystem.cc ('k') | chrome/browser/policy/user_policy_identity_strategy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698