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

Unified Diff: content/browser/child_process_security_policy.cc

Issue 8496027: Enhance --enable-strict-site-isolation to prevent a site-isolated renderer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/child_process_security_policy.cc
===================================================================
--- content/browser/child_process_security_policy.cc (revision 109054)
+++ content/browser/child_process_security_policy.cc (working copy)
@@ -9,6 +9,7 @@
#include "base/platform_file.h"
#include "base/stl_util.h"
#include "base/string_util.h"
+#include "content/browser/site_instance.h"
#include "content/public/common/bindings_policy.h"
#include "content/public/common/url_constants.h"
#include "googleurl/src/gurl.h"
@@ -92,6 +93,17 @@
return false;
}
+ bool CanUseCookiesForOrigin(const GURL& gurl) {
+ if (origin_lock_.is_empty())
+ return true;
+ GURL site_gurl = SiteInstance::GetSiteForURL(NULL, gurl);
Charlie Reis 2011/11/10 01:09:26 Is NULL ok for the context? I think that means we
+ return origin_lock_ == site_gurl;
+ }
+
+ void LockToOrigin(const GURL& gurl) {
+ origin_lock_ = gurl.GetOrigin();
Charlie Reis 2011/11/10 01:09:26 Why use GetOrigin for one and GetSiteForURL for th
+ }
+
bool has_web_ui_bindings() const {
return enabled_bindings_ & content::BINDINGS_POLICY_WEB_UI;
}
@@ -118,6 +130,8 @@
bool can_read_raw_cookies_;
+ GURL origin_lock_;
+
DISALLOW_COPY_AND_ASSIGN(SecurityState);
};
@@ -443,3 +457,23 @@
return false;
return state->second->HasPermissionsForFile(file, permissions);
}
+
+bool ChildProcessSecurityPolicy::CanUseCookiesForOrigin(int child_id,
+ const GURL& gurl) {
+ base::AutoLock lock(lock_);
+ SecurityStateMap::iterator state = security_state_.find(child_id);
+ if (state == security_state_.end()) {
+ NOTREACHED();
+ return false;
+ }
+ return state->second->CanUseCookiesForOrigin(gurl);
+}
+
+void ChildProcessSecurityPolicy::LockToOrigin(int child_id, const GURL& gurl) {
+ DCHECK(!gurl.is_empty());
+ base::AutoLock lock(lock_);
+ SecurityStateMap::iterator state = security_state_.find(child_id);
+ DCHECK(state != security_state_.end());
+ state->second->LockToOrigin(gurl);
+}
+

Powered by Google App Engine
This is Rietveld 408576698