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/extension_sync_bundle.h" | 5 #include "chrome/browser/extensions/extension_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/common/extension.h" | 12 #include "extensions/common/extension.h" |
11 #include "extensions/common/extension_set.h" | 13 #include "extensions/common/extension_set.h" |
12 #include "sync/api/sync_change_processor.h" | 14 #include "sync/api/sync_change_processor.h" |
13 #include "sync/api/sync_error_factory.h" | 15 #include "sync/api/sync_error_factory.h" |
14 | 16 |
15 namespace extensions { | 17 namespace extensions { |
16 | 18 |
17 ExtensionSyncBundle::ExtensionSyncBundle( | 19 ExtensionSyncBundle::ExtensionSyncBundle( |
18 ExtensionSyncService* extension_sync_service) | 20 ExtensionSyncService* extension_sync_service) |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
135 ++i) { | 137 ++i) { |
136 pending_extensions.push_back(i->second); | 138 pending_extensions.push_back(i->second); |
137 } | 139 } |
138 | 140 |
139 return pending_extensions; | 141 return pending_extensions; |
140 } | 142 } |
141 | 143 |
142 void ExtensionSyncBundle::GetExtensionSyncDataListHelper( | 144 void ExtensionSyncBundle::GetExtensionSyncDataListHelper( |
143 const ExtensionSet& extensions, | 145 const ExtensionSet& extensions, |
144 std::vector<ExtensionSyncData>* sync_data_list) const { | 146 std::vector<ExtensionSyncData>* sync_data_list) const { |
147 Profile* profile = extension_sync_service_->profile(); | |
148 | |
145 for (ExtensionSet::const_iterator it = extensions.begin(); | 149 for (ExtensionSet::const_iterator it = extensions.begin(); |
146 it != extensions.end(); ++it) { | 150 it != extensions.end(); ++it) { |
147 const Extension& extension = *it->get(); | 151 const Extension& extension = *it->get(); |
148 // If we have pending extension data for this extension, then this | 152 // If we have pending extension data for this extension, then this |
149 // version is out of date. We'll sync back the version we got from | 153 // version is out of date. We'll sync back the version we got from |
150 // sync. | 154 // sync. |
151 if (IsSyncing() && sync_helper::IsSyncableExtension(&extension) && | 155 if (IsSyncing() && util::ShouldSyncExtension(&extension, profile) && |
not at google - send to devlin
2014/06/13 20:01:22
could you add a comment to sync_helper.h saying "y
xiyuan
2014/06/13 20:35:42
Done.
| |
152 !HasPendingExtensionId(extension.id())) { | 156 !HasPendingExtensionId(extension.id())) { |
153 sync_data_list->push_back( | 157 sync_data_list->push_back( |
154 extension_sync_service_->GetExtensionSyncData(extension)); | 158 extension_sync_service_->GetExtensionSyncData(extension)); |
155 } | 159 } |
156 } | 160 } |
157 } | 161 } |
158 | 162 |
159 void ExtensionSyncBundle::AddExtension(const std::string& id) { | 163 void ExtensionSyncBundle::AddExtension(const std::string& id) { |
160 synced_extensions_.insert(id); | 164 synced_extensions_.insert(id); |
161 } | 165 } |
162 | 166 |
163 void ExtensionSyncBundle::RemoveExtension(const std::string& id) { | 167 void ExtensionSyncBundle::RemoveExtension(const std::string& id) { |
164 synced_extensions_.erase(id); | 168 synced_extensions_.erase(id); |
165 } | 169 } |
166 | 170 |
167 void ExtensionSyncBundle::MarkPendingExtensionSynced(const std::string& id) { | 171 void ExtensionSyncBundle::MarkPendingExtensionSynced(const std::string& id) { |
168 pending_sync_data_.erase(id); | 172 pending_sync_data_.erase(id); |
169 synced_extensions_.insert(id); | 173 synced_extensions_.insert(id); |
170 } | 174 } |
171 | 175 |
172 } // namespace extensions | 176 } // namespace extensions |
OLD | NEW |