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

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

Issue 6537020: Update policy backend and testserver for the newest policy protocol (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more last minute changes Created 9 years, 9 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_POLICY_DEVICE_POLICY_IDENTITY_STRATEGY_H_ 5 #ifndef CHROME_BROWSER_POLICY_DEVICE_POLICY_IDENTITY_STRATEGY_H_
6 #define CHROME_BROWSER_POLICY_DEVICE_POLICY_IDENTITY_STRATEGY_H_ 6 #define CHROME_BROWSER_POLICY_DEVICE_POLICY_IDENTITY_STRATEGY_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/ref_counted.h"
12 #include "base/weak_ptr.h"
11 #include "chrome/browser/policy/cloud_policy_identity_strategy.h" 13 #include "chrome/browser/policy/cloud_policy_identity_strategy.h"
12 #include "chrome/common/notification_observer.h" 14 #include "chrome/common/notification_observer.h"
13 #include "chrome/common/notification_registrar.h" 15 #include "chrome/common/notification_registrar.h"
14 16
15 class TokenService; 17 class TokenService;
16 18
17 namespace policy { 19 namespace policy {
18 20
19 // DM token provider that stores the token in CrOS signed settings. 21 // DM token provider that stores the token in CrOS signed settings.
20 class DevicePolicyIdentityStrategy : public CloudPolicyIdentityStrategy, 22 class DevicePolicyIdentityStrategy : public CloudPolicyIdentityStrategy,
21 public NotificationObserver { 23 public NotificationObserver {
22 public: 24 public:
23 DevicePolicyIdentityStrategy(); 25 DevicePolicyIdentityStrategy();
24 virtual ~DevicePolicyIdentityStrategy() {} 26 virtual ~DevicePolicyIdentityStrategy();
27
28 // Called by DevicePolicyIdentityStrategy::OwnershipChecker:
29 virtual void OnOwnershipInformationAvailable(bool current_user_is_owner);
25 30
26 // CloudPolicyIdentityStrategy implementation: 31 // CloudPolicyIdentityStrategy implementation:
27 virtual std::string GetDeviceToken(); 32 virtual std::string GetDeviceToken();
28 virtual std::string GetDeviceID(); 33 virtual std::string GetDeviceID();
34 virtual std::string GetMachineID();
35 virtual em::DeviceRegisterRequest_Type GetPolicyRegisterType();
36 virtual std::string GetPolicyType();
29 virtual bool GetCredentials(std::string* username, 37 virtual bool GetCredentials(std::string* username,
30 std::string* auth_token); 38 std::string* auth_token);
31 virtual void OnDeviceTokenAvailable(const std::string& token); 39 virtual void OnDeviceTokenAvailable(const std::string& token);
32 40
33 private: 41 private:
42 class OwnershipChecker;
43
34 // Recheck whether all parameters are available and if so, trigger a 44 // Recheck whether all parameters are available and if so, trigger a
35 // credentials changed notification. 45 // credentials changed notification.
36 void CheckAndTriggerFetch(); 46 void CheckAndTriggerFetch();
37 47
48 // Updates the ownership information and then passes control to
49 // |CheckAndTriggerFetch|.
50 void CheckOwnershipAndTriggerFetch();
51
38 // NotificationObserver method overrides: 52 // NotificationObserver method overrides:
39 virtual void Observe(NotificationType type, 53 virtual void Observe(NotificationType type,
40 const NotificationSource& source, 54 const NotificationSource& source,
41 const NotificationDetails& details); 55 const NotificationDetails& details);
42 56
43 // The machine identifier. 57 // The machine identifier.
44 std::string machine_id_; 58 std::string machine_id_;
45 59
60 // The device identifier to be sent with requests. (This is actually more like
61 // a session identifier since it is re-generated for each registration
62 // request.)
63 std::string device_id_;
64
46 // Current token. Empty if not available. 65 // Current token. Empty if not available.
47 std::string device_token_; 66 std::string device_token_;
48 67
49 // Whether to try and register. Device policy enrollment does not happen 68 // Whether the currently logged in user is the device's owner. This variable
50 // automatically except for the case that the device gets claimed. This 69 // is owned by the UI thread but updated from the FILE thread. Therefore
51 // situation is detected by listening for the OWNERSHIP_TAKEN notification. 70 // after an owner login it will take some time before it turns to true.
52 bool should_register_; 71 bool current_user_is_owner_;
53 72
54 // Registers the provider for notification of successful Gaia logins. 73 // Registers the provider for notification of successful Gaia logins.
55 NotificationRegistrar registrar_; 74 NotificationRegistrar registrar_;
56 75
76 scoped_refptr<OwnershipChecker> ownership_checker_;
77
78 // Allows to construct weak ptrs.
79 base::WeakPtrFactory<DevicePolicyIdentityStrategy> weak_ptr_factory_;
80
57 DISALLOW_COPY_AND_ASSIGN(DevicePolicyIdentityStrategy); 81 DISALLOW_COPY_AND_ASSIGN(DevicePolicyIdentityStrategy);
58 }; 82 };
59 83
60 } // namespace policy 84 } // namespace policy
61 85
62 #endif // CHROME_BROWSER_POLICY_DEVICE_POLICY_IDENTITY_STRATEGY_H_ 86 #endif // CHROME_BROWSER_POLICY_DEVICE_POLICY_IDENTITY_STRATEGY_H_
OLDNEW
« no previous file with comments | « chrome/browser/policy/device_management_backend_mock.h ('k') | chrome/browser/policy/device_policy_identity_strategy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698