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

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

Issue 10458063: Add sanbdoxed_pages to allow extension/app pages to be served in a sandboxed, unique origin (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 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 "chrome/common/extensions/extension.h" 5 #include "chrome/common/extensions/extension.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 return false; 519 return false;
520 } 520 }
521 521
522 bool Extension::HasWebAccessibleResources() const { 522 bool Extension::HasWebAccessibleResources() const {
523 if (web_accessible_resources_.size()) 523 if (web_accessible_resources_.size())
524 return true; 524 return true;
525 525
526 return false; 526 return false;
527 } 527 }
528 528
529 bool Extension::IsResourceSandboxed(const std::string& relative_path) const {
530 return sandboxed_resources_.find(relative_path) !=
531 sandboxed_resources_.end();
532 }
533
529 bool Extension::GenerateId(const std::string& input, std::string* output) { 534 bool Extension::GenerateId(const std::string& input, std::string* output) {
530 DCHECK(output); 535 DCHECK(output);
531 uint8 hash[Extension::kIdSize]; 536 uint8 hash[Extension::kIdSize];
532 crypto::SHA256HashString(input, hash, sizeof(hash)); 537 crypto::SHA256HashString(input, hash, sizeof(hash));
533 *output = StringToLowerASCII(base::HexEncode(hash, sizeof(hash))); 538 *output = StringToLowerASCII(base::HexEncode(hash, sizeof(hash)));
534 ConvertHexadecimalToIDAlphabet(output); 539 ConvertHexadecimalToIDAlphabet(output);
535 540
536 return true; 541 return true;
537 } 542 }
538 543
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
1273 const ExtensionAPIPermissionSet& api_permissions, 1278 const ExtensionAPIPermissionSet& api_permissions,
1274 string16* error) { 1279 string16* error) {
1275 if (!LoadDescription(error) || 1280 if (!LoadDescription(error) ||
1276 !LoadHomepageURL(error) || 1281 !LoadHomepageURL(error) ||
1277 !LoadUpdateURL(error) || 1282 !LoadUpdateURL(error) ||
1278 !LoadIcons(error) || 1283 !LoadIcons(error) ||
1279 !LoadCommands(error) || 1284 !LoadCommands(error) ||
1280 !LoadPlugins(error) || 1285 !LoadPlugins(error) ||
1281 !LoadNaClModules(error) || 1286 !LoadNaClModules(error) ||
1282 !LoadWebAccessibleResources(error) || 1287 !LoadWebAccessibleResources(error) ||
1288 !LoadSandboxedResources(error) ||
1283 !CheckRequirements(error) || 1289 !CheckRequirements(error) ||
1284 !LoadDefaultLocale(error) || 1290 !LoadDefaultLocale(error) ||
1285 !LoadOfflineEnabled(error) || 1291 !LoadOfflineEnabled(error) ||
1286 !LoadOptionsPage(error) || 1292 !LoadOptionsPage(error) ||
1287 // LoadBackgroundScripts() must be called before LoadBackgroundPage(). 1293 // LoadBackgroundScripts() must be called before LoadBackgroundPage().
1288 !LoadBackgroundScripts(error) || 1294 !LoadBackgroundScripts(error) ||
1289 !LoadBackgroundPage(api_permissions, error) || 1295 !LoadBackgroundPage(api_permissions, error) ||
1290 !LoadBackgroundPersistent(api_permissions, error) || 1296 !LoadBackgroundPersistent(api_permissions, error) ||
1291 !LoadBackgroundAllowJSAccess(api_permissions, error) || 1297 !LoadBackgroundAllowJSAccess(api_permissions, error) ||
1292 !LoadWebIntentServices(error)) 1298 !LoadWebIntentServices(error))
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
1564 return false; 1570 return false;
1565 } 1571 }
1566 if (relative_path[0] != '/') 1572 if (relative_path[0] != '/')
1567 relative_path = '/' + relative_path; 1573 relative_path = '/' + relative_path;
1568 web_accessible_resources_.insert(relative_path); 1574 web_accessible_resources_.insert(relative_path);
1569 } 1575 }
1570 1576
1571 return true; 1577 return true;
1572 } 1578 }
1573 1579
1580 bool Extension::LoadSandboxedResources(string16* error) {
1581 if (!manifest_->HasKey(keys::kSandboxedResources))
1582 return true;
1583 ListValue* list_value;
Aaron Boodman 2012/06/04 07:05:42 = NULL;
Mihai Parparita -not on Chrome 2012/06/05 04:32:40 Done (though I don't think it's necessary; we don'
1584 if (!manifest_->GetList(keys::kSandboxedResources, &list_value)) {
1585 *error = ASCIIToUTF16(errors::kInvalidSandboxedResourcesList);
1586 return false;
1587 }
1588 for (size_t i = 0; i < list_value->GetSize(); ++i) {
1589 std::string relative_path;
1590 if (!list_value->GetString(i, &relative_path)) {
1591 *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
1592 errors::kInvalidSandboxedResource, base::IntToString(i));
1593 return false;
1594 }
1595 if (relative_path[0] != '/')
1596 relative_path = '/' + relative_path;
1597 sandboxed_resources_.insert(relative_path);
1598 }
1599
1600 return true;
1601 }
1602
1574 // These are not actually persisted (they're only used by the store), but 1603 // These are not actually persisted (they're only used by the store), but
1575 // still validated. 1604 // still validated.
1576 bool Extension::CheckRequirements(string16* error) { 1605 bool Extension::CheckRequirements(string16* error) {
1577 if (!manifest_->HasKey(keys::kRequirements)) 1606 if (!manifest_->HasKey(keys::kRequirements))
1578 return true; 1607 return true;
1579 DictionaryValue* requirements_value = NULL; 1608 DictionaryValue* requirements_value = NULL;
1580 if (!manifest_->GetDictionary(keys::kRequirements, &requirements_value)) { 1609 if (!manifest_->GetDictionary(keys::kRequirements, &requirements_value)) {
1581 *error = ASCIIToUTF16(errors::kInvalidRequirements); 1610 *error = ASCIIToUTF16(errors::kInvalidRequirements);
1582 return false; 1611 return false;
1583 } 1612 }
(...skipping 2050 matching lines...) Expand 10 before | Expand all | Expand 10 after
3634 3663
3635 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( 3664 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo(
3636 const Extension* extension, 3665 const Extension* extension,
3637 const ExtensionPermissionSet* permissions, 3666 const ExtensionPermissionSet* permissions,
3638 Reason reason) 3667 Reason reason)
3639 : reason(reason), 3668 : reason(reason),
3640 extension(extension), 3669 extension(extension),
3641 permissions(permissions) {} 3670 permissions(permissions) {}
3642 3671
3643 } // namespace extensions 3672 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698