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

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

Issue 11273049: Revert 164120 - content/browser: Move more files into the content namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_impl.h" 5 #include "content/browser/child_process_security_policy_impl.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/browser/site_instance_impl.h"
14 #include "content/public/browser/content_browser_client.h" 14 #include "content/public/browser/content_browser_client.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/base/net_util.h" 18 #include "net/base/net_util.h"
19 #include "net/url_request/url_request.h" 19 #include "net/url_request/url_request.h"
20 #include "webkit/fileapi/isolated_context.h" 20 #include "webkit/fileapi/isolated_context.h"
21 21
22 namespace content { 22 using content::ChildProcessSecurityPolicy;
23 using content::SiteInstance;
23 24
24 namespace { 25 namespace {
25 26
26 const int kReadFilePermissions = 27 const int kReadFilePermissions =
27 base::PLATFORM_FILE_OPEN | 28 base::PLATFORM_FILE_OPEN |
28 base::PLATFORM_FILE_READ | 29 base::PLATFORM_FILE_READ |
29 base::PLATFORM_FILE_EXCLUSIVE_READ | 30 base::PLATFORM_FILE_EXCLUSIVE_READ |
30 base::PLATFORM_FILE_ASYNC; 31 base::PLATFORM_FILE_ASYNC;
31 32
32 const int kWriteFilePermissions = 33 const int kWriteFilePermissions =
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 return true; 161 return true;
161 GURL site_gurl = SiteInstanceImpl::GetSiteForURL(NULL, gurl); 162 GURL site_gurl = SiteInstanceImpl::GetSiteForURL(NULL, gurl);
162 return origin_lock_ == site_gurl; 163 return origin_lock_ == site_gurl;
163 } 164 }
164 165
165 void LockToOrigin(const GURL& gurl) { 166 void LockToOrigin(const GURL& gurl) {
166 origin_lock_ = gurl; 167 origin_lock_ = gurl;
167 } 168 }
168 169
169 bool has_web_ui_bindings() const { 170 bool has_web_ui_bindings() const {
170 return enabled_bindings_ & BINDINGS_POLICY_WEB_UI; 171 return enabled_bindings_ & content::BINDINGS_POLICY_WEB_UI;
171 } 172 }
172 173
173 bool can_read_raw_cookies() const { 174 bool can_read_raw_cookies() const {
174 return can_read_raw_cookies_; 175 return can_read_raw_cookies_;
175 } 176 }
176 177
177 private: 178 private:
178 typedef std::map<std::string, bool> SchemeMap; 179 typedef std::map<std::string, bool> SchemeMap;
179 180
180 typedef int FilePermissionFlags; // bit-set of PlatformFileFlags 181 typedef int FilePermissionFlags; // bit-set of PlatformFileFlags
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 state->second->GrantScheme(scheme); 418 state->second->GrantScheme(scheme);
418 } 419 }
419 420
420 void ChildProcessSecurityPolicyImpl::GrantWebUIBindings(int child_id) { 421 void ChildProcessSecurityPolicyImpl::GrantWebUIBindings(int child_id) {
421 base::AutoLock lock(lock_); 422 base::AutoLock lock(lock_);
422 423
423 SecurityStateMap::iterator state = security_state_.find(child_id); 424 SecurityStateMap::iterator state = security_state_.find(child_id);
424 if (state == security_state_.end()) 425 if (state == security_state_.end())
425 return; 426 return;
426 427
427 state->second->GrantBindings(BINDINGS_POLICY_WEB_UI); 428 state->second->GrantBindings(content::BINDINGS_POLICY_WEB_UI);
428 429
429 // Web UI bindings need the ability to request chrome: URLs. 430 // Web UI bindings need the ability to request chrome: URLs.
430 state->second->GrantScheme(chrome::kChromeUIScheme); 431 state->second->GrantScheme(chrome::kChromeUIScheme);
431 432
432 // Web UI pages can contain links to file:// URLs. 433 // Web UI pages can contain links to file:// URLs.
433 state->second->GrantScheme(chrome::kFileScheme); 434 state->second->GrantScheme(chrome::kFileScheme);
434 } 435 }
435 436
436 void ChildProcessSecurityPolicyImpl::GrantReadRawCookies(int child_id) { 437 void ChildProcessSecurityPolicyImpl::GrantReadRawCookies(int child_id) {
437 base::AutoLock lock(lock_); 438 base::AutoLock lock(lock_);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 481
481 if (LowerCaseEqualsASCII(url.spec(), chrome::kAboutBlankURL)) 482 if (LowerCaseEqualsASCII(url.spec(), chrome::kAboutBlankURL))
482 return true; // Every child process can request <about:blank>. 483 return true; // Every child process can request <about:blank>.
483 484
484 // URLs like <about:memory> and <about:crash> shouldn't be requestable by 485 // URLs like <about:memory> and <about:crash> shouldn't be requestable by
485 // any child process. Also, this case covers <javascript:...>, which should 486 // any child process. Also, this case covers <javascript:...>, which should
486 // be handled internally by the process and not kicked up to the browser. 487 // be handled internally by the process and not kicked up to the browser.
487 return false; 488 return false;
488 } 489 }
489 490
490 if (!GetContentClient()->browser()->IsHandledURL(url) && 491 if (!content::GetContentClient()->browser()->IsHandledURL(url) &&
491 !net::URLRequest::IsHandledURL(url)) { 492 !net::URLRequest::IsHandledURL(url)) {
492 return true; // This URL request is destined for ShellExecute. 493 return true; // This URL request is destined for ShellExecute.
493 } 494 }
494 495
495 { 496 {
496 base::AutoLock lock(lock_); 497 base::AutoLock lock(lock_);
497 498
498 SecurityStateMap::iterator state = security_state_.find(child_id); 499 SecurityStateMap::iterator state = security_state_.find(child_id);
499 if (state == security_state_.end()) 500 if (state == security_state_.end())
500 return false; 501 return false;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 int child_id, 622 int child_id,
622 const std::string& filesystem_id, 623 const std::string& filesystem_id,
623 int permission) { 624 int permission) {
624 base::AutoLock lock(lock_); 625 base::AutoLock lock(lock_);
625 626
626 SecurityStateMap::iterator state = security_state_.find(child_id); 627 SecurityStateMap::iterator state = security_state_.find(child_id);
627 if (state == security_state_.end()) 628 if (state == security_state_.end())
628 return false; 629 return false;
629 return state->second->HasPermissionsForFileSystem(filesystem_id, permission); 630 return state->second->HasPermissionsForFileSystem(filesystem_id, permission);
630 } 631 }
631
632 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/child_process_security_policy_impl.h ('k') | content/browser/child_process_security_policy_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698