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 23 matching lines...) Expand all Loading... |
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, | 36 policy.Set(key::kIncognitoEnabled, |
37 POLICY_LEVEL_MANDATORY, | 37 POLICY_LEVEL_MANDATORY, |
38 POLICY_SCOPE_USER, | 38 POLICY_SCOPE_USER, |
39 new base::FundamentalValue(incognito_enabled == | 39 new base::FundamentalValue(incognito_enabled == |
40 INCOGNITO_ENABLED_TRUE), | 40 INCOGNITO_ENABLED_TRUE), |
41 NULL); | 41 NULL); |
42 } | 42 } |
43 if (availability >= 0) { | 43 if (availability >= 0) { |
44 policy.Set(key::kIncognitoModeAvailability, POLICY_LEVEL_MANDATORY, | 44 policy.Set(key::kIncognitoModeAvailability, |
| 45 POLICY_LEVEL_MANDATORY, |
45 POLICY_SCOPE_USER, | 46 POLICY_SCOPE_USER, |
46 base::Value::CreateIntegerValue(availability), | 47 new base::FundamentalValue(availability), |
47 NULL); | 48 NULL); |
48 } | 49 } |
49 UpdateProviderPolicy(policy); | 50 UpdateProviderPolicy(policy); |
50 } | 51 } |
51 | 52 |
52 void VerifyValues(IncognitoModePrefs::Availability availability) { | 53 void VerifyValues(IncognitoModePrefs::Availability availability) { |
53 const base::Value* value = NULL; | 54 const base::Value* value = NULL; |
54 EXPECT_TRUE(store_->GetValue(prefs::kIncognitoModeAvailability, &value)); | 55 EXPECT_TRUE(store_->GetValue(prefs::kIncognitoModeAvailability, &value)); |
55 EXPECT_TRUE(base::FundamentalValue(availability).Equals(value)); | 56 EXPECT_TRUE(base::FundamentalValue(availability).Equals(value)); |
56 } | 57 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 VerifyValues(IncognitoModePrefs::ENABLED); | 106 VerifyValues(IncognitoModePrefs::ENABLED); |
106 } | 107 } |
107 | 108 |
108 TEST_F(IncognitoModePolicyHandlerTest, | 109 TEST_F(IncognitoModePolicyHandlerTest, |
109 ObsoletePolicySetsPreferenceToDisabled) { | 110 ObsoletePolicySetsPreferenceToDisabled) { |
110 SetPolicies(INCOGNITO_ENABLED_FALSE, kIncognitoModeAvailabilityNotSet); | 111 SetPolicies(INCOGNITO_ENABLED_FALSE, kIncognitoModeAvailabilityNotSet); |
111 VerifyValues(IncognitoModePrefs::DISABLED); | 112 VerifyValues(IncognitoModePrefs::DISABLED); |
112 } | 113 } |
113 | 114 |
114 } // namespace policy | 115 } // namespace policy |
OLD | NEW |