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 "base/callback.h" | 5 #include "base/callback.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 #include "policy/proto/cloud_policy.pb.h" | 47 #include "policy/proto/cloud_policy.pb.h" |
48 #include "policy/proto/device_management_backend.pb.h" | 48 #include "policy/proto/device_management_backend.pb.h" |
49 #include "testing/gmock/include/gmock/gmock.h" | 49 #include "testing/gmock/include/gmock/gmock.h" |
50 #include "testing/gtest/include/gtest/gtest.h" | 50 #include "testing/gtest/include/gtest/gtest.h" |
51 #include "url/gurl.h" | 51 #include "url/gurl.h" |
52 | 52 |
53 #if defined(OS_CHROMEOS) | 53 #if defined(OS_CHROMEOS) |
54 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" | 54 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" |
55 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom
eos.h" | 55 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom
eos.h" |
56 #include "chromeos/chromeos_paths.h" | 56 #include "chromeos/chromeos_paths.h" |
| 57 #include "chromeos/cryptohome/cryptohome_parameters.h" |
57 #include "chromeos/dbus/cryptohome_client.h" | 58 #include "chromeos/dbus/cryptohome_client.h" |
58 #include "chromeos/login/user_names.h" | 59 #include "chromeos/login/user_names.h" |
| 60 #include "components/signin/core/account_id/account_id.h" |
59 #else | 61 #else |
60 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h" | 62 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h" |
61 #include "chrome/browser/signin/signin_manager_factory.h" | 63 #include "chrome/browser/signin/signin_manager_factory.h" |
62 #include "components/policy/core/common/cloud/user_cloud_policy_manager.h" | 64 #include "components/policy/core/common/cloud/user_cloud_policy_manager.h" |
63 #include "components/signin/core/browser/signin_manager.h" | 65 #include "components/signin/core/browser/signin_manager.h" |
64 #endif | 66 #endif |
65 | 67 |
66 using testing::AnyNumber; | 68 using testing::AnyNumber; |
67 using testing::InvokeWithoutArgs; | 69 using testing::InvokeWithoutArgs; |
68 using testing::Mock; | 70 using testing::Mock; |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 Mock::VerifyAndClearExpectations(&observer); | 329 Mock::VerifyAndClearExpectations(&observer); |
328 policy_manager->core()->client()->RemoveObserver(&observer); | 330 policy_manager->core()->client()->RemoveObserver(&observer); |
329 EXPECT_TRUE(policy_manager->core()->client()->is_registered()); | 331 EXPECT_TRUE(policy_manager->core()->client()->is_registered()); |
330 | 332 |
331 #if defined(OS_CHROMEOS) | 333 #if defined(OS_CHROMEOS) |
332 // Get the path to the user policy key file. | 334 // Get the path to the user policy key file. |
333 base::FilePath user_policy_key_dir; | 335 base::FilePath user_policy_key_dir; |
334 ASSERT_TRUE( | 336 ASSERT_TRUE( |
335 PathService::Get(chromeos::DIR_USER_POLICY_KEYS, &user_policy_key_dir)); | 337 PathService::Get(chromeos::DIR_USER_POLICY_KEYS, &user_policy_key_dir)); |
336 std::string sanitized_username = | 338 std::string sanitized_username = |
337 chromeos::CryptohomeClient::GetStubSanitizedUsername(GetTestUser()); | 339 chromeos::CryptohomeClient::GetStubSanitizedUsername( |
| 340 cryptohome::Identification( |
| 341 AccountId::FromUserEmail(GetTestUser()))); |
338 user_policy_key_file_ = user_policy_key_dir.AppendASCII(sanitized_username) | 342 user_policy_key_file_ = user_policy_key_dir.AppendASCII(sanitized_username) |
339 .AppendASCII("policy.pub"); | 343 .AppendASCII("policy.pub"); |
340 #endif | 344 #endif |
341 } | 345 } |
342 | 346 |
343 PolicyService* GetPolicyService() { | 347 PolicyService* GetPolicyService() { |
344 ProfilePolicyConnector* profile_connector = | 348 ProfilePolicyConnector* profile_connector = |
345 ProfilePolicyConnectorFactory::GetForBrowserContext( | 349 ProfilePolicyConnectorFactory::GetForBrowserContext( |
346 browser()->profile()); | 350 browser()->profile()); |
347 return profile_connector->policy_service(); | 351 return profile_connector->policy_service(); |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 | 542 |
539 // They should now serialize to the same bytes. | 543 // They should now serialize to the same bytes. |
540 std::string chrome_settings_serialized; | 544 std::string chrome_settings_serialized; |
541 std::string cloud_policy_serialized; | 545 std::string cloud_policy_serialized; |
542 ASSERT_TRUE(chrome_settings.SerializeToString(&chrome_settings_serialized)); | 546 ASSERT_TRUE(chrome_settings.SerializeToString(&chrome_settings_serialized)); |
543 ASSERT_TRUE(cloud_policy.SerializeToString(&cloud_policy_serialized)); | 547 ASSERT_TRUE(cloud_policy.SerializeToString(&cloud_policy_serialized)); |
544 EXPECT_EQ(chrome_settings_serialized, cloud_policy_serialized); | 548 EXPECT_EQ(chrome_settings_serialized, cloud_policy_serialized); |
545 } | 549 } |
546 | 550 |
547 } // namespace policy | 551 } // namespace policy |
OLD | NEW |