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

Side by Side Diff: chrome/browser/chrome_content_browser_client.cc

Issue 7008025: Apply third party cookie blocking to all kinds of cookies (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates 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
« no previous file with comments | « no previous file | chrome/browser/chrome_worker_message_filter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/chrome_content_browser_client.h" 5 #include "chrome/browser/chrome_content_browser_client.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/app/breakpad_mac.h" 8 #include "chrome/app/breakpad_mac.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/character_encoding.h" 10 #include "chrome/browser/character_encoding.h"
(...skipping 26 matching lines...) Expand all
37 #include "content/browser/plugin_process_host.h" 37 #include "content/browser/plugin_process_host.h"
38 #include "content/browser/renderer_host/browser_render_process_host.h" 38 #include "content/browser/renderer_host/browser_render_process_host.h"
39 #include "content/browser/renderer_host/render_view_host.h" 39 #include "content/browser/renderer_host/render_view_host.h"
40 #include "content/browser/resource_context.h" 40 #include "content/browser/resource_context.h"
41 #include "content/browser/site_instance.h" 41 #include "content/browser/site_instance.h"
42 #include "content/browser/tab_contents/tab_contents.h" 42 #include "content/browser/tab_contents/tab_contents.h"
43 #include "content/browser/worker_host/worker_process_host.h" 43 #include "content/browser/worker_host/worker_process_host.h"
44 #include "content/common/bindings_policy.h" 44 #include "content/common/bindings_policy.h"
45 #include "net/base/cookie_monster.h" 45 #include "net/base/cookie_monster.h"
46 #include "net/base/cookie_options.h" 46 #include "net/base/cookie_options.h"
47 #include "net/base/static_cookie_policy.h"
48 47
49 #if defined(OS_LINUX) 48 #if defined(OS_LINUX)
50 #include "base/linux_util.h" 49 #include "base/linux_util.h"
51 #include "chrome/browser/crash_handler_host_linux.h" 50 #include "chrome/browser/crash_handler_host_linux.h"
52 #endif // OS_LINUX 51 #endif // OS_LINUX
53 52
54 namespace { 53 namespace {
55 54
56 void InitRenderViewHostForExtensions(RenderViewHost* render_view_host) { 55 void InitRenderViewHostForExtensions(RenderViewHost* render_view_host) {
57 // Note that due to GetEffectiveURL(), even hosted apps will have a 56 // Note that due to GetEffectiveURL(), even hosted apps will have a
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 if (!g_browser_process->safe_browsing_detection_service()) 226 if (!g_browser_process->safe_browsing_detection_service())
228 command_line->AppendSwitch(switches::kDisableClientSidePhishingDetection); 227 command_line->AppendSwitch(switches::kDisableClientSidePhishingDetection);
229 } 228 }
230 } 229 }
231 230
232 std::string ChromeContentBrowserClient::GetApplicationLocale() { 231 std::string ChromeContentBrowserClient::GetApplicationLocale() {
233 return g_browser_process->GetApplicationLocale(); 232 return g_browser_process->GetApplicationLocale();
234 } 233 }
235 234
236 bool ChromeContentBrowserClient::AllowAppCache( 235 bool ChromeContentBrowserClient::AllowAppCache(
237 const GURL& manifest_url, const content::ResourceContext& context) { 236 const GURL& manifest_url,
237 const content::ResourceContext& context) {
238 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 238 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
239 ProfileIOData* io_data = 239 ProfileIOData* io_data =
240 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); 240 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL));
241 // FIXME(jochen): get the correct top-level origin.
241 ContentSetting setting = io_data->GetHostContentSettingsMap()-> 242 ContentSetting setting = io_data->GetHostContentSettingsMap()->
242 GetContentSetting(manifest_url, CONTENT_SETTINGS_TYPE_COOKIES, ""); 243 GetCookieContentSetting(manifest_url, manifest_url, true);
243 DCHECK(setting != CONTENT_SETTING_DEFAULT); 244 DCHECK(setting != CONTENT_SETTING_DEFAULT);
244 return setting != CONTENT_SETTING_BLOCK; 245 return setting != CONTENT_SETTING_BLOCK;
245 } 246 }
246 247
247 bool ChromeContentBrowserClient::AllowGetCookie( 248 bool ChromeContentBrowserClient::AllowGetCookie(
248 const GURL& url, 249 const GURL& url,
249 const GURL& first_party, 250 const GURL& first_party,
250 const net::CookieList& cookie_list, 251 const net::CookieList& cookie_list,
251 const content::ResourceContext& context, 252 const content::ResourceContext& context,
252 int render_process_id, 253 int render_process_id,
253 int render_view_id) { 254 int render_view_id) {
254 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 255 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
255 bool allow = true;
256 ProfileIOData* io_data = 256 ProfileIOData* io_data =
257 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); 257 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL));
258 if (io_data->GetHostContentSettingsMap()->BlockThirdPartyCookies()) { 258 ContentSetting setting = io_data->GetHostContentSettingsMap()->
259 bool strict = CommandLine::ForCurrentProcess()->HasSwitch( 259 GetCookieContentSetting(url, first_party, false);
260 switches::kBlockReadingThirdPartyCookies); 260 bool allow = setting == CONTENT_SETTING_ALLOW ||
261 net::StaticCookiePolicy policy(strict ? 261 setting == CONTENT_SETTING_SESSION_ONLY;
262 net::StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES :
263 net::StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES);
264 int rv = policy.CanGetCookies(url, first_party);
265 DCHECK_NE(net::ERR_IO_PENDING, rv);
266 if (rv != net::OK)
267 allow = false;
268 }
269
270 if (allow) {
271 ContentSetting setting = io_data->GetHostContentSettingsMap()->
272 GetContentSetting(url, CONTENT_SETTINGS_TYPE_COOKIES, "");
273 allow = setting == CONTENT_SETTING_ALLOW ||
274 setting == CONTENT_SETTING_SESSION_ONLY;
275 }
276 262
277 BrowserThread::PostTask( 263 BrowserThread::PostTask(
278 BrowserThread::UI, FROM_HERE, 264 BrowserThread::UI, FROM_HERE,
279 NewRunnableFunction( 265 NewRunnableFunction(
280 &TabSpecificContentSettings::CookiesRead, 266 &TabSpecificContentSettings::CookiesRead,
281 render_process_id, render_view_id, url, cookie_list, !allow)); 267 render_process_id, render_view_id, url, cookie_list, !allow));
282 return allow; 268 return allow;
283 } 269 }
284 270
285 bool ChromeContentBrowserClient::AllowSetCookie( 271 bool ChromeContentBrowserClient::AllowSetCookie(
286 const GURL& url, 272 const GURL& url,
287 const GURL& first_party, 273 const GURL& first_party,
288 const std::string& cookie_line, 274 const std::string& cookie_line,
289 const content::ResourceContext& context, 275 const content::ResourceContext& context,
290 int render_process_id, 276 int render_process_id,
291 int render_view_id, 277 int render_view_id,
292 net::CookieOptions* options) { 278 net::CookieOptions* options) {
293 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 279 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
294 bool allow = true;
295 ProfileIOData* io_data = 280 ProfileIOData* io_data =
296 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); 281 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL));
297 if (io_data->GetHostContentSettingsMap()->BlockThirdPartyCookies()) { 282 ContentSetting setting = io_data->GetHostContentSettingsMap()->
298 bool strict = CommandLine::ForCurrentProcess()->HasSwitch( 283 GetCookieContentSetting(url, first_party, true);
299 switches::kBlockReadingThirdPartyCookies);
300 net::StaticCookiePolicy policy(strict ?
301 net::StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES :
302 net::StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES);
303 int rv = policy.CanSetCookie(url, first_party, cookie_line);
304 if (rv != net::OK)
305 allow = false;
306 }
307 284
308 if (allow) { 285 if (setting == CONTENT_SETTING_SESSION_ONLY)
309 ContentSetting setting = io_data->GetHostContentSettingsMap()-> 286 options->set_force_session();
310 GetContentSetting(url, CONTENT_SETTINGS_TYPE_COOKIES, "");
311 287
312 if (setting == CONTENT_SETTING_SESSION_ONLY) 288 bool allow = setting == CONTENT_SETTING_ALLOW ||
313 options->set_force_session(); 289 setting == CONTENT_SETTING_SESSION_ONLY;
314
315 allow = setting == CONTENT_SETTING_ALLOW ||
316 setting == CONTENT_SETTING_SESSION_ONLY;
317 }
318 290
319 BrowserThread::PostTask( 291 BrowserThread::PostTask(
320 BrowserThread::UI, FROM_HERE, 292 BrowserThread::UI, FROM_HERE,
321 NewRunnableFunction( 293 NewRunnableFunction(
322 &TabSpecificContentSettings::CookieChanged, 294 &TabSpecificContentSettings::CookieChanged,
323 render_process_id, render_view_id, url, cookie_line, *options, 295 render_process_id, render_view_id, url, cookie_line, *options,
324 !allow)); 296 !allow));
325 return allow; 297 return allow;
326 } 298 }
327 299
(...skipping 10 matching lines...) Expand all
338 return PpapiCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); 310 return PpapiCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
339 311
340 if (process_type == switches::kGpuProcess) 312 if (process_type == switches::kGpuProcess)
341 return GpuCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); 313 return GpuCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
342 314
343 return -1; 315 return -1;
344 } 316 }
345 #endif 317 #endif
346 318
347 } // namespace chrome 319 } // namespace chrome
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chrome_worker_message_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698