OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/extensions_service.h" | 5 #include "chrome/browser/extensions/extensions_service.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 } | 362 } |
363 | 363 |
364 void ExtensionsService::OnExternalExtensionFound(const std::string& id, | 364 void ExtensionsService::OnExternalExtensionFound(const std::string& id, |
365 const std::string& version, | 365 const std::string& version, |
366 const FilePath& path, | 366 const FilePath& path, |
367 Extension::Location location) { | 367 Extension::Location location) { |
368 // Before even bothering to unpack, check and see if we already have this | 368 // Before even bothering to unpack, check and see if we already have this |
369 // version. This is important because these extensions are going to get | 369 // version. This is important because these extensions are going to get |
370 // installed on every startup. | 370 // installed on every startup. |
371 Extension* existing = GetExtensionById(id); | 371 Extension* existing = GetExtensionById(id); |
| 372 scoped_ptr<Version> other(Version::GetVersionFromString(version)); |
372 if (existing) { | 373 if (existing) { |
373 switch (existing->version()->CompareTo( | 374 switch (existing->version()->CompareTo(*other)) { |
374 *Version::GetVersionFromString(version))) { | |
375 case -1: // existing version is older, we should upgrade | 375 case -1: // existing version is older, we should upgrade |
376 break; | 376 break; |
377 case 0: // existing version is same, do nothing | 377 case 0: // existing version is same, do nothing |
378 return; | 378 return; |
379 case 1: // existing version is newer, uh-oh | 379 case 1: // existing version is newer, uh-oh |
380 LOG(WARNING) << "Found external version of extension " << id | 380 LOG(WARNING) << "Found external version of extension " << id |
381 << "that is older than current version. Current version " | 381 << "that is older than current version. Current version " |
382 << "is: " << existing->VersionString() << ". New version " | 382 << "is: " << existing->VersionString() << ". New version " |
383 << "is: " << version << ". Keeping current version."; | 383 << "is: " << version << ". Keeping current version."; |
384 return; | 384 return; |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 linked_ptr<ExternalExtensionProvider>(test_provider); | 581 linked_ptr<ExternalExtensionProvider>(test_provider); |
582 } | 582 } |
583 | 583 |
584 void ExtensionsServiceBackend::OnExternalExtensionFound( | 584 void ExtensionsServiceBackend::OnExternalExtensionFound( |
585 const std::string& id, const Version* version, const FilePath& path, | 585 const std::string& id, const Version* version, const FilePath& path, |
586 Extension::Location location) { | 586 Extension::Location location) { |
587 frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(frontend_, | 587 frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(frontend_, |
588 &ExtensionsService::OnExternalExtensionFound, id, version->GetString(), | 588 &ExtensionsService::OnExternalExtensionFound, id, version->GetString(), |
589 path, location)); | 589 path, location)); |
590 } | 590 } |
OLD | NEW |