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