OLD | NEW |
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 static const int kReadFilePermissions = | 20 static const int kReadFilePermissions = |
21 base::PLATFORM_FILE_OPEN | | 21 base::PLATFORM_FILE_OPEN | |
22 base::PLATFORM_FILE_READ | | 22 base::PLATFORM_FILE_READ | |
23 base::PLATFORM_FILE_EXCLUSIVE_READ | | 23 base::PLATFORM_FILE_EXCLUSIVE_READ | |
24 base::PLATFORM_FILE_ASYNC; | 24 base::PLATFORM_FILE_ASYNC; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 last_path = current_path; | 96 last_path = current_path; |
97 current_path = current_path.DirName(); | 97 current_path = current_path.DirName(); |
98 } | 98 } |
99 | 99 |
100 return false; | 100 return false; |
101 } | 101 } |
102 | 102 |
103 bool CanUseCookiesForOrigin(const GURL& gurl) { | 103 bool CanUseCookiesForOrigin(const GURL& gurl) { |
104 if (origin_lock_.is_empty()) | 104 if (origin_lock_.is_empty()) |
105 return true; | 105 return true; |
106 GURL site_gurl = SiteInstance::GetSiteForURL(NULL, gurl); | 106 GURL site_gurl = content::SiteInstance::GetSiteForURL(NULL, gurl); |
107 return origin_lock_ == site_gurl; | 107 return origin_lock_ == site_gurl; |
108 } | 108 } |
109 | 109 |
110 void LockToOrigin(const GURL& gurl) { | 110 void LockToOrigin(const GURL& gurl) { |
111 origin_lock_ = gurl; | 111 origin_lock_ = gurl; |
112 } | 112 } |
113 | 113 |
114 bool has_web_ui_bindings() const { | 114 bool has_web_ui_bindings() const { |
115 return enabled_bindings_ & content::BINDINGS_POLICY_WEB_UI; | 115 return enabled_bindings_ & content::BINDINGS_POLICY_WEB_UI; |
116 } | 116 } |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 const GURL& gurl) { | 471 const GURL& gurl) { |
472 base::AutoLock lock(lock_); | 472 base::AutoLock lock(lock_); |
473 SecurityStateMap::iterator state = security_state_.find(child_id); | 473 SecurityStateMap::iterator state = security_state_.find(child_id); |
474 if (state == security_state_.end()) | 474 if (state == security_state_.end()) |
475 return false; | 475 return false; |
476 return state->second->CanUseCookiesForOrigin(gurl); | 476 return state->second->CanUseCookiesForOrigin(gurl); |
477 } | 477 } |
478 | 478 |
479 void ChildProcessSecurityPolicy::LockToOrigin(int child_id, const GURL& gurl) { | 479 void ChildProcessSecurityPolicy::LockToOrigin(int child_id, const GURL& gurl) { |
480 // "gurl" can be currently empty in some cases, such as file://blah. | 480 // "gurl" can be currently empty in some cases, such as file://blah. |
481 DCHECK(SiteInstance::GetSiteForURL(NULL, gurl) == gurl); | 481 DCHECK(content::SiteInstance::GetSiteForURL(NULL, gurl) == gurl); |
482 base::AutoLock lock(lock_); | 482 base::AutoLock lock(lock_); |
483 SecurityStateMap::iterator state = security_state_.find(child_id); | 483 SecurityStateMap::iterator state = security_state_.find(child_id); |
484 DCHECK(state != security_state_.end()); | 484 DCHECK(state != security_state_.end()); |
485 state->second->LockToOrigin(gurl); | 485 state->second->LockToOrigin(gurl); |
486 } | 486 } |
487 | 487 |
OLD | NEW |