| 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_USER_CROS_SETTINGS_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_USER_CROS_SETTINGS_PROVIDER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_USER_CROS_SETTINGS_PROVIDER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_USER_CROS_SETTINGS_PROVIDER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/callback.h" |
| 12 #include "chrome/browser/chromeos/cros_settings_provider.h" | 13 #include "chrome/browser/chromeos/cros_settings_provider.h" |
| 13 #include "chrome/browser/chromeos/login/signed_settings_helper.h" | 14 #include "chrome/browser/chromeos/login/signed_settings_helper.h" |
| 14 | 15 |
| 15 class PrefService; | 16 class PrefService; |
| 16 class Task; | 17 class Task; |
| 17 | 18 |
| 18 namespace base { | 19 namespace base { |
| 19 class ListValue; | 20 class ListValue; |
| 20 } | 21 } |
| 21 | 22 |
| 22 namespace chromeos { | 23 namespace chromeos { |
| 23 | 24 |
| 24 // CrosSettingsProvider implementation that works with SignedSettings. | 25 // CrosSettingsProvider implementation that works with SignedSettings. |
| 25 // TODO(nkostylev): Rename this class to indicate that it is | 26 // TODO(nkostylev): Rename this class to indicate that it is |
| 26 // SignedSettings specific. | 27 // SignedSettings specific. |
| 27 class UserCrosSettingsProvider : public CrosSettingsProvider { | 28 class UserCrosSettingsProvider : public CrosSettingsProvider { |
| 28 public: | 29 public: |
| 29 UserCrosSettingsProvider(); | 30 UserCrosSettingsProvider(); |
| 30 virtual ~UserCrosSettingsProvider() {} | 31 virtual ~UserCrosSettingsProvider() {} |
| 31 | 32 |
| 32 // Registers cached users settings in preferences. | 33 // Registers cached users settings in preferences. |
| 33 static void RegisterPrefs(PrefService* local_state); | 34 static void RegisterPrefs(PrefService* local_state); |
| 34 | 35 |
| 35 // Methods to use when trusted (signature verified) values are required. | |
| 36 // Return true if subsequent call to corresponding cached_* getter shall | |
| 37 // return trusted value. | |
| 38 // Return false if trusted values are unavailable at a moment. | |
| 39 // In latter case passed task will be posted when ready. | |
| 40 bool RequestTrustedAllowGuest(Task* callback); | |
| 41 bool RequestTrustedAllowNewUser(Task* callback); | |
| 42 bool RequestTrustedDataRoamingEnabled(Task* callback); | |
| 43 bool RequestTrustedShowUsersOnSignin(Task* callback); | |
| 44 bool RequestTrustedOwner(Task* callback); | |
| 45 bool RequestTrustedReportingEnabled(Task* callback); | |
| 46 | |
| 47 // Reloads values from device settings. | 36 // Reloads values from device settings. |
| 48 void Reload(); | 37 void Reload(); |
| 49 | 38 |
| 50 // Helper functions to access cached settings. | |
| 51 static bool cached_allow_guest(); | |
| 52 static bool cached_allow_new_user(); | |
| 53 static bool cached_data_roaming_enabled(); | |
| 54 static bool cached_show_users_on_signin(); | |
| 55 static bool cached_reporting_enabled(); | |
| 56 static const base::ListValue* cached_whitelist(); | |
| 57 static std::string cached_owner(); | |
| 58 | |
| 59 // Returns true if given email is in user whitelist. | |
| 60 // Note this function is for display purpose only and should use | |
| 61 // CheckWhitelist op for the real whitelist check. | |
| 62 static bool IsEmailInCachedWhitelist(const std::string& email); | |
| 63 | |
| 64 // CrosSettingsProvider implementation. | 39 // CrosSettingsProvider implementation. |
| 65 virtual bool Get(const std::string& path, | 40 virtual const base::Value* Get(const std::string& path) const OVERRIDE; |
| 66 base::Value** out_value) const OVERRIDE; | 41 virtual bool GetTrusted(const std::string& path, |
| 42 const base::Closure& callback) const OVERRIDE; |
| 67 virtual bool HandlesSetting(const std::string& path) const OVERRIDE; | 43 virtual bool HandlesSetting(const std::string& path) const OVERRIDE; |
| 68 | 44 |
| 69 void WhitelistUser(const std::string& email); | 45 static void WhitelistUser(const std::string& email); |
| 70 void UnwhitelistUser(const std::string& email); | 46 static void UnwhitelistUser(const std::string& email); |
| 71 | 47 |
| 72 // Updates cached value of the owner. | 48 // Updates cached value of the owner. |
| 73 static void UpdateCachedOwner(const std::string& email); | 49 static void UpdateCachedOwner(const std::string& email); |
| 74 | 50 |
| 75 private: | 51 private: |
| 76 // CrosSettingsProvider implementation. | 52 // CrosSettingsProvider implementation. |
| 77 virtual void DoSet(const std::string& path, base::Value* value) OVERRIDE; | 53 virtual void DoSet(const std::string& path, base::Value* value) OVERRIDE; |
| 78 | 54 |
| 79 DISALLOW_COPY_AND_ASSIGN(UserCrosSettingsProvider); | 55 DISALLOW_COPY_AND_ASSIGN(UserCrosSettingsProvider); |
| 80 }; | 56 }; |
| 81 | 57 |
| 82 } // namespace chromeos | 58 } // namespace chromeos |
| 83 | 59 |
| 84 #endif // CHROME_BROWSER_CHROMEOS_USER_CROS_SETTINGS_PROVIDER_H_ | 60 #endif // CHROME_BROWSER_CHROMEOS_USER_CROS_SETTINGS_PROVIDER_H_ |
| OLD | NEW |