OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_sync_service.h" | 5 #include "chrome/browser/extensions/extension_sync_service.h" |
6 | 6 |
7 #include <iterator> | 7 #include <iterator> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
488 } else { | 488 } else { |
489 extension_service_->DisableExtension( | 489 extension_service_->DisableExtension( |
490 id, Extension::DISABLE_UNKNOWN_FROM_SYNC); | 490 id, Extension::DISABLE_UNKNOWN_FROM_SYNC); |
491 } | 491 } |
492 } | 492 } |
493 | 493 |
494 // We need to cache some version information here because setting the | 494 // We need to cache some version information here because setting the |
495 // incognito flag invalidates the |extension| pointer (it reloads the | 495 // incognito flag invalidates the |extension| pointer (it reloads the |
496 // extension). | 496 // extension). |
497 bool extension_installed = (extension != NULL); | 497 bool extension_installed = (extension != NULL); |
498 int result = extension ? | 498 int version_compare_result = extension ? |
499 extension->version()->CompareTo(extension_sync_data.version()) : 0; | 499 extension->version()->CompareTo(extension_sync_data.version()) : 0; |
500 | |
501 // If the target extension has already been installed ephemerally, it can | |
502 // be promoted to a regular installed extension and downloading from the Web | |
503 // Store is not necessary. | |
504 if (extension && extensions::util::IsEphemeralApp(id, profile_)) | |
505 extension_service_->InstallEphemeralApp(extension, false); | |
benwells
2014/05/27 01:42:56
Is this code path tested at all?
tmdiep
2014/05/27 07:46:05
Done.
| |
506 | |
507 // Update the incognito flag. | |
500 extensions::util::SetIsIncognitoEnabled( | 508 extensions::util::SetIsIncognitoEnabled( |
501 id, profile_, extension_sync_data.incognito_enabled()); | 509 id, profile_, extension_sync_data.incognito_enabled()); |
502 extension = NULL; // No longer safe to use. | 510 extension = NULL; // No longer safe to use. |
503 | 511 |
504 if (extension_installed) { | 512 if (extension_installed) { |
505 // If the extension is already installed, check if it's outdated. | 513 // If the extension is already installed, check if it's outdated. |
506 if (result < 0) { | 514 if (version_compare_result < 0) { |
507 // Extension is outdated. | 515 // Extension is outdated. |
508 return false; | 516 return false; |
509 } | 517 } |
510 } else { | 518 } else { |
511 // TODO(akalin): Replace silent update with a list of enabled | 519 // TODO(akalin): Replace silent update with a list of enabled |
512 // permissions. | 520 // permissions. |
513 const bool kInstallSilently = true; | 521 const bool kInstallSilently = true; |
514 | 522 |
515 CHECK(type == syncer::EXTENSIONS || type == syncer::APPS); | 523 CHECK(type == syncer::EXTENSIONS || type == syncer::APPS); |
516 extensions::PendingExtensionInfo::ShouldAllowInstallPredicate filter = | 524 extensions::PendingExtensionInfo::ShouldAllowInstallPredicate filter = |
(...skipping 26 matching lines...) Expand all Loading... | |
543 app_sync_bundle_.SyncChangeIfNeeded(extension); | 551 app_sync_bundle_.SyncChangeIfNeeded(extension); |
544 else if (extension_service_->is_ready() && !flare_.is_null()) | 552 else if (extension_service_->is_ready() && !flare_.is_null()) |
545 flare_.Run(syncer::APPS); | 553 flare_.Run(syncer::APPS); |
546 } else if (extensions::sync_helper::IsSyncableExtension(&extension)) { | 554 } else if (extensions::sync_helper::IsSyncableExtension(&extension)) { |
547 if (extension_sync_bundle_.IsSyncing()) | 555 if (extension_sync_bundle_.IsSyncing()) |
548 extension_sync_bundle_.SyncChangeIfNeeded(extension); | 556 extension_sync_bundle_.SyncChangeIfNeeded(extension); |
549 else if (extension_service_->is_ready() && !flare_.is_null()) | 557 else if (extension_service_->is_ready() && !flare_.is_null()) |
550 flare_.Run(syncer::EXTENSIONS); | 558 flare_.Run(syncer::EXTENSIONS); |
551 } | 559 } |
552 } | 560 } |
OLD | NEW |