| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/extension_service.h" | 5 #include "chrome/browser/extensions/extension_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 1744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1755 const Version old_version(old_version_string); | 1755 const Version old_version(old_version_string); |
| 1756 | 1756 |
| 1757 VLOG(1) << "AddComponentExtension " << extension->name(); | 1757 VLOG(1) << "AddComponentExtension " << extension->name(); |
| 1758 if (!old_version.IsValid() || !old_version.Equals(*extension->version())) { | 1758 if (!old_version.IsValid() || !old_version.Equals(*extension->version())) { |
| 1759 VLOG(1) << "Component extension " << extension->name() << " (" | 1759 VLOG(1) << "Component extension " << extension->name() << " (" |
| 1760 << extension->id() << ") installing/upgrading from '" | 1760 << extension->id() << ") installing/upgrading from '" |
| 1761 << old_version_string << "' to " << extension->version()->GetString(); | 1761 << old_version_string << "' to " << extension->version()->GetString(); |
| 1762 | 1762 |
| 1763 AddNewOrUpdatedExtension(extension, | 1763 AddNewOrUpdatedExtension(extension, |
| 1764 Extension::ENABLED_COMPONENT, | 1764 Extension::ENABLED_COMPONENT, |
| 1765 extensions::Blacklist::NOT_BLACKLISTED, | 1765 extensions::NOT_BLACKLISTED, |
| 1766 syncer::StringOrdinal()); | 1766 syncer::StringOrdinal()); |
| 1767 return; | 1767 return; |
| 1768 } | 1768 } |
| 1769 | 1769 |
| 1770 AddExtension(extension); | 1770 AddExtension(extension); |
| 1771 } | 1771 } |
| 1772 | 1772 |
| 1773 void ExtensionService::UpdateActivePermissions(const Extension* extension) { | 1773 void ExtensionService::UpdateActivePermissions(const Extension* extension) { |
| 1774 // If the extension has used the optional permissions API, it will have a | 1774 // If the extension has used the optional permissions API, it will have a |
| 1775 // custom set of active permissions defined in the extension prefs. Here, | 1775 // custom set of active permissions defined in the extension prefs. Here, |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2009 } | 2009 } |
| 2010 } | 2010 } |
| 2011 } | 2011 } |
| 2012 } | 2012 } |
| 2013 } | 2013 } |
| 2014 | 2014 |
| 2015 void ExtensionService::OnExtensionInstalled( | 2015 void ExtensionService::OnExtensionInstalled( |
| 2016 const Extension* extension, | 2016 const Extension* extension, |
| 2017 const syncer::StringOrdinal& page_ordinal, | 2017 const syncer::StringOrdinal& page_ordinal, |
| 2018 bool has_requirement_errors, | 2018 bool has_requirement_errors, |
| 2019 extensions::Blacklist::BlacklistState blacklist_state, | 2019 extensions::BlacklistState blacklist_state, |
| 2020 bool wait_for_idle) { | 2020 bool wait_for_idle) { |
| 2021 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2021 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 2022 | 2022 |
| 2023 const std::string& id = extension->id(); | 2023 const std::string& id = extension->id(); |
| 2024 bool initial_enable = ShouldEnableOnInstall(extension); | 2024 bool initial_enable = ShouldEnableOnInstall(extension); |
| 2025 const extensions::PendingExtensionInfo* pending_extension_info = NULL; | 2025 const extensions::PendingExtensionInfo* pending_extension_info = NULL; |
| 2026 if ((pending_extension_info = pending_extension_manager()->GetById(id))) { | 2026 if ((pending_extension_info = pending_extension_manager()->GetById(id))) { |
| 2027 if (!pending_extension_info->ShouldAllowInstall(extension)) { | 2027 if (!pending_extension_info->ShouldAllowInstall(extension)) { |
| 2028 pending_extension_manager()->Remove(id); | 2028 pending_extension_manager()->Remove(id); |
| 2029 | 2029 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2061 id, Extension::DISABLE_UNSUPPORTED_REQUIREMENT); | 2061 id, Extension::DISABLE_UNSUPPORTED_REQUIREMENT); |
| 2062 // If the extension was disabled because of unsupported requirements but | 2062 // If the extension was disabled because of unsupported requirements but |
| 2063 // now supports all requirements after an update and there are not other | 2063 // now supports all requirements after an update and there are not other |
| 2064 // disable reasons, enable it. | 2064 // disable reasons, enable it. |
| 2065 } else if (extension_prefs_->GetDisableReasons(id) == | 2065 } else if (extension_prefs_->GetDisableReasons(id) == |
| 2066 Extension::DISABLE_UNSUPPORTED_REQUIREMENT) { | 2066 Extension::DISABLE_UNSUPPORTED_REQUIREMENT) { |
| 2067 initial_enable = true; | 2067 initial_enable = true; |
| 2068 extension_prefs_->ClearDisableReasons(id); | 2068 extension_prefs_->ClearDisableReasons(id); |
| 2069 } | 2069 } |
| 2070 | 2070 |
| 2071 if (blacklist_state == extensions::Blacklist::BLACKLISTED_MALWARE) { | 2071 if (blacklist_state == extensions::BLACKLISTED_MALWARE) { |
| 2072 // Installation of a blacklisted extension can happen from sync, policy, | 2072 // Installation of a blacklisted extension can happen from sync, policy, |
| 2073 // etc, where to maintain consistency we need to install it, just never | 2073 // etc, where to maintain consistency we need to install it, just never |
| 2074 // load it (see AddExtension). Usually it should be the job of callers to | 2074 // load it (see AddExtension). Usually it should be the job of callers to |
| 2075 // incercept blacklisted extension earlier (e.g. CrxInstaller, before even | 2075 // incercept blacklisted extension earlier (e.g. CrxInstaller, before even |
| 2076 // showing the install dialogue). | 2076 // showing the install dialogue). |
| 2077 extension_prefs()->AcknowledgeBlacklistedExtension(id); | 2077 extension_prefs()->AcknowledgeBlacklistedExtension(id); |
| 2078 UMA_HISTOGRAM_ENUMERATION("ExtensionBlacklist.SilentInstall", | 2078 UMA_HISTOGRAM_ENUMERATION("ExtensionBlacklist.SilentInstall", |
| 2079 extension->location(), | 2079 extension->location(), |
| 2080 Manifest::NUM_LOCATIONS); | 2080 Manifest::NUM_LOCATIONS); |
| 2081 } | 2081 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2094 extension->location(), Manifest::NUM_LOCATIONS); | 2094 extension->location(), Manifest::NUM_LOCATIONS); |
| 2095 } | 2095 } |
| 2096 | 2096 |
| 2097 // Certain extension locations are specific enough that we can | 2097 // Certain extension locations are specific enough that we can |
| 2098 // auto-acknowledge any extension that came from one of them. | 2098 // auto-acknowledge any extension that came from one of them. |
| 2099 if (Manifest::IsPolicyLocation(extension->location())) | 2099 if (Manifest::IsPolicyLocation(extension->location())) |
| 2100 AcknowledgeExternalExtension(extension->id()); | 2100 AcknowledgeExternalExtension(extension->id()); |
| 2101 const Extension::State initial_state = | 2101 const Extension::State initial_state = |
| 2102 initial_enable ? Extension::ENABLED : Extension::DISABLED; | 2102 initial_enable ? Extension::ENABLED : Extension::DISABLED; |
| 2103 const bool blacklisted_for_malware = | 2103 const bool blacklisted_for_malware = |
| 2104 blacklist_state == extensions::Blacklist::BLACKLISTED_MALWARE; | 2104 blacklist_state == extensions::BLACKLISTED_MALWARE; |
| 2105 if (ShouldDelayExtensionUpdate(id, wait_for_idle)) { | 2105 if (ShouldDelayExtensionUpdate(id, wait_for_idle)) { |
| 2106 extension_prefs_->SetDelayedInstallInfo( | 2106 extension_prefs_->SetDelayedInstallInfo( |
| 2107 extension, | 2107 extension, |
| 2108 initial_state, | 2108 initial_state, |
| 2109 blacklisted_for_malware, | 2109 blacklisted_for_malware, |
| 2110 extensions::ExtensionPrefs::DELAY_REASON_WAIT_FOR_IDLE, | 2110 extensions::ExtensionPrefs::DELAY_REASON_WAIT_FOR_IDLE, |
| 2111 page_ordinal); | 2111 page_ordinal); |
| 2112 | 2112 |
| 2113 // Transfer ownership of |extension|. | 2113 // Transfer ownership of |extension|. |
| 2114 delayed_installs_.Insert(extension); | 2114 delayed_installs_.Insert(extension); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2142 AddNewOrUpdatedExtension(extension, | 2142 AddNewOrUpdatedExtension(extension, |
| 2143 initial_state, | 2143 initial_state, |
| 2144 blacklist_state, | 2144 blacklist_state, |
| 2145 page_ordinal); | 2145 page_ordinal); |
| 2146 } | 2146 } |
| 2147 } | 2147 } |
| 2148 | 2148 |
| 2149 void ExtensionService::AddNewOrUpdatedExtension( | 2149 void ExtensionService::AddNewOrUpdatedExtension( |
| 2150 const Extension* extension, | 2150 const Extension* extension, |
| 2151 Extension::State initial_state, | 2151 Extension::State initial_state, |
| 2152 extensions::Blacklist::BlacklistState blacklist_state, | 2152 extensions::BlacklistState blacklist_state, |
| 2153 const syncer::StringOrdinal& page_ordinal) { | 2153 const syncer::StringOrdinal& page_ordinal) { |
| 2154 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2154 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 2155 const bool blacklisted_for_malware = | 2155 const bool blacklisted_for_malware = |
| 2156 blacklist_state == extensions::Blacklist::BLACKLISTED_MALWARE; | 2156 blacklist_state == extensions::BLACKLISTED_MALWARE; |
| 2157 extension_prefs_->OnExtensionInstalled(extension, | 2157 extension_prefs_->OnExtensionInstalled(extension, |
| 2158 initial_state, | 2158 initial_state, |
| 2159 blacklisted_for_malware, | 2159 blacklisted_for_malware, |
| 2160 page_ordinal); | 2160 page_ordinal); |
| 2161 delayed_installs_.Remove(extension->id()); | 2161 delayed_installs_.Remove(extension->id()); |
| 2162 if (extensions::ManifestURL::UpdatesFromGallery(extension)) { | 2162 if (extensions::ManifestURL::UpdatesFromGallery(extension)) { |
| 2163 extensions::ExtensionSystem::Get(profile_)->install_verifier()->Add( | 2163 extensions::ExtensionSystem::Get(profile_)->install_verifier()->Add( |
| 2164 extension->id(), InstallVerifier::AddResultCallback()); | 2164 extension->id(), InstallVerifier::AddResultCallback()); |
| 2165 } | 2165 } |
| 2166 FinishInstallation(extension); | 2166 FinishInstallation(extension); |
| (...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2789 } | 2789 } |
| 2790 | 2790 |
| 2791 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { | 2791 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { |
| 2792 update_observers_.AddObserver(observer); | 2792 update_observers_.AddObserver(observer); |
| 2793 } | 2793 } |
| 2794 | 2794 |
| 2795 void ExtensionService::RemoveUpdateObserver( | 2795 void ExtensionService::RemoveUpdateObserver( |
| 2796 extensions::UpdateObserver* observer) { | 2796 extensions::UpdateObserver* observer) { |
| 2797 update_observers_.RemoveObserver(observer); | 2797 update_observers_.RemoveObserver(observer); |
| 2798 } | 2798 } |
| OLD | NEW |