| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/app_sync_bundle.h" | 5 #include "chrome/browser/extensions/app_sync_bundle.h" |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "chrome/browser/extensions/extension_sync_service.h" | 8 #include "chrome/browser/extensions/extension_sync_service.h" |
| 9 #include "chrome/browser/extensions/extension_util.h" |
| 10 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/common/extensions/sync_helper.h" | 11 #include "chrome/common/extensions/sync_helper.h" |
| 10 #include "extensions/browser/app_sorting.h" | 12 #include "extensions/browser/app_sorting.h" |
| 11 #include "extensions/common/extension.h" | 13 #include "extensions/common/extension.h" |
| 12 #include "extensions/common/extension_set.h" | 14 #include "extensions/common/extension_set.h" |
| 13 #include "sync/api/sync_change_processor.h" | 15 #include "sync/api/sync_change_processor.h" |
| 14 #include "sync/api/sync_data.h" | 16 #include "sync/api/sync_data.h" |
| 15 #include "sync/api/sync_error_factory.h" | 17 #include "sync/api/sync_error_factory.h" |
| 16 | 18 |
| 17 namespace extensions { | 19 namespace extensions { |
| 18 | 20 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 ++i) { | 136 ++i) { |
| 135 pending_apps.push_back(i->second); | 137 pending_apps.push_back(i->second); |
| 136 } | 138 } |
| 137 | 139 |
| 138 return pending_apps; | 140 return pending_apps; |
| 139 } | 141 } |
| 140 | 142 |
| 141 void AppSyncBundle::GetAppSyncDataListHelper( | 143 void AppSyncBundle::GetAppSyncDataListHelper( |
| 142 const ExtensionSet& extensions, | 144 const ExtensionSet& extensions, |
| 143 std::vector<AppSyncData>* sync_data_list) const { | 145 std::vector<AppSyncData>* sync_data_list) const { |
| 146 Profile* profile = extension_sync_service_->profile(); |
| 147 |
| 144 for (ExtensionSet::const_iterator it = extensions.begin(); | 148 for (ExtensionSet::const_iterator it = extensions.begin(); |
| 145 it != extensions.end(); ++it) { | 149 it != extensions.end(); ++it) { |
| 146 const Extension& extension = *it->get(); | 150 const Extension& extension = *it->get(); |
| 147 // If we have pending app data for this app, then this | 151 // If we have pending app data for this app, then this |
| 148 // version is out of date. We'll sync back the version we got from | 152 // version is out of date. We'll sync back the version we got from |
| 149 // sync. | 153 // sync. |
| 150 if (IsSyncing() && sync_helper::IsSyncableApp(&extension) && | 154 if (IsSyncing() && util::ShouldSyncApp(&extension, profile) && |
| 151 !HasPendingExtensionId(extension.id())) { | 155 !HasPendingExtensionId(extension.id())) { |
| 152 sync_data_list->push_back(extension_sync_service_->GetAppSyncData( | 156 sync_data_list->push_back(extension_sync_service_->GetAppSyncData( |
| 153 extension)); | 157 extension)); |
| 154 } | 158 } |
| 155 } | 159 } |
| 156 } | 160 } |
| 157 | 161 |
| 158 void AppSyncBundle::AddApp(const std::string& id) { | 162 void AppSyncBundle::AddApp(const std::string& id) { |
| 159 synced_apps_.insert(id); | 163 synced_apps_.insert(id); |
| 160 } | 164 } |
| 161 | 165 |
| 162 void AppSyncBundle::RemoveApp(const std::string& id) { | 166 void AppSyncBundle::RemoveApp(const std::string& id) { |
| 163 synced_apps_.erase(id); | 167 synced_apps_.erase(id); |
| 164 } | 168 } |
| 165 | 169 |
| 166 | 170 |
| 167 void AppSyncBundle::MarkPendingAppSynced(const std::string& id) { | 171 void AppSyncBundle::MarkPendingAppSynced(const std::string& id) { |
| 168 pending_sync_data_.erase(id); | 172 pending_sync_data_.erase(id); |
| 169 synced_apps_.insert(id); | 173 synced_apps_.insert(id); |
| 170 } | 174 } |
| 171 | 175 |
| 172 | 176 |
| 173 } // namespace extensions | 177 } // namespace extensions |
| OLD | NEW |