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