| OLD | NEW |
| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 // TODO(nick): https://crbug.com/651534 blob: and filesystem: schemes embed | 332 // TODO(nick): https://crbug.com/651534 blob: and filesystem: schemes embed |
| 333 // other origins, so we should not treat them as web safe. Remove callers of | 333 // other origins, so we should not treat them as web safe. Remove callers of |
| 334 // IsWebSafeScheme(), and then eliminate the next two lines. | 334 // IsWebSafeScheme(), and then eliminate the next two lines. |
| 335 RegisterWebSafeScheme(url::kBlobScheme); | 335 RegisterWebSafeScheme(url::kBlobScheme); |
| 336 RegisterWebSafeScheme(url::kFileSystemScheme); | 336 RegisterWebSafeScheme(url::kFileSystemScheme); |
| 337 | 337 |
| 338 // We know about the following pseudo schemes and treat them specially. | 338 // We know about the following pseudo schemes and treat them specially. |
| 339 RegisterPseudoScheme(url::kAboutScheme); | 339 RegisterPseudoScheme(url::kAboutScheme); |
| 340 RegisterPseudoScheme(url::kJavaScriptScheme); | 340 RegisterPseudoScheme(url::kJavaScriptScheme); |
| 341 RegisterPseudoScheme(kViewSourceScheme); | 341 RegisterPseudoScheme(kViewSourceScheme); |
| 342 RegisterPseudoScheme(kHttpSuboriginScheme); | 342 RegisterPseudoScheme(url::kHttpSuboriginScheme); |
| 343 RegisterPseudoScheme(kHttpsSuboriginScheme); | 343 RegisterPseudoScheme(url::kHttpsSuboriginScheme); |
| 344 } | 344 } |
| 345 | 345 |
| 346 ChildProcessSecurityPolicyImpl::~ChildProcessSecurityPolicyImpl() { | 346 ChildProcessSecurityPolicyImpl::~ChildProcessSecurityPolicyImpl() { |
| 347 } | 347 } |
| 348 | 348 |
| 349 // static | 349 // static |
| 350 ChildProcessSecurityPolicy* ChildProcessSecurityPolicy::GetInstance() { | 350 ChildProcessSecurityPolicy* ChildProcessSecurityPolicy::GetInstance() { |
| 351 return ChildProcessSecurityPolicyImpl::GetInstance(); | 351 return ChildProcessSecurityPolicyImpl::GetInstance(); |
| 352 } | 352 } |
| 353 | 353 |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 return state->second->CanCommitURL(url); | 699 return state->second->CanCommitURL(url); |
| 700 } | 700 } |
| 701 } | 701 } |
| 702 | 702 |
| 703 bool ChildProcessSecurityPolicyImpl::CanSetAsOriginHeader(int child_id, | 703 bool ChildProcessSecurityPolicyImpl::CanSetAsOriginHeader(int child_id, |
| 704 const GURL& url) { | 704 const GURL& url) { |
| 705 if (!url.is_valid()) | 705 if (!url.is_valid()) |
| 706 return false; // Can't set invalid URLs as origin headers. | 706 return false; // Can't set invalid URLs as origin headers. |
| 707 | 707 |
| 708 // Suborigin URLs are a special case and are allowed to be an origin header. | 708 // Suborigin URLs are a special case and are allowed to be an origin header. |
| 709 if (url.scheme() == kHttpSuboriginScheme || | 709 if (url.scheme() == url::kHttpSuboriginScheme || |
| 710 url.scheme() == kHttpsSuboriginScheme) { | 710 url.scheme() == url::kHttpsSuboriginScheme) { |
| 711 DCHECK(IsPseudoScheme(url.scheme())); | 711 DCHECK(IsPseudoScheme(url.scheme())); |
| 712 return true; | 712 return true; |
| 713 } | 713 } |
| 714 | 714 |
| 715 // If this process can commit |url|, it can use |url| as an origin for | 715 // If this process can commit |url|, it can use |url| as an origin for |
| 716 // outbound requests. | 716 // outbound requests. |
| 717 if (CanCommitURL(child_id, url)) | 717 if (CanCommitURL(child_id, url)) |
| 718 return true; | 718 return true; |
| 719 | 719 |
| 720 // Allow schemes which may come from scripts executing in isolated worlds; | 720 // Allow schemes which may come from scripts executing in isolated worlds; |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 base::AutoLock lock(lock_); | 971 base::AutoLock lock(lock_); |
| 972 | 972 |
| 973 SecurityStateMap::iterator state = security_state_.find(child_id); | 973 SecurityStateMap::iterator state = security_state_.find(child_id); |
| 974 if (state == security_state_.end()) | 974 if (state == security_state_.end()) |
| 975 return false; | 975 return false; |
| 976 | 976 |
| 977 return state->second->can_send_midi_sysex(); | 977 return state->second->can_send_midi_sysex(); |
| 978 } | 978 } |
| 979 | 979 |
| 980 } // namespace content | 980 } // namespace content |
| OLD | NEW |