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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 } | 125 } |
126 } | 126 } |
127 | 127 |
128 void ExtensionSyncService::SyncEnableExtension( | 128 void ExtensionSyncService::SyncEnableExtension( |
129 const extensions::Extension& extension) { | 129 const extensions::Extension& extension) { |
130 | 130 |
131 // Syncing may not have started yet, so handle pending enables. | 131 // Syncing may not have started yet, so handle pending enables. |
132 if (extensions::util::ShouldSyncApp(&extension, profile_)) | 132 if (extensions::util::ShouldSyncApp(&extension, profile_)) |
133 pending_app_enables_.OnExtensionEnabled(extension.id()); | 133 pending_app_enables_.OnExtensionEnabled(extension.id()); |
134 | 134 |
135 if (extensions::sync_helper::IsSyncableExtension(&extension)) | 135 if (extensions::util::ShouldSyncExtension(&extension, profile_)) |
136 pending_extension_enables_.OnExtensionEnabled(extension.id()); | 136 pending_extension_enables_.OnExtensionEnabled(extension.id()); |
137 | 137 |
138 SyncExtensionChangeIfNeeded(extension); | 138 SyncExtensionChangeIfNeeded(extension); |
139 } | 139 } |
140 | 140 |
141 void ExtensionSyncService::SyncDisableExtension( | 141 void ExtensionSyncService::SyncDisableExtension( |
142 const extensions::Extension& extension) { | 142 const extensions::Extension& extension) { |
143 | 143 |
144 // Syncing may not have started yet, so handle pending enables. | 144 // Syncing may not have started yet, so handle pending enables. |
145 if (extensions::util::ShouldSyncApp(&extension, profile_)) | 145 if (extensions::util::ShouldSyncApp(&extension, profile_)) |
146 pending_app_enables_.OnExtensionDisabled(extension.id()); | 146 pending_app_enables_.OnExtensionDisabled(extension.id()); |
147 | 147 |
148 if (extensions::sync_helper::IsSyncableExtension(&extension)) | 148 if (extensions::util::ShouldSyncExtension(&extension, profile_)) |
149 pending_extension_enables_.OnExtensionDisabled(extension.id()); | 149 pending_extension_enables_.OnExtensionDisabled(extension.id()); |
150 | 150 |
151 SyncExtensionChangeIfNeeded(extension); | 151 SyncExtensionChangeIfNeeded(extension); |
152 } | 152 } |
153 | 153 |
154 syncer::SyncMergeResult ExtensionSyncService::MergeDataAndStartSyncing( | 154 syncer::SyncMergeResult ExtensionSyncService::MergeDataAndStartSyncing( |
155 syncer::ModelType type, | 155 syncer::ModelType type, |
156 const syncer::SyncDataList& initial_sync_data, | 156 const syncer::SyncDataList& initial_sync_data, |
157 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, | 157 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, |
158 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) { | 158 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) { |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 | 467 |
468 // Set user settings. | 468 // Set user settings. |
469 // If the extension has been disabled from sync, it may not have | 469 // If the extension has been disabled from sync, it may not have |
470 // been installed yet, so we don't know if the disable reason was a | 470 // been installed yet, so we don't know if the disable reason was a |
471 // permissions increase. That will be updated once CheckPermissionsIncrease | 471 // permissions increase. That will be updated once CheckPermissionsIncrease |
472 // is called for it. | 472 // is called for it. |
473 // However if the extension is marked as a remote install in sync, we know | 473 // However if the extension is marked as a remote install in sync, we know |
474 // what the disable reason is, so set it to that directly. Note that when | 474 // what the disable reason is, so set it to that directly. Note that when |
475 // CheckPermissionsIncrease runs, it might still add permissions increase | 475 // CheckPermissionsIncrease runs, it might still add permissions increase |
476 // as a disable reason for the extension. | 476 // as a disable reason for the extension. |
477 if (extension_sync_data.enabled()) | 477 if (extension_sync_data.enabled()) { |
478 extension_service_->EnableExtension(id); | 478 extension_service_->EnableExtension(id); |
479 else if (!IsPendingEnable(id)) { | 479 } else if (!IsPendingEnable(id)) { |
480 if (extension_sync_data.remote_install()) { | 480 if (extension_sync_data.remote_install()) { |
481 extension_service_->DisableExtension(id, | 481 extension_service_->DisableExtension(id, |
482 Extension::DISABLE_REMOTE_INSTALL); | 482 Extension::DISABLE_REMOTE_INSTALL); |
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 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 return true; | 539 return true; |
540 } | 540 } |
541 | 541 |
542 void ExtensionSyncService::SyncExtensionChangeIfNeeded( | 542 void ExtensionSyncService::SyncExtensionChangeIfNeeded( |
543 const Extension& extension) { | 543 const Extension& extension) { |
544 if (extensions::util::ShouldSyncApp(&extension, profile_)) { | 544 if (extensions::util::ShouldSyncApp(&extension, profile_)) { |
545 if (app_sync_bundle_.IsSyncing()) | 545 if (app_sync_bundle_.IsSyncing()) |
546 app_sync_bundle_.SyncChangeIfNeeded(extension); | 546 app_sync_bundle_.SyncChangeIfNeeded(extension); |
547 else if (extension_service_->is_ready() && !flare_.is_null()) | 547 else if (extension_service_->is_ready() && !flare_.is_null()) |
548 flare_.Run(syncer::APPS); | 548 flare_.Run(syncer::APPS); |
549 } else if (extensions::sync_helper::IsSyncableExtension(&extension)) { | 549 } else if (extensions::util::ShouldSyncExtension(&extension, profile_)) { |
550 if (extension_sync_bundle_.IsSyncing()) | 550 if (extension_sync_bundle_.IsSyncing()) |
551 extension_sync_bundle_.SyncChangeIfNeeded(extension); | 551 extension_sync_bundle_.SyncChangeIfNeeded(extension); |
552 else if (extension_service_->is_ready() && !flare_.is_null()) | 552 else if (extension_service_->is_ready() && !flare_.is_null()) |
553 flare_.Run(syncer::EXTENSIONS); | 553 flare_.Run(syncer::EXTENSIONS); |
554 } | 554 } |
555 } | 555 } |
OLD | NEW |