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

Side by Side Diff: chrome/common/extensions/extension.cc

Issue 10828067: Extension resources should only load in contexts the extension has permission to access. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: NaCl Created 8 years, 4 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 "chrome/common/extensions/extension.h" 5 #include "chrome/common/extensions/extension.h"
6 6
7 #include <ostream> 7 #include <ostream>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 return ResourceMatches(web_accessible_resources_, relative_path); 528 return ResourceMatches(web_accessible_resources_, relative_path);
529 } 529 }
530 530
531 bool Extension::HasWebAccessibleResources() const { 531 bool Extension::HasWebAccessibleResources() const {
532 if (web_accessible_resources_.size()) 532 if (web_accessible_resources_.size())
533 return true; 533 return true;
534 534
535 return false; 535 return false;
536 } 536 }
537 537
538 bool Extension::HasNaClModules() const {
539 if (nacl_modules_.size())
540 return true;
541
542 return false;
543 }
544
538 bool Extension::IsSandboxedPage(const std::string& relative_path) const { 545 bool Extension::IsSandboxedPage(const std::string& relative_path) const {
539 return ResourceMatches(sandboxed_pages_, relative_path); 546 return ResourceMatches(sandboxed_pages_, relative_path);
540 } 547 }
541 548
549 bool Extension::IsResourceNaClModule(const std::string& resource) const {
550 GURL url = extension_url_.Resolve(resource);
551 for (std::vector<NaClModuleInfo>::const_iterator it = nacl_modules_.begin();
552 it != nacl_modules_.end(); it++) {
553 if (it->url == url)
554 return true;
555 }
556 return false;
557 }
558
542 559
543 std::string Extension::GetResourceContentSecurityPolicy( 560 std::string Extension::GetResourceContentSecurityPolicy(
544 const std::string& relative_path) const { 561 const std::string& relative_path) const {
545 return IsSandboxedPage(relative_path) ? 562 return IsSandboxedPage(relative_path) ?
546 sandboxed_pages_content_security_policy_ : content_security_policy_; 563 sandboxed_pages_content_security_policy_ : content_security_policy_;
547 } 564 }
548 565
549 bool Extension::GenerateId(const std::string& input, std::string* output) { 566 bool Extension::GenerateId(const std::string& input, std::string* output) {
550 DCHECK(output); 567 DCHECK(output);
551 uint8 hash[Extension::kIdSize]; 568 uint8 hash[Extension::kIdSize];
(...skipping 3332 matching lines...) Expand 10 before | Expand all | Expand 10 after
3884 3901
3885 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( 3902 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo(
3886 const Extension* extension, 3903 const Extension* extension,
3887 const PermissionSet* permissions, 3904 const PermissionSet* permissions,
3888 Reason reason) 3905 Reason reason)
3889 : reason(reason), 3906 : reason(reason),
3890 extension(extension), 3907 extension(extension),
3891 permissions(permissions) {} 3908 permissions(permissions) {}
3892 3909
3893 } // namespace extensions 3910 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698