| OLD | NEW |
| 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/browser/extensions/extension_service.h" | 5 #include "chrome/browser/extensions/extension_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 linked_ptr<ExternalExtensionProviderInterface>(test_provider)); | 408 linked_ptr<ExternalExtensionProviderInterface>(test_provider)); |
| 409 } | 409 } |
| 410 | 410 |
| 411 void ExtensionService::OnExternalExtensionUpdateUrlFound( | 411 void ExtensionService::OnExternalExtensionUpdateUrlFound( |
| 412 const std::string& id, | 412 const std::string& id, |
| 413 const GURL& update_url, | 413 const GURL& update_url, |
| 414 Extension::Location location) { | 414 Extension::Location location) { |
| 415 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 415 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 416 CHECK(Extension::IdIsValid(id)); | 416 CHECK(Extension::IdIsValid(id)); |
| 417 | 417 |
| 418 if (GetExtensionById(id, true)) { | 418 bool overwrite = false; |
| 419 // Already installed. Do not change the update URL that the extension set. | 419 const Extension* extension = GetExtensionById(id, true); |
| 420 return; | 420 if (extension) { |
| 421 // Already installed. Skip this install if the current location has |
| 422 // higher priority than |location|. |
| 423 Extension::Location current = extension->location(); |
| 424 if (current == Extension::GetHigherPriorityLocation(current, location)) |
| 425 return; |
| 426 // Otherwise, overwrite the current installation. |
| 427 overwrite = true; |
| 421 } | 428 } |
| 422 pending_extension_manager()->AddFromExternalUpdateUrl( | 429 pending_extension_manager()->AddFromExternalUpdateUrl( |
| 423 id, update_url, location); | 430 id, update_url, location, overwrite); |
| 424 external_extension_url_added_ |= true; | 431 external_extension_url_added_ |= true; |
| 425 } | 432 } |
| 426 | 433 |
| 427 bool ExtensionService::IsDownloadFromGallery(const GURL& download_url, | 434 bool ExtensionService::IsDownloadFromGallery(const GURL& download_url, |
| 428 const GURL& referrer_url) { | 435 const GURL& referrer_url) { |
| 429 // Special-case the themes mini-gallery. | 436 // Special-case the themes mini-gallery. |
| 430 // TODO(erikkay) When that gallery goes away, remove this code. | 437 // TODO(erikkay) When that gallery goes away, remove this code. |
| 431 if (IsDownloadFromMiniGallery(download_url) && | 438 if (IsDownloadFromMiniGallery(download_url) && |
| 432 StartsWithASCII(referrer_url.spec(), | 439 StartsWithASCII(referrer_url.spec(), |
| 433 extension_urls::kMiniGalleryBrowsePrefix, false)) { | 440 extension_urls::kMiniGalleryBrowsePrefix, false)) { |
| (...skipping 1722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2156 OnExtensionInstalled(extension, false); // Not from web store. | 2163 OnExtensionInstalled(extension, false); // Not from web store. |
| 2157 } | 2164 } |
| 2158 | 2165 |
| 2159 void ExtensionService::OnExtensionInstalled( | 2166 void ExtensionService::OnExtensionInstalled( |
| 2160 const Extension* extension, bool from_webstore) { | 2167 const Extension* extension, bool from_webstore) { |
| 2161 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2168 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 2162 | 2169 |
| 2163 // Ensure extension is deleted unless we transfer ownership. | 2170 // Ensure extension is deleted unless we transfer ownership. |
| 2164 scoped_refptr<const Extension> scoped_extension(extension); | 2171 scoped_refptr<const Extension> scoped_extension(extension); |
| 2165 const std::string& id = extension->id(); | 2172 const std::string& id = extension->id(); |
| 2166 bool initial_enable = !extension_prefs_->IsExtensionDisabled(id); | 2173 // Extensions installed by policy can't be disabled. So even if a previous |
| 2174 // installation disabled the extension, make sure it is now enabled. |
| 2175 bool initial_enable = |
| 2176 !extension_prefs_->IsExtensionDisabled(id) || |
| 2177 !Extension::UserMayDisable(extension->location()); |
| 2167 PendingExtensionInfo pending_extension_info; | 2178 PendingExtensionInfo pending_extension_info; |
| 2168 if (pending_extension_manager()->GetById(id, &pending_extension_info)) { | 2179 if (pending_extension_manager()->GetById(id, &pending_extension_info)) { |
| 2169 pending_extension_manager()->Remove(id); | 2180 pending_extension_manager()->Remove(id); |
| 2170 | 2181 |
| 2171 if (!pending_extension_info.ShouldAllowInstall(*extension)) { | 2182 if (!pending_extension_info.ShouldAllowInstall(*extension)) { |
| 2172 LOG(WARNING) | 2183 LOG(WARNING) |
| 2173 << "ShouldAllowInstall() returned false for " | 2184 << "ShouldAllowInstall() returned false for " |
| 2174 << id << " of type " << extension->GetType() | 2185 << id << " of type " << extension->GetType() |
| 2175 << " and update URL " << extension->update_url().spec() | 2186 << " and update URL " << extension->update_url().spec() |
| 2176 << "; not installing"; | 2187 << "; not installing"; |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2588 | 2599 |
| 2589 ExtensionService::NaClModuleInfoList::iterator | 2600 ExtensionService::NaClModuleInfoList::iterator |
| 2590 ExtensionService::FindNaClModule(const GURL& url) { | 2601 ExtensionService::FindNaClModule(const GURL& url) { |
| 2591 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); | 2602 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); |
| 2592 iter != nacl_module_list_.end(); ++iter) { | 2603 iter != nacl_module_list_.end(); ++iter) { |
| 2593 if (iter->url == url) | 2604 if (iter->url == url) |
| 2594 return iter; | 2605 return iter; |
| 2595 } | 2606 } |
| 2596 return nacl_module_list_.end(); | 2607 return nacl_module_list_.end(); |
| 2597 } | 2608 } |
| OLD | NEW |