| 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/numerics/safe_conversions.h" | 13 #include "base/numerics/safe_conversions.h" |
| 14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 17 #include "base/threading/thread_restrictions.h" |
| 17 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 18 #include "build/build_config.h" | 19 #include "build/build_config.h" |
| 19 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
| 20 #include "chrome/browser/chrome_notification_types.h" | 21 #include "chrome/browser/chrome_notification_types.h" |
| 21 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" | 22 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" |
| 22 #include "chrome/browser/policy/cloud/cloud_policy_test_utils.h" | 23 #include "chrome/browser/policy/cloud/cloud_policy_test_utils.h" |
| 23 #include "chrome/browser/policy/profile_policy_connector.h" | 24 #include "chrome/browser/policy/profile_policy_connector.h" |
| 24 #include "chrome/browser/policy/profile_policy_connector_factory.h" | 25 #include "chrome/browser/policy/profile_policy_connector_factory.h" |
| 25 #include "chrome/browser/policy/test/local_policy_test_server.h" | 26 #include "chrome/browser/policy/test/local_policy_test_server.h" |
| 26 #include "chrome/browser/profiles/profile.h" | 27 #include "chrome/browser/profiles/profile.h" |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 } | 276 } |
| 276 | 277 |
| 277 invalidation::FakeInvalidationService* GetInvalidationService() { | 278 invalidation::FakeInvalidationService* GetInvalidationService() { |
| 278 return static_cast<invalidation::FakeInvalidationService*>( | 279 return static_cast<invalidation::FakeInvalidationService*>( |
| 279 static_cast<invalidation::ProfileInvalidationProvider*>( | 280 static_cast<invalidation::ProfileInvalidationProvider*>( |
| 280 invalidation::ProfileInvalidationProviderFactory::GetInstance()-> | 281 invalidation::ProfileInvalidationProviderFactory::GetInstance()-> |
| 281 GetForProfile(browser()->profile()))->GetInvalidationService()); | 282 GetForProfile(browser()->profile()))->GetInvalidationService()); |
| 282 } | 283 } |
| 283 | 284 |
| 284 void SetServerPolicy(const std::string& policy) { | 285 void SetServerPolicy(const std::string& policy) { |
| 286 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 285 int result = base::WriteFile(policy_file_path(), policy.data(), | 287 int result = base::WriteFile(policy_file_path(), policy.data(), |
| 286 policy.size()); | 288 policy.size()); |
| 287 ASSERT_EQ(base::checked_cast<int>(policy.size()), result); | 289 ASSERT_EQ(base::checked_cast<int>(policy.size()), result); |
| 288 } | 290 } |
| 289 | 291 |
| 290 base::FilePath policy_file_path() const { | 292 base::FilePath policy_file_path() const { |
| 291 return temp_dir_.GetPath().AppendASCII("policy.json"); | 293 return temp_dir_.GetPath().AppendASCII("policy.json"); |
| 292 } | 294 } |
| 293 | 295 |
| 294 void OnPolicyUpdated(const PolicyNamespace& ns, | 296 void OnPolicyUpdated(const PolicyNamespace& ns, |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 | 493 |
| 492 // They should now serialize to the same bytes. | 494 // They should now serialize to the same bytes. |
| 493 std::string chrome_settings_serialized; | 495 std::string chrome_settings_serialized; |
| 494 std::string cloud_policy_serialized; | 496 std::string cloud_policy_serialized; |
| 495 ASSERT_TRUE(chrome_settings.SerializeToString(&chrome_settings_serialized)); | 497 ASSERT_TRUE(chrome_settings.SerializeToString(&chrome_settings_serialized)); |
| 496 ASSERT_TRUE(cloud_policy.SerializeToString(&cloud_policy_serialized)); | 498 ASSERT_TRUE(cloud_policy.SerializeToString(&cloud_policy_serialized)); |
| 497 EXPECT_EQ(chrome_settings_serialized, cloud_policy_serialized); | 499 EXPECT_EQ(chrome_settings_serialized, cloud_policy_serialized); |
| 498 } | 500 } |
| 499 | 501 |
| 500 } // namespace policy | 502 } // namespace policy |
| OLD | NEW |