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

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

Issue 10833014: Coverity fixlet. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 1592 matching lines...) Expand 10 before | Expand all | Expand 10 after
1603 return false; 1603 return false;
1604 } 1604 }
1605 for (size_t i = 0; i < list_value->GetSize(); ++i) { 1605 for (size_t i = 0; i < list_value->GetSize(); ++i) {
1606 std::string relative_path; 1606 std::string relative_path;
1607 if (!list_value->GetString(i, &relative_path)) { 1607 if (!list_value->GetString(i, &relative_path)) {
1608 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( 1608 *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
1609 errors::kInvalidWebAccessibleResource, base::IntToString(i)); 1609 errors::kInvalidWebAccessibleResource, base::IntToString(i));
1610 return false; 1610 return false;
1611 } 1611 }
1612 URLPattern pattern(URLPattern::SCHEME_EXTENSION); 1612 URLPattern pattern(URLPattern::SCHEME_EXTENSION);
1613 pattern.Parse(extension_url_.spec()); 1613 if (pattern.Parse(extension_url_.spec()) != URLPattern::PARSE_SUCCESS) {
1614 *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
1615 errors::kInvalidURLPatternError, extension_url_.spec());
1616 return false;
1617 }
1614 while (relative_path[0] == '/') 1618 while (relative_path[0] == '/')
1615 relative_path = relative_path.substr(1, relative_path.length() - 1); 1619 relative_path = relative_path.substr(1, relative_path.length() - 1);
1616 pattern.SetPath(pattern.path() + relative_path); 1620 pattern.SetPath(pattern.path() + relative_path);
1617 web_accessible_resources_.AddPattern(pattern); 1621 web_accessible_resources_.AddPattern(pattern);
1618 } 1622 }
1619 1623
1620 return true; 1624 return true;
1621 } 1625 }
1622 1626
1623 bool Extension::LoadSandboxedPages(string16* error) { 1627 bool Extension::LoadSandboxedPages(string16* error) {
1624 if (!manifest_->HasPath(keys::kSandboxedPages)) 1628 if (!manifest_->HasPath(keys::kSandboxedPages))
1625 return true; 1629 return true;
1626 1630
1627 ListValue* list_value = NULL; 1631 ListValue* list_value = NULL;
1628 if (!manifest_->GetList(keys::kSandboxedPages, &list_value)) { 1632 if (!manifest_->GetList(keys::kSandboxedPages, &list_value)) {
1629 *error = ASCIIToUTF16(errors::kInvalidSandboxedPagesList); 1633 *error = ASCIIToUTF16(errors::kInvalidSandboxedPagesList);
1630 return false; 1634 return false;
1631 } 1635 }
1632 for (size_t i = 0; i < list_value->GetSize(); ++i) { 1636 for (size_t i = 0; i < list_value->GetSize(); ++i) {
1633 std::string relative_path; 1637 std::string relative_path;
1634 if (!list_value->GetString(i, &relative_path)) { 1638 if (!list_value->GetString(i, &relative_path)) {
1635 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( 1639 *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
1636 errors::kInvalidSandboxedPage, base::IntToString(i)); 1640 errors::kInvalidSandboxedPage, base::IntToString(i));
1637 return false; 1641 return false;
1638 } 1642 }
1639 URLPattern pattern(URLPattern::SCHEME_EXTENSION); 1643 URLPattern pattern(URLPattern::SCHEME_EXTENSION);
1640 pattern.Parse(extension_url_.spec()); 1644 if (pattern.Parse(extension_url_.spec()) != URLPattern::PARSE_SUCCESS) {
1645 *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
1646 errors::kInvalidURLPatternError, extension_url_.spec());
1647 return false;
1648 }
1641 while (relative_path[0] == '/') 1649 while (relative_path[0] == '/')
1642 relative_path = relative_path.substr(1, relative_path.length() - 1); 1650 relative_path = relative_path.substr(1, relative_path.length() - 1);
1643 pattern.SetPath(pattern.path() + relative_path); 1651 pattern.SetPath(pattern.path() + relative_path);
1644 sandboxed_pages_.AddPattern(pattern); 1652 sandboxed_pages_.AddPattern(pattern);
1645 } 1653 }
1646 1654
1647 if (manifest_->HasPath(keys::kSandboxedPagesCSP)) { 1655 if (manifest_->HasPath(keys::kSandboxedPagesCSP)) {
1648 if (!manifest_->GetString( 1656 if (!manifest_->GetString(
1649 keys::kSandboxedPagesCSP, &sandboxed_pages_content_security_policy_)) { 1657 keys::kSandboxedPagesCSP, &sandboxed_pages_content_security_policy_)) {
1650 *error = ASCIIToUTF16(errors::kInvalidSandboxedPagesCSP); 1658 *error = ASCIIToUTF16(errors::kInvalidSandboxedPagesCSP);
(...skipping 2219 matching lines...) Expand 10 before | Expand all | Expand 10 after
3870 3878
3871 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( 3879 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo(
3872 const Extension* extension, 3880 const Extension* extension,
3873 const PermissionSet* permissions, 3881 const PermissionSet* permissions,
3874 Reason reason) 3882 Reason reason)
3875 : reason(reason), 3883 : reason(reason),
3876 extension(extension), 3884 extension(extension),
3877 permissions(permissions) {} 3885 permissions(permissions) {}
3878 3886
3879 } // namespace extensions 3887 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698