| 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 1804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1815 const Version old_version(old_version_string); | 1815 const Version old_version(old_version_string); |
| 1816 | 1816 |
| 1817 VLOG(1) << "AddComponentExtension " << extension->name(); | 1817 VLOG(1) << "AddComponentExtension " << extension->name(); |
| 1818 if (!old_version.IsValid() || !old_version.Equals(*extension->version())) { | 1818 if (!old_version.IsValid() || !old_version.Equals(*extension->version())) { |
| 1819 VLOG(1) << "Component extension " << extension->name() << " (" | 1819 VLOG(1) << "Component extension " << extension->name() << " (" |
| 1820 << extension->id() << ") installing/upgrading from '" | 1820 << extension->id() << ") installing/upgrading from '" |
| 1821 << old_version_string << "' to " << extension->version()->GetString(); | 1821 << old_version_string << "' to " << extension->version()->GetString(); |
| 1822 | 1822 |
| 1823 AddNewOrUpdatedExtension(extension, | 1823 AddNewOrUpdatedExtension(extension, |
| 1824 Extension::ENABLED_COMPONENT, | 1824 Extension::ENABLED_COMPONENT, |
| 1825 extensions::Blacklist::NOT_BLACKLISTED, | 1825 extensions::NOT_BLACKLISTED, |
| 1826 syncer::StringOrdinal()); | 1826 syncer::StringOrdinal()); |
| 1827 return; | 1827 return; |
| 1828 } | 1828 } |
| 1829 | 1829 |
| 1830 AddExtension(extension); | 1830 AddExtension(extension); |
| 1831 } | 1831 } |
| 1832 | 1832 |
| 1833 void ExtensionService::UpdateActivePermissions(const Extension* extension) { | 1833 void ExtensionService::UpdateActivePermissions(const Extension* extension) { |
| 1834 // If the extension has used the optional permissions API, it will have a | 1834 // If the extension has used the optional permissions API, it will have a |
| 1835 // custom set of active permissions defined in the extension prefs. Here, | 1835 // custom set of active permissions defined in the extension prefs. Here, |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2069 } | 2069 } |
| 2070 } | 2070 } |
| 2071 } | 2071 } |
| 2072 } | 2072 } |
| 2073 } | 2073 } |
| 2074 | 2074 |
| 2075 void ExtensionService::OnExtensionInstalled( | 2075 void ExtensionService::OnExtensionInstalled( |
| 2076 const Extension* extension, | 2076 const Extension* extension, |
| 2077 const syncer::StringOrdinal& page_ordinal, | 2077 const syncer::StringOrdinal& page_ordinal, |
| 2078 bool has_requirement_errors, | 2078 bool has_requirement_errors, |
| 2079 extensions::Blacklist::BlacklistState blacklist_state, | 2079 extensions::BlacklistState blacklist_state, |
| 2080 bool wait_for_idle) { | 2080 bool wait_for_idle) { |
| 2081 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2081 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 2082 | 2082 |
| 2083 const std::string& id = extension->id(); | 2083 const std::string& id = extension->id(); |
| 2084 bool initial_enable = ShouldEnableOnInstall(extension); | 2084 bool initial_enable = ShouldEnableOnInstall(extension); |
| 2085 const extensions::PendingExtensionInfo* pending_extension_info = NULL; | 2085 const extensions::PendingExtensionInfo* pending_extension_info = NULL; |
| 2086 if ((pending_extension_info = pending_extension_manager()->GetById(id))) { | 2086 if ((pending_extension_info = pending_extension_manager()->GetById(id))) { |
| 2087 if (!pending_extension_info->ShouldAllowInstall(extension)) { | 2087 if (!pending_extension_info->ShouldAllowInstall(extension)) { |
| 2088 pending_extension_manager()->Remove(id); | 2088 pending_extension_manager()->Remove(id); |
| 2089 | 2089 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2121 id, Extension::DISABLE_UNSUPPORTED_REQUIREMENT); | 2121 id, Extension::DISABLE_UNSUPPORTED_REQUIREMENT); |
| 2122 // If the extension was disabled because of unsupported requirements but | 2122 // If the extension was disabled because of unsupported requirements but |
| 2123 // now supports all requirements after an update and there are not other | 2123 // now supports all requirements after an update and there are not other |
| 2124 // disable reasons, enable it. | 2124 // disable reasons, enable it. |
| 2125 } else if (extension_prefs_->GetDisableReasons(id) == | 2125 } else if (extension_prefs_->GetDisableReasons(id) == |
| 2126 Extension::DISABLE_UNSUPPORTED_REQUIREMENT) { | 2126 Extension::DISABLE_UNSUPPORTED_REQUIREMENT) { |
| 2127 initial_enable = true; | 2127 initial_enable = true; |
| 2128 extension_prefs_->ClearDisableReasons(id); | 2128 extension_prefs_->ClearDisableReasons(id); |
| 2129 } | 2129 } |
| 2130 | 2130 |
| 2131 if (blacklist_state == extensions::Blacklist::BLACKLISTED_MALWARE) { | 2131 if (blacklist_state == extensions::BLACKLISTED_MALWARE) { |
| 2132 // Installation of a blacklisted extension can happen from sync, policy, | 2132 // Installation of a blacklisted extension can happen from sync, policy, |
| 2133 // etc, where to maintain consistency we need to install it, just never | 2133 // etc, where to maintain consistency we need to install it, just never |
| 2134 // load it (see AddExtension). Usually it should be the job of callers to | 2134 // load it (see AddExtension). Usually it should be the job of callers to |
| 2135 // incercept blacklisted extension earlier (e.g. CrxInstaller, before even | 2135 // incercept blacklisted extension earlier (e.g. CrxInstaller, before even |
| 2136 // showing the install dialogue). | 2136 // showing the install dialogue). |
| 2137 extension_prefs()->AcknowledgeBlacklistedExtension(id); | 2137 extension_prefs()->AcknowledgeBlacklistedExtension(id); |
| 2138 UMA_HISTOGRAM_ENUMERATION("ExtensionBlacklist.SilentInstall", | 2138 UMA_HISTOGRAM_ENUMERATION("ExtensionBlacklist.SilentInstall", |
| 2139 extension->location(), | 2139 extension->location(), |
| 2140 Manifest::NUM_LOCATIONS); | 2140 Manifest::NUM_LOCATIONS); |
| 2141 } | 2141 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2154 extension->location(), Manifest::NUM_LOCATIONS); | 2154 extension->location(), Manifest::NUM_LOCATIONS); |
| 2155 } | 2155 } |
| 2156 | 2156 |
| 2157 // Certain extension locations are specific enough that we can | 2157 // Certain extension locations are specific enough that we can |
| 2158 // auto-acknowledge any extension that came from one of them. | 2158 // auto-acknowledge any extension that came from one of them. |
| 2159 if (Manifest::IsPolicyLocation(extension->location())) | 2159 if (Manifest::IsPolicyLocation(extension->location())) |
| 2160 AcknowledgeExternalExtension(extension->id()); | 2160 AcknowledgeExternalExtension(extension->id()); |
| 2161 const Extension::State initial_state = | 2161 const Extension::State initial_state = |
| 2162 initial_enable ? Extension::ENABLED : Extension::DISABLED; | 2162 initial_enable ? Extension::ENABLED : Extension::DISABLED; |
| 2163 const bool blacklisted_for_malware = | 2163 const bool blacklisted_for_malware = |
| 2164 blacklist_state == extensions::Blacklist::BLACKLISTED_MALWARE; | 2164 blacklist_state == extensions::BLACKLISTED_MALWARE; |
| 2165 if (ShouldDelayExtensionUpdate(id, wait_for_idle)) { | 2165 if (ShouldDelayExtensionUpdate(id, wait_for_idle)) { |
| 2166 extension_prefs_->SetDelayedInstallInfo( | 2166 extension_prefs_->SetDelayedInstallInfo( |
| 2167 extension, | 2167 extension, |
| 2168 initial_state, | 2168 initial_state, |
| 2169 blacklisted_for_malware, | 2169 blacklisted_for_malware, |
| 2170 extensions::ExtensionPrefs::DELAY_REASON_WAIT_FOR_IDLE, | 2170 extensions::ExtensionPrefs::DELAY_REASON_WAIT_FOR_IDLE, |
| 2171 page_ordinal); | 2171 page_ordinal); |
| 2172 | 2172 |
| 2173 // Transfer ownership of |extension|. | 2173 // Transfer ownership of |extension|. |
| 2174 delayed_installs_.Insert(extension); | 2174 delayed_installs_.Insert(extension); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2202 AddNewOrUpdatedExtension(extension, | 2202 AddNewOrUpdatedExtension(extension, |
| 2203 initial_state, | 2203 initial_state, |
| 2204 blacklist_state, | 2204 blacklist_state, |
| 2205 page_ordinal); | 2205 page_ordinal); |
| 2206 } | 2206 } |
| 2207 } | 2207 } |
| 2208 | 2208 |
| 2209 void ExtensionService::AddNewOrUpdatedExtension( | 2209 void ExtensionService::AddNewOrUpdatedExtension( |
| 2210 const Extension* extension, | 2210 const Extension* extension, |
| 2211 Extension::State initial_state, | 2211 Extension::State initial_state, |
| 2212 extensions::Blacklist::BlacklistState blacklist_state, | 2212 extensions::BlacklistState blacklist_state, |
| 2213 const syncer::StringOrdinal& page_ordinal) { | 2213 const syncer::StringOrdinal& page_ordinal) { |
| 2214 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2214 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 2215 const bool blacklisted_for_malware = | 2215 const bool blacklisted_for_malware = |
| 2216 blacklist_state == extensions::Blacklist::BLACKLISTED_MALWARE; | 2216 blacklist_state == extensions::BLACKLISTED_MALWARE; |
| 2217 extension_prefs_->OnExtensionInstalled(extension, | 2217 extension_prefs_->OnExtensionInstalled(extension, |
| 2218 initial_state, | 2218 initial_state, |
| 2219 blacklisted_for_malware, | 2219 blacklisted_for_malware, |
| 2220 page_ordinal); | 2220 page_ordinal); |
| 2221 delayed_installs_.Remove(extension->id()); | 2221 delayed_installs_.Remove(extension->id()); |
| 2222 if (extensions::ManifestURL::UpdatesFromGallery(extension)) { | 2222 if (extensions::ManifestURL::UpdatesFromGallery(extension)) { |
| 2223 extensions::ExtensionSystem::Get(profile_)->install_verifier()->Add( | 2223 extensions::ExtensionSystem::Get(profile_)->install_verifier()->Add( |
| 2224 extension->id(), InstallVerifier::AddResultCallback()); | 2224 extension->id(), InstallVerifier::AddResultCallback()); |
| 2225 } | 2225 } |
| 2226 FinishInstallation(extension); | 2226 FinishInstallation(extension); |
| (...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2849 } | 2849 } |
| 2850 | 2850 |
| 2851 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { | 2851 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { |
| 2852 update_observers_.AddObserver(observer); | 2852 update_observers_.AddObserver(observer); |
| 2853 } | 2853 } |
| 2854 | 2854 |
| 2855 void ExtensionService::RemoveUpdateObserver( | 2855 void ExtensionService::RemoveUpdateObserver( |
| 2856 extensions::UpdateObserver* observer) { | 2856 extensions::UpdateObserver* observer) { |
| 2857 update_observers_.RemoveObserver(observer); | 2857 update_observers_.RemoveObserver(observer); |
| 2858 } | 2858 } |
| OLD | NEW |