OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/policy/default_geolocation_policy_handler.h" | 5 #include "chrome/browser/policy/default_geolocation_policy_handler.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/common/pref_names.h" | 9 #include "chrome/common/pref_names.h" |
10 #include "components/content_settings/core/common/content_settings.h" | 10 #include "components/content_settings/core/common/content_settings.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 handler_list_.AddHandler(base::WrapUnique<ConfigurationPolicyHandler>( | 23 handler_list_.AddHandler(base::WrapUnique<ConfigurationPolicyHandler>( |
24 new DefaultGeolocationPolicyHandler)); | 24 new DefaultGeolocationPolicyHandler)); |
25 } | 25 } |
26 }; | 26 }; |
27 | 27 |
28 TEST_F(DefaultGeolocationPolicyHandlerTest, AllowGeolocation) { | 28 TEST_F(DefaultGeolocationPolicyHandlerTest, AllowGeolocation) { |
29 // DefaultGeolocationSetting of CONTENT_SETTING_ALLOW (AllowGeolocation) | 29 // DefaultGeolocationSetting of CONTENT_SETTING_ALLOW (AllowGeolocation) |
30 // should not translate to the ArcLocationServiceEnabled preference. | 30 // should not translate to the ArcLocationServiceEnabled preference. |
31 EXPECT_FALSE(store_->GetValue(prefs::kArcLocationServiceEnabled, nullptr)); | 31 EXPECT_FALSE(store_->GetValue(prefs::kArcLocationServiceEnabled, nullptr)); |
32 PolicyMap policy; | 32 PolicyMap policy; |
33 policy.Set(key::kDefaultGeolocationSetting, | 33 policy.Set(key::kDefaultGeolocationSetting, POLICY_LEVEL_MANDATORY, |
34 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 34 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
35 POLICY_SOURCE_CLOUD, | 35 base::WrapUnique(new base::Value(CONTENT_SETTING_ALLOW)), nullptr); |
36 base::WrapUnique(new base::FundamentalValue(CONTENT_SETTING_ALLOW)), | |
37 nullptr); | |
38 UpdateProviderPolicy(policy); | 36 UpdateProviderPolicy(policy); |
39 EXPECT_FALSE(store_->GetValue(prefs::kArcLocationServiceEnabled, nullptr)); | 37 EXPECT_FALSE(store_->GetValue(prefs::kArcLocationServiceEnabled, nullptr)); |
40 } | 38 } |
41 | 39 |
42 TEST_F(DefaultGeolocationPolicyHandlerTest, BlockGeolocation) { | 40 TEST_F(DefaultGeolocationPolicyHandlerTest, BlockGeolocation) { |
43 // DefaultGeolocationSetting of CONTENT_SETTING_BLOCK (BlockGeolocation) | 41 // DefaultGeolocationSetting of CONTENT_SETTING_BLOCK (BlockGeolocation) |
44 // should set the ArcLocationServiceEnabled preference to false. | 42 // should set the ArcLocationServiceEnabled preference to false. |
45 EXPECT_FALSE(store_->GetValue(prefs::kArcLocationServiceEnabled, nullptr)); | 43 EXPECT_FALSE(store_->GetValue(prefs::kArcLocationServiceEnabled, nullptr)); |
46 PolicyMap policy; | 44 PolicyMap policy; |
47 policy.Set(key::kDefaultGeolocationSetting, | 45 policy.Set(key::kDefaultGeolocationSetting, POLICY_LEVEL_MANDATORY, |
48 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 46 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
49 POLICY_SOURCE_CLOUD, | 47 base::WrapUnique(new base::Value(CONTENT_SETTING_BLOCK)), nullptr); |
50 base::WrapUnique(new base::FundamentalValue(CONTENT_SETTING_BLOCK)), | |
51 nullptr); | |
52 UpdateProviderPolicy(policy); | 48 UpdateProviderPolicy(policy); |
53 const base::Value* value = nullptr; | 49 const base::Value* value = nullptr; |
54 EXPECT_TRUE(store_->GetValue(prefs::kArcLocationServiceEnabled, &value)); | 50 EXPECT_TRUE(store_->GetValue(prefs::kArcLocationServiceEnabled, &value)); |
55 EXPECT_TRUE(base::FundamentalValue(false).Equals(value)); | 51 EXPECT_TRUE(base::Value(false).Equals(value)); |
56 } | 52 } |
57 | 53 |
58 TEST_F(DefaultGeolocationPolicyHandlerTest, AskGeolocation) { | 54 TEST_F(DefaultGeolocationPolicyHandlerTest, AskGeolocation) { |
59 // DefaultGeolocationSetting of CONTENT_SETTING_ASK (AskGeolocation) should | 55 // DefaultGeolocationSetting of CONTENT_SETTING_ASK (AskGeolocation) should |
60 // not translate to the ArcLocationServiceEnabled preference. | 56 // not translate to the ArcLocationServiceEnabled preference. |
61 EXPECT_FALSE(store_->GetValue(prefs::kArcLocationServiceEnabled, nullptr)); | 57 EXPECT_FALSE(store_->GetValue(prefs::kArcLocationServiceEnabled, nullptr)); |
62 PolicyMap policy; | 58 PolicyMap policy; |
63 policy.Set(key::kDefaultGeolocationSetting, | 59 policy.Set(key::kDefaultGeolocationSetting, POLICY_LEVEL_MANDATORY, |
64 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 60 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
65 POLICY_SOURCE_CLOUD, | 61 base::WrapUnique(new base::Value(CONTENT_SETTING_ASK)), nullptr); |
66 base::WrapUnique(new base::FundamentalValue(CONTENT_SETTING_ASK)), | |
67 nullptr); | |
68 UpdateProviderPolicy(policy); | 62 UpdateProviderPolicy(policy); |
69 EXPECT_FALSE(store_->GetValue(prefs::kArcLocationServiceEnabled, nullptr)); | 63 EXPECT_FALSE(store_->GetValue(prefs::kArcLocationServiceEnabled, nullptr)); |
70 } | 64 } |
71 | 65 |
72 } // namespace policy | 66 } // namespace policy |
73 | 67 |
OLD | NEW |