| 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/at_exit.h" |
| 5 #include "base/basictypes.h" | 6 #include "base/basictypes.h" |
| 6 #include "base/at_exit.h" | |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "base/win/registry.h" | 11 #include "base/win/registry.h" |
| 12 #include "chrome_frame/policy_settings.h" | 12 #include "chrome_frame/policy_settings.h" |
| 13 #include "chrome_frame/test/chrome_frame_test_utils.h" | 13 #include "chrome_frame/test/chrome_frame_test_utils.h" |
| 14 #include "content/public/common/content_switches.h" | 14 #include "content/public/common/content_switches.h" |
| 15 #include "policy/policy_constants.h" | 15 #include "policy/policy_constants.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 17 |
| 18 using base::win::RegKey; | 18 using base::win::RegKey; |
| 19 using chrome_frame_test::ScopedVirtualizeHklmAndHkcu; | 19 using chrome_frame_test::ScopedVirtualizeHklmAndHkcu; |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 // A best effort way to zap CF policy entries that may be in the registry. | 23 // A best effort way to zap CF policy entries that may be in the registry. |
| 24 void DeleteChromeFramePolicyEntries(HKEY root) { | 24 void DeleteChromeFramePolicyEntries(HKEY root) { |
| 25 RegKey key; | 25 RegKey key; |
| 26 if (key.Open(root, policy::kRegistryMandatorySubKey, | 26 if (key.Open(root, policy::kRegistryChromePolicyKey, |
| 27 KEY_ALL_ACCESS) == ERROR_SUCCESS) { | 27 KEY_ALL_ACCESS) == ERROR_SUCCESS) { |
| 28 key.DeleteValue( | 28 key.DeleteValue( |
| 29 ASCIIToWide(policy::key::kChromeFrameRendererSettings).c_str()); | 29 ASCIIToWide(policy::key::kChromeFrameRendererSettings).c_str()); |
| 30 key.DeleteKey(ASCIIToWide(policy::key::kRenderInChromeFrameList).c_str()); | 30 key.DeleteKey(ASCIIToWide(policy::key::kRenderInChromeFrameList).c_str()); |
| 31 key.DeleteKey(ASCIIToWide(policy::key::kRenderInHostList).c_str()); | 31 key.DeleteKey(ASCIIToWide(policy::key::kRenderInHostList).c_str()); |
| 32 key.DeleteKey(ASCIIToWide(policy::key::kChromeFrameContentTypes).c_str()); | 32 key.DeleteKey(ASCIIToWide(policy::key::kChromeFrameContentTypes).c_str()); |
| 33 key.DeleteKey(ASCIIToWide(policy::key::kApplicationLocaleValue).c_str()); | 33 key.DeleteKey(ASCIIToWide(policy::key::kApplicationLocaleValue).c_str()); |
| 34 } | 34 } |
| 35 } | 35 } |
| 36 | 36 |
| 37 bool InitializePolicyKey(HKEY policy_root, RegKey* policy_key) { | 37 bool InitializePolicyKey(HKEY policy_root, RegKey* policy_key) { |
| 38 EXPECT_EQ(ERROR_SUCCESS, policy_key->Create(policy_root, | 38 EXPECT_EQ(ERROR_SUCCESS, policy_key->Create(policy_root, |
| 39 policy::kRegistryMandatorySubKey, KEY_ALL_ACCESS)); | 39 policy::kRegistryChromePolicyKey, KEY_ALL_ACCESS)); |
| 40 return policy_key->Valid(); | 40 return policy_key->Valid(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void WritePolicyList(RegKey* policy_key, | 43 void WritePolicyList(RegKey* policy_key, |
| 44 const wchar_t* list_name, | 44 const wchar_t* list_name, |
| 45 const wchar_t* values[], int count) { | 45 const wchar_t* values[], int count) { |
| 46 DCHECK(policy_key); | 46 DCHECK(policy_key); |
| 47 // Remove any previous settings | 47 // Remove any previous settings |
| 48 policy_key->DeleteKey(list_name); | 48 policy_key->DeleteKey(list_name); |
| 49 | 49 |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 | 238 |
| 239 base::FilePath program_path(FILE_PATH_LITERAL("my_chrome.exe")); | 239 base::FilePath program_path(FILE_PATH_LITERAL("my_chrome.exe")); |
| 240 CommandLine new_cmd_line(program_path); | 240 CommandLine new_cmd_line(program_path); |
| 241 new_cmd_line.AppendArguments(additional_params, false); | 241 new_cmd_line.AppendArguments(additional_params, false); |
| 242 EXPECT_NE(new_cmd_line.GetProgram(), additional_params.GetProgram()); | 242 EXPECT_NE(new_cmd_line.GetProgram(), additional_params.GetProgram()); |
| 243 EXPECT_TRUE(new_cmd_line.HasSwitch(switches::kDisableMediaSource)); | 243 EXPECT_TRUE(new_cmd_line.HasSwitch(switches::kDisableMediaSource)); |
| 244 | 244 |
| 245 DeleteChromeFramePolicyEntries(root[i]); | 245 DeleteChromeFramePolicyEntries(root[i]); |
| 246 } | 246 } |
| 247 } | 247 } |
| OLD | NEW |