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/pending_enables.h" | 5 #include "chrome/browser/extensions/pending_enables.h" |
6 | 6 |
7 #include "chrome/browser/extensions/extension_service.h" | 7 #include "chrome/browser/extensions/extension_service.h" |
8 #include "chrome/browser/extensions/sync_bundle.h" | 8 #include "chrome/browser/extensions/sync_bundle.h" |
9 #include "components/sync_driver/sync_prefs.h" | 9 #include "components/sync_driver/sync_prefs.h" |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 void PendingEnables::Remove(const std::string& extension_id) { | 29 void PendingEnables::Remove(const std::string& extension_id) { |
30 if (IsWaitingForSync()) | 30 if (IsWaitingForSync()) |
31 ids_.erase(extension_id); | 31 ids_.erase(extension_id); |
32 } | 32 } |
33 | 33 |
34 void PendingEnables::OnSyncStarted(ExtensionService* service) { | 34 void PendingEnables::OnSyncStarted(ExtensionService* service) { |
35 for (std::set<std::string>::const_iterator it = ids_.begin(); | 35 for (std::set<std::string>::const_iterator it = ids_.begin(); |
36 it != ids_.end(); ++it) { | 36 it != ids_.end(); ++it) { |
37 const Extension* extension = service->GetExtensionById(*it, true); | 37 const Extension* extension = service->GetExtensionById(*it, true); |
38 if (extension) | 38 if (extension) |
39 sync_bundle_->PushSyncChangeIfNeeded(*extension); | 39 sync_bundle_->PushSyncAddOrUpdate(*extension); |
40 } | 40 } |
41 ids_.clear(); | 41 ids_.clear(); |
42 } | 42 } |
43 | 43 |
44 bool PendingEnables::Contains(const std::string& extension_id) const { | 44 bool PendingEnables::Contains(const std::string& extension_id) const { |
45 return ids_.find(extension_id) != ids_.end(); | 45 return ids_.find(extension_id) != ids_.end(); |
46 } | 46 } |
47 | 47 |
48 bool PendingEnables::IsSyncEnabled() { | 48 bool PendingEnables::IsSyncEnabled() { |
49 if (is_sync_enabled_for_test_) | 49 if (is_sync_enabled_for_test_) |
50 return true; | 50 return true; |
51 return sync_prefs_ && | 51 return sync_prefs_ && |
52 sync_prefs_->HasSyncSetupCompleted() && | 52 sync_prefs_->HasSyncSetupCompleted() && |
53 sync_prefs_->GetPreferredDataTypes(syncer::ModelTypeSet(enable_type_)) | 53 sync_prefs_->GetPreferredDataTypes(syncer::ModelTypeSet(enable_type_)) |
54 .Has(enable_type_); | 54 .Has(enable_type_); |
55 } | 55 } |
56 | 56 |
57 bool PendingEnables::IsWaitingForSync() { | 57 bool PendingEnables::IsWaitingForSync() { |
58 return IsSyncEnabled() && !sync_bundle_->IsSyncing(); | 58 return IsSyncEnabled() && !sync_bundle_->IsSyncing(); |
59 } | 59 } |
60 | 60 |
61 } // namespace extensions | 61 } // namespace extensions |
62 | 62 |
OLD | NEW |