| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_SIGNED_SETTINGS_MIGRATION_HELPER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_SIGNED_SETTINGS_MIGRATION_HELPER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_SIGNED_SETTINGS_MIGRATION_HELPER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_SIGNED_SETTINGS_MIGRATION_HELPER_H_ |
| 7 | 7 |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "chrome/browser/chromeos/login/ownership_service.h" | 9 #include "chrome/browser/chromeos/login/device_settings_service.h" |
| 10 #include "chrome/browser/chromeos/login/signed_settings_helper.h" | |
| 11 #include "chrome/browser/prefs/pref_value_map.h" | 10 #include "chrome/browser/prefs/pref_value_map.h" |
| 12 #include "content/public/browser/notification_observer.h" | |
| 13 #include "content/public/browser/notification_registrar.h" | |
| 14 | 11 |
| 15 namespace base { | 12 namespace base { |
| 16 class Value; | 13 class Value; |
| 17 } | 14 } |
| 18 | 15 |
| 19 namespace chromeos { | 16 namespace chromeos { |
| 20 | 17 |
| 21 // This class provides the means to migrate settings to the signed settings | 18 // This class provides the means to migrate settings to the signed settings |
| 22 // store. It does one of three things - store the settings in the policy blob | 19 // store. It does one of three things - store the settings in the policy blob |
| 23 // immediately if the current user is the owner. Uses the | 20 // immediately if the current user is the owner. Uses the SignedSettingsCache if |
| 24 // SignedSettingsCache if there is no owner yet, or waits for an | 21 // there is no owner yet, or waits for an call from DeviceSettingsProvider to |
| 25 // OWNERSHIP_CHECKED notification to delay the storing until the owner has | 22 // delay the storing until the owner has logged in. |
| 26 // logged in. | 23 class SignedSettingsMigrationHelper { |
| 27 class SignedSettingsMigrationHelper : public content::NotificationObserver { | |
| 28 public: | 24 public: |
| 29 SignedSettingsMigrationHelper(); | 25 SignedSettingsMigrationHelper(); |
| 30 virtual ~SignedSettingsMigrationHelper(); | 26 virtual ~SignedSettingsMigrationHelper(); |
| 31 | 27 |
| 32 // Adds a value to be migrated. The class takes ownership of the |value|. | 28 // Adds a value to be migrated. The class takes ownership of the |value|. |
| 33 void AddMigrationValue(const std::string& path, base::Value* value); | 29 void AddMigrationValue(const std::string& path, base::Value* value); |
| 34 | 30 |
| 35 // Initiates values migration. If the device is already owned this will | 31 // Initiates values migration. If the device is already owned this will |
| 36 // happen immediately if not it will wait for ownership login and finish the | 32 // happen immediately if not it will wait for ownership login and finish the |
| 37 // migration then. | 33 // migration then. |
| 38 void MigrateValues(void); | 34 void MigrateValues(void); |
| 39 | 35 |
| 40 // NotificationObserver overrides: | |
| 41 virtual void Observe(int type, | |
| 42 const content::NotificationSource& source, | |
| 43 const content::NotificationDetails& details) OVERRIDE; | |
| 44 | |
| 45 private: | 36 private: |
| 46 // Does the actual migration when ownership has been confirmed. | 37 // Does the actual migration when ownership has been confirmed. |
| 47 void DoMigrateValues(OwnershipService::Status status, | 38 void DoMigrateValues(DeviceSettingsService::OwnershipStatus status, |
| 48 bool current_user_is_owner); | 39 bool current_user_is_owner); |
| 49 | 40 |
| 50 content::NotificationRegistrar registrar_; | |
| 51 base::WeakPtrFactory<SignedSettingsMigrationHelper> ptr_factory_; | 41 base::WeakPtrFactory<SignedSettingsMigrationHelper> ptr_factory_; |
| 52 PrefValueMap migration_values_; | 42 PrefValueMap migration_values_; |
| 53 | 43 |
| 54 DISALLOW_COPY_AND_ASSIGN(SignedSettingsMigrationHelper); | 44 DISALLOW_COPY_AND_ASSIGN(SignedSettingsMigrationHelper); |
| 55 }; | 45 }; |
| 56 | 46 |
| 57 } // namespace chromeos | 47 } // namespace chromeos |
| 58 | 48 |
| 59 #endif // CHROME_BROWSER_CHROMEOS_SIGNED_SETTINGS_MIGRATION_HELPER_H_ | 49 #endif // CHROME_BROWSER_CHROMEOS_SIGNED_SETTINGS_MIGRATION_HELPER_H_ |
| OLD | NEW |