| 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 15 matching lines...) Expand all Loading... |
| 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, |
| 34 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 34 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 35 POLICY_SOURCE_CLOUD, | 35 POLICY_SOURCE_CLOUD, |
| 36 base::WrapUnique(new base::FundamentalValue(CONTENT_SETTING_ALLOW)), | 36 base::WrapUnique(new base::Value(CONTENT_SETTING_ALLOW)), |
| 37 nullptr); | 37 nullptr); |
| 38 UpdateProviderPolicy(policy); | 38 UpdateProviderPolicy(policy); |
| 39 EXPECT_FALSE(store_->GetValue(prefs::kArcLocationServiceEnabled, nullptr)); | 39 EXPECT_FALSE(store_->GetValue(prefs::kArcLocationServiceEnabled, nullptr)); |
| 40 } | 40 } |
| 41 | 41 |
| 42 TEST_F(DefaultGeolocationPolicyHandlerTest, BlockGeolocation) { | 42 TEST_F(DefaultGeolocationPolicyHandlerTest, BlockGeolocation) { |
| 43 // DefaultGeolocationSetting of CONTENT_SETTING_BLOCK (BlockGeolocation) | 43 // DefaultGeolocationSetting of CONTENT_SETTING_BLOCK (BlockGeolocation) |
| 44 // should set the ArcLocationServiceEnabled preference to false. | 44 // should set the ArcLocationServiceEnabled preference to false. |
| 45 EXPECT_FALSE(store_->GetValue(prefs::kArcLocationServiceEnabled, nullptr)); | 45 EXPECT_FALSE(store_->GetValue(prefs::kArcLocationServiceEnabled, nullptr)); |
| 46 PolicyMap policy; | 46 PolicyMap policy; |
| 47 policy.Set(key::kDefaultGeolocationSetting, | 47 policy.Set(key::kDefaultGeolocationSetting, |
| 48 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 48 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 49 POLICY_SOURCE_CLOUD, | 49 POLICY_SOURCE_CLOUD, |
| 50 base::WrapUnique(new base::FundamentalValue(CONTENT_SETTING_BLOCK)), | 50 base::WrapUnique(new base::Value(CONTENT_SETTING_BLOCK)), |
| 51 nullptr); | 51 nullptr); |
| 52 UpdateProviderPolicy(policy); | 52 UpdateProviderPolicy(policy); |
| 53 const base::Value* value = nullptr; | 53 const base::Value* value = nullptr; |
| 54 EXPECT_TRUE(store_->GetValue(prefs::kArcLocationServiceEnabled, &value)); | 54 EXPECT_TRUE(store_->GetValue(prefs::kArcLocationServiceEnabled, &value)); |
| 55 EXPECT_TRUE(base::FundamentalValue(false).Equals(value)); | 55 EXPECT_TRUE(base::Value(false).Equals(value)); |
| 56 } | 56 } |
| 57 | 57 |
| 58 TEST_F(DefaultGeolocationPolicyHandlerTest, AskGeolocation) { | 58 TEST_F(DefaultGeolocationPolicyHandlerTest, AskGeolocation) { |
| 59 // DefaultGeolocationSetting of CONTENT_SETTING_ASK (AskGeolocation) should | 59 // DefaultGeolocationSetting of CONTENT_SETTING_ASK (AskGeolocation) should |
| 60 // not translate to the ArcLocationServiceEnabled preference. | 60 // not translate to the ArcLocationServiceEnabled preference. |
| 61 EXPECT_FALSE(store_->GetValue(prefs::kArcLocationServiceEnabled, nullptr)); | 61 EXPECT_FALSE(store_->GetValue(prefs::kArcLocationServiceEnabled, nullptr)); |
| 62 PolicyMap policy; | 62 PolicyMap policy; |
| 63 policy.Set(key::kDefaultGeolocationSetting, | 63 policy.Set(key::kDefaultGeolocationSetting, |
| 64 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 64 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 65 POLICY_SOURCE_CLOUD, | 65 POLICY_SOURCE_CLOUD, |
| 66 base::WrapUnique(new base::FundamentalValue(CONTENT_SETTING_ASK)), | 66 base::WrapUnique(new base::Value(CONTENT_SETTING_ASK)), |
| 67 nullptr); | 67 nullptr); |
| 68 UpdateProviderPolicy(policy); | 68 UpdateProviderPolicy(policy); |
| 69 EXPECT_FALSE(store_->GetValue(prefs::kArcLocationServiceEnabled, nullptr)); | 69 EXPECT_FALSE(store_->GetValue(prefs::kArcLocationServiceEnabled, nullptr)); |
| 70 } | 70 } |
| 71 | 71 |
| 72 } // namespace policy | 72 } // namespace policy |
| 73 | 73 |
| OLD | NEW |