OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 5 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
6 #include "chrome/browser/profiles/incognito_mode_policy_handler.h" | 6 #include "chrome/browser/profiles/incognito_mode_policy_handler.h" |
7 #include "chrome/common/pref_names.h" | 7 #include "chrome/common/pref_names.h" |
8 #include "components/policy/core/browser/configuration_policy_pref_store.h" | 8 #include "components/policy/core/browser/configuration_policy_pref_store.h" |
9 #include "components/policy/core/browser/configuration_policy_pref_store_test.h" | 9 #include "components/policy/core/browser/configuration_policy_pref_store_test.h" |
10 #include "grit/generated_resources.h" | 10 #include "grit/generated_resources.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 enum ObsoleteIncognitoEnabledValue { | 26 enum ObsoleteIncognitoEnabledValue { |
27 INCOGNITO_ENABLED_UNKNOWN, | 27 INCOGNITO_ENABLED_UNKNOWN, |
28 INCOGNITO_ENABLED_TRUE, | 28 INCOGNITO_ENABLED_TRUE, |
29 INCOGNITO_ENABLED_FALSE | 29 INCOGNITO_ENABLED_FALSE |
30 }; | 30 }; |
31 | 31 |
32 void SetPolicies(ObsoleteIncognitoEnabledValue incognito_enabled, | 32 void SetPolicies(ObsoleteIncognitoEnabledValue incognito_enabled, |
33 int availability) { | 33 int availability) { |
34 PolicyMap policy; | 34 PolicyMap policy; |
35 if (incognito_enabled != INCOGNITO_ENABLED_UNKNOWN) { | 35 if (incognito_enabled != INCOGNITO_ENABLED_UNKNOWN) { |
36 policy.Set(key::kIncognitoEnabled, POLICY_LEVEL_MANDATORY, | 36 policy.Set(key::kIncognitoEnabled, |
| 37 POLICY_LEVEL_MANDATORY, |
37 POLICY_SCOPE_USER, | 38 POLICY_SCOPE_USER, |
38 base::Value::CreateBooleanValue( | 39 new base::FundamentalValue(incognito_enabled == |
39 incognito_enabled == INCOGNITO_ENABLED_TRUE), | 40 INCOGNITO_ENABLED_TRUE), |
40 NULL); | 41 NULL); |
41 } | 42 } |
42 if (availability >= 0) { | 43 if (availability >= 0) { |
43 policy.Set(key::kIncognitoModeAvailability, POLICY_LEVEL_MANDATORY, | 44 policy.Set(key::kIncognitoModeAvailability, POLICY_LEVEL_MANDATORY, |
44 POLICY_SCOPE_USER, | 45 POLICY_SCOPE_USER, |
45 base::Value::CreateIntegerValue(availability), | 46 base::Value::CreateIntegerValue(availability), |
46 NULL); | 47 NULL); |
47 } | 48 } |
48 UpdateProviderPolicy(policy); | 49 UpdateProviderPolicy(policy); |
49 } | 50 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 VerifyValues(IncognitoModePrefs::ENABLED); | 105 VerifyValues(IncognitoModePrefs::ENABLED); |
105 } | 106 } |
106 | 107 |
107 TEST_F(IncognitoModePolicyHandlerTest, | 108 TEST_F(IncognitoModePolicyHandlerTest, |
108 ObsoletePolicySetsPreferenceToDisabled) { | 109 ObsoletePolicySetsPreferenceToDisabled) { |
109 SetPolicies(INCOGNITO_ENABLED_FALSE, kIncognitoModeAvailabilityNotSet); | 110 SetPolicies(INCOGNITO_ENABLED_FALSE, kIncognitoModeAvailabilityNotSet); |
110 VerifyValues(IncognitoModePrefs::DISABLED); | 111 VerifyValues(IncognitoModePrefs::DISABLED); |
111 } | 112 } |
112 | 113 |
113 } // namespace policy | 114 } // namespace policy |
OLD | NEW |