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

Side by Side Diff: chrome/browser/extensions/extension_content_settings_apitest.cc

Issue 7041005: Content settings extension API: Implement ContentSetting.getResourceIdentifiers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 9 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) 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/mock_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
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* kFooName = "Foo Plugin";
186 const char* kBarName = "Bar Plugin";
187 const webkit::npapi::PluginGroupDefinition kPluginDefinitions[] = {
188 { "foo", "Foo", kFooName, NULL, 0,
189 "http://example.com/foo" },
battre 2011/06/15 12:53:39 nit: single line?
190 };
191
192 webkit::npapi::MockPluginList plugin_list(kPluginDefinitions,
193 arraysize(kPluginDefinitions));
194 plugin_list.AddPluginToLoad(
195 webkit::npapi::WebPluginInfo(ASCIIToUTF16(kFooName),
196 FilePath(kFooPath),
197 ASCIIToUTF16("1.2.3"),
198 ASCIIToUTF16("foo")));
199 plugin_list.AddPluginToLoad(
200 webkit::npapi::WebPluginInfo(ASCIIToUTF16(kBarName),
201 FilePath(kBarPath),
202 ASCIIToUTF16("2.3.4"),
203 ASCIIToUTF16("bar")));
204 GetResourceIdentifiersFunction::SetPluginListForTesting(&plugin_list);
205
206 EXPECT_TRUE(RunExtensionTest("content_settings/getresourceidentifiers"))
207 << message_;
208
209 GetResourceIdentifiersFunction::SetPluginListForTesting(NULL);
210 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698