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

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

Issue 15950011: content: Move kViewSourceScheme constant into content namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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) 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/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 RegisterWebSafeScheme(chrome::kHttpsScheme); 263 RegisterWebSafeScheme(chrome::kHttpsScheme);
264 RegisterWebSafeScheme(chrome::kFtpScheme); 264 RegisterWebSafeScheme(chrome::kFtpScheme);
265 RegisterWebSafeScheme(chrome::kDataScheme); 265 RegisterWebSafeScheme(chrome::kDataScheme);
266 RegisterWebSafeScheme("feed"); 266 RegisterWebSafeScheme("feed");
267 RegisterWebSafeScheme(chrome::kBlobScheme); 267 RegisterWebSafeScheme(chrome::kBlobScheme);
268 RegisterWebSafeScheme(chrome::kFileSystemScheme); 268 RegisterWebSafeScheme(chrome::kFileSystemScheme);
269 269
270 // We know about the following pseudo schemes and treat them specially. 270 // We know about the following pseudo schemes and treat them specially.
271 RegisterPseudoScheme(chrome::kAboutScheme); 271 RegisterPseudoScheme(chrome::kAboutScheme);
272 RegisterPseudoScheme(chrome::kJavaScriptScheme); 272 RegisterPseudoScheme(chrome::kJavaScriptScheme);
273 RegisterPseudoScheme(chrome::kViewSourceScheme); 273 RegisterPseudoScheme(kViewSourceScheme);
274 } 274 }
275 275
276 ChildProcessSecurityPolicyImpl::~ChildProcessSecurityPolicyImpl() { 276 ChildProcessSecurityPolicyImpl::~ChildProcessSecurityPolicyImpl() {
277 web_safe_schemes_.clear(); 277 web_safe_schemes_.clear();
278 pseudo_schemes_.clear(); 278 pseudo_schemes_.clear();
279 STLDeleteContainerPairSecondPointers(security_state_.begin(), 279 STLDeleteContainerPairSecondPointers(security_state_.begin(),
280 security_state_.end()); 280 security_state_.end());
281 security_state_.clear(); 281 security_state_.clear();
282 } 282 }
283 283
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 362
363 if (!url.is_valid()) 363 if (!url.is_valid())
364 return; // Can't grant the capability to request invalid URLs. 364 return; // Can't grant the capability to request invalid URLs.
365 365
366 if (IsWebSafeScheme(url.scheme())) 366 if (IsWebSafeScheme(url.scheme()))
367 return; // The scheme has already been whitelisted for every child process. 367 return; // The scheme has already been whitelisted for every child process.
368 368
369 if (IsPseudoScheme(url.scheme())) { 369 if (IsPseudoScheme(url.scheme())) {
370 // The view-source scheme is a special case of a pseudo-URL that eventually 370 // The view-source scheme is a special case of a pseudo-URL that eventually
371 // results in requesting its embedded URL. 371 // results in requesting its embedded URL.
372 if (url.SchemeIs(chrome::kViewSourceScheme)) { 372 if (url.SchemeIs(kViewSourceScheme)) {
373 // URLs with the view-source scheme typically look like: 373 // URLs with the view-source scheme typically look like:
374 // view-source:http://www.google.com/a 374 // view-source:http://www.google.com/a
375 // In order to request these URLs, the child_id needs to be able to 375 // In order to request these URLs, the child_id needs to be able to
376 // request the embedded URL. 376 // request the embedded URL.
377 GrantRequestURL(child_id, GURL(url.path())); 377 GrantRequestURL(child_id, GURL(url.path()));
378 } 378 }
379 379
380 return; // Can't grant the capability to request pseudo schemes. 380 return; // Can't grant the capability to request pseudo schemes.
381 } 381 }
382 382
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 529
530 if (IsDisabledScheme(url.scheme())) 530 if (IsDisabledScheme(url.scheme()))
531 return false; // The scheme is disabled by policy. 531 return false; // The scheme is disabled by policy.
532 532
533 if (IsWebSafeScheme(url.scheme())) 533 if (IsWebSafeScheme(url.scheme()))
534 return true; // The scheme has been white-listed for every child process. 534 return true; // The scheme has been white-listed for every child process.
535 535
536 if (IsPseudoScheme(url.scheme())) { 536 if (IsPseudoScheme(url.scheme())) {
537 // There are a number of special cases for pseudo schemes. 537 // There are a number of special cases for pseudo schemes.
538 538
539 if (url.SchemeIs(chrome::kViewSourceScheme)) { 539 if (url.SchemeIs(kViewSourceScheme)) {
540 // A view-source URL is allowed if the child process is permitted to 540 // A view-source URL is allowed if the child process is permitted to
541 // request the embedded URL. Careful to avoid pointless recursion. 541 // request the embedded URL. Careful to avoid pointless recursion.
542 GURL child_url(url.path()); 542 GURL child_url(url.path());
543 if (child_url.SchemeIs(chrome::kViewSourceScheme) && 543 if (child_url.SchemeIs(kViewSourceScheme) &&
544 url.SchemeIs(chrome::kViewSourceScheme)) 544 url.SchemeIs(kViewSourceScheme))
545 return false; 545 return false;
546 546
547 return CanRequestURL(child_id, child_url); 547 return CanRequestURL(child_id, child_url);
548 } 548 }
549 549
550 if (LowerCaseEqualsASCII(url.spec(), kAboutBlankURL)) 550 if (LowerCaseEqualsASCII(url.spec(), kAboutBlankURL))
551 return true; // Every child process can request <about:blank>. 551 return true; // Every child process can request <about:blank>.
552 552
553 // URLs like <about:memory> and <about:crash> shouldn't be requestable by 553 // URLs like <about:memory> and <about:crash> shouldn't be requestable by
554 // any child process. Also, this case covers <javascript:...>, which should 554 // any child process. Also, this case covers <javascript:...>, which should
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 int permission) { 701 int permission) {
702 base::AutoLock lock(lock_); 702 base::AutoLock lock(lock_);
703 703
704 SecurityStateMap::iterator state = security_state_.find(child_id); 704 SecurityStateMap::iterator state = security_state_.find(child_id);
705 if (state == security_state_.end()) 705 if (state == security_state_.end())
706 return false; 706 return false;
707 return state->second->HasPermissionsForFileSystem(filesystem_id, permission); 707 return state->second->HasPermissionsForFileSystem(filesystem_id, permission);
708 } 708 }
709 709
710 } // namespace content 710 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_url_handler_impl.cc ('k') | content/browser/child_process_security_policy_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698