| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| 11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 18 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
| 19 #include "chrome/browser/chrome_notification_types.h" | 19 #include "chrome/browser/chrome_notification_types.h" |
| 20 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" | 20 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" |
| 21 #include "chrome/browser/policy/cloud/cloud_policy_test_utils.h" |
| 21 #include "chrome/browser/policy/profile_policy_connector.h" | 22 #include "chrome/browser/policy/profile_policy_connector.h" |
| 22 #include "chrome/browser/policy/profile_policy_connector_factory.h" | 23 #include "chrome/browser/policy/profile_policy_connector_factory.h" |
| 23 #include "chrome/browser/policy/test/local_policy_test_server.h" | 24 #include "chrome/browser/policy/test/local_policy_test_server.h" |
| 24 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
| 25 #include "chrome/browser/ui/browser.h" | 26 #include "chrome/browser/ui/browser.h" |
| 26 #include "chrome/test/base/in_process_browser_test.h" | 27 #include "chrome/test/base/in_process_browser_test.h" |
| 27 #include "components/invalidation/impl/fake_invalidation_service.h" | 28 #include "components/invalidation/impl/fake_invalidation_service.h" |
| 28 #include "components/invalidation/impl/profile_invalidation_provider.h" | 29 #include "components/invalidation/impl/profile_invalidation_provider.h" |
| 29 #include "components/invalidation/public/invalidation.h" | 30 #include "components/invalidation/public/invalidation.h" |
| 30 #include "components/invalidation/public/invalidation_service.h" | 31 #include "components/invalidation/public/invalidation_service.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 " \"invalidation_name\": \"test_policy\"" | 142 " \"invalidation_name\": \"test_policy\"" |
| 142 "}"; | 143 "}"; |
| 143 | 144 |
| 144 return base::StringPrintf(kTestPolicy, | 145 return base::StringPrintf(kTestPolicy, |
| 145 dm_protocol::kChromeUserPolicyType, | 146 dm_protocol::kChromeUserPolicyType, |
| 146 homepage, | 147 homepage, |
| 147 GetTestUser(), | 148 GetTestUser(), |
| 148 key_version); | 149 key_version); |
| 149 } | 150 } |
| 150 | 151 |
| 151 void GetExpectedDefaultPolicy(PolicyMap* policy_map) { | |
| 152 policy_map->Set(key::kNTPContentSuggestionsEnabled, POLICY_LEVEL_MANDATORY, | |
| 153 POLICY_SCOPE_USER, POLICY_SOURCE_ENTERPRISE_DEFAULT, | |
| 154 base::WrapUnique(new base::FundamentalValue(false)), nullptr); | |
| 155 #if defined(OS_CHROMEOS) | |
| 156 policy_map->Set(key::kChromeOsMultiProfileUserBehavior, | |
| 157 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | |
| 158 POLICY_SOURCE_ENTERPRISE_DEFAULT, | |
| 159 base::MakeUnique<base::StringValue>("primary-only"), nullptr); | |
| 160 policy_map->Set(key::kEasyUnlockAllowed, POLICY_LEVEL_MANDATORY, | |
| 161 POLICY_SCOPE_USER, POLICY_SOURCE_ENTERPRISE_DEFAULT, | |
| 162 base::MakeUnique<base::FundamentalValue>(false), nullptr); | |
| 163 policy_map->Set(key::kCaptivePortalAuthenticationIgnoresProxy, | |
| 164 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | |
| 165 POLICY_SOURCE_ENTERPRISE_DEFAULT, | |
| 166 base::MakeUnique<base::FundamentalValue>(false), nullptr); | |
| 167 policy_map->Set(key::kAllowDinosaurEasterEgg, POLICY_LEVEL_MANDATORY, | |
| 168 POLICY_SCOPE_USER, POLICY_SOURCE_ENTERPRISE_DEFAULT, | |
| 169 base::MakeUnique<base::FundamentalValue>(false), nullptr); | |
| 170 policy_map->Set(key::kArcEnabled, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | |
| 171 POLICY_SOURCE_ENTERPRISE_DEFAULT, | |
| 172 base::MakeUnique<base::FundamentalValue>(false), nullptr); | |
| 173 policy_map->Set(key::kPacHttpsUrlStrippingEnabled, POLICY_LEVEL_MANDATORY, | |
| 174 POLICY_SCOPE_USER, POLICY_SOURCE_ENTERPRISE_DEFAULT, | |
| 175 base::MakeUnique<base::FundamentalValue>(false), nullptr); | |
| 176 #endif | |
| 177 } | |
| 178 | |
| 179 void GetExpectedTestPolicy(PolicyMap* expected, const char* homepage) { | 152 void GetExpectedTestPolicy(PolicyMap* expected, const char* homepage) { |
| 180 GetExpectedDefaultPolicy(expected); | 153 GetExpectedDefaultPolicy(expected); |
| 181 | 154 |
| 182 expected->Set(key::kShowHomeButton, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 155 expected->Set(key::kShowHomeButton, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 183 POLICY_SOURCE_CLOUD, | 156 POLICY_SOURCE_CLOUD, |
| 184 base::MakeUnique<base::FundamentalValue>(true), nullptr); | 157 base::MakeUnique<base::FundamentalValue>(true), nullptr); |
| 185 expected->Set(key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, | 158 expected->Set(key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, |
| 186 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 159 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 187 base::MakeUnique<base::FundamentalValue>(4), nullptr); | 160 base::MakeUnique<base::FundamentalValue>(4), nullptr); |
| 188 base::ListValue list; | 161 base::ListValue list; |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 | 467 |
| 495 // They should now serialize to the same bytes. | 468 // They should now serialize to the same bytes. |
| 496 std::string chrome_settings_serialized; | 469 std::string chrome_settings_serialized; |
| 497 std::string cloud_policy_serialized; | 470 std::string cloud_policy_serialized; |
| 498 ASSERT_TRUE(chrome_settings.SerializeToString(&chrome_settings_serialized)); | 471 ASSERT_TRUE(chrome_settings.SerializeToString(&chrome_settings_serialized)); |
| 499 ASSERT_TRUE(cloud_policy.SerializeToString(&cloud_policy_serialized)); | 472 ASSERT_TRUE(cloud_policy.SerializeToString(&cloud_policy_serialized)); |
| 500 EXPECT_EQ(chrome_settings_serialized, cloud_policy_serialized); | 473 EXPECT_EQ(chrome_settings_serialized, cloud_policy_serialized); |
| 501 } | 474 } |
| 502 | 475 |
| 503 } // namespace policy | 476 } // namespace policy |
| OLD | NEW |