| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_OWNERSHIP_OWNER_SETTINGS_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_OWNERSHIP_OWNER_SETTINGS_SERVICE_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_OWNERSHIP_OWNER_SETTINGS_SERVICE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_OWNERSHIP_OWNER_SETTINGS_SERVICE_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/threading/thread_checker.h" | 15 #include "base/threading/thread_checker.h" |
| 16 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 16 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
| 17 #include "chromeos/dbus/session_manager_client.h" | 17 #include "chromeos/dbus/session_manager_client.h" |
| 18 #include "chromeos/tpm_token_loader.h" | |
| 19 #include "components/keyed_service/core/keyed_service.h" | 18 #include "components/keyed_service/core/keyed_service.h" |
| 20 #include "components/ownership/owner_key_util.h" | 19 #include "components/ownership/owner_key_util.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 class Profile; | 23 class Profile; |
| 25 | 24 |
| 26 namespace chromeos { | 25 namespace chromeos { |
| 27 | 26 |
| 28 class SessionManagerOperation; | 27 class SessionManagerOperation; |
| 29 | 28 |
| 30 // This class reloads owner key from profile NSS slots. | 29 // This class reloads owner key from profile NSS slots. |
| 31 // | 30 // |
| 32 // TODO (ygorshenin@): move write path for device settings here | 31 // TODO (ygorshenin@): move write path for device settings here |
| 33 // (crbug.com/230018). | 32 // (crbug.com/230018). |
| 34 class OwnerSettingsService : public DeviceSettingsService::PrivateKeyDelegate, | 33 class OwnerSettingsService : public DeviceSettingsService::PrivateKeyDelegate, |
| 35 public KeyedService, | 34 public KeyedService, |
| 36 public content::NotificationObserver, | 35 public content::NotificationObserver, |
| 37 public TPMTokenLoader::Observer, | |
| 38 public SessionManagerClient::Observer { | 36 public SessionManagerClient::Observer { |
| 39 public: | 37 public: |
| 40 virtual ~OwnerSettingsService(); | 38 virtual ~OwnerSettingsService(); |
| 41 | 39 |
| 42 base::WeakPtr<OwnerSettingsService> as_weak_ptr() { | 40 base::WeakPtr<OwnerSettingsService> as_weak_ptr() { |
| 43 return weak_factory_.GetWeakPtr(); | 41 return weak_factory_.GetWeakPtr(); |
| 44 } | 42 } |
| 45 | 43 |
| 44 void OnTPMTokenReady(bool tpm_token_enabled); |
| 45 |
| 46 // DeviceSettingsService::PrivateKeyDelegate implementation: | 46 // DeviceSettingsService::PrivateKeyDelegate implementation: |
| 47 virtual bool IsOwner() OVERRIDE; | 47 virtual bool IsOwner() OVERRIDE; |
| 48 virtual void IsOwnerAsync(const IsOwnerCallback& callback) OVERRIDE; | 48 virtual void IsOwnerAsync(const IsOwnerCallback& callback) OVERRIDE; |
| 49 virtual bool AssembleAndSignPolicyAsync( | 49 virtual bool AssembleAndSignPolicyAsync( |
| 50 scoped_ptr<enterprise_management::PolicyData> policy, | 50 scoped_ptr<enterprise_management::PolicyData> policy, |
| 51 const AssembleAndSignPolicyCallback& callback) OVERRIDE; | 51 const AssembleAndSignPolicyCallback& callback) OVERRIDE; |
| 52 virtual void SignAndStoreAsync( | 52 virtual void SignAndStoreAsync( |
| 53 scoped_ptr<enterprise_management::ChromeDeviceSettingsProto> settings, | 53 scoped_ptr<enterprise_management::ChromeDeviceSettingsProto> settings, |
| 54 const base::Closure& callback) OVERRIDE; | 54 const base::Closure& callback) OVERRIDE; |
| 55 virtual void SetManagementSettingsAsync( | 55 virtual void SetManagementSettingsAsync( |
| 56 enterprise_management::PolicyData::ManagementMode management_mode, | 56 enterprise_management::PolicyData::ManagementMode management_mode, |
| 57 const std::string& request_token, | 57 const std::string& request_token, |
| 58 const std::string& device_id, | 58 const std::string& device_id, |
| 59 const base::Closure& callback) OVERRIDE; | 59 const base::Closure& callback) OVERRIDE; |
| 60 | 60 |
| 61 // NotificationObserver implementation: | 61 // NotificationObserver implementation: |
| 62 virtual void Observe(int type, | 62 virtual void Observe(int type, |
| 63 const content::NotificationSource& source, | 63 const content::NotificationSource& source, |
| 64 const content::NotificationDetails& details) OVERRIDE; | 64 const content::NotificationDetails& details) OVERRIDE; |
| 65 | 65 |
| 66 // TPMTokenLoader::Observer: | |
| 67 virtual void OnTPMTokenReady() OVERRIDE; | |
| 68 | |
| 69 // SessionManagerClient::Observer: | 66 // SessionManagerClient::Observer: |
| 70 virtual void OwnerKeySet(bool success) OVERRIDE; | 67 virtual void OwnerKeySet(bool success) OVERRIDE; |
| 71 | 68 |
| 72 // Checks if the user is the device owner, without the user profile having to | 69 // Checks if the user is the device owner, without the user profile having to |
| 73 // been initialized. Should be used only if login state is in safe mode. | 70 // been initialized. Should be used only if login state is in safe mode. |
| 74 static void IsOwnerForSafeModeAsync( | 71 static void IsOwnerForSafeModeAsync( |
| 75 const std::string& user_hash, | 72 const std::string& user_hash, |
| 76 const scoped_refptr<ownership::OwnerKeyUtil>& owner_key_util, | 73 const scoped_refptr<ownership::OwnerKeyUtil>& owner_key_util, |
| 77 const IsOwnerCallback& callback); | 74 const IsOwnerCallback& callback); |
| 78 | 75 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 base::ThreadChecker thread_checker_; | 145 base::ThreadChecker thread_checker_; |
| 149 | 146 |
| 150 base::WeakPtrFactory<OwnerSettingsService> weak_factory_; | 147 base::WeakPtrFactory<OwnerSettingsService> weak_factory_; |
| 151 | 148 |
| 152 DISALLOW_COPY_AND_ASSIGN(OwnerSettingsService); | 149 DISALLOW_COPY_AND_ASSIGN(OwnerSettingsService); |
| 153 }; | 150 }; |
| 154 | 151 |
| 155 } // namespace chromeos | 152 } // namespace chromeos |
| 156 | 153 |
| 157 #endif // CHROME_BROWSER_CHROMEOS_OWNERSHIP_OWNER_SETTINGS_SERVICE_H_ | 154 #endif // CHROME_BROWSER_CHROMEOS_OWNERSHIP_OWNER_SETTINGS_SERVICE_H_ |
| OLD | NEW |