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

Side by Side Diff: chrome/browser/content_settings/content_settings_browsertest.cc

Issue 11275088: Remove implicit scoped_refptr operator T* Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 8 years, 1 month 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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/path_service.h" 6 #include "base/path_service.h"
7 #include "base/stringprintf.h" 7 #include "base/stringprintf.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/content_settings/cookie_settings.h" 9 #include "chrome/browser/content_settings/cookie_settings.h"
10 #include "chrome/browser/content_settings/host_content_settings_map.h" 10 #include "chrome/browser/content_settings/host_content_settings_map.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 CookieSettings::Factory::GetForProfile(browser()->profile())-> 147 CookieSettings::Factory::GetForProfile(browser()->profile())->
148 GetDefaultCookieSetting(NULL)); 148 GetDefaultCookieSetting(NULL));
149 } 149 }
150 150
151 // Verify that cookies can be allowed and set using exceptions for particular 151 // Verify that cookies can be allowed and set using exceptions for particular
152 // website(s) when all others are blocked. 152 // website(s) when all others are blocked.
153 IN_PROC_BROWSER_TEST_F(ContentSettingsTest, AllowCookiesUsingExceptions) { 153 IN_PROC_BROWSER_TEST_F(ContentSettingsTest, AllowCookiesUsingExceptions) {
154 ASSERT_TRUE(test_server()->Start()); 154 ASSERT_TRUE(test_server()->Start());
155 GURL url = test_server()->GetURL("files/setcookie.html"); 155 GURL url = test_server()->GetURL("files/setcookie.html");
156 CookieSettings* settings = 156 CookieSettings* settings =
157 CookieSettings::Factory::GetForProfile(browser()->profile()); 157 CookieSettings::Factory::GetForProfile(browser()->profile()).get();
158 settings->SetDefaultCookieSetting(CONTENT_SETTING_BLOCK); 158 settings->SetDefaultCookieSetting(CONTENT_SETTING_BLOCK);
159 159
160 ui_test_utils::NavigateToURL(browser(), url); 160 ui_test_utils::NavigateToURL(browser(), url);
161 ASSERT_TRUE(GetCookies(browser()->profile(), url).empty()); 161 ASSERT_TRUE(GetCookies(browser()->profile(), url).empty());
162 162
163 settings->SetCookieSetting( 163 settings->SetCookieSetting(
164 ContentSettingsPattern::FromURL(url), 164 ContentSettingsPattern::FromURL(url),
165 ContentSettingsPattern::Wildcard(), CONTENT_SETTING_ALLOW); 165 ContentSettingsPattern::Wildcard(), CONTENT_SETTING_ALLOW);
166 166
167 ui_test_utils::NavigateToURL(browser(), url); 167 ui_test_utils::NavigateToURL(browser(), url);
168 ASSERT_FALSE(GetCookies(browser()->profile(), url).empty()); 168 ASSERT_FALSE(GetCookies(browser()->profile(), url).empty());
169 } 169 }
170 170
171 // Verify that cookies can be blocked for a specific website using exceptions. 171 // Verify that cookies can be blocked for a specific website using exceptions.
172 IN_PROC_BROWSER_TEST_F(ContentSettingsTest, BlockCookiesUsingExceptions) { 172 IN_PROC_BROWSER_TEST_F(ContentSettingsTest, BlockCookiesUsingExceptions) {
173 ASSERT_TRUE(test_server()->Start()); 173 ASSERT_TRUE(test_server()->Start());
174 GURL url = test_server()->GetURL("files/setcookie.html"); 174 GURL url = test_server()->GetURL("files/setcookie.html");
175 CookieSettings* settings = 175 CookieSettings* settings =
176 CookieSettings::Factory::GetForProfile(browser()->profile()); 176 CookieSettings::Factory::GetForProfile(browser()->profile()).get();
177 settings->SetCookieSetting( 177 settings->SetCookieSetting(
178 ContentSettingsPattern::FromURL(url), 178 ContentSettingsPattern::FromURL(url),
179 ContentSettingsPattern::Wildcard(), CONTENT_SETTING_BLOCK); 179 ContentSettingsPattern::Wildcard(), CONTENT_SETTING_BLOCK);
180 180
181 ui_test_utils::NavigateToURL(browser(), url); 181 ui_test_utils::NavigateToURL(browser(), url);
182 ASSERT_TRUE(GetCookies(browser()->profile(), url).empty()); 182 ASSERT_TRUE(GetCookies(browser()->profile(), url).empty());
183 183
184 ASSERT_TRUE(https_server_.Start()); 184 ASSERT_TRUE(https_server_.Start());
185 GURL unblocked_url = https_server_.GetURL("files/cookie1.html"); 185 GURL unblocked_url = https_server_.GetURL("files/cookie1.html");
186 186
187 ui_test_utils::NavigateToURL(browser(), unblocked_url); 187 ui_test_utils::NavigateToURL(browser(), unblocked_url);
188 ASSERT_FALSE(GetCookies(browser()->profile(), unblocked_url).empty()); 188 ASSERT_FALSE(GetCookies(browser()->profile(), unblocked_url).empty());
189 } 189 }
190 190
191 // This fails on ChromeOS because kRestoreOnStartup is ignored and the startup 191 // This fails on ChromeOS because kRestoreOnStartup is ignored and the startup
192 // preference is always "continue where I left off. 192 // preference is always "continue where I left off.
193 #if !defined(OS_CHROMEOS) 193 #if !defined(OS_CHROMEOS)
194 194
195 // Verify that cookies can be allowed and set using exceptions for particular 195 // Verify that cookies can be allowed and set using exceptions for particular
196 // website(s) only for a session when all others are blocked. 196 // website(s) only for a session when all others are blocked.
197 IN_PROC_BROWSER_TEST_F(ContentSettingsTest, 197 IN_PROC_BROWSER_TEST_F(ContentSettingsTest,
198 PRE_AllowCookiesForASessionUsingExceptions) { 198 PRE_AllowCookiesForASessionUsingExceptions) {
199 // NOTE: don't use test_server here, since we need the port to be the same 199 // NOTE: don't use test_server here, since we need the port to be the same
200 // across the restart. 200 // across the restart.
201 GURL url = URLRequestMockHTTPJob::GetMockUrl( 201 GURL url = URLRequestMockHTTPJob::GetMockUrl(
202 FilePath(FILE_PATH_LITERAL("setcookie.html"))); 202 FilePath(FILE_PATH_LITERAL("setcookie.html")));
203 CookieSettings* settings = 203 CookieSettings* settings =
204 CookieSettings::Factory::GetForProfile(browser()->profile()); 204 CookieSettings::Factory::GetForProfile(browser()->profile()).get();
205 settings->SetDefaultCookieSetting(CONTENT_SETTING_BLOCK); 205 settings->SetDefaultCookieSetting(CONTENT_SETTING_BLOCK);
206 206
207 ui_test_utils::NavigateToURL(browser(), url); 207 ui_test_utils::NavigateToURL(browser(), url);
208 ASSERT_TRUE(GetCookies(browser()->profile(), url).empty()); 208 ASSERT_TRUE(GetCookies(browser()->profile(), url).empty());
209 209
210 settings->SetCookieSetting( 210 settings->SetCookieSetting(
211 ContentSettingsPattern::FromURL(url), 211 ContentSettingsPattern::FromURL(url),
212 ContentSettingsPattern::Wildcard(), CONTENT_SETTING_SESSION_ONLY); 212 ContentSettingsPattern::Wildcard(), CONTENT_SETTING_SESSION_ONLY);
213 ui_test_utils::NavigateToURL(browser(), url); 213 ui_test_utils::NavigateToURL(browser(), url);
214 ASSERT_FALSE(GetCookies(browser()->profile(), url).empty()); 214 ASSERT_FALSE(GetCookies(browser()->profile(), url).empty());
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 427
428 content::RenderViewHost* host = 428 content::RenderViewHost* host =
429 chrome::GetActiveWebContents(browser())->GetRenderViewHost(); 429 chrome::GetActiveWebContents(browser())->GetRenderViewHost();
430 host->Send(new ChromeViewMsg_LoadBlockedPlugins( 430 host->Send(new ChromeViewMsg_LoadBlockedPlugins(
431 host->GetRoutingID(), std::string())); 431 host->GetRoutingID(), std::string()));
432 432
433 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); 433 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
434 } 434 }
435 435
436 #endif // !defined(USE_AURA) 436 #endif // !defined(USE_AURA)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698