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

Side by Side Diff: chrome/browser/extensions/extensions_service.cc

Issue 4687005: Track permissions granted to extensions in prefs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix mac test failure Created 10 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/browser/extensions/extensions_service.h" 5 #include "chrome/browser/extensions/extensions_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 340
341 if (!extension) { 341 if (!extension) {
342 ReportExtensionLoadError(extension_path, error); 342 ReportExtensionLoadError(extension_path, error);
343 return; 343 return;
344 } 344 }
345 345
346 // Report this as an installed extension so that it gets remembered in the 346 // Report this as an installed extension so that it gets remembered in the
347 // prefs. 347 // prefs.
348 BrowserThread::PostTask( 348 BrowserThread::PostTask(
349 BrowserThread::UI, FROM_HERE, 349 BrowserThread::UI, FROM_HERE,
350 NewRunnableMethod(frontend_, &ExtensionsService::OnExtensionInstalled, 350 NewRunnableMethod(frontend_,
351 extension, true)); 351 &ExtensionsService::OnExtensionInstalled,
352 extension));
352 } 353 }
353 354
354 void ExtensionsServiceBackend::ReportExtensionLoadError( 355 void ExtensionsServiceBackend::ReportExtensionLoadError(
355 const FilePath& extension_path, const std::string &error) { 356 const FilePath& extension_path, const std::string &error) {
356 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 357 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
357 BrowserThread::PostTask( 358 BrowserThread::PostTask(
358 BrowserThread::UI, FROM_HERE, 359 BrowserThread::UI, FROM_HERE,
359 NewRunnableMethod( 360 NewRunnableMethod(
360 frontend_, 361 frontend_,
361 &ExtensionsService::ReportExtensionLoadError, extension_path, 362 &ExtensionsService::ReportExtensionLoadError, extension_path,
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 CheckForExternalUpdates(); 638 CheckForExternalUpdates();
638 639
639 // TODO(erikkay) this should probably be deferred as well. 640 // TODO(erikkay) this should probably be deferred as well.
640 GarbageCollectExtensions(); 641 GarbageCollectExtensions();
641 } 642 }
642 643
643 void ExtensionsService::InstallExtension(const FilePath& extension_path) { 644 void ExtensionsService::InstallExtension(const FilePath& extension_path) {
644 scoped_refptr<CrxInstaller> installer( 645 scoped_refptr<CrxInstaller> installer(
645 new CrxInstaller(this, // frontend 646 new CrxInstaller(this, // frontend
646 NULL)); // no client (silent install) 647 NULL)); // no client (silent install)
647 installer->set_allow_privilege_increase(true);
648 installer->InstallCrx(extension_path); 648 installer->InstallCrx(extension_path);
649 } 649 }
650 650
651 namespace { 651 namespace {
652 // TODO(akalin): Put this somewhere where both crx_installer.cc and 652 // TODO(akalin): Put this somewhere where both crx_installer.cc and
653 // this file can use it. 653 // this file can use it.
654 void DeleteFileHelper(const FilePath& path, bool recursive) { 654 void DeleteFileHelper(const FilePath& path, bool recursive) {
655 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 655 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
656 file_util::Delete(path, recursive); 656 file_util::Delete(path, recursive);
657 } 657 }
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 extension); 936 extension);
937 extensions_.erase(iter); 937 extensions_.erase(iter);
938 938
939 ExtensionDOMUI::UnregisterChromeURLOverrides(profile_, 939 ExtensionDOMUI::UnregisterChromeURLOverrides(profile_,
940 extension->GetChromeURLOverrides()); 940 extension->GetChromeURLOverrides());
941 941
942 NotifyExtensionUnloaded(extension); 942 NotifyExtensionUnloaded(extension);
943 UpdateActiveExtensionsInCrashReporter(); 943 UpdateActiveExtensionsInCrashReporter();
944 } 944 }
945 945
946 void ExtensionsService::GrantPermissions(const Extension* extension) {
947 CHECK(extension);
948
949 // We only maintain the granted permissions prefs for INTERNAL extensions.
950 CHECK(extension->location() == Extension::INTERNAL);
951
952 ExtensionExtent effective_hosts = extension->GetEffectiveHostPermissions();
953 extension_prefs_->AddGrantedPermissions(extension->id(),
954 extension->HasFullPermissions(),
955 extension->api_permissions(),
956 effective_hosts);
957 }
958
959 void ExtensionsService::GrantPermissionsAndEnableExtension(
960 const Extension* extension) {
961 CHECK(extension);
962 GrantPermissions(extension);
963 extension_prefs_->SetDidExtensionEscalatePermissions(extension, false);
964 EnableExtension(extension->id());
965 }
966
946 void ExtensionsService::LoadExtension(const FilePath& extension_path) { 967 void ExtensionsService::LoadExtension(const FilePath& extension_path) {
947 BrowserThread::PostTask( 968 BrowserThread::PostTask(
948 BrowserThread::FILE, FROM_HERE, 969 BrowserThread::FILE, FROM_HERE,
949 NewRunnableMethod( 970 NewRunnableMethod(
950 backend_.get(), 971 backend_.get(),
951 &ExtensionsServiceBackend::LoadSingleExtension, 972 &ExtensionsServiceBackend::LoadSingleExtension,
952 extension_path, scoped_refptr<ExtensionsService>(this))); 973 extension_path, scoped_refptr<ExtensionsService>(this)));
953 } 974 }
954 975
955 void ExtensionsService::LoadComponentExtensions() { 976 void ExtensionsService::LoadComponentExtensions() {
(...skipping 12 matching lines...) Expand all
968 it->root_directory, 989 it->root_directory,
969 Extension::COMPONENT, 990 Extension::COMPONENT,
970 *static_cast<DictionaryValue*>(manifest.get()), 991 *static_cast<DictionaryValue*>(manifest.get()),
971 true, // require key 992 true, // require key
972 &error)); 993 &error));
973 if (!extension.get()) { 994 if (!extension.get()) {
974 NOTREACHED() << error; 995 NOTREACHED() << error;
975 return; 996 return;
976 } 997 }
977 998
978 OnExtensionLoaded(extension, false); // Don't allow privilege increase. 999 OnExtensionLoaded(extension);
979 } 1000 }
980 } 1001 }
981 1002
982 void ExtensionsService::LoadAllExtensions() { 1003 void ExtensionsService::LoadAllExtensions() {
983 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1004 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
984 1005
985 base::TimeTicks start_time = base::TimeTicks::Now(); 1006 base::TimeTicks start_time = base::TimeTicks::Now();
986 1007
987 // Load any component extensions. 1008 // Load any component extensions.
988 LoadComponentExtensions(); 1009 LoadComponentExtensions();
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadPackagedApp", packaged_app_count); 1134 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadPackagedApp", packaged_app_count);
1114 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadExtension", extension_count); 1135 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadExtension", extension_count);
1115 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadUserScript", user_script_count); 1136 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadUserScript", user_script_count);
1116 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadTheme", theme_count); 1137 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadTheme", theme_count);
1117 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadExternal", external_count); 1138 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadExternal", external_count);
1118 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadPageAction", page_action_count); 1139 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadPageAction", page_action_count);
1119 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadBrowserAction", 1140 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadBrowserAction",
1120 browser_action_count); 1141 browser_action_count);
1121 } 1142 }
1122 1143
1123
1124 void ExtensionsService::LoadInstalledExtension(const ExtensionInfo& info, 1144 void ExtensionsService::LoadInstalledExtension(const ExtensionInfo& info,
1125 bool write_to_prefs) { 1145 bool write_to_prefs) {
1126 std::string error; 1146 std::string error;
1127 scoped_refptr<const Extension> extension(NULL); 1147 scoped_refptr<const Extension> extension(NULL);
1128 if (!extension_prefs_->IsExtensionAllowedByPolicy(info.extension_id)) { 1148 if (!extension_prefs_->IsExtensionAllowedByPolicy(info.extension_id)) {
1129 error = errors::kDisabledByPolicy; 1149 error = errors::kDisabledByPolicy;
1130 } else if (info.extension_manifest.get()) { 1150 } else if (info.extension_manifest.get()) {
1131 bool require_key = info.extension_location != Extension::LOAD; 1151 bool require_key = info.extension_location != Extension::LOAD;
1132 extension = Extension::Create( 1152 extension = Extension::Create(
1133 info.extension_path, info.extension_location, *info.extension_manifest, 1153 info.extension_path, info.extension_location, *info.extension_manifest,
1134 require_key, &error); 1154 require_key, &error);
1135 } else { 1155 } else {
1136 error = errors::kManifestUnreadable; 1156 error = errors::kManifestUnreadable;
1137 } 1157 }
1138 1158
1139 if (!extension) { 1159 if (!extension) {
1140 ReportExtensionLoadError(info.extension_path, 1160 ReportExtensionLoadError(info.extension_path,
1141 error, 1161 error,
1142 NotificationType::EXTENSION_INSTALL_ERROR, 1162 NotificationType::EXTENSION_INSTALL_ERROR,
1143 false); 1163 false);
1144 return; 1164 return;
1145 } 1165 }
1146 1166
1147 if (write_to_prefs) 1167 if (write_to_prefs)
1148 extension_prefs_->UpdateManifest(extension); 1168 extension_prefs_->UpdateManifest(extension);
1149 1169
1150 OnExtensionLoaded(extension, true); 1170 OnExtensionLoaded(extension);
1151 1171
1152 if (Extension::IsExternalLocation(info.extension_location)) { 1172 if (Extension::IsExternalLocation(info.extension_location)) {
1153 BrowserThread::PostTask( 1173 BrowserThread::PostTask(
1154 BrowserThread::FILE, FROM_HERE, 1174 BrowserThread::FILE, FROM_HERE,
1155 NewRunnableMethod( 1175 NewRunnableMethod(
1156 backend_.get(), 1176 backend_.get(),
1157 &ExtensionsServiceBackend::CheckExternalUninstall, 1177 &ExtensionsServiceBackend::CheckExternalUninstall,
1158 scoped_refptr<ExtensionsService>(this), 1178 scoped_refptr<ExtensionsService>(this),
1159 info.extension_id)); 1179 info.extension_id));
1160 } 1180 }
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1516 updater_->Start(); 1536 updater_->Start();
1517 } 1537 }
1518 1538
1519 ready_ = true; 1539 ready_ = true;
1520 NotificationService::current()->Notify( 1540 NotificationService::current()->Notify(
1521 NotificationType::EXTENSIONS_READY, 1541 NotificationType::EXTENSIONS_READY,
1522 Source<Profile>(profile_), 1542 Source<Profile>(profile_),
1523 NotificationService::NoDetails()); 1543 NotificationService::NoDetails());
1524 } 1544 }
1525 1545
1526 void ExtensionsService::OnExtensionLoaded(const Extension* extension, 1546 void ExtensionsService::OnExtensionLoaded(const Extension* extension) {
1527 bool allow_privilege_increase) {
1528 // Ensure extension is deleted unless we transfer ownership. 1547 // Ensure extension is deleted unless we transfer ownership.
1529 scoped_refptr<const Extension> scoped_extension(extension); 1548 scoped_refptr<const Extension> scoped_extension(extension);
1530 1549
1531 // The extension is now loaded, remove its data from unloaded extension map. 1550 // The extension is now loaded, remove its data from unloaded extension map.
1532 unloaded_extension_paths_.erase(extension->id()); 1551 unloaded_extension_paths_.erase(extension->id());
1533 1552
1534 // If the extension was disabled for a reload, then enable it. 1553 // If the extension was disabled for a reload, then enable it.
1535 if (disabled_extension_paths_.erase(extension->id()) > 0) 1554 if (disabled_extension_paths_.erase(extension->id()) > 0)
1536 EnableExtension(extension->id()); 1555 EnableExtension(extension->id());
1537 1556
1538 // TODO(aa): Need to re-evaluate this branch. Does this still make sense now 1557 // Check if the extension's privileges have changed and disable the extension
1539 // that extensions are enabled by default? 1558 // if necessary.
1540 if (extensions_enabled() || 1559 DisableIfPrivilegeIncrease(extension);
1541 extension->is_theme() ||
1542 extension->location() == Extension::LOAD ||
1543 extension->location() == Extension::COMPONENT ||
1544 Extension::IsExternalLocation(extension->location())) {
1545 const Extension* old = GetExtensionByIdInternal(extension->id(),
1546 true, true);
1547 if (old) {
1548 // CrxInstaller should have guaranteed that we aren't downgrading.
1549 CHECK(extension->version()->CompareTo(*(old->version())) >= 0);
1550 1560
1551 bool allow_silent_upgrade = 1561 switch (extension_prefs_->GetExtensionState(extension->id())) {
1552 allow_privilege_increase || !Extension::IsPrivilegeIncrease( 1562 case Extension::ENABLED:
1553 old, extension); 1563 extensions_.push_back(scoped_extension);
1554 1564
1555 // Extensions get upgraded if silent upgrades are allowed, otherwise 1565 NotifyExtensionLoaded(extension);
1556 // they get disabled.
1557 if (allow_silent_upgrade) {
1558 SetBeingUpgraded(old, true);
1559 SetBeingUpgraded(extension, true);
1560 }
1561 1566
1562 // To upgrade an extension in place, unload the old one and 1567 ExtensionDOMUI::RegisterChromeURLOverrides(
1563 // then load the new one. 1568 profile_, extension->GetChromeURLOverrides());
1564 UnloadExtension(old->id()); 1569 break;
1565 old = NULL; 1570 case Extension::DISABLED:
1566 1571 disabled_extensions_.push_back(scoped_extension);
1567 if (!allow_silent_upgrade) { 1572 NotificationService::current()->Notify(
1568 // Extension has changed permissions significantly. Disable it. We 1573 NotificationType::EXTENSION_UPDATE_DISABLED,
1569 // send a notification below. 1574 Source<Profile>(profile_),
1570 extension_prefs_->SetExtensionState(extension, Extension::DISABLED); 1575 Details<const Extension>(extension));
1571 extension_prefs_->SetDidExtensionEscalatePermissions(extension, true); 1576 break;
1572 } 1577 default:
1573 } 1578 NOTREACHED();
1574 1579 break;
1575 switch (extension_prefs_->GetExtensionState(extension->id())) {
1576 case Extension::ENABLED:
1577 extensions_.push_back(scoped_extension);
1578
1579 NotifyExtensionLoaded(extension);
1580
1581 ExtensionDOMUI::RegisterChromeURLOverrides(profile_,
1582 extension->GetChromeURLOverrides());
1583 break;
1584 case Extension::DISABLED:
1585 disabled_extensions_.push_back(scoped_extension);
1586 NotificationService::current()->Notify(
1587 NotificationType::EXTENSION_UPDATE_DISABLED,
1588 Source<Profile>(profile_),
1589 Details<const Extension>(extension));
1590 break;
1591 default:
1592 NOTREACHED();
1593 break;
1594 }
1595 } 1580 }
1596 1581
1597 SetBeingUpgraded(extension, false); 1582 SetBeingUpgraded(extension, false);
1598 1583
1599 UpdateActiveExtensionsInCrashReporter(); 1584 UpdateActiveExtensionsInCrashReporter();
1600 1585
1601 if (profile_->GetTemplateURLModel()) 1586 if (profile_->GetTemplateURLModel())
1602 profile_->GetTemplateURLModel()->RegisterExtensionKeyword(extension); 1587 profile_->GetTemplateURLModel()->RegisterExtensionKeyword(extension);
1603 1588
1604 // Load the icon for omnibox-enabled extensions so it will be ready to display 1589 // Load the icon for omnibox-enabled extensions so it will be ready to display
1605 // in the URL bar. 1590 // in the URL bar.
1606 if (!extension->omnibox_keyword().empty()) { 1591 if (!extension->omnibox_keyword().empty()) {
1607 omnibox_popup_icon_manager_.LoadIcon(extension); 1592 omnibox_popup_icon_manager_.LoadIcon(extension);
1608 omnibox_icon_manager_.LoadIcon(extension); 1593 omnibox_icon_manager_.LoadIcon(extension);
1609 } 1594 }
1610 } 1595 }
1611 1596
1597 void ExtensionsService::DisableIfPrivilegeIncrease(const Extension* extension) {
1598 // We keep track of all permissions the user has granted each extension.
1599 // This allows extensions to gracefully support backwards compatibility
1600 // by including unknown permissions in their manifests. When the user
1601 // installs the extension, only the recognized permissions are recorded.
1602 // When the unknown permissions become recognized (e.g., through browser
1603 // upgrade), we can prompt the user to accept these new permissions.
1604 // Extensions can also silently upgrade to less permissions, and then
1605 // silently upgrade to a version that adds these permissions back.
1606 //
1607 // For example, pretend that Chrome 10 includes a permission "omnibox"
1608 // for an API that adds suggestions to the omnibox. An extension can
1609 // maintain backwards compatibility while still having "omnibox" in the
1610 // manifest. If a user installs the extension on Chrome 9, the browser
1611 // will record the permissions it recognized, not including "omnibox."
1612 // When upgrading to Chrome 10, "omnibox" will be recognized and Chrome
1613 // will disable the extension and prompt the user to approve the increase
1614 // in privileges. The extension could then release a new version that
1615 // removes the "omnibox" permission. When the user upgrades, Chrome will
1616 // still remember that "omnibox" had been granted, so that if the
1617 // extension once again includes "omnibox" in an upgrade, the extension
1618 // can upgrade without requiring this user's approval.
1619 const Extension* old = GetExtensionByIdInternal(extension->id(),
1620 true, true);
1621 bool granted_full_access;
1622 std::set<std::string> granted_apis;
1623 ExtensionExtent granted_extent;
1624
1625 bool is_extension_upgrade = old != NULL;
1626 bool is_privilege_increase = false;
1627
1628 // We only record the granted permissions for INTERNAL extensions, since
1629 // they can't silently increase privileges.
1630 if (extension->location() == Extension::INTERNAL) {
1631 // Add all the recognized permissions if the granted permissions list
1632 // hasn't been initialized yet.
1633 if (!extension_prefs_->GetGrantedPermissions(extension->id(),
1634 &granted_full_access,
1635 &granted_apis,
1636 &granted_extent)) {
1637 GrantPermissions(extension);
1638 CHECK(extension_prefs_->GetGrantedPermissions(extension->id(),
1639 &granted_full_access,
1640 &granted_apis,
1641 &granted_extent));
1642 }
1643
1644 // Here, we check if an extension's privileges have increased in a manner
1645 // that requires the user's approval. This could occur because the browser
1646 // upgraded and recognized additional privileges, or an extension upgrades
1647 // to a version that requires additional privileges.
1648 is_privilege_increase = Extension::IsPrivilegeIncrease(
1649 granted_full_access, granted_apis, granted_extent, extension);
1650 }
1651
1652 if (is_extension_upgrade) {
1653 // CrxInstaller should have guaranteed that we aren't downgrading.
1654 CHECK(extension->version()->CompareTo(*(old->version())) >= 0);
1655
1656 // Extensions get upgraded if the privileges are allowed to increase or
1657 // the privileges haven't increased.
1658 if (!is_privilege_increase) {
1659 SetBeingUpgraded(old, true);
1660 SetBeingUpgraded(extension, true);
1661 }
1662
1663 // To upgrade an extension in place, unload the old one and
1664 // then load the new one.
1665 UnloadExtension(old->id());
1666 old = NULL;
1667 }
1668
1669 // Extension has changed permissions significantly. Disable it. A
1670 // notification should be sent by the caller.
1671 if (is_privilege_increase) {
1672 extension_prefs_->SetExtensionState(extension, Extension::DISABLED);
1673 extension_prefs_->SetDidExtensionEscalatePermissions(extension, true);
1674 }
1675 }
1676
1612 void ExtensionsService::UpdateActiveExtensionsInCrashReporter() { 1677 void ExtensionsService::UpdateActiveExtensionsInCrashReporter() {
1613 std::set<std::string> extension_ids; 1678 std::set<std::string> extension_ids;
1614 for (size_t i = 0; i < extensions_.size(); ++i) { 1679 for (size_t i = 0; i < extensions_.size(); ++i) {
1615 if (!extensions_[i]->is_theme() && 1680 if (!extensions_[i]->is_theme() &&
1616 extensions_[i]->location() != Extension::COMPONENT) 1681 extensions_[i]->location() != Extension::COMPONENT)
1617 extension_ids.insert(extensions_[i]->id()); 1682 extension_ids.insert(extensions_[i]->id());
1618 } 1683 }
1619 1684
1620 child_process_logging::SetActiveExtensions(extension_ids); 1685 child_process_logging::SetActiveExtensions(extension_ids);
1621 } 1686 }
1622 1687
1623 void ExtensionsService::OnExtensionInstalled(const Extension* extension, 1688 void ExtensionsService::OnExtensionInstalled(const Extension* extension) {
1624 bool allow_privilege_increase) {
1625 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1689 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1626 1690
1627 // Ensure extension is deleted unless we transfer ownership. 1691 // Ensure extension is deleted unless we transfer ownership.
1628 scoped_refptr<const Extension> scoped_extension(extension); 1692 scoped_refptr<const Extension> scoped_extension(extension);
1629 Extension::State initial_state = Extension::DISABLED; 1693 Extension::State initial_state = Extension::DISABLED;
1630 bool initial_enable_incognito = false; 1694 bool initial_enable_incognito = false;
1631 PendingExtensionMap::iterator it = 1695 PendingExtensionMap::iterator it =
1632 pending_extensions_.find(extension->id()); 1696 pending_extensions_.find(extension->id());
1633 if (it != pending_extensions_.end()) { 1697 if (it != pending_extensions_.end()) {
1634 PendingExtensionInfo pending_extension_info = it->second; 1698 PendingExtensionInfo pending_extension_info = it->second;
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1756 Details<const Extension>(extension)); 1820 Details<const Extension>(extension));
1757 } 1821 }
1758 1822
1759 if (extension->is_app()) { 1823 if (extension->is_app()) {
1760 ExtensionIdSet installed_ids = GetAppIds(); 1824 ExtensionIdSet installed_ids = GetAppIds();
1761 installed_ids.insert(extension->id()); 1825 installed_ids.insert(extension->id());
1762 default_apps_.DidInstallApp(installed_ids); 1826 default_apps_.DidInstallApp(installed_ids);
1763 } 1827 }
1764 1828
1765 // Transfer ownership of |extension| to OnExtensionLoaded. 1829 // Transfer ownership of |extension| to OnExtensionLoaded.
1766 OnExtensionLoaded(scoped_extension, allow_privilege_increase); 1830 OnExtensionLoaded(scoped_extension);
1767 } 1831 }
1768 1832
1769 const Extension* ExtensionsService::GetExtensionByIdInternal( 1833 const Extension* ExtensionsService::GetExtensionByIdInternal(
1770 const std::string& id, bool include_enabled, bool include_disabled) { 1834 const std::string& id, bool include_enabled, bool include_disabled) {
1771 std::string lowercase_id = StringToLowerASCII(id); 1835 std::string lowercase_id = StringToLowerASCII(id);
1772 if (include_enabled) { 1836 if (include_enabled) {
1773 for (ExtensionList::const_iterator iter = extensions_.begin(); 1837 for (ExtensionList::const_iterator iter = extensions_.begin();
1774 iter != extensions_.end(); ++iter) { 1838 iter != extensions_.end(); ++iter) {
1775 if ((*iter)->id() == lowercase_id) 1839 if ((*iter)->id() == lowercase_id)
1776 return *iter; 1840 return *iter;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1874 << "is: " << version << ". Keeping current version."; 1938 << "is: " << version << ". Keeping current version.";
1875 return; 1939 return;
1876 } 1940 }
1877 } 1941 }
1878 1942
1879 scoped_refptr<CrxInstaller> installer( 1943 scoped_refptr<CrxInstaller> installer(
1880 new CrxInstaller(this, // frontend 1944 new CrxInstaller(this, // frontend
1881 NULL)); // no client (silent install) 1945 NULL)); // no client (silent install)
1882 installer->set_install_source(location); 1946 installer->set_install_source(location);
1883 installer->set_expected_id(id); 1947 installer->set_expected_id(id);
1884 installer->set_allow_privilege_increase(true);
1885 installer->InstallCrx(path); 1948 installer->InstallCrx(path);
1886 } 1949 }
1887 1950
1888 void ExtensionsService::ReportExtensionLoadError( 1951 void ExtensionsService::ReportExtensionLoadError(
1889 const FilePath& extension_path, 1952 const FilePath& extension_path,
1890 const std::string &error, 1953 const std::string &error,
1891 NotificationType type, 1954 NotificationType type,
1892 bool be_noisy) { 1955 bool be_noisy) {
1893 NotificationService* service = NotificationService::current(); 1956 NotificationService* service = NotificationService::current();
1894 service->Notify(type, 1957 service->Notify(type,
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1991 } 2054 }
1992 2055
1993 void ExtensionsService::SetBeingUpgraded(const Extension* extension, 2056 void ExtensionsService::SetBeingUpgraded(const Extension* extension,
1994 bool value) { 2057 bool value) {
1995 extension_runtime_data_[extension->id()].being_upgraded = value; 2058 extension_runtime_data_[extension->id()].being_upgraded = value;
1996 } 2059 }
1997 2060
1998 PropertyBag* ExtensionsService::GetPropertyBag(const Extension* extension) { 2061 PropertyBag* ExtensionsService::GetPropertyBag(const Extension* extension) {
1999 return &extension_runtime_data_[extension->id()].property_bag; 2062 return &extension_runtime_data_[extension->id()].property_bag;
2000 } 2063 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extensions_service.h ('k') | chrome/browser/extensions/extensions_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698