| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 2242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2253 const Version* version, | 2253 const Version* version, |
| 2254 const FilePath& path, | 2254 const FilePath& path, |
| 2255 Extension::Location location, | 2255 Extension::Location location, |
| 2256 int creation_flags, | 2256 int creation_flags, |
| 2257 bool mark_acknowledged) { | 2257 bool mark_acknowledged) { |
| 2258 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2258 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 2259 CHECK(Extension::IdIsValid(id)); | 2259 CHECK(Extension::IdIsValid(id)); |
| 2260 if (extension_prefs_->IsExternalExtensionUninstalled(id)) | 2260 if (extension_prefs_->IsExternalExtensionUninstalled(id)) |
| 2261 return false; | 2261 return false; |
| 2262 | 2262 |
| 2263 DCHECK(version); | |
| 2264 | |
| 2265 // Before even bothering to unpack, check and see if we already have this | 2263 // Before even bothering to unpack, check and see if we already have this |
| 2266 // version. This is important because these extensions are going to get | 2264 // version. This is important because these extensions are going to get |
| 2267 // installed on every startup. | 2265 // installed on every startup. |
| 2268 const Extension* existing = GetExtensionById(id, true); | 2266 const Extension* existing = GetExtensionById(id, true); |
| 2267 |
| 2269 if (existing) { | 2268 if (existing) { |
| 2270 switch (existing->version()->CompareTo(*version)) { | 2269 // The default apps will have the location set as INTERNAL. Since older |
| 2271 case -1: // existing version is older, we should upgrade | 2270 // default apps are installed as EXTERNAL, we override them. However, if the |
| 2272 break; | 2271 // app is already installed as internal, then do the version check. |
| 2273 case 0: // existing version is same, do nothing | 2272 // TODO (grv) : Remove after Q1-2013. |
| 2274 return false; | 2273 bool is_default_apps_migration = |
| 2275 case 1: // existing version is newer, uh-oh | 2274 (location == Extension::INTERNAL && |
| 2276 LOG(WARNING) << "Found external version of extension " << id | 2275 Extension::IsExternalLocation(existing->location())); |
| 2277 << "that is older than current version. Current version " | 2276 |
| 2278 << "is: " << existing->VersionString() << ". New version " | 2277 if (!is_default_apps_migration) { |
| 2279 << "is: " << version->GetString() | 2278 DCHECK(version); |
| 2280 << ". Keeping current version."; | 2279 |
| 2281 return false; | 2280 switch (existing->version()->CompareTo(*version)) { |
| 2281 case -1: // existing version is older, we should upgrade |
| 2282 break; |
| 2283 case 0: // existing version is same, do nothing |
| 2284 return false; |
| 2285 case 1: // existing version is newer, uh-oh |
| 2286 LOG(WARNING) << "Found external version of extension " << id |
| 2287 << "that is older than current version. Current version " |
| 2288 << "is: " << existing->VersionString() << ". New " |
| 2289 << "version is: " << version->GetString() |
| 2290 << ". Keeping current version."; |
| 2291 return false; |
| 2292 } |
| 2282 } | 2293 } |
| 2283 } | 2294 } |
| 2284 | 2295 |
| 2285 // If the extension is already pending, don't start an install. | 2296 // If the extension is already pending, don't start an install. |
| 2286 if (!pending_extension_manager()->AddFromExternalFile( | 2297 if (!pending_extension_manager()->AddFromExternalFile( |
| 2287 id, location, *version)) { | 2298 id, location, *version)) { |
| 2288 return false; | 2299 return false; |
| 2289 } | 2300 } |
| 2290 | 2301 |
| 2291 // no client (silent install) | 2302 // no client (silent install) |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2557 | 2568 |
| 2558 ExtensionService::NaClModuleInfoList::iterator | 2569 ExtensionService::NaClModuleInfoList::iterator |
| 2559 ExtensionService::FindNaClModule(const GURL& url) { | 2570 ExtensionService::FindNaClModule(const GURL& url) { |
| 2560 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); | 2571 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); |
| 2561 iter != nacl_module_list_.end(); ++iter) { | 2572 iter != nacl_module_list_.end(); ++iter) { |
| 2562 if (iter->url == url) | 2573 if (iter->url == url) |
| 2563 return iter; | 2574 return iter; |
| 2564 } | 2575 } |
| 2565 return nacl_module_list_.end(); | 2576 return nacl_module_list_.end(); |
| 2566 } | 2577 } |
| OLD | NEW |