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 23 matching lines...) Expand all Loading... |
34 #include "extensions/common/manifest_constants.h" | 34 #include "extensions/common/manifest_constants.h" |
35 #include "extensions/common/manifest_handlers/icons_handler.h" | 35 #include "extensions/common/manifest_handlers/icons_handler.h" |
36 #include "sync/api/sync_change.h" | 36 #include "sync/api/sync_change.h" |
37 #include "sync/api/sync_error_factory.h" | 37 #include "sync/api/sync_error_factory.h" |
38 #include "ui/gfx/image/image_family.h" | 38 #include "ui/gfx/image/image_family.h" |
39 | 39 |
40 using extensions::Extension; | 40 using extensions::Extension; |
41 using extensions::ExtensionPrefs; | 41 using extensions::ExtensionPrefs; |
42 using extensions::ExtensionRegistry; | 42 using extensions::ExtensionRegistry; |
43 using extensions::FeatureSwitch; | 43 using extensions::FeatureSwitch; |
| 44 using extensions::UninstalledExtensionInfo; |
44 | 45 |
45 namespace { | 46 namespace { |
46 | 47 |
47 void OnWebApplicationInfoLoaded( | 48 void OnWebApplicationInfoLoaded( |
48 WebApplicationInfo synced_info, | 49 WebApplicationInfo synced_info, |
49 base::WeakPtr<ExtensionService> extension_service, | 50 base::WeakPtr<ExtensionService> extension_service, |
50 const WebApplicationInfo& loaded_info) { | 51 const WebApplicationInfo& loaded_info) { |
51 DCHECK_EQ(synced_info.app_url, loaded_info.app_url); | 52 DCHECK_EQ(synced_info.app_url, loaded_info.app_url); |
52 | 53 |
53 if (!extension_service) | 54 if (!extension_service) |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 | 444 |
444 // TODO(bolms): we should really handle this better. The particularly bad | 445 // TODO(bolms): we should really handle this better. The particularly bad |
445 // case is where an app becomes an extension or vice versa, and we end up with | 446 // case is where an app becomes an extension or vice versa, and we end up with |
446 // a zombie extension that won't go away. | 447 // a zombie extension that won't go away. |
447 if (extension && !IsCorrectSyncType(*extension, type)) | 448 if (extension && !IsCorrectSyncType(*extension, type)) |
448 return true; | 449 return true; |
449 | 450 |
450 // Handle uninstalls first. | 451 // Handle uninstalls first. |
451 if (extension_sync_data.uninstalled()) { | 452 if (extension_sync_data.uninstalled()) { |
452 if (!extension_service_->UninstallExtensionHelper( | 453 if (!extension_service_->UninstallExtensionHelper( |
453 extension_service_, id, ExtensionService::UNINSTALL_REASON_SYNC)) { | 454 extension_service_, id, UninstalledExtensionInfo::REASON_SYNC)) { |
454 LOG(WARNING) << "Could not uninstall extension " << id | 455 LOG(WARNING) << "Could not uninstall extension " << id |
455 << " for sync"; | 456 << " for sync"; |
456 } | 457 } |
457 return true; | 458 return true; |
458 } | 459 } |
459 | 460 |
460 // Extension from sync was uninstalled by the user as external extensions. | 461 // Extension from sync was uninstalled by the user as external extensions. |
461 // Honor user choice and skip installation/enabling. | 462 // Honor user choice and skip installation/enabling. |
462 if (extensions::ExtensionPrefs::Get(profile_) | 463 if (extensions::ExtensionPrefs::Get(profile_) |
463 ->IsExternalExtensionUninstalled(id)) { | 464 ->IsExternalExtensionUninstalled(id)) { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 app_sync_bundle_.SyncChangeIfNeeded(extension); | 548 app_sync_bundle_.SyncChangeIfNeeded(extension); |
548 else if (extension_service_->is_ready() && !flare_.is_null()) | 549 else if (extension_service_->is_ready() && !flare_.is_null()) |
549 flare_.Run(syncer::APPS); | 550 flare_.Run(syncer::APPS); |
550 } else if (extensions::util::ShouldSyncExtension(&extension, profile_)) { | 551 } else if (extensions::util::ShouldSyncExtension(&extension, profile_)) { |
551 if (extension_sync_bundle_.IsSyncing()) | 552 if (extension_sync_bundle_.IsSyncing()) |
552 extension_sync_bundle_.SyncChangeIfNeeded(extension); | 553 extension_sync_bundle_.SyncChangeIfNeeded(extension); |
553 else if (extension_service_->is_ready() && !flare_.is_null()) | 554 else if (extension_service_->is_ready() && !flare_.is_null()) |
554 flare_.Run(syncer::EXTENSIONS); | 555 flare_.Run(syncer::EXTENSIONS); |
555 } | 556 } |
556 } | 557 } |
OLD | NEW |