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

Side by Side Diff: chrome/browser/extensions/api/content_settings/content_settings_apitest.cc

Issue 843413003: Add `chrome.contentSettings.location`. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
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/prefs/pref_service.h" 5 #include "base/prefs/pref_service.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "chrome/browser/browser_process.h" 7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/chrome_notification_types.h" 8 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/browser/content_settings/cookie_settings.h" 9 #include "chrome/browser/content_settings/cookie_settings.h"
10 #include "chrome/browser/extensions/api/content_settings/content_settings_api.h" 10 #include "chrome/browser/extensions/api/content_settings/content_settings_api.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 EXPECT_EQ(CONTENT_SETTING_ALLOW, 89 EXPECT_EQ(CONTENT_SETTING_ALLOW,
90 map->GetContentSetting(example_url, 90 map->GetContentSetting(example_url,
91 example_url, 91 example_url,
92 CONTENT_SETTINGS_TYPE_PLUGINS, 92 CONTENT_SETTINGS_TYPE_PLUGINS,
93 std::string())); 93 std::string()));
94 EXPECT_EQ(CONTENT_SETTING_BLOCK, 94 EXPECT_EQ(CONTENT_SETTING_BLOCK,
95 map->GetContentSetting(example_url, 95 map->GetContentSetting(example_url,
96 example_url, 96 example_url,
97 CONTENT_SETTINGS_TYPE_POPUPS, 97 CONTENT_SETTINGS_TYPE_POPUPS,
98 std::string())); 98 std::string()));
99 #if 0 99 EXPECT_EQ(CONTENT_SETTING_ASK,
100 // TODO(bauerb): Enable once geolocation settings are integrated into the
101 // HostContentSettingsMap.
102 EXPECT_EQ(CONTENT_SETTING_ALLOW,
103 map->GetContentSetting(example_url, 100 map->GetContentSetting(example_url,
104 example_url, 101 example_url,
105 CONTENT_SETTINGS_TYPE_GEOLOCATION, 102 CONTENT_SETTINGS_TYPE_GEOLOCATION,
106 std::string())); 103 std::string()));
107 #endif
108 EXPECT_EQ(CONTENT_SETTING_ASK, 104 EXPECT_EQ(CONTENT_SETTING_ASK,
109 map->GetContentSetting(example_url, 105 map->GetContentSetting(example_url,
110 example_url, 106 example_url,
111 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, 107 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
112 std::string())); 108 std::string()));
113 109
114 // Check content settings for www.google.com 110 // Check content settings for www.google.com
115 GURL url("http://www.google.com"); 111 GURL url("http://www.google.com");
116 EXPECT_FALSE(cookie_settings->IsReadingCookieAllowed(url, url)); 112 EXPECT_FALSE(cookie_settings->IsReadingCookieAllowed(url, url));
117 EXPECT_EQ(CONTENT_SETTING_ALLOW, 113 EXPECT_EQ(CONTENT_SETTING_ALLOW,
118 map->GetContentSetting( 114 map->GetContentSetting(
119 url, url, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); 115 url, url, CONTENT_SETTINGS_TYPE_IMAGES, std::string()));
120 EXPECT_EQ(CONTENT_SETTING_BLOCK, 116 EXPECT_EQ(CONTENT_SETTING_BLOCK,
121 map->GetContentSetting( 117 map->GetContentSetting(
122 url, url, CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string())); 118 url, url, CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string()));
123 EXPECT_EQ(CONTENT_SETTING_BLOCK, 119 EXPECT_EQ(CONTENT_SETTING_BLOCK,
124 map->GetContentSetting( 120 map->GetContentSetting(
125 url, url, CONTENT_SETTINGS_TYPE_PLUGINS, std::string())); 121 url, url, CONTENT_SETTINGS_TYPE_PLUGINS, std::string()));
126 EXPECT_EQ(CONTENT_SETTING_ALLOW, 122 EXPECT_EQ(CONTENT_SETTING_ALLOW,
127 map->GetContentSetting( 123 map->GetContentSetting(
128 url, url, CONTENT_SETTINGS_TYPE_POPUPS, std::string())); 124 url, url, CONTENT_SETTINGS_TYPE_POPUPS, std::string()));
129 #if 0
130 EXPECT_EQ(CONTENT_SETTING_BLOCK, 125 EXPECT_EQ(CONTENT_SETTING_BLOCK,
131 map->GetContentSetting( 126 map->GetContentSetting(
132 url, url, CONTENT_SETTINGS_TYPE_GEOLOCATION, std::string())); 127 url, url, CONTENT_SETTINGS_TYPE_GEOLOCATION, std::string()));
133 #endif
134 EXPECT_EQ( 128 EXPECT_EQ(
135 CONTENT_SETTING_BLOCK, 129 CONTENT_SETTING_BLOCK,
136 map->GetContentSetting( 130 map->GetContentSetting(
137 url, url, CONTENT_SETTINGS_TYPE_NOTIFICATIONS, std::string())); 131 url, url, CONTENT_SETTINGS_TYPE_NOTIFICATIONS, std::string()));
138 } 132 }
139 133
140 void CheckContentSettingsDefault() { 134 void CheckContentSettingsDefault() {
141 HostContentSettingsMap* map = 135 HostContentSettingsMap* map =
142 profile_->GetHostContentSettingsMap(); 136 profile_->GetHostContentSettingsMap();
143 CookieSettings* cookie_settings = 137 CookieSettings* cookie_settings =
144 CookieSettings::Factory::GetForProfile(profile_).get(); 138 CookieSettings::Factory::GetForProfile(profile_).get();
145 139
146 // Check content settings for www.google.com 140 // Check content settings for www.google.com
147 GURL url("http://www.google.com"); 141 GURL url("http://www.google.com");
148 EXPECT_TRUE(cookie_settings->IsReadingCookieAllowed(url, url)); 142 EXPECT_TRUE(cookie_settings->IsReadingCookieAllowed(url, url));
149 EXPECT_TRUE(cookie_settings->IsSettingCookieAllowed(url, url)); 143 EXPECT_TRUE(cookie_settings->IsSettingCookieAllowed(url, url));
150 EXPECT_FALSE(cookie_settings->IsCookieSessionOnly(url)); 144 EXPECT_FALSE(cookie_settings->IsCookieSessionOnly(url));
151 EXPECT_EQ(CONTENT_SETTING_ALLOW, 145 EXPECT_EQ(CONTENT_SETTING_ALLOW,
152 map->GetContentSetting( 146 map->GetContentSetting(
153 url, url, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); 147 url, url, CONTENT_SETTINGS_TYPE_IMAGES, std::string()));
154 EXPECT_EQ(CONTENT_SETTING_ALLOW, 148 EXPECT_EQ(CONTENT_SETTING_ALLOW,
155 map->GetContentSetting( 149 map->GetContentSetting(
156 url, url, CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string())); 150 url, url, CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string()));
157 EXPECT_EQ(CONTENT_SETTING_ALLOW, 151 EXPECT_EQ(CONTENT_SETTING_ALLOW,
158 map->GetContentSetting( 152 map->GetContentSetting(
159 url, url, CONTENT_SETTINGS_TYPE_PLUGINS, std::string())); 153 url, url, CONTENT_SETTINGS_TYPE_PLUGINS, std::string()));
160 EXPECT_EQ(CONTENT_SETTING_BLOCK, 154 EXPECT_EQ(CONTENT_SETTING_BLOCK,
161 map->GetContentSetting( 155 map->GetContentSetting(
162 url, url, CONTENT_SETTINGS_TYPE_POPUPS, std::string())); 156 url, url, CONTENT_SETTINGS_TYPE_POPUPS, std::string()));
163 #if 0 157 EXPECT_EQ(CONTENT_SETTING_ASK,
164 // TODO(bauerb): Enable once geolocation settings are integrated into the
165 // HostContentSettingsMap.
166 EXPECT_EQ(CONTENT_SETTING_ALLOW,
167 map->GetContentSetting( 158 map->GetContentSetting(
168 url, url, CONTENT_SETTINGS_TYPE_GEOLOCATION, std::string())); 159 url, url, CONTENT_SETTINGS_TYPE_GEOLOCATION, std::string()));
169 #endif
170 EXPECT_EQ( 160 EXPECT_EQ(
171 CONTENT_SETTING_ASK, 161 CONTENT_SETTING_ASK,
172 map->GetContentSetting( 162 map->GetContentSetting(
173 url, url, CONTENT_SETTINGS_TYPE_NOTIFICATIONS, std::string())); 163 url, url, CONTENT_SETTINGS_TYPE_NOTIFICATIONS, std::string()));
174 } 164 }
175 165
176 private: 166 private:
177 Profile* profile_; 167 Profile* profile_;
178 }; 168 };
179 169
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 base::FilePath(kBarPath), 218 base::FilePath(kBarPath),
229 base::ASCIIToUTF16("2.3.4"), 219 base::ASCIIToUTF16("2.3.4"),
230 base::ASCIIToUTF16("bar")), 220 base::ASCIIToUTF16("bar")),
231 false); 221 false);
232 222
233 EXPECT_TRUE(RunExtensionTest("content_settings/getresourceidentifiers")) 223 EXPECT_TRUE(RunExtensionTest("content_settings/getresourceidentifiers"))
234 << message_; 224 << message_;
235 } 225 }
236 226
237 } // namespace extensions 227 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/api/content_settings.json » ('j') | chrome/common/extensions/api/content_settings.json » ('J')

Powered by Google App Engine
This is Rietveld 408576698