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

Unified Diff: chrome/browser/chrome_content_browser_client.cc

Issue 6995013: More progress towards removing content settings code from the content layer. We can't use Cookie... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix net_unittests Created 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chrome_content_browser_client.cc
===================================================================
--- chrome/browser/chrome_content_browser_client.cc (revision 84586)
+++ chrome/browser/chrome_content_browser_client.cc (working copy)
@@ -29,9 +29,13 @@
#include "chrome/common/pref_names.h"
#include "content/browser/renderer_host/browser_render_process_host.h"
#include "content/browser/renderer_host/render_view_host.h"
+#include "content/browser/renderer_host/render_view_host_notification_task.h"
#include "content/browser/resource_context.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/browser/worker_host/worker_process_host.h"
+#include "net/base/cookie_monster.h"
+#include "net/base/cookie_options.h"
+#include "net/base/static_cookie_policy.h"
#if defined(OS_LINUX)
#include "base/linux_util.h"
@@ -183,13 +187,87 @@
}
bool ChromeContentBrowserClient::AllowAppCache(
- const GURL& manifest_url, const content::ResourceContext* context) {
- ContentSetting setting = context->host_content_settings_map()->
+ const GURL& manifest_url, const content::ResourceContext& context) {
+ ContentSetting setting = context.host_content_settings_map()->
GetContentSetting(manifest_url, CONTENT_SETTINGS_TYPE_COOKIES, "");
DCHECK(setting != CONTENT_SETTING_DEFAULT);
return setting != CONTENT_SETTING_BLOCK;
}
+bool ChromeContentBrowserClient::AllowGetCookie(
+ const GURL& url,
+ const GURL& first_party,
+ const net::CookieList& cookie_list,
+ const content::ResourceContext& context,
+ int render_process_id,
+ int render_view_id) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ bool allow = true;
+ if (context.host_content_settings_map()->BlockThirdPartyCookies()) {
+ bool strict = CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kBlockReadingThirdPartyCookies);
+ net::StaticCookiePolicy policy(strict ?
+ net::StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES :
+ net::StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES);
+ int rv = policy.CanGetCookies(url, first_party);
+ DCHECK_NE(net::ERR_IO_PENDING, rv);
+ if (rv != net::OK)
+ allow = false;
+ }
+
+ if (allow) {
+ ContentSetting setting = context.host_content_settings_map()->
+ GetContentSetting(url, CONTENT_SETTINGS_TYPE_COOKIES, "");
+ allow = setting == CONTENT_SETTING_ALLOW ||
+ setting == CONTENT_SETTING_SESSION_ONLY;
+ }
+
+ CallRenderViewHostContentSettingsDelegate(
+ render_process_id, render_view_id,
+ &RenderViewHostDelegate::ContentSettings::OnCookiesRead,
+ url, cookie_list, !allow);
+ return allow;
+}
+
+bool ChromeContentBrowserClient::AllowSetCookie(
+ const GURL& url,
+ const GURL& first_party,
+ const std::string& cookie_line,
+ net::CookieOptions* options,
willchan no longer on Chromium 2011/05/10 18:36:56 Nit: maybe this should be last? It looks like ever
jam 2011/05/10 19:27:22 Done.
+ const content::ResourceContext& context,
+ int render_process_id,
+ int render_view_id) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ bool allow = true;
+ if (context.host_content_settings_map()->BlockThirdPartyCookies()) {
+ bool strict = CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kBlockReadingThirdPartyCookies);
+ net::StaticCookiePolicy policy(strict ?
+ net::StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES :
+ net::StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES);
+ int rv = policy.CanSetCookie(url, first_party, cookie_line);
+ if (rv != net::OK)
+ allow = false;
+ }
+
+ if (allow) {
+ ContentSetting setting = context.host_content_settings_map()->
+ GetContentSetting(url, CONTENT_SETTINGS_TYPE_COOKIES, "");
+
+ if (setting == CONTENT_SETTING_SESSION_ONLY)
+ options->set_force_session();
+
+ allow = setting == CONTENT_SETTING_ALLOW ||
+ setting == CONTENT_SETTING_SESSION_ONLY;
+ }
+
+ CallRenderViewHostContentSettingsDelegate(
+ render_process_id, render_view_id,
+ &RenderViewHostDelegate::ContentSettings::OnCookieChanged,
+ url, cookie_line, *options, !allow);
+ return allow;
+}
+
#if defined(OS_LINUX)
int ChromeContentBrowserClient::GetCrashSignalFD(
const std::string& process_type) {

Powered by Google App Engine
This is Rietveld 408576698