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

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

Issue 10782030: Add content pack information to Extension. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 11 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 1332 matching lines...) Expand 10 before | Expand all | Expand 10 after
1343 } 1343 }
1344 1344
1345 bool Extension::can_be_incognito_enabled() const { 1345 bool Extension::can_be_incognito_enabled() const {
1346 return !is_platform_app(); 1346 return !is_platform_app();
1347 } 1347 }
1348 1348
1349 bool Extension::is_theme() const { 1349 bool Extension::is_theme() const {
1350 return manifest()->is_theme(); 1350 return manifest()->is_theme();
1351 } 1351 }
1352 1352
1353 ExtensionResource Extension::GetContentPackSiteList() const {
1354 if (content_pack_site_list_.empty())
1355 return ExtensionResource();
1356
1357 return GetResource(content_pack_site_list_);
1358 }
1359
1353 GURL Extension::GetBackgroundURL() const { 1360 GURL Extension::GetBackgroundURL() const {
1354 if (background_scripts_.empty()) 1361 if (background_scripts_.empty())
1355 return background_url_; 1362 return background_url_;
1356 return GetResourceURL(extension_filenames::kGeneratedBackgroundPageFilename); 1363 return GetResourceURL(extension_filenames::kGeneratedBackgroundPageFilename);
1357 } 1364 }
1358 1365
1359 Extension::RuntimeData::RuntimeData() {} 1366 Extension::RuntimeData::RuntimeData() {}
1360 Extension::RuntimeData::RuntimeData(const PermissionSet* active) 1367 Extension::RuntimeData::RuntimeData(const PermissionSet* active)
1361 : active_permissions_(active) {} 1368 : active_permissions_(active) {}
1362 Extension::RuntimeData::~RuntimeData() {} 1369 Extension::RuntimeData::~RuntimeData() {}
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1448 if (path_str.size() >= 2 && path_str[0] >= L'a' && path_str[0] <= L'z' && 1455 if (path_str.size() >= 2 && path_str[0] >= L'a' && path_str[0] <= L'z' &&
1449 path_str[1] == ':') 1456 path_str[1] == ':')
1450 path_str[0] += ('A' - 'a'); 1457 path_str[0] += ('A' - 'a');
1451 1458
1452 return FilePath(path_str); 1459 return FilePath(path_str);
1453 #else 1460 #else
1454 return path; 1461 return path;
1455 #endif 1462 #endif
1456 } 1463 }
1457 1464
1465 bool Extension::LoadManagedModeFeatures(string16* error) {
1466 if (!manifest_->HasKey(keys::kContentPack))
1467 return true;
1468 DictionaryValue* content_pack_value = NULL;
1469 if (!manifest_->GetDictionary(keys::kContentPack, &content_pack_value)) {
1470 *error = ASCIIToUTF16(errors::kInvalidContentPack);
1471 return false;
1472 }
1473
1474 if (!LoadManagedModeSites(content_pack_value, error))
1475 return false;
1476 if (!LoadManagedModeConfigurations(content_pack_value, error))
1477 return false;
1478
1479 return true;
1480 }
1481
1482 bool Extension::LoadManagedModeSites(
1483 const DictionaryValue* content_pack_value,
1484 string16* error) {
1485 if (!content_pack_value->HasKey(keys::kContentPackSites))
1486 return true;
1487
1488 FilePath::StringType site_list_str;
1489 if (!content_pack_value->GetString(keys::kContentPackSites, &site_list_str)) {
1490 *error = ASCIIToUTF16(errors::kInvalidContentPackSites);
1491 return false;
1492 }
1493
1494 content_pack_site_list_ = FilePath(site_list_str);
1495
1496 return true;
1497 }
1498
1499 bool Extension::LoadManagedModeConfigurations(
1500 const DictionaryValue* content_pack_value,
1501 string16* error) {
1502 NOTIMPLEMENTED();
1503 return true;
1504 }
1505
1458 // static 1506 // static
1459 bool Extension::IsTrustedId(const std::string& id) { 1507 bool Extension::IsTrustedId(const std::string& id) {
1460 // See http://b/4946060 for more details. 1508 // See http://b/4946060 for more details.
1461 return id == std::string("nckgahadagoaajjgafhacjanaoiihapd"); 1509 return id == std::string("nckgahadagoaajjgafhacjanaoiihapd");
1462 } 1510 }
1463 1511
1464 Extension::Extension(const FilePath& path, 1512 Extension::Extension(const FilePath& path,
1465 scoped_ptr<extensions::Manifest> manifest) 1513 scoped_ptr<extensions::Manifest> manifest)
1466 : manifest_version_(0), 1514 : manifest_version_(0),
1467 incognito_split_mode_(false), 1515 incognito_split_mode_(false),
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1574 1622
1575 if (!LoadSharedFeatures(api_permissions, error)) 1623 if (!LoadSharedFeatures(api_permissions, error))
1576 return false; 1624 return false;
1577 1625
1578 if (!LoadExtensionFeatures(&api_permissions, error)) 1626 if (!LoadExtensionFeatures(&api_permissions, error))
1579 return false; 1627 return false;
1580 1628
1581 if (!LoadThemeFeatures(error)) 1629 if (!LoadThemeFeatures(error))
1582 return false; 1630 return false;
1583 1631
1632 if (!LoadManagedModeFeatures(error))
1633 return false;
1634
1584 if (HasMultipleUISurfaces()) { 1635 if (HasMultipleUISurfaces()) {
1585 *error = ASCIIToUTF16(errors::kOneUISurfaceOnly); 1636 *error = ASCIIToUTF16(errors::kOneUISurfaceOnly);
1586 return false; 1637 return false;
1587 } 1638 }
1588 1639
1589 runtime_data_.SetActivePermissions(new PermissionSet( 1640 runtime_data_.SetActivePermissions(new PermissionSet(
1590 this, api_permissions, host_permissions)); 1641 this, api_permissions, host_permissions));
1591 required_permission_set_ = new PermissionSet( 1642 required_permission_set_ = new PermissionSet(
1592 this, api_permissions, host_permissions); 1643 this, api_permissions, host_permissions);
1593 optional_permission_set_ = new PermissionSet( 1644 optional_permission_set_ = new PermissionSet(
(...skipping 2454 matching lines...) Expand 10 before | Expand all | Expand 10 after
4048 4099
4049 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( 4100 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo(
4050 const Extension* extension, 4101 const Extension* extension,
4051 const PermissionSet* permissions, 4102 const PermissionSet* permissions,
4052 Reason reason) 4103 Reason reason)
4053 : reason(reason), 4104 : reason(reason),
4054 extension(extension), 4105 extension(extension),
4055 permissions(permissions) {} 4106 permissions(permissions) {}
4056 4107
4057 } // namespace extensions 4108 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension.h ('k') | chrome/common/extensions/extension_manifest_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698