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

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

Issue 10381097: Move content settings extension API to content_settings dir. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fixed conflict Created 8 years, 7 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/utf_string_conversions.h"
6 #include "chrome/browser/content_settings/cookie_settings.h"
7 #include "chrome/browser/content_settings/host_content_settings_map.h"
8 #include "chrome/browser/extensions/extension_apitest.h"
9 #include "chrome/browser/extensions/extension_content_settings_api.h"
10 #include "chrome/browser/prefs/pref_service.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/common/chrome_switches.h"
14 #include "chrome/common/pref_names.h"
15 #include "webkit/plugins/npapi/mock_plugin_list.h"
16
17 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentSettings) {
18 CommandLine::ForCurrentProcess()->AppendSwitch(
19 switches::kEnableExperimentalExtensionApis);
20
21 EXPECT_TRUE(RunExtensionTest("content_settings/standard")) << message_;
22
23 HostContentSettingsMap* map =
24 browser()->profile()->GetHostContentSettingsMap();
25 CookieSettings* cookie_settings =
26 CookieSettings::Factory::GetForProfile(browser()->profile());
27
28 // Check default content settings by using an unknown URL.
29 GURL example_url("http://www.example.com");
30 EXPECT_TRUE(cookie_settings->IsReadingCookieAllowed(
31 example_url, example_url));
32 EXPECT_TRUE(cookie_settings->IsSettingCookieAllowed(
33 example_url, example_url));
34 EXPECT_TRUE(cookie_settings->IsCookieSessionOnly(example_url));
35 EXPECT_EQ(CONTENT_SETTING_ALLOW,
36 map->GetContentSetting(example_url,
37 example_url,
38 CONTENT_SETTINGS_TYPE_IMAGES,
39 std::string()));
40 EXPECT_EQ(CONTENT_SETTING_BLOCK,
41 map->GetContentSetting(example_url,
42 example_url,
43 CONTENT_SETTINGS_TYPE_JAVASCRIPT,
44 std::string()));
45 EXPECT_EQ(CONTENT_SETTING_ALLOW,
46 map->GetContentSetting(example_url,
47 example_url,
48 CONTENT_SETTINGS_TYPE_PLUGINS,
49 std::string()));
50 EXPECT_EQ(CONTENT_SETTING_BLOCK,
51 map->GetContentSetting(example_url,
52 example_url,
53 CONTENT_SETTINGS_TYPE_POPUPS,
54 std::string()));
55 #if 0
56 // TODO(bauerb): Enable once geolocation settings are integrated into the
57 // HostContentSettingsMap.
58 EXPECT_EQ(CONTENT_SETTING_ALLOW,
59 map->GetContentSetting(example_url,
60 example_url,
61 CONTENT_SETTINGS_TYPE_GEOLOCATION,
62 std::string()));
63 #endif
64 EXPECT_EQ(CONTENT_SETTING_ASK,
65 map->GetContentSetting(example_url,
66 example_url,
67 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
68 std::string()));
69
70 // Check content settings for www.google.com
71 GURL url("http://www.google.com");
72 EXPECT_FALSE(cookie_settings->IsReadingCookieAllowed(url, url));
73 EXPECT_EQ(CONTENT_SETTING_ALLOW,
74 map->GetContentSetting(
75 url, url, CONTENT_SETTINGS_TYPE_IMAGES, ""));
76 EXPECT_EQ(CONTENT_SETTING_BLOCK,
77 map->GetContentSetting(
78 url, url, CONTENT_SETTINGS_TYPE_JAVASCRIPT, ""));
79 EXPECT_EQ(CONTENT_SETTING_BLOCK,
80 map->GetContentSetting(
81 url, url, CONTENT_SETTINGS_TYPE_PLUGINS, ""));
82 EXPECT_EQ(CONTENT_SETTING_ALLOW,
83 map->GetContentSetting(
84 url, url, CONTENT_SETTINGS_TYPE_POPUPS, ""));
85 #if 0
86 EXPECT_EQ(CONTENT_SETTING_BLOCK,
87 map->GetContentSetting(
88 url, url, CONTENT_SETTINGS_TYPE_GEOLOCATION, ""));
89 #endif
90 EXPECT_EQ(CONTENT_SETTING_BLOCK,
91 map->GetContentSetting(
92 url, url, CONTENT_SETTINGS_TYPE_NOTIFICATIONS, ""));
93 }
94
95 // Flaky on the trybots. See http://crbug.com/96725.
96 IN_PROC_BROWSER_TEST_F(ExtensionApiTest,
97 DISABLED_ContentSettingsGetResourceIdentifiers) {
98 CommandLine::ForCurrentProcess()->AppendSwitch(
99 switches::kEnableExperimentalExtensionApis);
100
101 FilePath::CharType kFooPath[] = FILE_PATH_LITERAL("/plugins/foo.plugin");
102 FilePath::CharType kBarPath[] = FILE_PATH_LITERAL("/plugins/bar.plugin");
103 const char* kFooName = "Foo Plugin";
104 const char* kBarName = "Bar Plugin";
105 const webkit::npapi::PluginGroupDefinition kPluginDefinitions[] = {
106 { "foo", "Foo", kFooName, NULL, 0 },
107 };
108
109 webkit::npapi::MockPluginList plugin_list(kPluginDefinitions,
110 arraysize(kPluginDefinitions));
111 plugin_list.AddPluginToLoad(
112 webkit::WebPluginInfo(ASCIIToUTF16(kFooName),
113 FilePath(kFooPath),
114 ASCIIToUTF16("1.2.3"),
115 ASCIIToUTF16("foo")));
116 plugin_list.AddPluginToLoad(
117 webkit::WebPluginInfo(ASCIIToUTF16(kBarName),
118 FilePath(kBarPath),
119 ASCIIToUTF16("2.3.4"),
120 ASCIIToUTF16("bar")));
121
122 std::vector<webkit::npapi::PluginGroup> groups;
123 plugin_list.GetPluginGroups(true, &groups);
124
125 GetResourceIdentifiersFunction::SetPluginGroupsForTesting(&groups);
126
127 EXPECT_TRUE(RunExtensionTest("content_settings/getresourceidentifiers"))
128 << message_;
129
130 GetResourceIdentifiersFunction::SetPluginGroupsForTesting(NULL);
131 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698