OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/utf_string_conversions.h" | |
5 #include "chrome/browser/content_settings/host_content_settings_map.h" | 6 #include "chrome/browser/content_settings/host_content_settings_map.h" |
6 #include "chrome/browser/extensions/extension_apitest.h" | 7 #include "chrome/browser/extensions/extension_apitest.h" |
8 #include "chrome/browser/extensions/extension_content_settings_api.h" | |
7 #include "chrome/browser/prefs/pref_service.h" | 9 #include "chrome/browser/prefs/pref_service.h" |
8 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
11 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
14 #include "webkit/plugins/npapi/stub_plugin_list.h" | |
12 | 15 |
13 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentSettings) { | 16 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentSettings) { |
14 CommandLine::ForCurrentProcess()->AppendSwitch( | 17 CommandLine::ForCurrentProcess()->AppendSwitch( |
15 switches::kEnableExperimentalExtensionApis); | 18 switches::kEnableExperimentalExtensionApis); |
16 | 19 |
17 PrefService* pref_service = browser()->profile()->GetPrefs(); | 20 PrefService* pref_service = browser()->profile()->GetPrefs(); |
18 pref_service->SetBoolean(prefs::kBlockThirdPartyCookies, true); | 21 pref_service->SetBoolean(prefs::kBlockThirdPartyCookies, true); |
19 pref_service->SetBoolean(prefs::kEnableReferrers, false); | 22 pref_service->SetBoolean(prefs::kEnableReferrers, false); |
20 | 23 |
21 EXPECT_TRUE(RunExtensionTest("content_settings/standard")) << message_; | 24 EXPECT_TRUE(RunExtensionTest("content_settings/standard")) << message_; |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
162 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentSettingsOnChange) { | 165 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentSettingsOnChange) { |
163 CommandLine::ForCurrentProcess()->AppendSwitch( | 166 CommandLine::ForCurrentProcess()->AppendSwitch( |
164 switches::kEnableExperimentalExtensionApis); | 167 switches::kEnableExperimentalExtensionApis); |
165 | 168 |
166 PrefService* prefs = browser()->profile()->GetPrefs(); | 169 PrefService* prefs = browser()->profile()->GetPrefs(); |
167 prefs->SetBoolean(prefs::kBlockThirdPartyCookies, false); | 170 prefs->SetBoolean(prefs::kBlockThirdPartyCookies, false); |
168 | 171 |
169 EXPECT_TRUE(RunExtensionTestIncognito("content_settings/onchange")) << | 172 EXPECT_TRUE(RunExtensionTestIncognito("content_settings/onchange")) << |
170 message_; | 173 message_; |
171 } | 174 } |
175 | |
176 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, | |
177 ContentSettingsGetResourceIdentifiers) { | |
178 CommandLine::ForCurrentProcess()->AppendSwitch( | |
179 switches::kEnableExperimentalExtensionApis); | |
180 CommandLine::ForCurrentProcess()->AppendSwitch( | |
181 switches::kEnableResourceContentSettings); | |
182 | |
183 FilePath::CharType kFooPath[] = FILE_PATH_LITERAL("/plugins/foo.plugin"); | |
184 FilePath::CharType kBarPath[] = FILE_PATH_LITERAL("/plugins/bar.plugin"); | |
185 const char* kFooIdentifier = "foo"; | |
186 const char* kFooGroupName = "Foo"; | |
187 const char* kFooName = "Foo Plugin"; | |
188 const webkit::npapi::PluginGroupDefinition kPluginDefinitions[] = { | |
189 { kFooIdentifier, kFooGroupName, kFooName, NULL, 0, | |
190 "http://example.com/foo" }, | |
191 }; | |
192 | |
193 webkit::npapi::StubPluginList plugin_list(kPluginDefinitions, | |
194 arraysize(kPluginDefinitions)); | |
195 plugin_list.AddPluginToLoad( | |
196 webkit::npapi::WebPluginInfo(ASCIIToUTF16(kFooName), | |
197 FilePath(kFooPath), | |
198 ASCIIToUTF16("1.2.3"), | |
199 ASCIIToUTF16("foo"))); | |
200 plugin_list.AddPluginToLoad( | |
201 webkit::npapi::WebPluginInfo(ASCIIToUTF16("Bar Plugin"), | |
battre
2011/06/14 16:31:01
nit: Why do you use a constant only for the path b
Bernhard Bauer
2011/06/15 10:04:57
I tried to clean it up a bit.
| |
202 FilePath(kBarPath), | |
203 ASCIIToUTF16("2.3.4"), | |
204 ASCIIToUTF16("bar"))); | |
205 GetResourceIdentifiersFunction::SetPluginList(&plugin_list); | |
206 | |
207 EXPECT_TRUE(RunExtensionTest("content_settings/getresourceidentifiers")) | |
208 << message_; | |
209 | |
210 GetResourceIdentifiersFunction::SetPluginList(NULL); | |
211 } | |
OLD | NEW |