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/at_exit.h" |
6 #include "base/basictypes.h" | 6 #include "base/basictypes.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/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 12 matching lines...) Expand all Loading... |
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::kRegistryChromePolicyKey, | 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.DeleteValue(ASCIIToWide(policy::key::kApplicationLocaleValue).c_str()); |
| 34 key.DeleteValue( |
| 35 ASCIIToWide(policy::key::kSuppressChromeFrameTurndownPrompt).c_str()); |
34 } | 36 } |
35 } | 37 } |
36 | 38 |
37 bool InitializePolicyKey(HKEY policy_root, RegKey* policy_key) { | 39 bool InitializePolicyKey(HKEY policy_root, RegKey* policy_key) { |
38 EXPECT_EQ(ERROR_SUCCESS, policy_key->Create(policy_root, | 40 EXPECT_EQ(ERROR_SUCCESS, policy_key->Create(policy_root, |
39 policy::kRegistryChromePolicyKey, KEY_ALL_ACCESS)); | 41 policy::kRegistryChromePolicyKey, KEY_ALL_ACCESS)); |
40 return policy_key->Valid(); | 42 return policy_key->Valid(); |
41 } | 43 } |
42 | 44 |
43 void WritePolicyList(RegKey* policy_key, | 45 void WritePolicyList(RegKey* policy_key, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 RegKey policy_key; | 99 RegKey policy_key; |
98 if (!InitializePolicyKey(policy_root, &policy_key)) | 100 if (!InitializePolicyKey(policy_root, &policy_key)) |
99 return false; | 101 return false; |
100 | 102 |
101 std::wstring policy_name_str(ASCIIToWide(policy_name)); | 103 std::wstring policy_name_str(ASCIIToWide(policy_name)); |
102 EXPECT_EQ(ERROR_SUCCESS, | 104 EXPECT_EQ(ERROR_SUCCESS, |
103 policy_key.WriteValue(policy_name_str.c_str(), value)); | 105 policy_key.WriteValue(policy_name_str.c_str(), value)); |
104 return true; | 106 return true; |
105 } | 107 } |
106 | 108 |
| 109 void SetCFPolicyBool(HKEY policy_root, |
| 110 const char* policy_name, |
| 111 bool value) { |
| 112 RegKey policy_key; |
| 113 if (InitializePolicyKey(policy_root, &policy_key)) { |
| 114 std::wstring policy_name_str(ASCIIToWide(policy_name)); |
| 115 EXPECT_EQ(ERROR_SUCCESS, |
| 116 policy_key.WriteValue(policy_name_str.c_str(), value ? 1U : 0U)); |
| 117 } |
| 118 } |
| 119 |
107 } // end namespace | 120 } // end namespace |
108 | 121 |
109 class PolicySettingsTest : public testing::Test { | 122 class PolicySettingsTest : public testing::Test { |
110 protected: | 123 protected: |
111 void SetUp() { | 124 void SetUp() { |
112 ResetPolicySettings(); | 125 ResetPolicySettings(); |
113 } | 126 } |
114 | 127 |
115 void TearDown() { | 128 void TearDown() { |
116 } | 129 } |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 | 252 |
240 base::FilePath program_path(FILE_PATH_LITERAL("my_chrome.exe")); | 253 base::FilePath program_path(FILE_PATH_LITERAL("my_chrome.exe")); |
241 CommandLine new_cmd_line(program_path); | 254 CommandLine new_cmd_line(program_path); |
242 new_cmd_line.AppendArguments(additional_params, false); | 255 new_cmd_line.AppendArguments(additional_params, false); |
243 EXPECT_NE(new_cmd_line.GetProgram(), additional_params.GetProgram()); | 256 EXPECT_NE(new_cmd_line.GetProgram(), additional_params.GetProgram()); |
244 EXPECT_TRUE(new_cmd_line.HasSwitch(switches::kDisableWebKitMediaSource)); | 257 EXPECT_TRUE(new_cmd_line.HasSwitch(switches::kDisableWebKitMediaSource)); |
245 | 258 |
246 DeleteChromeFramePolicyEntries(root[i]); | 259 DeleteChromeFramePolicyEntries(root[i]); |
247 } | 260 } |
248 } | 261 } |
| 262 |
| 263 TEST_F(PolicySettingsTest, SuppressTurndownPrompt) { |
| 264 EXPECT_FALSE(PolicySettings::GetInstance()->suppress_turndown_prompt()); |
| 265 |
| 266 HKEY root[] = { HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER }; |
| 267 for (int i = 0; i < arraysize(root); ++i) { |
| 268 SetCFPolicyBool(root[i], policy::key::kSuppressChromeFrameTurndownPrompt, |
| 269 true); |
| 270 ResetPolicySettings(); |
| 271 EXPECT_TRUE(PolicySettings::GetInstance()->suppress_turndown_prompt()); |
| 272 |
| 273 DeleteChromeFramePolicyEntries(root[i]); |
| 274 } |
| 275 } |
OLD | NEW |