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 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 } else { | 483 } else { |
484 extension_service_->DisableExtension( | 484 extension_service_->DisableExtension( |
485 id, Extension::DISABLE_UNKNOWN_FROM_SYNC); | 485 id, Extension::DISABLE_UNKNOWN_FROM_SYNC); |
486 } | 486 } |
487 } | 487 } |
488 | 488 |
489 // We need to cache some version information here because setting the | 489 // We need to cache some version information here because setting the |
490 // incognito flag invalidates the |extension| pointer (it reloads the | 490 // incognito flag invalidates the |extension| pointer (it reloads the |
491 // extension). | 491 // extension). |
492 bool extension_installed = (extension != NULL); | 492 bool extension_installed = (extension != NULL); |
493 int result = extension ? | 493 int version_compare_result = extension ? |
494 extension->version()->CompareTo(extension_sync_data.version()) : 0; | 494 extension->version()->CompareTo(extension_sync_data.version()) : 0; |
| 495 |
| 496 // If the target extension has already been installed ephemerally, it can |
| 497 // be promoted to a regular installed extension and downloading from the Web |
| 498 // Store is not necessary. |
| 499 if (extension && extensions::util::IsEphemeralApp(id, profile_)) |
| 500 extension_service_->PromoteEphemeralApp(extension, true); |
| 501 |
| 502 // Update the incognito flag. |
495 extensions::util::SetIsIncognitoEnabled( | 503 extensions::util::SetIsIncognitoEnabled( |
496 id, profile_, extension_sync_data.incognito_enabled()); | 504 id, profile_, extension_sync_data.incognito_enabled()); |
497 extension = NULL; // No longer safe to use. | 505 extension = NULL; // No longer safe to use. |
498 | 506 |
499 if (extension_installed) { | 507 if (extension_installed) { |
500 // If the extension is already installed, check if it's outdated. | 508 // If the extension is already installed, check if it's outdated. |
501 if (result < 0) { | 509 if (version_compare_result < 0) { |
502 // Extension is outdated. | 510 // Extension is outdated. |
503 return false; | 511 return false; |
504 } | 512 } |
505 } else { | 513 } else { |
506 // TODO(akalin): Replace silent update with a list of enabled | 514 // TODO(akalin): Replace silent update with a list of enabled |
507 // permissions. | 515 // permissions. |
508 const bool kInstallSilently = true; | 516 const bool kInstallSilently = true; |
509 | 517 |
510 CHECK(type == syncer::EXTENSIONS || type == syncer::APPS); | 518 CHECK(type == syncer::EXTENSIONS || type == syncer::APPS); |
511 extensions::PendingExtensionInfo::ShouldAllowInstallPredicate filter = | 519 extensions::PendingExtensionInfo::ShouldAllowInstallPredicate filter = |
(...skipping 26 matching lines...) Expand all Loading... |
538 app_sync_bundle_.SyncChangeIfNeeded(extension); | 546 app_sync_bundle_.SyncChangeIfNeeded(extension); |
539 else if (extension_service_->is_ready() && !flare_.is_null()) | 547 else if (extension_service_->is_ready() && !flare_.is_null()) |
540 flare_.Run(syncer::APPS); | 548 flare_.Run(syncer::APPS); |
541 } else if (extensions::sync_helper::IsSyncableExtension(&extension)) { | 549 } else if (extensions::sync_helper::IsSyncableExtension(&extension)) { |
542 if (extension_sync_bundle_.IsSyncing()) | 550 if (extension_sync_bundle_.IsSyncing()) |
543 extension_sync_bundle_.SyncChangeIfNeeded(extension); | 551 extension_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::EXTENSIONS); | 553 flare_.Run(syncer::EXTENSIONS); |
546 } | 554 } |
547 } | 555 } |
OLD | NEW |