Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: chrome/browser/extensions/extension_service.cc

Issue 10834191: new implementation of default apps (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: fixed broken test Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 2243 matching lines...) Expand 10 before | Expand all | Expand 10 after
2254 const Version* version, 2254 const Version* version,
2255 const FilePath& path, 2255 const FilePath& path,
2256 Extension::Location location, 2256 Extension::Location location,
2257 int creation_flags, 2257 int creation_flags,
2258 bool mark_acknowledged) { 2258 bool mark_acknowledged) {
2259 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 2259 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
2260 CHECK(Extension::IdIsValid(id)); 2260 CHECK(Extension::IdIsValid(id));
2261 if (extension_prefs_->IsExternalExtensionUninstalled(id)) 2261 if (extension_prefs_->IsExternalExtensionUninstalled(id))
2262 return false; 2262 return false;
2263 2263
2264 DCHECK(version);
2265
2266 // Before even bothering to unpack, check and see if we already have this 2264 // Before even bothering to unpack, check and see if we already have this
2267 // version. This is important because these extensions are going to get 2265 // version. This is important because these extensions are going to get
2268 // installed on every startup. 2266 // installed on every startup.
2269 const Extension* existing = GetExtensionById(id, true); 2267 const Extension* existing = GetExtensionById(id, true);
2270 if (existing) { 2268
2269 // The default apps will have the location set as INTERNAL. Since older
2270 // default apps are installed as EXTERNAL, we override them. However, if the
2271 // app is already installed as internal, then do the version check.
2272 if (existing && (location != Extension::INTERNAL ||
Mihai Parparita -not on Chrome 2012/08/15 00:32:13 I found this boolean expression hard to read becau
2273 !Extension::IsExternalLocation(existing->location()))) {
2274
2275 DCHECK(version);
2276
2271 switch (existing->version()->CompareTo(*version)) { 2277 switch (existing->version()->CompareTo(*version)) {
2272 case -1: // existing version is older, we should upgrade 2278 case -1: // existing version is older, we should upgrade
2273 break; 2279 break;
2274 case 0: // existing version is same, do nothing 2280 case 0: // existing version is same, do nothing
2275 return false; 2281 return false;
2276 case 1: // existing version is newer, uh-oh 2282 case 1: // existing version is newer, uh-oh
2277 LOG(WARNING) << "Found external version of extension " << id 2283 LOG(WARNING) << "Found external version of extension " << id
2278 << "that is older than current version. Current version " 2284 << "that is older than current version. Current version "
2279 << "is: " << existing->VersionString() << ". New version " 2285 << "is: " << existing->VersionString() << ". New "
2280 << "is: " << version->GetString() 2286 << "version is: " << version->GetString()
2281 << ". Keeping current version."; 2287 << ". Keeping current version.";
2282 return false; 2288 return false;
2283 } 2289 }
2284 } 2290 }
2285 2291
2286 // If the extension is already pending, don't start an install. 2292 // If the extension is already pending, don't start an install.
2287 if (!pending_extension_manager()->AddFromExternalFile( 2293 if (!pending_extension_manager()->AddFromExternalFile(
2288 id, location, *version)) { 2294 id, location, *version)) {
2289 return false; 2295 return false;
2290 } 2296 }
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
2552 2558
2553 ExtensionService::NaClModuleInfoList::iterator 2559 ExtensionService::NaClModuleInfoList::iterator
2554 ExtensionService::FindNaClModule(const GURL& url) { 2560 ExtensionService::FindNaClModule(const GURL& url) {
2555 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); 2561 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin();
2556 iter != nacl_module_list_.end(); ++iter) { 2562 iter != nacl_module_list_.end(); ++iter) {
2557 if (iter->url == url) 2563 if (iter->url == url)
2558 return iter; 2564 return iter;
2559 } 2565 }
2560 return nacl_module_list_.end(); 2566 return nacl_module_list_.end();
2561 } 2567 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698