| OLD | NEW |
| 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_CHROMEOS_LOGIN_OWNERSHIP_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_OWNERSHIP_SERVICE_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_OWNERSHIP_SERVICE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_OWNERSHIP_SERVICE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
| 17 #include "chrome/browser/chromeos/login/owner_key_utils.h" | 17 #include "chrome/browser/chromeos/login/owner_key_utils.h" |
| 18 #include "chrome/browser/chromeos/login/owner_manager.h" | 18 #include "chrome/browser/chromeos/login/owner_manager.h" |
| 19 #include "chrome/browser/policy/proto/device_management_backend.pb.h" | |
| 20 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 21 #include "content/public/browser/notification_observer.h" | 20 #include "content/public/browser/notification_observer.h" |
| 22 #include "content/public/browser/notification_registrar.h" | 21 #include "content/public/browser/notification_registrar.h" |
| 23 | 22 |
| 24 namespace base { | 23 namespace base { |
| 25 template <typename T> struct DefaultLazyInstanceTraits; | 24 template <typename T> struct DefaultLazyInstanceTraits; |
| 26 } | 25 } |
| 27 | 26 |
| 28 namespace em = enterprise_management; | |
| 29 namespace chromeos { | 27 namespace chromeos { |
| 30 | 28 |
| 31 class OwnershipService : public content::NotificationObserver { | 29 class OwnershipService : public content::NotificationObserver { |
| 32 public: | 30 public: |
| 33 enum Status { | 31 enum Status { |
| 34 // Listed in upgrade order. | 32 // Listed in upgrade order. |
| 35 OWNERSHIP_UNKNOWN = 0, | 33 OWNERSHIP_UNKNOWN = 0, |
| 36 OWNERSHIP_NONE, | 34 OWNERSHIP_NONE, |
| 37 OWNERSHIP_TAKEN | 35 OWNERSHIP_TAKEN |
| 38 }; | 36 }; |
| 39 | 37 |
| 40 // Returns the singleton instance of the OwnershipService. | 38 // Returns the singleton instance of the OwnershipService. |
| 41 static OwnershipService* GetSharedInstance(); | 39 static OwnershipService* GetSharedInstance(); |
| 42 virtual ~OwnershipService(); | 40 virtual ~OwnershipService(); |
| 43 | 41 |
| 44 // Called after FILE thread is created to prefetch ownership status and avoid | 42 // Called after FILE thread is created to prefetch ownership status and avoid |
| 45 // blocking on UI thread. | 43 // blocking on UI thread. |
| 46 void Prewarm(); | 44 void Prewarm(); |
| 47 | 45 |
| 48 // Owner settings are being re-implemented as a single, signed protobuf | |
| 49 // that is stored by the session manager. Thus, to write a setting, you | |
| 50 // need to have the existing policy, update it, re-sign it, and then have | |
| 51 // it stored. This could be done by requesting the policy every time, or | |
| 52 // by caching it and updating it upon every successful store. | |
| 53 // Caching is faster and easier, so we'll do that. These are the | |
| 54 // getters/setters for the cached policy. | |
| 55 virtual void set_cached_policy(const em::PolicyData& pol); | |
| 56 virtual bool has_cached_policy(); | |
| 57 virtual const em::PolicyData& cached_policy(); | |
| 58 | |
| 59 // Sets a new owner key. This will _not_ load the key material from disk, but | 46 // Sets a new owner key. This will _not_ load the key material from disk, but |
| 60 // rather update Chrome's in-memory copy of the key. |callback| will be | 47 // rather update Chrome's in-memory copy of the key. |callback| will be |
| 61 // invoked once the operation completes. | 48 // invoked once the operation completes. |
| 62 virtual void StartUpdateOwnerKey(const std::vector<uint8>& new_key, | 49 virtual void StartUpdateOwnerKey(const std::vector<uint8>& new_key, |
| 63 OwnerManager::KeyUpdateDelegate* d); | 50 OwnerManager::KeyUpdateDelegate* d); |
| 64 | 51 |
| 65 // If the device has been owned already, posts a task to the FILE thread to | 52 // If the device has been owned already, posts a task to the FILE thread to |
| 66 // fetch the public key off disk. | 53 // fetch the public key off disk. |
| 67 // | 54 // |
| 68 // Sends out a OWNER_KEY_FETCH_ATTEMPT_SUCCESS notification on success, | 55 // Sends out a OWNER_KEY_FETCH_ATTEMPT_SUCCESS notification on success, |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 const content::BrowserThread::ID thread_id, | 119 const content::BrowserThread::ID thread_id, |
| 133 const std::string& data, | 120 const std::string& data, |
| 134 const std::vector<uint8>& signature, | 121 const std::vector<uint8>& signature, |
| 135 OwnerManager::Delegate* d); | 122 OwnerManager::Delegate* d); |
| 136 static void FailAttempt(OwnerManager::Delegate* d); | 123 static void FailAttempt(OwnerManager::Delegate* d); |
| 137 | 124 |
| 138 OwnerManager* manager() { return manager_.get(); } | 125 OwnerManager* manager() { return manager_.get(); } |
| 139 | 126 |
| 140 scoped_refptr<OwnerManager> manager_; | 127 scoped_refptr<OwnerManager> manager_; |
| 141 scoped_refptr<OwnerKeyUtils> utils_; | 128 scoped_refptr<OwnerKeyUtils> utils_; |
| 142 scoped_ptr<em::PolicyData> policy_; | |
| 143 content::NotificationRegistrar notification_registrar_; | 129 content::NotificationRegistrar notification_registrar_; |
| 144 volatile Status ownership_status_; | 130 volatile Status ownership_status_; |
| 145 base::Lock ownership_status_lock_; | 131 base::Lock ownership_status_lock_; |
| 146 }; | 132 }; |
| 147 | 133 |
| 148 } // namespace chromeos | 134 } // namespace chromeos |
| 149 | 135 |
| 150 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OWNERSHIP_SERVICE_H_ | 136 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OWNERSHIP_SERVICE_H_ |
| OLD | NEW |