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); |
+} |
+ |