| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <stdint.h> |
| 6 |
| 5 #include <string> | 7 #include <string> |
| 6 #include <vector> | 8 #include <vector> |
| 7 | 9 |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/callback.h" | 11 #include "base/callback.h" |
| 11 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 12 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 13 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 14 #include "base/files/file_util.h" | 15 #include "base/files/file_util.h" |
| 15 #include "base/location.h" | 16 #include "base/location.h" |
| 17 #include "base/macros.h" |
| 16 #include "base/message_loop/message_loop.h" | 18 #include "base/message_loop/message_loop.h" |
| 17 #include "base/path_service.h" | 19 #include "base/path_service.h" |
| 18 #include "base/run_loop.h" | 20 #include "base/run_loop.h" |
| 19 #include "chrome/browser/chrome_notification_types.h" | 21 #include "chrome/browser/chrome_notification_types.h" |
| 20 #include "chrome/browser/chromeos/policy/device_policy_builder.h" | 22 #include "chrome/browser/chromeos/policy/device_policy_builder.h" |
| 21 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" | 23 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" |
| 22 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | 24 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
| 23 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" | 25 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" |
| 24 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom
eos.h" | 26 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom
eos.h" |
| 25 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 27 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 | 203 |
| 202 void PowerPolicyBrowserTestBase::InstallUserKey() { | 204 void PowerPolicyBrowserTestBase::InstallUserKey() { |
| 203 base::FilePath user_keys_dir; | 205 base::FilePath user_keys_dir; |
| 204 ASSERT_TRUE(PathService::Get(chromeos::DIR_USER_POLICY_KEYS, &user_keys_dir)); | 206 ASSERT_TRUE(PathService::Get(chromeos::DIR_USER_POLICY_KEYS, &user_keys_dir)); |
| 205 std::string sanitized_username = | 207 std::string sanitized_username = |
| 206 chromeos::CryptohomeClient::GetStubSanitizedUsername( | 208 chromeos::CryptohomeClient::GetStubSanitizedUsername( |
| 207 chromeos::login::StubAccountId().GetUserEmail()); | 209 chromeos::login::StubAccountId().GetUserEmail()); |
| 208 base::FilePath user_key_file = | 210 base::FilePath user_key_file = |
| 209 user_keys_dir.AppendASCII(sanitized_username) | 211 user_keys_dir.AppendASCII(sanitized_username) |
| 210 .AppendASCII("policy.pub"); | 212 .AppendASCII("policy.pub"); |
| 211 std::vector<uint8> user_key_bits; | 213 std::vector<uint8_t> user_key_bits; |
| 212 ASSERT_TRUE(user_policy_.GetSigningKey()->ExportPublicKey(&user_key_bits)); | 214 ASSERT_TRUE(user_policy_.GetSigningKey()->ExportPublicKey(&user_key_bits)); |
| 213 ASSERT_TRUE(base::CreateDirectory(user_key_file.DirName())); | 215 ASSERT_TRUE(base::CreateDirectory(user_key_file.DirName())); |
| 214 ASSERT_EQ(base::WriteFile( | 216 ASSERT_EQ(base::WriteFile( |
| 215 user_key_file, | 217 user_key_file, |
| 216 reinterpret_cast<const char*>(user_key_bits.data()), | 218 reinterpret_cast<const char*>(user_key_bits.data()), |
| 217 user_key_bits.size()), | 219 user_key_bits.size()), |
| 218 static_cast<int>(user_key_bits.size())); | 220 static_cast<int>(user_key_bits.size())); |
| 219 } | 221 } |
| 220 | 222 |
| 221 void PowerPolicyBrowserTestBase::StoreAndReloadUserPolicy() { | 223 void PowerPolicyBrowserTestBase::StoreAndReloadUserPolicy() { |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 policy = baseline_policy; | 511 policy = baseline_policy; |
| 510 policy.set_ac_idle_action(power_manager_client_->policy().ac_idle_action()); | 512 policy.set_ac_idle_action(power_manager_client_->policy().ac_idle_action()); |
| 511 policy.set_battery_idle_action( | 513 policy.set_battery_idle_action( |
| 512 power_manager_client_->policy().battery_idle_action()); | 514 power_manager_client_->policy().battery_idle_action()); |
| 513 policy.set_reason(power_manager_client_->policy().reason()); | 515 policy.set_reason(power_manager_client_->policy().reason()); |
| 514 EXPECT_EQ(GetDebugString(policy), | 516 EXPECT_EQ(GetDebugString(policy), |
| 515 GetDebugString(power_manager_client_->policy())); | 517 GetDebugString(power_manager_client_->policy())); |
| 516 } | 518 } |
| 517 | 519 |
| 518 } // namespace policy | 520 } // namespace policy |
| OLD | NEW |