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

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: it was a bad idea to zero out machine_id_ in the prev. patchset 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"
11 #include "chrome/browser/policy/cloud_policy_identity_strategy.h" 12 #include "chrome/browser/policy/cloud_policy_identity_strategy.h"
12 #include "chrome/common/notification_observer.h" 13 #include "chrome/common/notification_observer.h"
13 #include "chrome/common/notification_registrar.h" 14 #include "chrome/common/notification_registrar.h"
14 15
15 class TokenService; 16 class TokenService;
16 17
17 namespace policy { 18 namespace policy {
18 19
19 // DM token provider that stores the token in CrOS signed settings. 20 // DM token provider that stores the token in CrOS signed settings.
20 class DevicePolicyIdentityStrategy : public CloudPolicyIdentityStrategy, 21 class DevicePolicyIdentityStrategy : public CloudPolicyIdentityStrategy,
21 public NotificationObserver { 22 public NotificationObserver {
22 public: 23 public:
23 DevicePolicyIdentityStrategy(); 24 DevicePolicyIdentityStrategy();
24 virtual ~DevicePolicyIdentityStrategy() {} 25 virtual ~DevicePolicyIdentityStrategy();
26
27 // Called by DevicePolicyIdentityStrategy::OwnershipChecker:
28 virtual void OnOwnershipInformationAvailable(bool current_user_is_owner);
25 29
26 // CloudPolicyIdentityStrategy implementation: 30 // CloudPolicyIdentityStrategy implementation:
27 virtual std::string GetDeviceToken(); 31 virtual std::string GetDeviceToken();
28 virtual std::string GetDeviceID(); 32 virtual std::string GetDeviceID();
33 virtual std::string GetMachineID();
34 virtual em::DeviceRegisterRequest_Type GetPolicyRegisterType();
35 virtual std::string GetPolicyType();
29 virtual bool GetCredentials(std::string* username, 36 virtual bool GetCredentials(std::string* username,
30 std::string* auth_token); 37 std::string* auth_token);
31 virtual void OnDeviceTokenAvailable(const std::string& token); 38 virtual void OnDeviceTokenAvailable(const std::string& token);
32 39
33 private: 40 private:
41 class OwnershipChecker;
42
34 // Recheck whether all parameters are available and if so, trigger a 43 // Recheck whether all parameters are available and if so, trigger a
35 // credentials changed notification. 44 // credentials changed notification.
36 void CheckAndTriggerFetch(); 45 void CheckAndTriggerFetch();
37 46
47 // Updates the ownership information and then passes control to
48 // |CheckAndTriggerFetch|.
49 void CheckOwnershipAndTriggerFetch();
50
38 // NotificationObserver method overrides: 51 // NotificationObserver method overrides:
39 virtual void Observe(NotificationType type, 52 virtual void Observe(NotificationType type,
40 const NotificationSource& source, 53 const NotificationSource& source,
41 const NotificationDetails& details); 54 const NotificationDetails& details);
42 55
43 // The machine identifier. 56 // The machine identifier.
44 std::string machine_id_; 57 std::string machine_id_;
45 58
59 // The device identifier to be sent with requests. (This is actually more like
60 // a session identifier since it is re-generated for each registration
61 // request.)
62 std::string device_id_;
63
46 // Current token. Empty if not available. 64 // Current token. Empty if not available.
47 std::string device_token_; 65 std::string device_token_;
48 66
49 // Whether to try and register. Device policy enrollment does not happen 67 // Whether to try and register. Device policy enrollment does not happen
50 // automatically except for the case that the device gets claimed. This 68 // automatically except for the case that the device gets claimed. This
51 // situation is detected by listening for the OWNERSHIP_TAKEN notification. 69 // situation is detected by listening for the OWNERSHIP_TAKEN notification.
52 bool should_register_; 70 bool should_register_;
53 71
72 // Whether the currently logged in user is the device's owner. This variable
73 // is owned by the UI thread but updated from the FILE thread. Therefore
74 // after an owner login it will take some time before it turns to true.
75 bool current_user_is_owner_;
76
54 // Registers the provider for notification of successful Gaia logins. 77 // Registers the provider for notification of successful Gaia logins.
55 NotificationRegistrar registrar_; 78 NotificationRegistrar registrar_;
56 79
80 scoped_refptr<OwnershipChecker> ownership_checker_;
81
57 DISALLOW_COPY_AND_ASSIGN(DevicePolicyIdentityStrategy); 82 DISALLOW_COPY_AND_ASSIGN(DevicePolicyIdentityStrategy);
58 }; 83 };
59 84
60 } // namespace policy 85 } // namespace policy
61 86
62 #endif // CHROME_BROWSER_POLICY_DEVICE_POLICY_IDENTITY_STRATEGY_H_ 87 #endif // CHROME_BROWSER_POLICY_DEVICE_POLICY_IDENTITY_STRATEGY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698