OLD | NEW |
---|---|
(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/file_path.h" | |
12 #include "base/ref_counted.h" | |
13 #include "base/weak_ptr.h" | |
14 #include "chrome/browser/policy/cloud_policy_identity_strategy.h" | |
15 #include "chrome/common/notification_observer.h" | |
16 #include "chrome/common/notification_registrar.h" | |
17 | |
18 class Profile; | |
19 | |
20 namespace policy { | |
21 | |
22 class DeviceManagementBackend; | |
23 | |
24 // A token provider implementation that provides a user device token for the | |
25 // user corresponding to a given profile. | |
26 class UserPolicyIdentityStrategy : public CloudPolicyIdentityStrategy, | |
27 public NotificationObserver { | |
28 public: | |
29 UserPolicyIdentityStrategy(Profile* profile, | |
30 const FilePath& token_cache_file); | |
31 virtual ~UserPolicyIdentityStrategy(); | |
32 | |
33 // CloudPolicyIdentityStrategy implementation: | |
34 virtual std::string GetDeviceToken(); | |
35 virtual std::string GetDeviceID(); | |
36 virtual bool GetCredentials(std::string* username, | |
37 std::string* auth_token); | |
38 virtual void OnDeviceTokenAvailable(const std::string& token); | |
39 | |
40 private: | |
41 class TokenCache; | |
42 | |
43 // Checks whether a new token should be fetched and if so, pokes the fetcher. | |
Mattias Nissler (ping if slow)
2011/02/15 10:15:16
Comment is not accurate. It doesn't poke the fetch
Jakob Kummerow
2011/02/21 12:12:15
Done.
| |
44 void CheckAndTriggerFetch(); | |
45 | |
46 // Gets the current user. | |
47 std::string GetCurrentUser(); | |
48 | |
49 // Called from the token cache when the token has been loaded. | |
50 void OnCacheLoaded(const std::string& token, const std::string& device_id); | |
51 | |
52 // NotificationObserver method overrides: | |
53 virtual void Observe(NotificationType type, | |
54 const NotificationSource& source, | |
55 const NotificationDetails& details); | |
56 | |
57 // The profile this provider is associated with. | |
58 Profile* profile_; | |
59 | |
60 // Keeps the on-disk copy of the token. | |
61 scoped_refptr<TokenCache> cache_; | |
62 | |
63 // The device ID we use. | |
64 std::string device_id_; | |
65 | |
66 // Current device token. Empty if not available. | |
67 std::string device_token_; | |
68 | |
69 // Registers the provider for notification of successful Gaia logins. | |
70 NotificationRegistrar registrar_; | |
71 | |
72 // Allows to construct weak ptrs. | |
73 base::WeakPtrFactory<UserPolicyIdentityStrategy> weak_ptr_factory_; | |
74 | |
75 DISALLOW_COPY_AND_ASSIGN(UserPolicyIdentityStrategy); | |
76 }; | |
77 | |
78 } // namespace policy | |
79 | |
80 #endif // CHROME_BROWSER_POLICY_USER_POLICY_IDENTITY_STRATEGY_H_ | |
OLD | NEW |