Chromium Code Reviews| 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 2259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2270 const Version* version, | 2270 const Version* version, |
| 2271 const FilePath& path, | 2271 const FilePath& path, |
| 2272 Extension::Location location, | 2272 Extension::Location location, |
| 2273 int creation_flags, | 2273 int creation_flags, |
| 2274 bool mark_acknowledged) { | 2274 bool mark_acknowledged) { |
| 2275 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2275 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 2276 CHECK(Extension::IdIsValid(id)); | 2276 CHECK(Extension::IdIsValid(id)); |
| 2277 if (extension_prefs_->IsExternalExtensionUninstalled(id)) | 2277 if (extension_prefs_->IsExternalExtensionUninstalled(id)) |
| 2278 return false; | 2278 return false; |
| 2279 | 2279 |
| 2280 DCHECK(version); | |
| 2281 | |
| 2282 // Before even bothering to unpack, check and see if we already have this | 2280 // Before even bothering to unpack, check and see if we already have this |
| 2283 // version. This is important because these extensions are going to get | 2281 // version. This is important because these extensions are going to get |
| 2284 // installed on every startup. | 2282 // installed on every startup. |
| 2285 const Extension* existing = GetExtensionById(id, true); | 2283 const Extension* existing = GetExtensionById(id, true); |
| 2284 | |
| 2286 if (existing) { | 2285 if (existing) { |
| 2287 switch (existing->version()->CompareTo(*version)) { | 2286 // The default apps will have the location set as INTERNAL. Since older |
| 2288 case -1: // existing version is older, we should upgrade | 2287 // default apps are installed as EXTERNAL, we override them. However, if the |
| 2289 break; | 2288 // app is already installed as internal, then do the version check. |
| 2290 case 0: // existing version is same, do nothing | 2289 // TODO (grv) : Remove after migration (~6 months). |
| 2291 return false; | 2290 bool is_default_apps_migration = |
| 2292 case 1: // existing version is newer, uh-oh | 2291 (location == Extension::INTERNAL && |
| 2293 LOG(WARNING) << "Found external version of extension " << id | 2292 Extension::IsExternalLocation(existing->location())); |
| 2294 << "that is older than current version. Current version " | 2293 |
| 2295 << "is: " << existing->VersionString() << ". New version " | 2294 if (!is_default_apps_migration) { |
| 2296 << "is: " << version->GetString() | 2295 |
|
Mihai Parparita -not on Chrome
2012/08/16 00:58:24
Nit: extra newline.
| |
| 2297 << ". Keeping current version."; | 2296 DCHECK(version); |
| 2298 return false; | 2297 |
| 2298 switch (existing->version()->CompareTo(*version)) { | |
| 2299 case -1: // existing version is older, we should upgrade | |
| 2300 break; | |
| 2301 case 0: // existing version is same, do nothing | |
| 2302 return false; | |
| 2303 case 1: // existing version is newer, uh-oh | |
| 2304 LOG(WARNING) << "Found external version of extension " << id | |
| 2305 << "that is older than current version. Current version " | |
| 2306 << "is: " << existing->VersionString() << ". New " | |
| 2307 << "version is: " << version->GetString() | |
| 2308 << ". Keeping current version."; | |
| 2309 return false; | |
| 2310 } | |
| 2299 } | 2311 } |
| 2300 } | 2312 } |
| 2301 | 2313 |
| 2302 // If the extension is already pending, don't start an install. | 2314 // If the extension is already pending, don't start an install. |
| 2303 if (!pending_extension_manager()->AddFromExternalFile( | 2315 if (!pending_extension_manager()->AddFromExternalFile( |
| 2304 id, location, *version)) { | 2316 id, location, *version)) { |
| 2305 return false; | 2317 return false; |
| 2306 } | 2318 } |
| 2307 | 2319 |
| 2308 // no client (silent install) | 2320 // no client (silent install) |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2568 | 2580 |
| 2569 ExtensionService::NaClModuleInfoList::iterator | 2581 ExtensionService::NaClModuleInfoList::iterator |
| 2570 ExtensionService::FindNaClModule(const GURL& url) { | 2582 ExtensionService::FindNaClModule(const GURL& url) { |
| 2571 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); | 2583 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); |
| 2572 iter != nacl_module_list_.end(); ++iter) { | 2584 iter != nacl_module_list_.end(); ++iter) { |
| 2573 if (iter->url == url) | 2585 if (iter->url == url) |
| 2574 return iter; | 2586 return iter; |
| 2575 } | 2587 } |
| 2576 return nacl_module_list_.end(); | 2588 return nacl_module_list_.end(); |
| 2577 } | 2589 } |
| OLD | NEW |