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

Side by Side Diff: content/browser/child_process_security_policy.cc

Issue 9146028: Define the public interface for content browser SiteInstance. This interface is implemented by th... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 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
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 "content/browser/child_process_security_policy.h" 5 #include "content/browser/child_process_security_policy.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/platform_file.h" 10 #include "base/platform_file.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "content/browser/site_instance_impl.h"
13 #include "content/public/browser/content_browser_client.h" 14 #include "content/public/browser/content_browser_client.h"
14 #include "content/browser/site_instance.h"
15 #include "content/public/common/bindings_policy.h" 15 #include "content/public/common/bindings_policy.h"
16 #include "content/public/common/url_constants.h" 16 #include "content/public/common/url_constants.h"
17 #include "googleurl/src/gurl.h" 17 #include "googleurl/src/gurl.h"
18 #include "net/url_request/url_request.h" 18 #include "net/url_request/url_request.h"
19 19
20 using content::SiteInstance;
21
20 static const int kReadFilePermissions = 22 static const int kReadFilePermissions =
21 base::PLATFORM_FILE_OPEN | 23 base::PLATFORM_FILE_OPEN |
22 base::PLATFORM_FILE_READ | 24 base::PLATFORM_FILE_READ |
23 base::PLATFORM_FILE_EXCLUSIVE_READ | 25 base::PLATFORM_FILE_EXCLUSIVE_READ |
24 base::PLATFORM_FILE_ASYNC; 26 base::PLATFORM_FILE_ASYNC;
25 27
26 static const int kEnumerateDirectoryPermissions = 28 static const int kEnumerateDirectoryPermissions =
27 kReadFilePermissions | 29 kReadFilePermissions |
28 base::PLATFORM_FILE_ENUMERATE; 30 base::PLATFORM_FILE_ENUMERATE;
29 31
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 last_path = current_path; 98 last_path = current_path;
97 current_path = current_path.DirName(); 99 current_path = current_path.DirName();
98 } 100 }
99 101
100 return false; 102 return false;
101 } 103 }
102 104
103 bool CanUseCookiesForOrigin(const GURL& gurl) { 105 bool CanUseCookiesForOrigin(const GURL& gurl) {
104 if (origin_lock_.is_empty()) 106 if (origin_lock_.is_empty())
105 return true; 107 return true;
106 GURL site_gurl = SiteInstance::GetSiteForURL(NULL, gurl); 108 GURL site_gurl = SiteInstanceImpl::GetSiteForURL(NULL, gurl);
107 return origin_lock_ == site_gurl; 109 return origin_lock_ == site_gurl;
108 } 110 }
109 111
110 void LockToOrigin(const GURL& gurl) { 112 void LockToOrigin(const GURL& gurl) {
111 origin_lock_ = gurl; 113 origin_lock_ = gurl;
112 } 114 }
113 115
114 bool has_web_ui_bindings() const { 116 bool has_web_ui_bindings() const {
115 return enabled_bindings_ & content::BINDINGS_POLICY_WEB_UI; 117 return enabled_bindings_ & content::BINDINGS_POLICY_WEB_UI;
116 } 118 }
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 const GURL& gurl) { 473 const GURL& gurl) {
472 base::AutoLock lock(lock_); 474 base::AutoLock lock(lock_);
473 SecurityStateMap::iterator state = security_state_.find(child_id); 475 SecurityStateMap::iterator state = security_state_.find(child_id);
474 if (state == security_state_.end()) 476 if (state == security_state_.end())
475 return false; 477 return false;
476 return state->second->CanUseCookiesForOrigin(gurl); 478 return state->second->CanUseCookiesForOrigin(gurl);
477 } 479 }
478 480
479 void ChildProcessSecurityPolicy::LockToOrigin(int child_id, const GURL& gurl) { 481 void ChildProcessSecurityPolicy::LockToOrigin(int child_id, const GURL& gurl) {
480 // "gurl" can be currently empty in some cases, such as file://blah. 482 // "gurl" can be currently empty in some cases, such as file://blah.
481 DCHECK(SiteInstance::GetSiteForURL(NULL, gurl) == gurl); 483 DCHECK(SiteInstanceImpl::GetSiteForURL(NULL, gurl) == gurl);
482 base::AutoLock lock(lock_); 484 base::AutoLock lock(lock_);
483 SecurityStateMap::iterator state = security_state_.find(child_id); 485 SecurityStateMap::iterator state = security_state_.find(child_id);
484 DCHECK(state != security_state_.end()); 486 DCHECK(state != security_state_.end());
485 state->second->LockToOrigin(gurl); 487 state->second->LockToOrigin(gurl);
486 } 488 }
487 489
OLDNEW
« no previous file with comments | « content/browser/browsing_instance.cc ('k') | content/browser/debugger/render_view_devtools_agent_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698