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

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

Issue 8805010: Fix Manifest leak in Extension::InitFromValue. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years 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
« no previous file with comments | « no previous file | tools/heapcheck/suppressions.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <algorithm> 7 #include <algorithm>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after
1378 1378
1379 GURL Extension::GetBaseURLFromExtensionId(const std::string& extension_id) { 1379 GURL Extension::GetBaseURLFromExtensionId(const std::string& extension_id) {
1380 return GURL(std::string(chrome::kExtensionScheme) + 1380 return GURL(std::string(chrome::kExtensionScheme) +
1381 chrome::kStandardSchemeSeparator + extension_id + "/"); 1381 chrome::kStandardSchemeSeparator + extension_id + "/");
1382 } 1382 }
1383 1383
1384 bool Extension::InitFromValue(extensions::Manifest* manifest, int flags, 1384 bool Extension::InitFromValue(extensions::Manifest* manifest, int flags,
1385 std::string* error) { 1385 std::string* error) {
1386 DCHECK(error); 1386 DCHECK(error);
1387 base::AutoLock auto_lock(runtime_data_lock_); 1387 base::AutoLock auto_lock(runtime_data_lock_);
1388 manifest_.reset(manifest);
1388 1389
1389 if (!manifest->ValidateManifest(error)) 1390 if (!manifest->ValidateManifest(error))
1390 return false; 1391 return false;
1391 1392
1392 // When strict error checks are enabled, make URL pattern parsing strict. 1393 // When strict error checks are enabled, make URL pattern parsing strict.
1393 URLPattern::ParseOption parse_strictness = 1394 URLPattern::ParseOption parse_strictness =
1394 (flags & STRICT_ERROR_CHECKS ? URLPattern::ERROR_ON_PORTS 1395 (flags & STRICT_ERROR_CHECKS ? URLPattern::ERROR_ON_PORTS
1395 : URLPattern::IGNORE_PORTS); 1396 : URLPattern::IGNORE_PORTS);
1396 1397
1397 // Initialize permissions with an empty, default permission set. 1398 // Initialize permissions with an empty, default permission set.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 // reloading the extension. 1440 // reloading the extension.
1440 id_ = Extension::GenerateIdForPath(path()); 1441 id_ = Extension::GenerateIdForPath(path());
1441 if (id_.empty()) { 1442 if (id_.empty()) {
1442 NOTREACHED() << "Could not create ID from path."; 1443 NOTREACHED() << "Could not create ID from path.";
1443 return false; 1444 return false;
1444 } 1445 }
1445 } 1446 }
1446 1447
1447 creation_flags_ = flags; 1448 creation_flags_ = flags;
1448 1449
1449 manifest_.reset(manifest);
1450
1451 // Initialize the URL. 1450 // Initialize the URL.
1452 extension_url_ = Extension::GetBaseURLFromExtensionId(id()); 1451 extension_url_ = Extension::GetBaseURLFromExtensionId(id());
1453 1452
1454 // Initialize version. 1453 // Initialize version.
1455 std::string version_str; 1454 std::string version_str;
1456 if (!manifest->GetString(keys::kVersion, &version_str)) { 1455 if (!manifest->GetString(keys::kVersion, &version_str)) {
1457 *error = errors::kInvalidVersion; 1456 *error = errors::kInvalidVersion;
1458 return false; 1457 return false;
1459 } 1458 }
1460 version_.reset(Version::GetVersionFromString(version_str)); 1459 version_.reset(Version::GetVersionFromString(version_str));
(...skipping 1539 matching lines...) Expand 10 before | Expand all | Expand 10 after
3000 already_disabled(false), 2999 already_disabled(false),
3001 extension(extension) {} 3000 extension(extension) {}
3002 3001
3003 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( 3002 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo(
3004 const Extension* extension, 3003 const Extension* extension,
3005 const ExtensionPermissionSet* permissions, 3004 const ExtensionPermissionSet* permissions,
3006 Reason reason) 3005 Reason reason)
3007 : reason(reason), 3006 : reason(reason),
3008 extension(extension), 3007 extension(extension),
3009 permissions(permissions) {} 3008 permissions(permissions) {}
OLDNEW
« no previous file with comments | « no previous file | tools/heapcheck/suppressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698