Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: chrome_frame/test/policy_settings_unittest.cc

Issue 17153006: Chrome Frame turndown prompt. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 bool SetCFPolicyBool(HKEY policy_root,
110 const char* policy_name,
111 bool value) {
112 RegKey policy_key;
113 if (!InitializePolicyKey(policy_root, &policy_key))
114 return false;
115
116 std::wstring policy_name_str(ASCIIToWide(policy_name));
117 EXPECT_EQ(ERROR_SUCCESS,
118 policy_key.WriteValue(policy_name_str.c_str(), value ? 1U : 0U));
119 return true;
120 }
robertshield 2013/06/19 23:36:33 The return value for this function is never used,
grt (UTC plus 2) 2013/06/20 19:55:29 Rejiggered.
121
107 } // end namespace 122 } // end namespace
108 123
109 class PolicySettingsTest : public testing::Test { 124 class PolicySettingsTest : public testing::Test {
110 protected: 125 protected:
111 void SetUp() { 126 void SetUp() {
112 ResetPolicySettings(); 127 ResetPolicySettings();
113 } 128 }
114 129
115 void TearDown() { 130 void TearDown() {
116 } 131 }
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 254
240 base::FilePath program_path(FILE_PATH_LITERAL("my_chrome.exe")); 255 base::FilePath program_path(FILE_PATH_LITERAL("my_chrome.exe"));
241 CommandLine new_cmd_line(program_path); 256 CommandLine new_cmd_line(program_path);
242 new_cmd_line.AppendArguments(additional_params, false); 257 new_cmd_line.AppendArguments(additional_params, false);
243 EXPECT_NE(new_cmd_line.GetProgram(), additional_params.GetProgram()); 258 EXPECT_NE(new_cmd_line.GetProgram(), additional_params.GetProgram());
244 EXPECT_TRUE(new_cmd_line.HasSwitch(switches::kDisableWebKitMediaSource)); 259 EXPECT_TRUE(new_cmd_line.HasSwitch(switches::kDisableWebKitMediaSource));
245 260
246 DeleteChromeFramePolicyEntries(root[i]); 261 DeleteChromeFramePolicyEntries(root[i]);
247 } 262 }
248 } 263 }
264
265 TEST_F(PolicySettingsTest, SuppressTurndownPrompt) {
266 EXPECT_FALSE(PolicySettings::GetInstance()->suppress_turndown_prompt());
267
268 HKEY root[] = { HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER };
269 for (int i = 0; i < arraysize(root); ++i) {
270 SetCFPolicyBool(root[i], policy::key::kSuppressChromeFrameTurndownPrompt,
271 true);
272 ResetPolicySettings();
273 EXPECT_TRUE(PolicySettings::GetInstance()->suppress_turndown_prompt());
274
275 DeleteChromeFramePolicyEntries(root[i]);
276 }
277 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698