diff options
author | glider@chromium.org <glider@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-21 11:52:37 +0000 |
---|---|---|
committer | glider@chromium.org <glider@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-21 11:52:37 +0000 |
commit | 4fcd13625bc2072ca0242176155b27278a9117a2 (patch) | |
tree | 1ed2f922dd9278b9c3793b2aa8afc83570282646 /chrome | |
parent | b3d3569d57c1bde829b3a5b9eb1c8b9be4ef0ec2 (diff) | |
download | chromium_src-4fcd13625bc2072ca0242176155b27278a9117a2.zip chromium_src-4fcd13625bc2072ca0242176155b27278a9117a2.tar.gz chromium_src-4fcd13625bc2072ca0242176155b27278a9117a2.tar.bz2 |
Revert 207755 "Add device policies to control accessibility sett..."
BUG=252670
TBR=bartfab@chromium.org
> Add device policies to control accessibility settings on the login screen
>
> This CL adds device policies that provide control over the default state
> of the following four accessibility settings on the login screen:
> * Large cursor
> * Spoken feedback
> * High contrast mode
> * Screen magnifier type
>
> The User can temporarily override the settings but the defaults are
> restored whenever the login screen is shown anew or the user remains idle
> on the login screen for one minute.
>
> BUG=225955, 225956, 243350, 247298
> TEST=New unittests + new browsertests + manual in VM
>
> Review URL: https://chromiumcodereview.appspot.com/16658015
TBR=bartfab@chromium.org
Review URL: https://codereview.chromium.org/17068004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207799 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
28 files changed, 69 insertions, 1774 deletions
diff --git a/chrome/app/policy/policy_templates.json b/chrome/app/policy/policy_templates.json index 7fca71b..fbd4a5b 100644 --- a/chrome/app/policy/policy_templates.json +++ b/chrome/app/policy/policy_templates.json @@ -112,7 +112,7 @@ # persistent IDs for all fields (but not for groups!) are needed. These are # specified by the 'id' keys of each policy. NEVER CHANGE EXISTING IDs, # because doing so would break the deployed wire format! -# For your editing convenience: highest ID currently used: 218 +# For your editing convenience: highest ID currently used: 214 # # Placeholders: # The following placeholder strings are automatically substituted: @@ -4604,107 +4604,6 @@ If this policy is left unset, the screen magnifier is disabled initially but can be enabled by the user anytime.''', }, - { - 'name': 'DeviceLoginScreenDefaultLargeCursorEnabled', - 'type': 'main', - 'schema': { 'type': 'boolean' }, - 'supported_on': ['chrome_os:29-'], - 'device_only': True, - 'features': { - 'dynamic_refresh': True, - }, - 'example_value': True, - 'id': 215, - 'caption': '''Set default state of the large cursor on the login screen''', - 'desc': '''Set the default state of the large cursor accessibility feature on the login screen. - - If this policy is set to true, the large cursor will be enabled when the login screen is shown. - - If this policy is set to false, the large cursor will be disabled when the login screen is shown. - - If you set this policy, users can temporarily override it by enabling or disabling the large cursor. However, the user's choice is not persistent and the default is restored whenever the login screen is shown anew or the user remains idle on the login screen for a minute. - - If this policy is left unset, the large cursor is disabled when the login screen is first shown. Users can enable or disable the large cursor anytime and its status on the login screen is persisted between users.''', - }, - { - 'name': 'DeviceLoginScreenDefaultSpokenFeedbackEnabled', - 'type': 'main', - 'schema': { 'type': 'boolean' }, - 'supported_on': ['chrome_os:29-'], - 'device_only': True, - 'features': { - 'dynamic_refresh': True, - }, - 'example_value': True, - 'id': 216, - 'caption': '''Set the default state of spoken feedback on the login screen''', - 'desc': '''Set the default state of the spoken feedback accessibility feature on the login screen. - - If this policy is set to true, spoken feedback will be enabled when the login screen is shown. - - If this policy is set to false, spoken feedback will be disabled when the login screen is shown. - - If you set this policy, users can temporarily override it by enabling or disabling spoken feedback. However, the user's choice is not persistent and the default is restored whenever the login screen is shown anew or the user remains idle on the login screen for a minute. - - If this policy is left unset, spoken feedback is disabled when the login screen is first shown. Users can enable or disable spoken feedback anytime and its status on the login screen is persisted between users.''', - }, - { - 'name': 'DeviceLoginScreenDefaultHighContrastEnabled', - 'type': 'main', - 'schema': { 'type': 'boolean' }, - 'supported_on': ['chrome_os:29-'], - 'device_only': True, - 'features': { - 'dynamic_refresh': True, - }, - 'example_value': True, - 'id': 217, - 'caption': '''Set the default state of high contrast mode on the login screen''', - 'desc': '''Set the default state of the high contrast mode accessibility feature on the login screen. - - If this policy is set to true, high contrast mode will be enabled when the login screen is shown. - - If this policy is set to false, high contrast mode will be disabled when the login screen is shown. - - If you set this policy, users can temporarily override it by enabling or disabling high contrast mode. However, the user's choice is not persistent and the default is restored whenever the login screen is shown anew or the user remains idle on the login screen for a minute. - - If this policy is left unset, high contrast mode is disabled when the login screen is first shown. Users can enable or disable high contrast mode anytime and its status on the login screen is persisted between users.''', - }, - { - 'name': 'DeviceLoginScreenDefaultScreenMagnifierType', - 'type': 'int-enum', - 'schema': { - 'type': 'integer', - 'enum': [ 0, 1 ], - }, - 'items': [ - { - 'name': 'None', - 'value': 0, - 'caption': '''Screen magnifier disabled''', - }, - { - 'name': 'Full-screen', - 'value': 1, - 'caption': '''Full-screen magnifier enabled''', - }, - ], - 'supported_on': ['chrome_os:29-'], - 'device_only': True, - 'features': { - 'dynamic_refresh': True, - }, - 'example_value': 1, - 'id': 218, - 'caption': '''Set the default screen magnifier type enabled on the login screen''', - 'desc': '''Set the default type of screen magnifier that is enabled on the login screen. - - If this policy is set, it controls the type of screen magnifier that is enabled when the login screen is shown. Setting the policy to "None" disables the screen magnifier. - - If you set this policy, users can temporarily override it by enabling or disabling the screen magnifier. However, the user's choice is not persistent and the default is restored whenever the login screen is shown anew or the user remains idle on the login screen for a minute. - - If this policy is left unset, the screen magnifier is disabled when the login screen is first shown. Users can enable or disable the screen magnifier anytime and its status on the login screen is persisted between users.''', - }, ], }, { diff --git a/chrome/browser/chromeos/policy/device_local_account_browsertest.cc b/chrome/browser/chromeos/policy/device_local_account_browsertest.cc index eade1ea..9a13741 100644 --- a/chrome/browser/chromeos/policy/device_local_account_browsertest.cc +++ b/chrome/browser/chromeos/policy/device_local_account_browsertest.cc @@ -25,12 +25,13 @@ #include "chrome/browser/chromeos/login/user_manager.h" #include "chrome/browser/chromeos/policy/device_local_account.h" #include "chrome/browser/chromeos/policy/device_policy_builder.h" -#include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" +#include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" #include "chrome/browser/lifetime/application_lifetime.h" #include "chrome/browser/policy/cloud/cloud_policy_constants.h" #include "chrome/browser/policy/cloud/policy_builder.h" #include "chrome/browser/policy/policy_service.h" #include "chrome/browser/policy/proto/chromeos/chrome_device_policy.pb.h" +#include "chrome/browser/policy/proto/chromeos/install_attributes.pb.h" #include "chrome/browser/policy/test/local_policy_test_server.h" #include "chrome/browser/prefs/session_startup_pref.h" #include "chrome/browser/ui/browser.h" @@ -116,7 +117,7 @@ class DeviceLocalAccountTest : public InProcessBrowserTest { command_line->InitFromArgv(argv); // Mark the device enterprise-enrolled. - DevicePolicyCrosBrowserTest::MarkAsEnterpriseOwned(&temp_dir_); + SetUpInstallAttributes(); // Redirect session_manager DBus calls to FakeSessionManagerClient. chromeos::MockDBusThreadManagerWithoutGMock* dbus_thread_manager = @@ -135,6 +136,30 @@ class DeviceLocalAccountTest : public InProcessBrowserTest { base::RunLoop().RunUntilIdle(); } + void SetUpInstallAttributes() { + cryptohome::SerializedInstallAttributes install_attrs_proto; + cryptohome::SerializedInstallAttributes::Attribute* attribute = NULL; + + attribute = install_attrs_proto.add_attributes(); + attribute->set_name(EnterpriseInstallAttributes::kAttrEnterpriseOwned); + attribute->set_value("true"); + + attribute = install_attrs_proto.add_attributes(); + attribute->set_name(EnterpriseInstallAttributes::kAttrEnterpriseUser); + attribute->set_value(PolicyBuilder::kFakeUsername); + + base::FilePath install_attrs_file = + temp_dir_.path().AppendASCII("install_attributes.pb"); + const std::string install_attrs_blob( + install_attrs_proto.SerializeAsString()); + ASSERT_EQ(static_cast<int>(install_attrs_blob.size()), + file_util::WriteFile(install_attrs_file, + install_attrs_blob.c_str(), + install_attrs_blob.size())); + ASSERT_TRUE(PathService::Override(chromeos::FILE_INSTALL_ATTRIBUTES, + install_attrs_file)); + } + void SetUpPolicy() { // Configure two device-local accounts in device settings. DevicePolicyBuilder device_policy; diff --git a/chrome/browser/chromeos/policy/device_policy_cros_browser_test.cc b/chrome/browser/chromeos/policy/device_policy_cros_browser_test.cc index 4b547d5..bbc8471 100644 --- a/chrome/browser/chromeos/policy/device_policy_cros_browser_test.cc +++ b/chrome/browser/chromeos/policy/device_policy_cros_browser_test.cc @@ -4,7 +4,6 @@ #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" -#include <string> #include <vector> #include "base/file_util.h" @@ -13,8 +12,6 @@ #include "base/path_service.h" #include "base/stl_util.h" #include "chrome/browser/chromeos/policy/device_policy_builder.h" -#include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" -#include "chrome/browser/policy/proto/chromeos/install_attributes.pb.h" #include "chromeos/chromeos_paths.h" #include "chromeos/dbus/mock_dbus_thread_manager_without_gmock.h" #include "crypto/rsa_private_key.h" @@ -27,32 +24,6 @@ using ::testing::Return; namespace policy { -// static -void DevicePolicyCrosBrowserTest::MarkAsEnterpriseOwned( - base::ScopedTempDir* temp_dir) { - cryptohome::SerializedInstallAttributes install_attrs_proto; - cryptohome::SerializedInstallAttributes::Attribute* attribute = NULL; - - attribute = install_attrs_proto.add_attributes(); - attribute->set_name(EnterpriseInstallAttributes::kAttrEnterpriseOwned); - attribute->set_value("true"); - - attribute = install_attrs_proto.add_attributes(); - attribute->set_name(EnterpriseInstallAttributes::kAttrEnterpriseUser); - attribute->set_value(DevicePolicyBuilder::kFakeUsername); - - base::FilePath install_attrs_file = - temp_dir->path().AppendASCII("install_attributes.pb"); - const std::string install_attrs_blob( - install_attrs_proto.SerializeAsString()); - ASSERT_EQ(static_cast<int>(install_attrs_blob.size()), - file_util::WriteFile(install_attrs_file, - install_attrs_blob.c_str(), - install_attrs_blob.size())); - ASSERT_TRUE(PathService::Override(chromeos::FILE_INSTALL_ATTRIBUTES, - install_attrs_file)); -} - DevicePolicyCrosBrowserTest::DevicePolicyCrosBrowserTest() : mock_dbus_thread_manager_( new chromeos::MockDBusThreadManagerWithoutGMock) { diff --git a/chrome/browser/chromeos/policy/device_policy_cros_browser_test.h b/chrome/browser/chromeos/policy/device_policy_cros_browser_test.h index a112f80..88961e6 100644 --- a/chrome/browser/chromeos/policy/device_policy_cros_browser_test.h +++ b/chrome/browser/chromeos/policy/device_policy_cros_browser_test.h @@ -20,12 +20,6 @@ namespace policy { // Used to test Device policy changes in Chrome OS. class DevicePolicyCrosBrowserTest : public chromeos::CrosInProcessBrowserTest { - public: - // Marks the device as enterprise-owned. Must be called to make device - // policies apply Chrome-wide. If this is not called, device policies will - // affect CrosSettings only. - static void MarkAsEnterpriseOwned(base::ScopedTempDir* temp_dir); - protected: DevicePolicyCrosBrowserTest(); virtual ~DevicePolicyCrosBrowserTest(); @@ -51,9 +45,6 @@ class DevicePolicyCrosBrowserTest : DevicePolicyBuilder* device_policy() { return &device_policy_; } - // Stores the device owner key and the install attributes. - base::ScopedTempDir temp_dir_; - private: // MockDBusThreadManagerWithoutGMock uses FakeSessionManagerClient. chromeos::MockDBusThreadManagerWithoutGMock* mock_dbus_thread_manager_; @@ -61,6 +52,9 @@ class DevicePolicyCrosBrowserTest : // Carries Chrome OS device policies for tests. DevicePolicyBuilder device_policy_; + // Stores the device owner key. + base::ScopedTempDir temp_dir_; + DISALLOW_COPY_AND_ASSIGN(DevicePolicyCrosBrowserTest); }; diff --git a/chrome/browser/chromeos/policy/device_policy_decoder_chromeos.cc b/chrome/browser/chromeos/policy/device_policy_decoder_chromeos.cc index 2233cb8..b1d9b62 100644 --- a/chrome/browser/chromeos/policy/device_policy_decoder_chromeos.cc +++ b/chrome/browser/chromeos/policy/device_policy_decoder_chromeos.cc @@ -416,50 +416,6 @@ void DecodeAutoUpdatePolicies(const em::ChromeDeviceSettingsProto& policy, } } -void DecodeAccessibilityPolicies(const em::ChromeDeviceSettingsProto& policy, - PolicyMap* policies) { - if (policy.has_accessibility_settings()) { - const em::AccessibilitySettingsProto& - container(policy.accessibility_settings()); - - if (container.has_login_screen_default_large_cursor_enabled()) { - policies->Set( - key::kDeviceLoginScreenDefaultLargeCursorEnabled, - POLICY_LEVEL_MANDATORY, - POLICY_SCOPE_MACHINE, - Value::CreateBooleanValue( - container.login_screen_default_large_cursor_enabled())); - } - - if (container.has_login_screen_default_spoken_feedback_enabled()) { - policies->Set( - key::kDeviceLoginScreenDefaultSpokenFeedbackEnabled, - POLICY_LEVEL_MANDATORY, - POLICY_SCOPE_MACHINE, - Value::CreateBooleanValue( - container.login_screen_default_spoken_feedback_enabled())); - } - - if (container.has_login_screen_default_high_contrast_enabled()) { - policies->Set( - key::kDeviceLoginScreenDefaultHighContrastEnabled, - POLICY_LEVEL_MANDATORY, - POLICY_SCOPE_MACHINE, - Value::CreateBooleanValue( - container.login_screen_default_high_contrast_enabled())); - } - - if (container.has_login_screen_default_screen_magnifier_type()) { - policies->Set( - key::kDeviceLoginScreenDefaultScreenMagnifierType, - POLICY_LEVEL_MANDATORY, - POLICY_SCOPE_MACHINE, - DecodeIntegerValue( - container.login_screen_default_screen_magnifier_type())); - } - } -} - void DecodeGenericPolicies(const em::ChromeDeviceSettingsProto& policy, PolicyMap* policies) { if (policy.has_device_policy_refresh_rate()) { @@ -577,7 +533,6 @@ void DecodeDevicePolicy(const em::ChromeDeviceSettingsProto& policy, DecodeNetworkPolicies(policy, policies, install_attributes); DecodeReportingPolicies(policy, policies); DecodeAutoUpdatePolicies(policy, policies); - DecodeAccessibilityPolicies(policy, policies); DecodeGenericPolicies(policy, policies); } diff --git a/chrome/browser/chromeos/policy/login_profile_policy_provider.cc b/chrome/browser/chromeos/policy/login_profile_policy_provider.cc deleted file mode 100644 index da88bea..0000000 --- a/chrome/browser/chromeos/policy/login_profile_policy_provider.cc +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/chromeos/policy/login_profile_policy_provider.h" - -#include <string> - -#include "base/bind.h" -#include "base/memory/scoped_ptr.h" -#include "base/values.h" -#include "chrome/browser/policy/policy_bundle.h" -#include "chrome/browser/policy/policy_map.h" -#include "chrome/browser/policy/policy_types.h" -#include "policy/policy_constants.h" - -namespace policy { - -namespace { - -// Applies the value of |device_policy| in |device_policy_map| as the -// recommended value of |user_policy| in |user_policy_map|. If the value of -// |device_policy| is unset, does nothing. -void ApplyDevicePolicy(const std::string& device_policy, - const std::string& user_policy, - const PolicyMap& device_policy_map, - PolicyMap* user_policy_map) { - const base::Value* value = device_policy_map.GetValue(device_policy); - if (value) { - user_policy_map->Set(user_policy, - POLICY_LEVEL_RECOMMENDED, - POLICY_SCOPE_USER, - value->DeepCopy()); - } -} - -} // namespace - -LoginProfilePolicyProvider::LoginProfilePolicyProvider( - PolicyService* device_policy_service) - : device_policy_service_(device_policy_service), - waiting_for_device_policy_refresh_(false), - weak_factory_(this) { -} - -LoginProfilePolicyProvider::~LoginProfilePolicyProvider() { -} - -void LoginProfilePolicyProvider::Init() { - ConfigurationPolicyProvider::Init(); - device_policy_service_->AddObserver(POLICY_DOMAIN_CHROME, this); - if (device_policy_service_->IsInitializationComplete(POLICY_DOMAIN_CHROME)) - UpdateFromDevicePolicy(); -} - -void LoginProfilePolicyProvider::Shutdown() { - device_policy_service_->RemoveObserver(POLICY_DOMAIN_CHROME, this); - weak_factory_.InvalidateWeakPtrs(); - ConfigurationPolicyProvider::Shutdown(); -} - -void LoginProfilePolicyProvider::RefreshPolicies() { - waiting_for_device_policy_refresh_ = true; - weak_factory_.InvalidateWeakPtrs(); - device_policy_service_->RefreshPolicies(base::Bind( - &LoginProfilePolicyProvider::OnDevicePolicyRefreshDone, - weak_factory_.GetWeakPtr())); -} - -void LoginProfilePolicyProvider::OnPolicyUpdated(const PolicyNamespace& ns, - const PolicyMap& previous, - const PolicyMap& current) { - if (ns == PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) - UpdateFromDevicePolicy(); -} - -void LoginProfilePolicyProvider::OnPolicyServiceInitialized( - PolicyDomain domain) { - if (domain == POLICY_DOMAIN_CHROME) - UpdateFromDevicePolicy(); -} - -void LoginProfilePolicyProvider::OnDevicePolicyRefreshDone() { - waiting_for_device_policy_refresh_ = false; - UpdateFromDevicePolicy(); -} - -void LoginProfilePolicyProvider::UpdateFromDevicePolicy() { - // If a policy refresh is in progress, wait for it to finish. - if (waiting_for_device_policy_refresh_) - return; - - const PolicyNamespace chrome_namespaces(POLICY_DOMAIN_CHROME, std::string()); - const PolicyMap& device_policy_map = - device_policy_service_->GetPolicies(chrome_namespaces); - scoped_ptr<PolicyBundle> bundle(new PolicyBundle); - PolicyMap& user_policy_map = bundle->Get(chrome_namespaces); - - ApplyDevicePolicy(key::kDeviceLoginScreenDefaultLargeCursorEnabled, - key::kLargeCursorEnabled, - device_policy_map, &user_policy_map); - ApplyDevicePolicy(key::kDeviceLoginScreenDefaultSpokenFeedbackEnabled, - key::kSpokenFeedbackEnabled, - device_policy_map, &user_policy_map); - ApplyDevicePolicy(key::kDeviceLoginScreenDefaultHighContrastEnabled, - key::kHighContrastEnabled, - device_policy_map, &user_policy_map); - ApplyDevicePolicy(key::kDeviceLoginScreenDefaultScreenMagnifierType, - key::kScreenMagnifierType, - device_policy_map, &user_policy_map); - UpdatePolicy(bundle.Pass()); -} - -} // namespace policy diff --git a/chrome/browser/chromeos/policy/login_profile_policy_provider.h b/chrome/browser/chromeos/policy/login_profile_policy_provider.h deleted file mode 100644 index 47ee1af..0000000 --- a/chrome/browser/chromeos/policy/login_profile_policy_provider.h +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_CHROMEOS_POLICY_LOGIN_PROFILE_POLICY_PROVIDER_H_ -#define CHROME_BROWSER_CHROMEOS_POLICY_LOGIN_PROFILE_POLICY_PROVIDER_H_ - -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "base/memory/weak_ptr.h" -#include "chrome/browser/policy/configuration_policy_provider.h" -#include "chrome/browser/policy/policy_service.h" - -namespace policy { - -// Policy provider for the login profile. Since the login profile is not -// associated with any user, it does not receive regular user policy. However, -// several device policies that control features on the login screen surface as -// recommended user policies in the login profile. -class LoginProfilePolicyProvider : public ConfigurationPolicyProvider, - public PolicyService::Observer { - public: - explicit LoginProfilePolicyProvider(PolicyService* device_policy_service); - virtual ~LoginProfilePolicyProvider(); - - // ConfigurationPolicyProvider: - virtual void Init() OVERRIDE; - virtual void Shutdown() OVERRIDE; - virtual void RefreshPolicies() OVERRIDE; - - // PolicyService::Observer: - virtual void OnPolicyUpdated(const PolicyNamespace& ns, - const PolicyMap& previous, - const PolicyMap& current) OVERRIDE; - virtual void OnPolicyServiceInitialized(PolicyDomain domain) OVERRIDE; - - void OnDevicePolicyRefreshDone(); - - private: - void UpdateFromDevicePolicy(); - - PolicyService* device_policy_service_; // Not owned. - - bool waiting_for_device_policy_refresh_; - - base::WeakPtrFactory<LoginProfilePolicyProvider> weak_factory_; - - DISALLOW_COPY_AND_ASSIGN(LoginProfilePolicyProvider); -}; - -} // namespace policy - -#endif // CHROME_BROWSER_CHROMEOS_POLICY_LOGIN_PROFILE_POLICY_PROVIDER_H_ diff --git a/chrome/browser/chromeos/policy/login_screen_default_policy_browsertest.cc b/chrome/browser/chromeos/policy/login_screen_default_policy_browsertest.cc deleted file mode 100644 index 9f4fe5f..0000000 --- a/chrome/browser/chromeos/policy/login_screen_default_policy_browsertest.cc +++ /dev/null @@ -1,438 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include <string> - -#include "ash/magnifier/magnifier_constants.h" -#include "base/basictypes.h" -#include "base/bind.h" -#include "base/bind_helpers.h" -#include "base/command_line.h" -#include "base/compiler_specific.h" -#include "base/files/scoped_temp_dir.h" -#include "base/location.h" -#include "base/message_loop.h" -#include "base/prefs/pref_change_registrar.h" -#include "base/prefs/pref_service.h" -#include "base/run_loop.h" -#include "base/values.h" -#include "chrome/browser/chromeos/accessibility/accessibility_manager.h" -#include "chrome/browser/chromeos/accessibility/magnification_manager.h" -#include "chrome/browser/chromeos/policy/device_policy_builder.h" -#include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" -#include "chrome/browser/chromeos/profiles/profile_helper.h" -#include "chrome/browser/chromeos/settings/device_settings_service.h" -#include "chrome/browser/lifetime/application_lifetime.h" -#include "chrome/browser/policy/proto/chromeos/chrome_device_policy.pb.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/browser/profiles/profile_manager.h" -#include "chrome/common/pref_names.h" -#include "chromeos/chromeos_switches.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace em = enterprise_management; - -namespace policy { - -namespace { - -const em::AccessibilitySettingsProto_ScreenMagnifierType kFullScreenMagnifier = - em::AccessibilitySettingsProto_ScreenMagnifierType_SCREEN_MAGNIFIER_TYPE_FULL; - -// Spins the loop until a notification is received from |prefs| that the value -// of |pref_name| has changed. If the notification is received before Wait() -// has been called, Wait() returns immediately and no loop is spun. -class PrefChangeWatcher { - public: - PrefChangeWatcher(const char* pref_name, PrefService* prefs); - - void Wait(); - - void OnPrefChange(); - - private: - bool pref_changed_; - - base::RunLoop run_loop_; - PrefChangeRegistrar registrar_; - - DISALLOW_COPY_AND_ASSIGN(PrefChangeWatcher); -}; - -PrefChangeWatcher::PrefChangeWatcher(const char* pref_name, - PrefService* prefs) - : pref_changed_(false) { - registrar_.Init(prefs); - registrar_.Add(pref_name, base::Bind(&PrefChangeWatcher::OnPrefChange, - base::Unretained(this))); -} - -void PrefChangeWatcher::Wait() { - if (!pref_changed_) - run_loop_.Run(); -} - -void PrefChangeWatcher::OnPrefChange() { - pref_changed_ = true; - run_loop_.Quit(); -} - -} // namespace - -class LoginScreenDefaultPolicyBrowsertestBase - : public DevicePolicyCrosBrowserTest { - protected: - LoginScreenDefaultPolicyBrowsertestBase(); - virtual ~LoginScreenDefaultPolicyBrowsertestBase(); - - // DevicePolicyCrosBrowserTest: - virtual void SetUpInProcessBrowserTestFixture() OVERRIDE; - virtual void SetUpOnMainThread() OVERRIDE; - - void RefreshDevicePolicyAndWaitForPrefChange(const char* pref_name); - - Profile* login_profile_; - - private: - DISALLOW_COPY_AND_ASSIGN(LoginScreenDefaultPolicyBrowsertestBase); -}; - -class LoginScreenDefaultPolicyLoginScreenBrowsertest - : public LoginScreenDefaultPolicyBrowsertestBase { - protected: - LoginScreenDefaultPolicyLoginScreenBrowsertest(); - virtual ~LoginScreenDefaultPolicyLoginScreenBrowsertest(); - - // LoginScreenDefaultPolicyBrowsertestBase: - virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; - virtual void SetUpOnMainThread() OVERRIDE; - virtual void CleanUpOnMainThread() OVERRIDE; - - void VerifyPrefFollowsRecommendation(const char* pref_name, - const base::Value& recommended_value); - - private: - DISALLOW_COPY_AND_ASSIGN(LoginScreenDefaultPolicyLoginScreenBrowsertest); -}; - -class LoginScreenDefaultPolicyInSessionBrowsertest - : public LoginScreenDefaultPolicyBrowsertestBase { - protected: - LoginScreenDefaultPolicyInSessionBrowsertest(); - virtual ~LoginScreenDefaultPolicyInSessionBrowsertest(); - - // LoginScreenDefaultPolicyBrowsertestBase: - virtual void SetUpOnMainThread() OVERRIDE; - - void VerifyPrefFollowsDefault(const char* pref_name); - - private: - DISALLOW_COPY_AND_ASSIGN(LoginScreenDefaultPolicyInSessionBrowsertest); -}; - -LoginScreenDefaultPolicyBrowsertestBase:: - LoginScreenDefaultPolicyBrowsertestBase() : login_profile_(NULL) { -} - -LoginScreenDefaultPolicyBrowsertestBase:: - ~LoginScreenDefaultPolicyBrowsertestBase() { -} - -void LoginScreenDefaultPolicyBrowsertestBase:: - SetUpInProcessBrowserTestFixture() { - InstallOwnerKey(); - MarkAsEnterpriseOwned(&temp_dir_); - DevicePolicyCrosBrowserTest::SetUpInProcessBrowserTestFixture(); -} - -void LoginScreenDefaultPolicyBrowsertestBase::SetUpOnMainThread() { - DevicePolicyCrosBrowserTest::SetUpOnMainThread(); - login_profile_ = chromeos::ProfileHelper::GetSigninProfile(); - ASSERT_TRUE(login_profile_); -} - -void LoginScreenDefaultPolicyBrowsertestBase:: - RefreshDevicePolicyAndWaitForPrefChange(const char* pref_name) { - PrefChangeWatcher watcher(pref_name, login_profile_->GetPrefs()); - RefreshDevicePolicy(); - watcher.Wait(); -} - -LoginScreenDefaultPolicyLoginScreenBrowsertest:: - LoginScreenDefaultPolicyLoginScreenBrowsertest() { -} - -LoginScreenDefaultPolicyLoginScreenBrowsertest:: - ~LoginScreenDefaultPolicyLoginScreenBrowsertest() { -} - -void LoginScreenDefaultPolicyLoginScreenBrowsertest::SetUpCommandLine( - CommandLine* command_line) { - LoginScreenDefaultPolicyBrowsertestBase::SetUpCommandLine(command_line); - command_line->AppendSwitch(chromeos::switches::kLoginManager); - command_line->AppendSwitch(chromeos::switches::kForceLoginManagerInTests); -} - -void LoginScreenDefaultPolicyLoginScreenBrowsertest::SetUpOnMainThread() { - LoginScreenDefaultPolicyBrowsertestBase::SetUpOnMainThread(); - - // Set the login screen profile. - chromeos::AccessibilityManager* accessibility_manager = - chromeos::AccessibilityManager::Get(); - ASSERT_TRUE(accessibility_manager); - accessibility_manager->SetProfileForTest( - chromeos::ProfileHelper::GetSigninProfile()); - - chromeos::MagnificationManager* magnification_manager = - chromeos::MagnificationManager::Get(); - ASSERT_TRUE(magnification_manager); - magnification_manager->SetProfileForTest( - chromeos::ProfileHelper::GetSigninProfile()); -} - -void LoginScreenDefaultPolicyLoginScreenBrowsertest::CleanUpOnMainThread() { - base::MessageLoop::current()->PostTask(FROM_HERE, - base::Bind(&chrome::AttemptExit)); - base::RunLoop().RunUntilIdle(); - LoginScreenDefaultPolicyBrowsertestBase::CleanUpOnMainThread(); -} - -void LoginScreenDefaultPolicyLoginScreenBrowsertest:: - VerifyPrefFollowsRecommendation(const char* pref_name, - const base::Value& recommended_value) { - const PrefService::Preference* pref = - login_profile_->GetPrefs()->FindPreference(pref_name); - ASSERT_TRUE(pref); - EXPECT_FALSE(pref->IsManaged()); - EXPECT_FALSE(pref->IsDefaultValue()); - EXPECT_TRUE(base::Value::Equals(&recommended_value, pref->GetValue())); - EXPECT_TRUE(base::Value::Equals(&recommended_value, - pref->GetRecommendedValue())); -} - -LoginScreenDefaultPolicyInSessionBrowsertest:: - LoginScreenDefaultPolicyInSessionBrowsertest() { -} - -LoginScreenDefaultPolicyInSessionBrowsertest:: - ~LoginScreenDefaultPolicyInSessionBrowsertest() { -} - -void LoginScreenDefaultPolicyInSessionBrowsertest::SetUpOnMainThread() { - LoginScreenDefaultPolicyBrowsertestBase::SetUpOnMainThread(); - - // Tell the DeviceSettingsService that there is no local owner. - chromeos::DeviceSettingsService::Get()->SetUsername(std::string()); -} - -void LoginScreenDefaultPolicyInSessionBrowsertest::VerifyPrefFollowsDefault( - const char* pref_name) { - Profile* profile = ProfileManager::GetDefaultProfile(); - ASSERT_TRUE(profile); - const PrefService::Preference* pref = - profile->GetPrefs()->FindPreference(pref_name); - ASSERT_TRUE(pref); - EXPECT_FALSE(pref->IsManaged()); - EXPECT_TRUE(pref->IsDefaultValue()); - EXPECT_FALSE(pref->GetRecommendedValue()); -} - -IN_PROC_BROWSER_TEST_F(LoginScreenDefaultPolicyLoginScreenBrowsertest, - DeviceLoginScreenDefaultLargeCursorEnabled) { - // Verifies that the default state of the large cursor accessibility feature - // on the login screen can be controlled through device policy. - - // Enable the large cursor through device policy and wait for the change to - // take effect. - em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); - proto.mutable_accessibility_settings()-> - set_login_screen_default_large_cursor_enabled(true); - RefreshDevicePolicyAndWaitForPrefChange(prefs::kLargeCursorEnabled); - - // Verify that the pref which controls the large cursor in the login profile - // has changed to the policy-supplied default. - VerifyPrefFollowsRecommendation(prefs::kLargeCursorEnabled, - base::FundamentalValue(true)); - - // Verify that the large cursor is enabled. - chromeos::AccessibilityManager* accessibility_manager = - chromeos::AccessibilityManager::Get(); - ASSERT_TRUE(accessibility_manager); - EXPECT_TRUE(accessibility_manager->IsLargeCursorEnabled()); -} - -IN_PROC_BROWSER_TEST_F(LoginScreenDefaultPolicyLoginScreenBrowsertest, - DeviceLoginScreenDefaultSpokenFeedbackEnabled) { - // Verifies that the default state of the spoken feedback accessibility - // feature on the login screen can be controlled through device policy. - - // Enable spoken feedback through device policy and wait for the change to - // take effect. - em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); - proto.mutable_accessibility_settings()-> - set_login_screen_default_spoken_feedback_enabled(true); - RefreshDevicePolicyAndWaitForPrefChange(prefs::kSpokenFeedbackEnabled); - - // Verify that the pref which controls spoken feedback in the login profile - // has changed to the policy-supplied default. - VerifyPrefFollowsRecommendation(prefs::kSpokenFeedbackEnabled, - base::FundamentalValue(true)); - - // Verify that spoken feedback is enabled. - chromeos::AccessibilityManager* accessibility_manager = - chromeos::AccessibilityManager::Get(); - ASSERT_TRUE(accessibility_manager); - EXPECT_TRUE(accessibility_manager->IsSpokenFeedbackEnabled()); -} - -IN_PROC_BROWSER_TEST_F(LoginScreenDefaultPolicyLoginScreenBrowsertest, - DeviceLoginScreenDefaultHighContrastEnabled) { - // Verifies that the default state of the high contrast mode accessibility - // feature on the login screen can be controlled through device policy. - - // Enable high contrast mode through device policy and wait for the change to - // take effect. - em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); - proto.mutable_accessibility_settings()-> - set_login_screen_default_high_contrast_enabled(true); - RefreshDevicePolicyAndWaitForPrefChange(prefs::kHighContrastEnabled); - - // Verify that the pref which controls high contrast mode in the login profile - // has changed to the policy-supplied default. - VerifyPrefFollowsRecommendation(prefs::kHighContrastEnabled, - base::FundamentalValue(true)); - - // Verify that high contrast mode is enabled. - chromeos::AccessibilityManager* accessibility_manager = - chromeos::AccessibilityManager::Get(); - ASSERT_TRUE(accessibility_manager); - EXPECT_TRUE(accessibility_manager->IsHighContrastEnabled()); -} - -IN_PROC_BROWSER_TEST_F(LoginScreenDefaultPolicyLoginScreenBrowsertest, - DeviceLoginScreenDefaultScreenMagnifierType) { - // Verifies that the default screen magnifier type enabled on the login screen - // can be controlled through device policy. - - // Set the screen magnifier type through device policy and wait for the change - // to take effect. - em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); - proto.mutable_accessibility_settings()-> - set_login_screen_default_screen_magnifier_type(kFullScreenMagnifier); - RefreshDevicePolicyAndWaitForPrefChange(prefs::kScreenMagnifierType); - - // Verify that the prefs which control the screen magnifier type have changed - // to the policy-supplied default. - VerifyPrefFollowsRecommendation(prefs::kScreenMagnifierEnabled, - base::FundamentalValue(true)); - VerifyPrefFollowsRecommendation(prefs::kScreenMagnifierType, - base::FundamentalValue(ash::MAGNIFIER_FULL)); - - // Verify that the full-screen magnifier is enabled. - chromeos::MagnificationManager* magnification_manager = - chromeos::MagnificationManager::Get(); - ASSERT_TRUE(magnification_manager); - EXPECT_TRUE(magnification_manager->IsMagnifierEnabled()); - EXPECT_EQ(ash::MAGNIFIER_FULL, magnification_manager->GetMagnifierType()); -} - -IN_PROC_BROWSER_TEST_F(LoginScreenDefaultPolicyInSessionBrowsertest, - DeviceLoginScreenDefaultLargeCursorEnabled) { - // Verifies that changing the default state of the large cursor accessibility - // feature on the login screen through policy does not affect its state in a - // session. - - // Enable the large cursor through device policy and wait for the change to - // take effect. - em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); - proto.mutable_accessibility_settings()-> - set_login_screen_default_large_cursor_enabled(true); - RefreshDevicePolicyAndWaitForPrefChange(prefs::kLargeCursorEnabled); - - // Verify that the pref which controls the large cursor in the session is - // unchanged. - VerifyPrefFollowsDefault(prefs::kLargeCursorEnabled); - - // Verify that the large cursor is disabled. - chromeos::AccessibilityManager* accessibility_manager = - chromeos::AccessibilityManager::Get(); - ASSERT_TRUE(accessibility_manager); - EXPECT_FALSE(accessibility_manager->IsLargeCursorEnabled()); -} - -IN_PROC_BROWSER_TEST_F(LoginScreenDefaultPolicyInSessionBrowsertest, - DeviceLoginScreenDefaultSpokenFeedbackEnabled) { - // Verifies that changing the default state of the spoken feedback - // accessibility feature on the login screen through policy does not affect - // its state in a session. - - // Enable spoken feedback through device policy and wait for the change to - // take effect. - em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); - proto.mutable_accessibility_settings()-> - set_login_screen_default_spoken_feedback_enabled(true); - RefreshDevicePolicyAndWaitForPrefChange(prefs::kSpokenFeedbackEnabled); - - // Verify that the pref which controls the spoken feedback in the session is - // unchanged. - VerifyPrefFollowsDefault(prefs::kSpokenFeedbackEnabled); - - // Verify that spoken feedback is disabled. - chromeos::AccessibilityManager* accessibility_manager = - chromeos::AccessibilityManager::Get(); - ASSERT_TRUE(accessibility_manager); - EXPECT_FALSE(accessibility_manager->IsSpokenFeedbackEnabled()); -} - -IN_PROC_BROWSER_TEST_F(LoginScreenDefaultPolicyInSessionBrowsertest, - DeviceLoginScreenDefaultHighContrastEnabled) { - // Verifies that changing the default state of the high contrast mode - // accessibility feature on the login screen through policy does not affect - // its state in a session. - - // Enable high contrast mode through device policy and wait for the change to - // take effect. - em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); - proto.mutable_accessibility_settings()-> - set_login_screen_default_high_contrast_enabled(true); - RefreshDevicePolicyAndWaitForPrefChange(prefs::kHighContrastEnabled); - - // Verify that the pref which controls high contrast mode in the session is - // unchanged. - VerifyPrefFollowsDefault(prefs::kHighContrastEnabled); - - // Verify that high contrast mode is disabled. - chromeos::AccessibilityManager* accessibility_manager = - chromeos::AccessibilityManager::Get(); - ASSERT_TRUE(accessibility_manager); - EXPECT_FALSE(accessibility_manager->IsHighContrastEnabled()); -} - -IN_PROC_BROWSER_TEST_F(LoginScreenDefaultPolicyInSessionBrowsertest, - DeviceLoginScreenDefaultScreenMagnifierType) { - // Verifies that changing the default screen magnifier type enabled on the - // login screen through policy does not affect its state in a session. - - // Set the screen magnifier type through device policy and wait for the change - // to take effect. - em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); - proto.mutable_accessibility_settings()-> - set_login_screen_default_screen_magnifier_type(kFullScreenMagnifier); - RefreshDevicePolicyAndWaitForPrefChange(prefs::kScreenMagnifierType); - - // Verify that the prefs which control the screen magnifier in the session are - // unchanged. - VerifyPrefFollowsDefault(prefs::kScreenMagnifierEnabled); - VerifyPrefFollowsDefault(prefs::kScreenMagnifierType); - - // Verify that the screen magnifier is disabled. - chromeos::MagnificationManager* magnification_manager = - chromeos::MagnificationManager::Get(); - ASSERT_TRUE(magnification_manager); - EXPECT_FALSE(magnification_manager->IsMagnifierEnabled()); - EXPECT_EQ(ash::kDefaultMagnifierType, - magnification_manager->GetMagnifierType()); -} - -} // namespace policy diff --git a/chrome/browser/chromeos/policy/recommendation_restorer.cc b/chrome/browser/chromeos/policy/recommendation_restorer.cc deleted file mode 100644 index e738ad6..0000000 --- a/chrome/browser/chromeos/policy/recommendation_restorer.cc +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/chromeos/policy/recommendation_restorer.h" - -#include "ash/shell.h" -#include "ash/wm/user_activity_detector.h" -#include "base/bind.h" -#include "base/bind_helpers.h" -#include "base/location.h" -#include "base/logging.h" -#include "base/prefs/pref_service.h" -#include "base/time.h" -#include "base/values.h" -#include "chrome/browser/chromeos/profiles/profile_helper.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/common/chrome_notification_types.h" -#include "chrome/common/pref_names.h" -#include "content/public/browser/notification_details.h" -#include "content/public/browser/notification_service.h" -#include "content/public/browser/notification_source.h" - -namespace policy { - -namespace { -// The amount of idle time after which recommended values are restored. -const int kRestoreDelayInMs = 60 * 1000; // 1 minute. -} // namespace - -RecommendationRestorer::RecommendationRestorer(Profile* profile) - : logged_in_(false) { - if (!chromeos::ProfileHelper::IsSigninProfile(profile)) - return; - - pref_change_registrar_.Init(profile->GetPrefs()); - pref_change_registrar_.Add(prefs::kLargeCursorEnabled, - base::Bind(&RecommendationRestorer::Restore, - base::Unretained(this), true)); - pref_change_registrar_.Add(prefs::kSpokenFeedbackEnabled, - base::Bind(&RecommendationRestorer::Restore, - base::Unretained(this), true)); - pref_change_registrar_.Add(prefs::kHighContrastEnabled, - base::Bind(&RecommendationRestorer::Restore, - base::Unretained(this), true)); - pref_change_registrar_.Add(prefs::kScreenMagnifierEnabled, - base::Bind(&RecommendationRestorer::Restore, - base::Unretained(this), true)); - pref_change_registrar_.Add(prefs::kScreenMagnifierType, - base::Bind(&RecommendationRestorer::Restore, - base::Unretained(this), true)); - - notification_registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_CHANGED, - content::NotificationService::AllSources()); - - RestoreAll(); -} - -RecommendationRestorer::~RecommendationRestorer() { -} - -void RecommendationRestorer::Shutdown() { - StopTimer(); - pref_change_registrar_.RemoveAll(); - notification_registrar_.RemoveAll(); -} - -void RecommendationRestorer::Observe( - int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) { - if (type == chrome::NOTIFICATION_LOGIN_USER_CHANGED) { - logged_in_ = true; - notification_registrar_.RemoveAll(); - StopTimer(); - RestoreAll(); - } else { - NOTREACHED(); - } -} - -void RecommendationRestorer::OnUserActivity() { - if (restore_timer_.IsRunning()) - restore_timer_.Reset(); -} - -void RecommendationRestorer::Restore(bool allow_delay, - const std::string& pref_name) { - const PrefService::Preference* pref = - pref_change_registrar_.prefs()->FindPreference(pref_name.c_str()); - if (!pref) { - NOTREACHED(); - return; - } - - if (!pref->GetRecommendedValue() || !pref->HasUserSetting()) - return; - - if (!logged_in_ && allow_delay) - StartTimer(); - else - pref_change_registrar_.prefs()->ClearPref(pref->name().c_str()); -} - -void RecommendationRestorer::RestoreAll() { - Restore(false, prefs::kLargeCursorEnabled); - Restore(false, prefs::kSpokenFeedbackEnabled); - Restore(false, prefs::kHighContrastEnabled); - Restore(false, prefs::kScreenMagnifierEnabled); - Restore(false, prefs::kScreenMagnifierType); -} - -void RecommendationRestorer::StartTimer() { - // Listen for user activity so that the timer can be reset while the user is - // active, causing it to fire only when the user remains idle for - // |kRestoreDelayInMs|. - if (ash::Shell::HasInstance()) { - ash::UserActivityDetector* user_activity_detector = - ash::Shell::GetInstance()->user_activity_detector(); - if (!user_activity_detector->HasObserver(this)) - user_activity_detector->AddObserver(this); - } - - // There should be a separate timer for each pref. However, in the common - // case of the user changing settings, a single timer is sufficient. This is - // because a change initiated by the user implies user activity, so that even - // if there was a separate timer per pref, they would all be reset at that - // point, causing them to fire at exactly the same time. In the much rarer - // case of a recommended value changing, a single timer is a close - // approximation of the behavior that would be obtained by resetting the timer - // for the affected pref only. - restore_timer_.Start(FROM_HERE, - base::TimeDelta::FromMilliseconds(kRestoreDelayInMs), - base::Bind(&RecommendationRestorer::RestoreAll, - base::Unretained(this))); -} - -void RecommendationRestorer::StopTimer() { - restore_timer_.Stop(); - if (ash::Shell::HasInstance()) - ash::Shell::GetInstance()->user_activity_detector()->RemoveObserver(this); -} - -} // namespace policy diff --git a/chrome/browser/chromeos/policy/recommendation_restorer.h b/chrome/browser/chromeos/policy/recommendation_restorer.h deleted file mode 100644 index 227741d..0000000 --- a/chrome/browser/chromeos/policy/recommendation_restorer.h +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_CHROMEOS_POLICY_RECOMMENDATION_RESTORER_H_ -#define CHROME_BROWSER_CHROMEOS_POLICY_RECOMMENDATION_RESTORER_H_ - -#include <string> - -#include "ash/wm/user_activity_observer.h" -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "base/prefs/pref_change_registrar.h" -#include "base/timer.h" -#include "components/browser_context_keyed_service/browser_context_keyed_service.h" -#include "content/public/browser/notification_observer.h" -#include "content/public/browser/notification_registrar.h" - -class Profile; - -namespace policy { - -// Observes a set of prefs in the login profile. If any of the prefs has a -// recommended value, its user setting is cleared so that the recommendation can -// take effect. This happens immediately when the login screen is shown, when -// a session is being started and whenever recommended values change during a -// user session. On the login screen, user settings are cleared when the user -// becomes idle for one minute. -class RecommendationRestorer : public BrowserContextKeyedService, - public content::NotificationObserver, - public ash::UserActivityObserver { - public: - explicit RecommendationRestorer(Profile* profile); - virtual ~RecommendationRestorer(); - - // BrowserContextKeyedService: - virtual void Shutdown() OVERRIDE; - - // content::NotificationObserver: - virtual void Observe(int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) OVERRIDE; - - // ash::UserActivityObserver::Observer: - virtual void OnUserActivity() OVERRIDE; - - // If a recommended value and a user setting exist for |pref_name|, clears the - // user setting so that the recommended value can take effect. If - // |allow_delay| is |true| and the login screen is being shown, a timer is - // started that will clear the setting when the user becomes idle for one - // minute. Otherwise, the setting is cleared immediately. - void Restore(bool allow_delay, const std::string& pref_name); - - private: - friend class RecommendationRestorerTest; - - void RestoreAll(); - - void StartTimer(); - void StopTimer(); - - PrefChangeRegistrar pref_change_registrar_; - content::NotificationRegistrar notification_registrar_; - - bool logged_in_; - - base::OneShotTimer<RecommendationRestorer> restore_timer_; - - DISALLOW_COPY_AND_ASSIGN(RecommendationRestorer); -}; - -} // namespace policy - -#endif // CHROME_BROWSER_CHROMEOS_POLICY_RECOMMENDATION_RESTORER_H_ diff --git a/chrome/browser/chromeos/policy/recommendation_restorer_factory.cc b/chrome/browser/chromeos/policy/recommendation_restorer_factory.cc deleted file mode 100644 index 59cab9a..0000000 --- a/chrome/browser/chromeos/policy/recommendation_restorer_factory.cc +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/chromeos/policy/recommendation_restorer_factory.h" - -#include "chrome/browser/chromeos/policy/recommendation_restorer.h" -#include "chrome/browser/profiles/profile.h" -#include "components/browser_context_keyed_service/browser_context_dependency_manager.h" -#include "content/public/browser/browser_context.h" - -namespace policy { - -// static -RecommendationRestorerFactory* RecommendationRestorerFactory::GetInstance() { - return Singleton<RecommendationRestorerFactory>::get(); -} - -// static -RecommendationRestorer* RecommendationRestorerFactory::GetForProfile( - Profile* profile) { - return reinterpret_cast<RecommendationRestorer*>( - GetInstance()->GetServiceForBrowserContext(profile, false)); -} - -BrowserContextKeyedService* - RecommendationRestorerFactory::BuildServiceInstanceFor( - content::BrowserContext* context) const { - return new RecommendationRestorer(static_cast<Profile*>(context)); -} - -bool RecommendationRestorerFactory::ServiceIsCreatedWithBrowserContext() const { - return true; -} - -RecommendationRestorerFactory::RecommendationRestorerFactory() - : BrowserContextKeyedServiceFactory( - "RecommendationRestorer", - BrowserContextDependencyManager::GetInstance()) { -} - -RecommendationRestorerFactory::~RecommendationRestorerFactory() { -} - -} // namespace policy diff --git a/chrome/browser/chromeos/policy/recommendation_restorer_factory.h b/chrome/browser/chromeos/policy/recommendation_restorer_factory.h deleted file mode 100644 index 9b5cda2..0000000 --- a/chrome/browser/chromeos/policy/recommendation_restorer_factory.h +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_CHROMEOS_POLICY_RECOMMENDATION_RESTORER_FACTORY_H_ -#define CHROME_BROWSER_CHROMEOS_POLICY_RECOMMENDATION_RESTORER_FACTORY_H_ - -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "base/memory/singleton.h" -#include "components/browser_context_keyed_service/browser_context_keyed_service_factory.h" - -class Profile; - -namespace policy { - -class RecommendationRestorer; - -class RecommendationRestorerFactory : public BrowserContextKeyedServiceFactory { - public: - static RecommendationRestorerFactory* GetInstance(); - - static RecommendationRestorer* GetForProfile(Profile* profile); - - protected: - // BrowserContextKeyedServiceFactory: - virtual BrowserContextKeyedService* BuildServiceInstanceFor( - content::BrowserContext* context) const OVERRIDE; - virtual bool ServiceIsCreatedWithBrowserContext() const OVERRIDE; - - private: - friend struct DefaultSingletonTraits<RecommendationRestorerFactory>; - - RecommendationRestorerFactory(); - virtual ~RecommendationRestorerFactory(); - - DISALLOW_COPY_AND_ASSIGN(RecommendationRestorerFactory); -}; - -} // namespace policy - -#endif // CHROME_BROWSER_CHROMEOS_POLICY_RECOMMENDATION_RESTORER_FACTORY_H_ diff --git a/chrome/browser/chromeos/policy/recommendation_restorer_unittest.cc b/chrome/browser/chromeos/policy/recommendation_restorer_unittest.cc deleted file mode 100644 index 8899c5a..0000000 --- a/chrome/browser/chromeos/policy/recommendation_restorer_unittest.cc +++ /dev/null @@ -1,493 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/chromeos/policy/recommendation_restorer.h" - -#include "ash/magnifier/magnifier_constants.h" -#include "base/memory/scoped_ptr.h" -#include "base/prefs/pref_notifier_impl.h" -#include "base/prefs/testing_pref_store.h" -#include "base/strings/utf_string_conversions.h" -#include "base/test/test_simple_task_runner.h" -#include "base/thread_task_runner_handle.h" -#include "base/time.h" -#include "base/values.h" -#include "chrome/browser/chromeos/policy/recommendation_restorer_factory.h" -#include "chrome/browser/prefs/browser_prefs.h" -#include "chrome/browser/prefs/pref_service_syncable.h" -#include "chrome/common/chrome_constants.h" -#include "chrome/common/chrome_notification_types.h" -#include "chrome/common/pref_names.h" -#include "chrome/test/base/testing_browser_process.h" -#include "chrome/test/base/testing_pref_service_syncable.h" -#include "chrome/test/base/testing_profile.h" -#include "chrome/test/base/testing_profile_manager.h" -#include "components/user_prefs/pref_registry_syncable.h" -#include "content/public/browser/notification_details.h" -#include "content/public/browser/notification_service.h" -#include "content/public/browser/notification_source.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace policy { - -namespace { - // The amount of idle time after which recommended values are restored. - const int kRestoreDelayInMs = 60 * 1000; // 1 minute. -} // namespace - -class RecommendationRestorerTest : public testing::Test { - protected: - RecommendationRestorerTest(); - - // testing::Test: - virtual void SetUp() OVERRIDE; - virtual void TearDown() OVERRIDE; - - void SetRecommendedValues(); - void SetUserSettings(); - - void CreateLoginProfile(); - void CreateUserProfile(); - - void NotifyOfSessionStart(); - void NotifyOfUserActivity(); - - void VerifyPrefFollowsUser(const char* pref_name, - const base::Value& expected_value) const; - void VerifyPrefsFollowUser() const; - void VerifyPrefFollowsRecommendation(const char* pref_name, - const base::Value& expected_value) const; - void VerifyPrefsFollowRecommendations() const; - - void VerifyNotListeningForNotifications() const; - void VerifyTimerIsStopped() const; - void VerifyTimerIsRunning() const; - - TestingPrefStore* recommended_prefs_; // Not owned. - TestingPrefServiceSyncable* prefs_; // Not owned. - RecommendationRestorer* restorer_; // Not owned. - - scoped_refptr<base::TestSimpleTaskRunner> runner_; - base::ThreadTaskRunnerHandle runner_handler_; - - private: - scoped_ptr<PrefServiceSyncable> prefs_owner_; - - TestingProfileManager* profile_manager_; // Not owned. - - DISALLOW_COPY_AND_ASSIGN(RecommendationRestorerTest); -}; - -RecommendationRestorerTest::RecommendationRestorerTest() - : recommended_prefs_(new TestingPrefStore), - prefs_(new TestingPrefServiceSyncable( - new TestingPrefStore, - new TestingPrefStore, - recommended_prefs_, - new user_prefs::PrefRegistrySyncable, - new PrefNotifierImpl)), - restorer_(NULL), - runner_(new base::TestSimpleTaskRunner), - runner_handler_(runner_), - prefs_owner_(prefs_), - profile_manager_(NULL) { - chrome::RegisterUserPrefs(prefs_->registry()); -} - -void RecommendationRestorerTest::SetUp() { - testing::Test::SetUp(); - profile_manager_ = - new TestingProfileManager(TestingBrowserProcess::GetGlobal()); - ASSERT_TRUE(profile_manager_->SetUp()); -} - -void RecommendationRestorerTest::TearDown() { - TestingBrowserProcess::GetGlobal()->SetLocalState(NULL); - testing::Test::TearDown(); -} - -void RecommendationRestorerTest::SetRecommendedValues() { - recommended_prefs_->SetBoolean(prefs::kLargeCursorEnabled, false); - recommended_prefs_->SetBoolean(prefs::kSpokenFeedbackEnabled, false); - recommended_prefs_->SetBoolean(prefs::kHighContrastEnabled, false); - recommended_prefs_->SetBoolean(prefs::kScreenMagnifierEnabled, false); - recommended_prefs_->SetInteger(prefs::kScreenMagnifierType, 0); -} - -void RecommendationRestorerTest::SetUserSettings() { - prefs_->SetBoolean(prefs::kLargeCursorEnabled, true); - prefs_->SetBoolean(prefs::kSpokenFeedbackEnabled, true); - prefs_->SetBoolean(prefs::kHighContrastEnabled, true); - prefs_->SetBoolean(prefs::kScreenMagnifierEnabled, true); - prefs_->SetInteger(prefs::kScreenMagnifierType, ash::MAGNIFIER_FULL); -} - -void RecommendationRestorerTest::CreateLoginProfile() { - ASSERT_FALSE(restorer_); - TestingProfile* profile = profile_manager_->CreateTestingProfile( - chrome::kInitialProfile, prefs_owner_.Pass(), - UTF8ToUTF16(chrome::kInitialProfile), 0); - restorer_ = RecommendationRestorerFactory::GetForProfile(profile); - EXPECT_TRUE(restorer_); -} - -void RecommendationRestorerTest::CreateUserProfile() { - ASSERT_FALSE(restorer_); - TestingProfile* profile = profile_manager_->CreateTestingProfile( - "user", prefs_owner_.Pass(), UTF8ToUTF16("user"), 0); - restorer_ = RecommendationRestorerFactory::GetForProfile(profile); - EXPECT_TRUE(restorer_); -} - -void RecommendationRestorerTest::NotifyOfSessionStart() { - ASSERT_TRUE(restorer_); - restorer_->Observe(chrome::NOTIFICATION_LOGIN_USER_CHANGED, - content::Source<RecommendationRestorerTest>(this), - content::NotificationService::NoDetails()); -} - -void RecommendationRestorerTest::NotifyOfUserActivity() { - ASSERT_TRUE(restorer_); - restorer_->OnUserActivity(); -} - -void RecommendationRestorerTest::VerifyPrefFollowsUser( - const char* pref_name, - const base::Value& expected_value) const { - const PrefServiceSyncable::Preference* pref = - prefs_->FindPreference(pref_name); - ASSERT_TRUE(pref); - EXPECT_TRUE(pref->HasUserSetting()); - const base::Value* value = pref->GetValue(); - ASSERT_TRUE(value); - EXPECT_TRUE(expected_value.Equals(value)); -} - -void RecommendationRestorerTest::VerifyPrefsFollowUser() const { - VerifyPrefFollowsUser(prefs::kLargeCursorEnabled, - base::FundamentalValue(true)); - VerifyPrefFollowsUser(prefs::kSpokenFeedbackEnabled, - base::FundamentalValue(true)); - VerifyPrefFollowsUser(prefs::kHighContrastEnabled, - base::FundamentalValue(true)); - VerifyPrefFollowsUser(prefs::kScreenMagnifierEnabled, - base::FundamentalValue(true)); - VerifyPrefFollowsUser(prefs::kScreenMagnifierType, - base::FundamentalValue(ash::MAGNIFIER_FULL)); -} - -void RecommendationRestorerTest::VerifyPrefFollowsRecommendation( - const char* pref_name, - const base::Value& expected_value) const { - const PrefServiceSyncable::Preference* pref = - prefs_->FindPreference(pref_name); - ASSERT_TRUE(pref); - EXPECT_TRUE(pref->IsRecommended()); - EXPECT_FALSE(pref->HasUserSetting()); - const base::Value* value = pref->GetValue(); - ASSERT_TRUE(value); - EXPECT_TRUE(expected_value.Equals(value)); -} - -void RecommendationRestorerTest::VerifyPrefsFollowRecommendations() const { - VerifyPrefFollowsRecommendation(prefs::kLargeCursorEnabled, - base::FundamentalValue(false)); - VerifyPrefFollowsRecommendation(prefs::kSpokenFeedbackEnabled, - base::FundamentalValue(false)); - VerifyPrefFollowsRecommendation(prefs::kHighContrastEnabled, - base::FundamentalValue(false)); - VerifyPrefFollowsRecommendation(prefs::kScreenMagnifierEnabled, - base::FundamentalValue(false)); - VerifyPrefFollowsRecommendation(prefs::kScreenMagnifierType, - base::FundamentalValue(0)); -} - -void RecommendationRestorerTest::VerifyNotListeningForNotifications() const { - ASSERT_TRUE(restorer_); - EXPECT_TRUE(restorer_->pref_change_registrar_.IsEmpty()); - EXPECT_TRUE(restorer_->notification_registrar_.IsEmpty()); -} - -void RecommendationRestorerTest::VerifyTimerIsStopped() const { - ASSERT_TRUE(restorer_); - EXPECT_FALSE(restorer_->restore_timer_.IsRunning()); -} - -void RecommendationRestorerTest::VerifyTimerIsRunning() const { - ASSERT_TRUE(restorer_); - EXPECT_TRUE(restorer_->restore_timer_.IsRunning()); - EXPECT_EQ(base::TimeDelta::FromMilliseconds(kRestoreDelayInMs), - restorer_->restore_timer_.GetCurrentDelay()); -} - -TEST_F(RecommendationRestorerTest, CreateForUserProfile) { - // Verifies that when a RecommendationRestorer is created for a user profile, - // it does not start listening for any notifications, does not clear user - // settings on initialization and does not start a timer that will clear user - // settings eventually. - SetRecommendedValues(); - SetUserSettings(); - - CreateUserProfile(); - VerifyNotListeningForNotifications(); - VerifyPrefsFollowUser(); - VerifyTimerIsStopped(); -} - -TEST_F(RecommendationRestorerTest, NoRecommendations) { - // Verifies that when no recommended values have been set and a - // RecommendationRestorer is created for the login profile, it does not clear - // user settings on initialization and does not start a timer that will clear - // user settings eventually. - SetUserSettings(); - - CreateLoginProfile(); - VerifyPrefsFollowUser(); - VerifyTimerIsStopped(); -} - -TEST_F(RecommendationRestorerTest, RestoreOnStartup) { - // Verifies that when recommended values have been set and a - // RecommendationRestorer is created for the login profile, it clears user - // settings on initialization. - SetRecommendedValues(); - SetUserSettings(); - - CreateLoginProfile(); - VerifyPrefsFollowRecommendations(); - VerifyTimerIsStopped(); -} - -TEST_F(RecommendationRestorerTest, RestoreOnRecommendationChangeOnLoginScreen) { - // Verifies that if recommended values change while the login screen is being - // shown, a timer is started that will clear user settings eventually. - SetUserSettings(); - - CreateLoginProfile(); - - VerifyTimerIsStopped(); - recommended_prefs_->SetBoolean(prefs::kLargeCursorEnabled, false); - VerifyPrefFollowsUser(prefs::kLargeCursorEnabled, - base::FundamentalValue(true)); - VerifyTimerIsRunning(); - runner_->RunUntilIdle(); - VerifyPrefFollowsRecommendation(prefs::kLargeCursorEnabled, - base::FundamentalValue(false)); - - VerifyTimerIsStopped(); - recommended_prefs_->SetBoolean(prefs::kSpokenFeedbackEnabled, false); - VerifyPrefFollowsUser(prefs::kSpokenFeedbackEnabled, - base::FundamentalValue(true)); - VerifyTimerIsRunning(); - runner_->RunUntilIdle(); - VerifyPrefFollowsRecommendation(prefs::kSpokenFeedbackEnabled, - base::FundamentalValue(false)); - - VerifyTimerIsStopped(); - recommended_prefs_->SetBoolean(prefs::kHighContrastEnabled, false); - VerifyPrefFollowsUser(prefs::kHighContrastEnabled, - base::FundamentalValue(true)); - VerifyTimerIsRunning(); - runner_->RunUntilIdle(); - VerifyPrefFollowsRecommendation(prefs::kHighContrastEnabled, - base::FundamentalValue(false)); - - VerifyTimerIsStopped(); - recommended_prefs_->SetBoolean(prefs::kScreenMagnifierEnabled, false); - recommended_prefs_->SetInteger(prefs::kScreenMagnifierType, 0); - VerifyPrefFollowsUser(prefs::kScreenMagnifierEnabled, - base::FundamentalValue(true)); - VerifyPrefFollowsUser(prefs::kScreenMagnifierType, - base::FundamentalValue(ash::MAGNIFIER_FULL)); - VerifyTimerIsRunning(); - runner_->RunUntilIdle(); - VerifyPrefFollowsRecommendation(prefs::kScreenMagnifierEnabled, - base::FundamentalValue(false)); - VerifyPrefFollowsRecommendation(prefs::kScreenMagnifierType, - base::FundamentalValue(0)); - - VerifyTimerIsStopped(); -} - -TEST_F(RecommendationRestorerTest, RestoreOnRecommendationChangeInUserSession) { - // Verifies that if recommended values change while a user session is in - // progress, user settings are cleared immediately. - SetUserSettings(); - - CreateLoginProfile(); - NotifyOfSessionStart(); - - VerifyPrefFollowsUser(prefs::kLargeCursorEnabled, - base::FundamentalValue(true)); - recommended_prefs_->SetBoolean(prefs::kLargeCursorEnabled, false); - VerifyTimerIsStopped(); - VerifyPrefFollowsRecommendation(prefs::kLargeCursorEnabled, - base::FundamentalValue(false)); - - VerifyPrefFollowsUser(prefs::kSpokenFeedbackEnabled, - base::FundamentalValue(true)); - recommended_prefs_->SetBoolean(prefs::kSpokenFeedbackEnabled, false); - VerifyTimerIsStopped(); - VerifyPrefFollowsRecommendation(prefs::kSpokenFeedbackEnabled, - base::FundamentalValue(false)); - - VerifyPrefFollowsUser(prefs::kHighContrastEnabled, - base::FundamentalValue(true)); - recommended_prefs_->SetBoolean(prefs::kHighContrastEnabled, false); - VerifyTimerIsStopped(); - VerifyPrefFollowsRecommendation(prefs::kHighContrastEnabled, - base::FundamentalValue(false)); - - VerifyPrefFollowsUser(prefs::kScreenMagnifierEnabled, - base::FundamentalValue(true)); - VerifyPrefFollowsUser(prefs::kScreenMagnifierType, - base::FundamentalValue(ash::MAGNIFIER_FULL)); - recommended_prefs_->SetBoolean(prefs::kScreenMagnifierEnabled, false); - recommended_prefs_->SetInteger(prefs::kScreenMagnifierType, 0); - VerifyTimerIsStopped(); - VerifyPrefFollowsRecommendation(prefs::kScreenMagnifierEnabled, - base::FundamentalValue(false)); - VerifyPrefFollowsRecommendation(prefs::kScreenMagnifierType, - base::FundamentalValue(0)); -} - -TEST_F(RecommendationRestorerTest, DoNothingOnUserChange) { - // Verifies that if no recommended values have been set and user settings - // change, the user settings are not cleared immediately and no timer is - // started that will clear the user settings eventually. - CreateLoginProfile(); - - prefs_->SetBoolean(prefs::kLargeCursorEnabled, true); - VerifyPrefFollowsUser(prefs::kLargeCursorEnabled, - base::FundamentalValue(true)); - VerifyTimerIsStopped(); - - prefs_->SetBoolean(prefs::kSpokenFeedbackEnabled, true); - VerifyPrefFollowsUser(prefs::kSpokenFeedbackEnabled, - base::FundamentalValue(true)); - VerifyTimerIsStopped(); - - prefs_->SetBoolean(prefs::kHighContrastEnabled, true); - VerifyPrefFollowsUser(prefs::kHighContrastEnabled, - base::FundamentalValue(true)); - VerifyTimerIsStopped(); - - prefs_->SetBoolean(prefs::kScreenMagnifierEnabled, true); - VerifyPrefFollowsUser(prefs::kScreenMagnifierEnabled, - base::FundamentalValue(true)); - VerifyTimerIsStopped(); - - prefs_->SetBoolean(prefs::kScreenMagnifierEnabled, true); - prefs_->SetInteger(prefs::kScreenMagnifierType, ash::MAGNIFIER_FULL); - VerifyPrefFollowsUser(prefs::kScreenMagnifierEnabled, - base::FundamentalValue(true)); - VerifyPrefFollowsUser(prefs::kScreenMagnifierType, - base::FundamentalValue(ash::MAGNIFIER_FULL)); - VerifyTimerIsStopped(); -} - -TEST_F(RecommendationRestorerTest, RestoreOnUserChange) { - // Verifies that if recommended values have been set and user settings change - // while the login screen is being shown, a timer is started that will clear - // the user settings eventually. - SetRecommendedValues(); - - CreateLoginProfile(); - - VerifyTimerIsStopped(); - prefs_->SetBoolean(prefs::kLargeCursorEnabled, true); - VerifyPrefFollowsUser(prefs::kLargeCursorEnabled, - base::FundamentalValue(true)); - VerifyTimerIsRunning(); - runner_->RunUntilIdle(); - VerifyPrefFollowsRecommendation(prefs::kLargeCursorEnabled, - base::FundamentalValue(false)); - - VerifyTimerIsStopped(); - prefs_->SetBoolean(prefs::kSpokenFeedbackEnabled, true); - VerifyPrefFollowsUser(prefs::kSpokenFeedbackEnabled, - base::FundamentalValue(true)); - VerifyTimerIsRunning(); - runner_->RunUntilIdle(); - VerifyPrefFollowsRecommendation(prefs::kSpokenFeedbackEnabled, - base::FundamentalValue(false)); - - VerifyTimerIsStopped(); - prefs_->SetBoolean(prefs::kHighContrastEnabled, true); - VerifyPrefFollowsUser(prefs::kHighContrastEnabled, - base::FundamentalValue(true)); - VerifyTimerIsRunning(); - runner_->RunUntilIdle(); - VerifyPrefFollowsRecommendation(prefs::kHighContrastEnabled, - base::FundamentalValue(false)); - - VerifyTimerIsStopped(); - prefs_->SetBoolean(prefs::kScreenMagnifierEnabled, true); - prefs_->SetInteger(prefs::kScreenMagnifierType, ash::MAGNIFIER_FULL); - VerifyPrefFollowsUser(prefs::kScreenMagnifierEnabled, - base::FundamentalValue(true)); - VerifyPrefFollowsUser(prefs::kScreenMagnifierType, - base::FundamentalValue(ash::MAGNIFIER_FULL)); - VerifyTimerIsRunning(); - runner_->RunUntilIdle(); - VerifyPrefFollowsRecommendation(prefs::kScreenMagnifierEnabled, - base::FundamentalValue(false)); - VerifyPrefFollowsRecommendation(prefs::kScreenMagnifierType, - base::FundamentalValue(0)); - - VerifyTimerIsStopped(); -} - -TEST_F(RecommendationRestorerTest, RestoreOnSessionStart) { - // Verifies that if recommended values have been set, user settings have - // changed and a session is then started, the user settings are cleared - // immediately and the timer that would have cleared them eventually on the - // login screen is stopped. - SetRecommendedValues(); - - CreateLoginProfile(); - SetUserSettings(); - - NotifyOfSessionStart(); - VerifyPrefsFollowRecommendations(); - VerifyTimerIsStopped(); -} - -TEST_F(RecommendationRestorerTest, DoNothingOnSessionStart) { - // Verifies that if recommended values have not been set, user settings have - // changed and a session is then started, the user settings are not cleared - // immediately. - CreateLoginProfile(); - SetUserSettings(); - - NotifyOfSessionStart(); - VerifyPrefsFollowUser(); - VerifyTimerIsStopped(); -} - -TEST_F(RecommendationRestorerTest, UserActivityResetsTimer) { - // Verifies that user activity resets the timer which clears user settings. - recommended_prefs_->SetBoolean(prefs::kLargeCursorEnabled, false); - - CreateLoginProfile(); - - prefs_->SetBoolean(prefs::kLargeCursorEnabled, true); - VerifyTimerIsRunning(); - - // Notify that there is user activity, then fast forward until the originally - // set timer fires. - NotifyOfUserActivity(); - runner_->RunPendingTasks(); - VerifyPrefFollowsUser(prefs::kLargeCursorEnabled, - base::FundamentalValue(true)); - - // Fast forward until the reset timer fires. - VerifyTimerIsRunning(); - runner_->RunUntilIdle(); - VerifyPrefFollowsRecommendation(prefs::kLargeCursorEnabled, - base::FundamentalValue(false)); - VerifyTimerIsStopped(); -} - -} // namespace policy diff --git a/chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos_unittest.cc b/chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos_unittest.cc index fce36a9..1beca08 100644 --- a/chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos_unittest.cc +++ b/chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos_unittest.cc @@ -24,7 +24,6 @@ #include "chrome/browser/policy/mock_configuration_policy_provider.h" #include "chrome/browser/policy/proto/cloud/device_management_backend.pb.h" #include "chrome/browser/prefs/browser_prefs.h" -#include "chrome/browser/prefs/pref_service_syncable.h" #include "chrome/browser/signin/token_service.h" #include "chrome/browser/signin/token_service_factory.h" #include "chrome/common/chrome_constants.h" @@ -86,8 +85,7 @@ class UserCloudPolicyManagerChromeOSTest : public testing::Test { new TestingProfileManager(TestingBrowserProcess::GetGlobal())); ASSERT_TRUE(profile_manager_->SetUp()); profile_ = profile_manager_->CreateTestingProfile( - chrome::kInitialProfile, scoped_ptr<PrefServiceSyncable>(), - UTF8ToUTF16("testing_profile"), 0); + chrome::kInitialProfile, UTF8ToUTF16("testing_profile"), 0); signin_profile_ = profile_manager_->CreateTestingProfile("signin_profile"); signin_profile_->set_incognito(true); // Usually the signin Profile and the main Profile are separate, but since diff --git a/chrome/browser/policy/configuration_policy_handler.cc b/chrome/browser/policy/configuration_policy_handler.cc index 07120fb..be6524f 100644 --- a/chrome/browser/policy/configuration_policy_handler.cc +++ b/chrome/browser/policy/configuration_policy_handler.cc @@ -292,8 +292,6 @@ bool StringToIntEnumListPolicyHandler::CheckPolicySettings( void StringToIntEnumListPolicyHandler::ApplyPolicySettings( const PolicyMap& policies, PrefValueMap* prefs) { - if (!pref_path_) - return; const base::Value* value = policies.GetValue(policy_name()); scoped_ptr<base::ListValue> list(new base::ListValue()); if (value && Convert(value, list.get(), NULL)) @@ -362,8 +360,6 @@ IntRangePolicyHandler::~IntRangePolicyHandler() { void IntRangePolicyHandler::ApplyPolicySettings(const PolicyMap& policies, PrefValueMap* prefs) { - if (!pref_path_) - return; const base::Value* value = policies.GetValue(policy_name()); int value_in_range; if (value && EnsureInRange(value, &value_in_range, NULL)) { @@ -390,8 +386,6 @@ IntPercentageToDoublePolicyHandler::~IntPercentageToDoublePolicyHandler() { void IntPercentageToDoublePolicyHandler::ApplyPolicySettings( const PolicyMap& policies, PrefValueMap* prefs) { - if (!pref_path_) - return; const base::Value* value = policies.GetValue(policy_name()); int percentage; if (value && EnsureInRange(value, &percentage, NULL)) { @@ -622,8 +616,6 @@ bool ExtensionURLPatternListPolicyHandler::CheckPolicySettings( void ExtensionURLPatternListPolicyHandler::ApplyPolicySettings( const PolicyMap& policies, PrefValueMap* prefs) { - if (!pref_path_) - return; const Value* value = policies.GetValue(policy_name()); if (value) prefs->SetValue(pref_path_, value->DeepCopy()); @@ -644,8 +636,6 @@ SimplePolicyHandler::~SimplePolicyHandler() { void SimplePolicyHandler::ApplyPolicySettings(const PolicyMap& policies, PrefValueMap* prefs) { - if (!pref_path_) - return; const Value* value = policies.GetValue(policy_name()); if (value) prefs->SetValue(pref_path_, value->DeepCopy()); diff --git a/chrome/browser/policy/configuration_policy_handler_list.cc b/chrome/browser/policy/configuration_policy_handler_list.cc index 1c73d0a..2baabf1 100644 --- a/chrome/browser/policy/configuration_policy_handler_list.cc +++ b/chrome/browser/policy/configuration_policy_handler_list.cc @@ -18,7 +18,6 @@ #include "policy/policy_constants.h" #if defined(OS_CHROMEOS) -#include "ash/magnifier/magnifier_constants.h" #include "chrome/browser/chromeos/policy/configuration_policy_handler_chromeos.h" #endif // defined(OS_CHROMEOS) @@ -384,15 +383,6 @@ const PolicyToPreferenceMapEntry kSimplePolicyMap[] = { { key::kHighContrastEnabled, prefs::kHighContrastEnabled, Value::TYPE_BOOLEAN }, - { key::kDeviceLoginScreenDefaultLargeCursorEnabled, - NULL, - Value::TYPE_BOOLEAN }, - { key::kDeviceLoginScreenDefaultSpokenFeedbackEnabled, - NULL, - Value::TYPE_BOOLEAN }, - { key::kDeviceLoginScreenDefaultHighContrastEnabled, - NULL, - Value::TYPE_BOOLEAN }, { key::kRebootAfterUpdate, prefs::kRebootAfterUpdate, Value::TYPE_BOOLEAN }, @@ -548,10 +538,6 @@ ConfigurationPolicyHandlerList::ConfigurationPolicyHandlerList() { handlers_.push_back(new IntRangePolicyHandler(key::kUptimeLimit, prefs::kUptimeLimit, 3600, INT_MAX, true)); - handlers_.push_back(new IntRangePolicyHandler( - key::kDeviceLoginScreenDefaultScreenMagnifierType, - NULL, - 0, ash::MAGNIFIER_FULL, false)); #endif // defined(OS_CHROMEOS) } diff --git a/chrome/browser/policy/profile_policy_connector.cc b/chrome/browser/policy/profile_policy_connector.cc index 36e07dc..f9f339a 100644 --- a/chrome/browser/policy/profile_policy_connector.cc +++ b/chrome/browser/policy/profile_policy_connector.cc @@ -22,12 +22,10 @@ #include "chrome/browser/chromeos/login/user.h" #include "chrome/browser/chromeos/login/user_manager.h" #include "chrome/browser/chromeos/policy/device_local_account_policy_provider.h" -#include "chrome/browser/chromeos/policy/login_profile_policy_provider.h" #include "chrome/browser/chromeos/policy/network_configuration_updater.h" #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chromeos.h" #include "chrome/browser/chromeos/profiles/profile_helper.h" -#include "chrome/browser/policy/policy_service.h" #include "chrome/common/pref_names.h" #include "chromeos/dbus/cryptohome_client.h" #include "chromeos/dbus/dbus_thread_manager.h" @@ -64,11 +62,7 @@ void ProfilePolicyConnector::Init( bool is_managed = false; std::string username; - if (chromeos::ProfileHelper::IsSigninProfile(profile_)) { - special_user_policy_provider_.reset(new LoginProfilePolicyProvider( - connector->GetPolicyService())); - special_user_policy_provider_->Init(); - } else { + if (!chromeos::ProfileHelper::IsSigninProfile(profile_)) { // |user| should never be NULL except for the signin profile. // TODO(joaodasilva): get the |user| that corresponds to the |profile_| // from the ProfileHelper, once that's ready. @@ -83,10 +77,9 @@ void ProfilePolicyConnector::Init( chromeos::UserManager::Get()->GetLoggedInUsers().size() == 1; if (user->GetType() == chromeos::User::USER_TYPE_PUBLIC_ACCOUNT) InitializeDeviceLocalAccountPolicyProvider(username); + if (device_local_account_policy_provider_) + providers.push_back(device_local_account_policy_provider_.get()); } - if (special_user_policy_provider_) - providers.push_back(special_user_policy_provider_.get()); - #else UserCloudPolicyManager* cloud_policy_manager = UserCloudPolicyManagerFactory::GetForProfile(profile_); @@ -105,10 +98,12 @@ void ProfilePolicyConnector::Init( #if defined(OS_CHROMEOS) if (is_primary_user_) { - if (cloud_policy_manager) + if (cloud_policy_manager) { connector->SetUserPolicyDelegate(cloud_policy_manager); - else if (special_user_policy_provider_) - connector->SetUserPolicyDelegate(special_user_policy_provider_.get()); + } else if (device_local_account_policy_provider_) { + connector->SetUserPolicyDelegate( + device_local_account_policy_provider_.get()); + } chromeos::CryptohomeClient* cryptohome_client = chromeos::DBusThreadManager::Get()->GetCryptohomeClient(); @@ -136,8 +131,8 @@ void ProfilePolicyConnector::Shutdown() { connector->GetNetworkConfigurationUpdater(); network_updater->UnsetUserPolicyService(); } - if (special_user_policy_provider_) - special_user_policy_provider_->Shutdown(); + if (device_local_account_policy_provider_) + device_local_account_policy_provider_->Shutdown(); #endif #if defined(ENABLE_MANAGED_USERS) @@ -163,9 +158,10 @@ void ProfilePolicyConnector::InitializeDeviceLocalAccountPolicyProvider( connector->GetDeviceLocalAccountPolicyService(); if (!device_local_account_policy_service) return; - special_user_policy_provider_.reset(new DeviceLocalAccountPolicyProvider( - username, device_local_account_policy_service)); - special_user_policy_provider_->Init(); + device_local_account_policy_provider_.reset( + new DeviceLocalAccountPolicyProvider( + username, device_local_account_policy_service)); + device_local_account_policy_provider_->Init(); } void ProfilePolicyConnector::InitializeNetworkConfigurationUpdater( diff --git a/chrome/browser/policy/profile_policy_connector.h b/chrome/browser/policy/profile_policy_connector.h index a7d726d..0669c7d 100644 --- a/chrome/browser/policy/profile_policy_connector.h +++ b/chrome/browser/policy/profile_policy_connector.h @@ -24,7 +24,7 @@ class SequencedTaskRunner; namespace policy { -class ConfigurationPolicyProvider; +class DeviceLocalAccountPolicyProvider; class ManagedModePolicyProvider; class PolicyService; @@ -82,7 +82,8 @@ class ProfilePolicyConnector : public BrowserContextKeyedService { // local state. bool is_primary_user_; - scoped_ptr<ConfigurationPolicyProvider> special_user_policy_provider_; + scoped_ptr<DeviceLocalAccountPolicyProvider> + device_local_account_policy_provider_; #endif #if defined(ENABLE_MANAGED_USERS) && defined(ENABLE_CONFIGURATION_POLICY) diff --git a/chrome/browser/policy/proto/chromeos/chrome_device_policy.proto b/chrome/browser/policy/proto/chromeos/chrome_device_policy.proto index 2ba6519..5d83a8a 100644 --- a/chrome/browser/policy/proto/chromeos/chrome_device_policy.proto +++ b/chrome/browser/policy/proto/chromeos/chrome_device_policy.proto @@ -347,67 +347,6 @@ message AttestationSettingsProto { optional bool attestation_enabled = 1; } -message AccessibilitySettingsProto { - // Sets the default state of the large cursor accessibility feature on the - // login screen. If this policy is set to true, the large cursor will be - // enabled when the login screen is shown. If this policy is set to false, the - // large cursor will be disabled when the login screen is shown. Users can - // temporarily override this setting by enabling or disabling the large - // cursor. However, the user's choice is not persistent and the default is - // restored whenever the login screen is shown anew or the user remains idle - // on the login screen for a minute. If this policy is left unset, the large - // cursor is disabled when the login screen is first shown. Users can enable - // or disable the large cursor anytime and its status on the login screen is - // persisted between users. - optional bool login_screen_default_large_cursor_enabled = 1; - - // Sets the default state of the spoken feedback accessibility feature on the - // login screen. If this policy is set to true, spoken feedback will be - // enabled when the login screen is shown. If this policy is set to false, - // spoken feedback will be disabled when the login screen is shown. Users can - // temporarily override this setting by enabling or disabling spoken feedback. - // However, the user's choice is not persistent and the default is restored - // whenever the login screen is shown anew or the user remains idle on the - // login screen for a minute. If this policy is left unset, spoken feedback is - // disabled when the login screen is first shown. Users can enable or disable - // spoken feedback anytime and its status on the login screen is persisted - // between users. - optional bool login_screen_default_spoken_feedback_enabled = 2; - - // Sets the default state of the high contrast mode accessibility feature on - // the login screen. If this policy is set to true, high contrast mode will be - // enabled when the login screen is shown. If this policy is set to false, - // high contrast mode will be disabled when the login screen is shown. Users - // can temporarily override this setting by enabling or disabling high - // contrast mode. However, the user's choice is not persistent and the default - // is restored whenever the login screen is shown anew or the user remains - // idle on the login screen for a minute. If this policy is left unset, high - // contrast mode is disabled when the login screen is first shown. Users can - // enable or disable high contrast mode anytime and its status on the login - // screen is persisted between users. - optional bool login_screen_default_high_contrast_enabled = 3; - - // Enumerates the screen magnifier types. - enum ScreenMagnifierType { - // Screen magnifier disabled. - SCREEN_MAGNIFIER_TYPE_NONE = 0; - // Full-screen magnifier enabled. - SCREEN_MAGNIFIER_TYPE_FULL = 1; - }; - - // Sets the default type of screen magnifier that is enabled on the login - // screen. If this policy is set, it controls the type of screen magnifier - // that is enabled when the login screen is shown. Users can temporarily - // override this setting by enabling or disabling the screen magnifier. - // However, the user's choice is not persistent and the default is restored - // whenever the login screen is shown anew or the user remains idle on the - // login screen for a minute. If this policy is left unset, the screen - // magnifier is disabled when the login screen is first shown. Users can - // enable or disable the screen magnifier anytime and its status on the login - // screen is persisted between users. - optional ScreenMagnifierType login_screen_default_screen_magnifier_type = 4; -} - message ChromeDeviceSettingsProto { optional DevicePolicyRefreshRateProto device_policy_refresh_rate = 1; optional UserWhitelistProto user_whitelist = 2; @@ -435,5 +374,4 @@ message ChromeDeviceSettingsProto { optional UptimeLimitProto uptime_limit = 24; optional VariationsParameterProto variations_parameter = 25; optional AttestationSettingsProto attestation_settings = 26; - optional AccessibilitySettingsProto accessibility_settings = 27; } diff --git a/chrome/browser/profiles/avatar_menu_model_unittest.cc b/chrome/browser/profiles/avatar_menu_model_unittest.cc index b012827..fcb5b14 100644 --- a/chrome/browser/profiles/avatar_menu_model_unittest.cc +++ b/chrome/browser/profiles/avatar_menu_model_unittest.cc @@ -4,11 +4,9 @@ #include "chrome/browser/profiles/avatar_menu_model.h" -#include "base/memory/scoped_ptr.h" #include "base/metrics/field_trial.h" #include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" -#include "chrome/browser/prefs/pref_service_syncable.h" #include "chrome/browser/profiles/avatar_menu_model_observer.h" #include "chrome/browser/profiles/profile_info_cache.h" #include "chrome/browser/profiles/profile_manager.h" @@ -62,10 +60,8 @@ TEST_F(AvatarMenuModelTest, InitialCreation) { string16 name1(ASCIIToUTF16("Test 1")); string16 name2(ASCIIToUTF16("Test 2")); - manager()->CreateTestingProfile("p1", scoped_ptr<PrefServiceSyncable>(), - name1, 0); - manager()->CreateTestingProfile("p2", scoped_ptr<PrefServiceSyncable>(), - name2, 0); + manager()->CreateTestingProfile("p1", name1, 0); + manager()->CreateTestingProfile("p2", name2, 0); MockObserver observer; EXPECT_EQ(0, observer.change_count()); @@ -88,10 +84,8 @@ TEST_F(AvatarMenuModelTest, ActiveItem) { string16 name1(ASCIIToUTF16("Test 1")); string16 name2(ASCIIToUTF16("Test 2")); - manager()->CreateTestingProfile("p1", scoped_ptr<PrefServiceSyncable>(), - name1, 0); - manager()->CreateTestingProfile("p2", scoped_ptr<PrefServiceSyncable>(), - name2, 0); + manager()->CreateTestingProfile("p1", name1, 0); + manager()->CreateTestingProfile("p2", name2, 0); MockObserver observer; AvatarMenuModel model(manager()->profile_info_cache(), &observer, browser()); @@ -106,10 +100,8 @@ TEST_F(AvatarMenuModelTest, ModifyingNameResortsCorrectly) { string16 name2(ASCIIToUTF16("Beta")); string16 newname1(ASCIIToUTF16("Gamma")); - manager()->CreateTestingProfile("p1", scoped_ptr<PrefServiceSyncable>(), - name1, 0); - manager()->CreateTestingProfile("p2", scoped_ptr<PrefServiceSyncable>(), - name2, 0); + manager()->CreateTestingProfile("p1", name1, 0); + manager()->CreateTestingProfile("p2", name2, 0); MockObserver observer; AvatarMenuModel model(manager()->profile_info_cache(), &observer, browser()); @@ -142,10 +134,8 @@ TEST_F(AvatarMenuModelTest, ChangeOnNotify) { string16 name1(ASCIIToUTF16("Test 1")); string16 name2(ASCIIToUTF16("Test 2")); - manager()->CreateTestingProfile("p1", scoped_ptr<PrefServiceSyncable>(), - name1, 0); - manager()->CreateTestingProfile("p2", scoped_ptr<PrefServiceSyncable>(), - name2, 0); + manager()->CreateTestingProfile("p1", name1, 0); + manager()->CreateTestingProfile("p2", name2, 0); MockObserver observer; EXPECT_EQ(0, observer.change_count()); @@ -155,8 +145,7 @@ TEST_F(AvatarMenuModelTest, ChangeOnNotify) { EXPECT_EQ(2U, model.GetNumberOfItems()); string16 name3(ASCIIToUTF16("Test 3")); - manager()->CreateTestingProfile("p3", scoped_ptr<PrefServiceSyncable>(), - name3, 0); + manager()->CreateTestingProfile("p3", name3, 0); // Four changes happened via the call to CreateTestingProfile: adding the // profile to the cache, setting the user name, rebuilding the list of @@ -197,8 +186,7 @@ TEST_F(AvatarMenuModelTest, ShowAvatarMenuInTrial) { TEST_F(AvatarMenuModelTest, DontShowAvatarMenu) { string16 name1(ASCIIToUTF16("Test 1")); - manager()->CreateTestingProfile("p1", scoped_ptr<PrefServiceSyncable>(), - name1, 0); + manager()->CreateTestingProfile("p1", name1, 0); EXPECT_FALSE(AvatarMenuModel::ShouldShowAvatarMenu()); @@ -208,8 +196,7 @@ TEST_F(AvatarMenuModelTest, DontShowAvatarMenu) { return; string16 name2(ASCIIToUTF16("Test 2")); - manager()->CreateTestingProfile("p2", scoped_ptr<PrefServiceSyncable>(), - name2, 0); + manager()->CreateTestingProfile("p2", name2, 0); EXPECT_FALSE(AvatarMenuModel::ShouldShowAvatarMenu()); } @@ -222,10 +209,8 @@ TEST_F(AvatarMenuModelTest, ShowAvatarMenu) { string16 name1(ASCIIToUTF16("Test 1")); string16 name2(ASCIIToUTF16("Test 2")); - manager()->CreateTestingProfile("p1", scoped_ptr<PrefServiceSyncable>(), - name1, 0); - manager()->CreateTestingProfile("p2", scoped_ptr<PrefServiceSyncable>(), - name2, 0); + manager()->CreateTestingProfile("p1", name1, 0); + manager()->CreateTestingProfile("p2", name2, 0); #if defined(OS_CHROMEOS) EXPECT_FALSE(AvatarMenuModel::ShouldShowAvatarMenu()); @@ -239,8 +224,7 @@ TEST_F(AvatarMenuModelTest, SyncState) { if (!ProfileManager::IsMultipleProfilesEnabled()) return; - manager()->CreateTestingProfile("p1", scoped_ptr<PrefServiceSyncable>(), - ASCIIToUTF16("Test 1"), 0); + manager()->CreateTestingProfile("p1", ASCIIToUTF16("Test 1"), 0); // Add a managed user profile. ProfileInfoCache* cache = manager()->profile_info_cache(); diff --git a/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc b/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc index 7da811b..dffbdbe 100644 --- a/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc +++ b/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc @@ -100,7 +100,6 @@ #if defined(ENABLE_CONFIGURATION_POLICY) #if defined(OS_CHROMEOS) -#include "chrome/browser/chromeos/policy/recommendation_restorer_factory.h" #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chromeos.h" #include "chrome/browser/chromeos/policy/user_cloud_policy_token_forwarder_factory.h" #else @@ -274,7 +273,6 @@ EnsureBrowserContextKeyedServiceFactoriesBuilt() { policy::ProfilePolicyConnectorFactory::GetInstance(); #if defined(ENABLE_CONFIGURATION_POLICY) #if defined(OS_CHROMEOS) - policy::RecommendationRestorerFactory::GetInstance(); policy::UserCloudPolicyManagerFactoryChromeOS::GetInstance(); policy::UserCloudPolicyTokenForwarderFactory::GetInstance(); #else diff --git a/chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller_unittest.mm b/chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller_unittest.mm index a252969..2f5b3be 100644 --- a/chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller_unittest.mm +++ b/chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller_unittest.mm @@ -7,7 +7,6 @@ #include "base/memory/scoped_nsobject.h" #include "base/message_loop/message_pump_mac.h" #include "base/strings/utf_string_conversions.h" -#include "chrome/browser/prefs/pref_service_syncable.h" #include "chrome/browser/profiles/avatar_menu_model.h" #include "chrome/browser/profiles/avatar_menu_model_observer.h" #include "chrome/browser/profiles/profile_info_cache.h" @@ -28,10 +27,8 @@ class AvatarMenuBubbleControllerTest : public CocoaTest { CocoaTest::SetUp(); ASSERT_TRUE(manager_.SetUp()); - manager_.CreateTestingProfile("test1", scoped_ptr<PrefServiceSyncable>(), - ASCIIToUTF16("Test 1"), 1); - manager_.CreateTestingProfile("test2", scoped_ptr<PrefServiceSyncable>(), - ASCIIToUTF16("Test 2"), 0); + manager_.CreateTestingProfile("test1", ASCIIToUTF16("Test 1"), 1); + manager_.CreateTestingProfile("test2", ASCIIToUTF16("Test 2"), 0); model_ = new AvatarMenuModel(manager_.profile_info_cache(), NULL, NULL); @@ -119,8 +116,7 @@ TEST_F(AvatarMenuBubbleControllerTest, PerformLayout) { scoped_nsobject<NSMutableArray> oldItems([[controller() items] copy]); // Now create a new profile and notify the delegate. - manager()->CreateTestingProfile("test3", scoped_ptr<PrefServiceSyncable>(), - ASCIIToUTF16("Test 3"), 0); + manager()->CreateTestingProfile("test3", ASCIIToUTF16("Test 3"), 0); // Testing the bridge is not worth the effort... [controller() performLayout]; diff --git a/chrome/chrome_browser_chromeos.gypi b/chrome/chrome_browser_chromeos.gypi index 87832b6..71001c9 100644 --- a/chrome/chrome_browser_chromeos.gypi +++ b/chrome/chrome_browser_chromeos.gypi @@ -631,8 +631,6 @@ 'browser/chromeos/policy/enrollment_status_chromeos.h', 'browser/chromeos/policy/enterprise_install_attributes.cc', 'browser/chromeos/policy/enterprise_install_attributes.h', - 'browser/chromeos/policy/login_profile_policy_provider.cc', - 'browser/chromeos/policy/login_profile_policy_provider.h', 'browser/chromeos/policy/network_configuration_updater.cc', 'browser/chromeos/policy/network_configuration_updater.h', 'browser/chromeos/policy/network_configuration_updater_impl.cc', @@ -645,10 +643,6 @@ 'browser/chromeos/policy/policy_oauth2_token_fetcher.h', 'browser/chromeos/policy/proxy_policy_provider.cc', 'browser/chromeos/policy/proxy_policy_provider.h', - 'browser/chromeos/policy/recommendation_restorer.cc', - 'browser/chromeos/policy/recommendation_restorer.h', - 'browser/chromeos/policy/recommendation_restorer_factory.cc', - 'browser/chromeos/policy/recommendation_restorer_factory.h', 'browser/chromeos/policy/user_cloud_policy_manager_chromeos.cc', 'browser/chromeos/policy/user_cloud_policy_manager_chromeos.h', 'browser/chromeos/policy/user_cloud_policy_manager_factory_chromeos.cc', diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 4c408d6..4765410 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -1268,7 +1268,6 @@ 'browser/chromeos/policy/device_policy_cros_browser_test.cc', 'browser/chromeos/policy/device_policy_cros_browser_test.h', 'browser/chromeos/policy/device_status_collector_browsertest.cc', - 'browser/chromeos/policy/login_screen_default_policy_browsertest.cc', 'browser/chromeos/policy/policy_cert_verifier_browsertest.cc', 'browser/chromeos/policy/power_policy_browsertest.cc', 'browser/chromeos/policy/variations_service_policy_browsertest.cc', diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi index 681d7b8..501cc0c 100644 --- a/chrome/chrome_tests_unit.gypi +++ b/chrome/chrome_tests_unit.gypi @@ -666,7 +666,6 @@ 'browser/chromeos/policy/enterprise_install_attributes_unittest.cc', 'browser/chromeos/policy/network_configuration_updater_impl_cros_unittest.cc', 'browser/chromeos/policy/proxy_policy_provider_unittest.cc', - 'browser/chromeos/policy/recommendation_restorer_unittest.cc', 'browser/chromeos/policy/user_cloud_policy_manager_chromeos_unittest.cc', 'browser/chromeos/policy/user_cloud_policy_store_chromeos_unittest.cc', 'browser/chromeos/preferences_unittest.cc', diff --git a/chrome/test/base/testing_profile_manager.cc b/chrome/test/base/testing_profile_manager.cc index 5a5f620..9871d4a 100644 --- a/chrome/test/base/testing_profile_manager.cc +++ b/chrome/test/base/testing_profile_manager.cc @@ -5,10 +5,8 @@ #include "chrome/test/base/testing_profile_manager.h" #include "base/files/file_path.h" -#include "base/memory/ref_counted.h" +#include "base/memory/scoped_ptr.h" #include "base/strings/utf_string_conversions.h" -#include "chrome/browser/extensions/extension_special_storage_policy.h" -#include "chrome/browser/prefs/pref_service_syncable.h" #include "chrome/browser/profiles/profile_info_cache.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/test/base/testing_browser_process.h" @@ -47,7 +45,6 @@ bool TestingProfileManager::SetUp() { TestingProfile* TestingProfileManager::CreateTestingProfile( const std::string& profile_name, - scoped_ptr<PrefServiceSyncable> prefs, const string16& user_name, int avatar_id) { DCHECK(called_set_up_); @@ -57,11 +54,7 @@ TestingProfile* TestingProfileManager::CreateTestingProfile( profile_path = profile_path.AppendASCII(profile_name); // Create the profile and register it. - TestingProfile* profile = new TestingProfile( - profile_path, - NULL, - scoped_refptr<ExtensionSpecialStoragePolicy>(), - prefs.Pass()); + TestingProfile* profile = new TestingProfile(profile_path); profile_manager_->AddProfile(profile); // Takes ownership. // Update the user metadata. @@ -78,8 +71,7 @@ TestingProfile* TestingProfileManager::CreateTestingProfile( TestingProfile* TestingProfileManager::CreateTestingProfile( const std::string& name) { DCHECK(called_set_up_); - return CreateTestingProfile(name, scoped_ptr<PrefServiceSyncable>(), - UTF8ToUTF16(name), 0); + return CreateTestingProfile(name, UTF8ToUTF16(name), 0); } void TestingProfileManager::DeleteTestingProfile(const std::string& name) { diff --git a/chrome/test/base/testing_profile_manager.h b/chrome/test/base/testing_profile_manager.h index 7a4205c..f6ae1f7 100644 --- a/chrome/test/base/testing_profile_manager.h +++ b/chrome/test/base/testing_profile_manager.h @@ -10,11 +10,9 @@ #include "base/compiler_specific.h" #include "base/files/scoped_temp_dir.h" -#include "base/memory/scoped_ptr.h" #include "base/strings/string16.h" #include "chrome/test/base/scoped_testing_local_state.h" -class PrefServiceSyncable; class ProfileInfoCache; class ProfileManager; class TestingBrowserProcess; @@ -40,14 +38,11 @@ class TestingProfileManager { // Creates a new TestingProfile whose data lives in a directory related to // profile_name, which is a non-user-visible key for the test environment. - // |prefs| is the PrefService used by the profile. If it is NULL, the profile - // creates a PrefService on demand. // |user_name| and |avatar_id| are passed along to the ProfileInfoCache and // provide the user-visible profile metadata. This will register the // TestingProfile with the profile subsystem as well. The subsystem owns the // Profile and returns a weak pointer. TestingProfile* CreateTestingProfile(const std::string& profile_name, - scoped_ptr<PrefServiceSyncable> prefs, const string16& user_name, int avatar_id); diff --git a/chrome/test/data/policy/policy_test_cases.json b/chrome/test/data/policy/policy_test_cases.json index bf86560..960e693 100644 --- a/chrome/test/data/policy/policy_test_cases.json +++ b/chrome/test/data/policy/policy_test_cases.json @@ -1933,18 +1933,6 @@ "DeviceVariationsRestrictParameter" : { }, - "DeviceLoginScreenDefaultLargeCursorEnabled" : { - }, - - "DeviceLoginScreenDefaultSpokenFeedbackEnabled" : { - }, - - "DeviceLoginScreenDefaultHighContrastEnabled" : { - }, - - "DeviceLoginScreenDefaultScreenMagnifierType" : { - }, - "UptimeLimit": { }, |