Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: chrome/browser/extensions/extension_sync_service.h

Issue 1240573012: Extension syncing: Introduce a NeedsSync pref (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ext_sync_uninstall
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SYNC_SERVICE_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SYNC_SERVICE_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SYNC_SERVICE_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SYNC_SERVICE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "chrome/browser/extensions/pending_enables.h"
12 #include "chrome/browser/extensions/sync_bundle.h" 11 #include "chrome/browser/extensions/sync_bundle.h"
13 #include "components/keyed_service/core/keyed_service.h" 12 #include "components/keyed_service/core/keyed_service.h"
14 #include "extensions/browser/extension_prefs.h" 13 #include "extensions/browser/extension_prefs.h"
15 #include "extensions/common/extension.h" 14 #include "extensions/common/extension.h"
16 #include "sync/api/syncable_service.h" 15 #include "sync/api/syncable_service.h"
17 16
17 class ExtensionService;
18 class Profile; 18 class Profile;
19 19
20 namespace extensions { 20 namespace extensions {
21 class Extension; 21 class Extension;
22 class ExtensionSet; 22 class ExtensionSet;
23 class ExtensionSyncData; 23 class ExtensionSyncData;
24 } // namespace extensions 24 } // namespace extensions
25 25
26 namespace syncer { 26 namespace syncer {
27 class SyncChange; 27 class SyncChange;
28 class SyncChangeProcessor; 28 class SyncChangeProcessor;
29 class SyncErrorFactory; 29 class SyncErrorFactory;
30 } 30 }
31 31
32 // SyncableService implementation responsible for the APPS and EXTENSIONS data 32 // SyncableService implementation responsible for the APPS and EXTENSIONS data
33 // types, i.e. "proper" apps/extensions (not themes). 33 // types, i.e. "proper" apps/extensions (not themes).
34 class ExtensionSyncService : public syncer::SyncableService, 34 class ExtensionSyncService : public syncer::SyncableService,
35 public KeyedService { 35 public KeyedService {
36 public: 36 public:
37 ExtensionSyncService(Profile* profile, 37 ExtensionSyncService(Profile* profile,
38 extensions::ExtensionPrefs* extension_prefs, 38 extensions::ExtensionPrefs* extension_prefs,
39 ExtensionService* extension_service); 39 ExtensionService* extension_service);
40 40
41 ~ExtensionSyncService() override; 41 ~ExtensionSyncService() override;
42 42
43 // Convenience function to get the ExtensionSyncService for a BrowserContext. 43 // Convenience function to get the ExtensionSyncService for a BrowserContext.
44 static ExtensionSyncService* Get(content::BrowserContext* context); 44 static ExtensionSyncService* Get(content::BrowserContext* context);
45 45
46 // Notifies Sync that the given |extension| has been uninstalled.
46 void SyncUninstallExtension(const extensions::Extension& extension); 47 void SyncUninstallExtension(const extensions::Extension& extension);
47 48
48 void SyncEnableExtension(const extensions::Extension& extension);
49 void SyncDisableExtension(const extensions::Extension& extension);
50
51 void SyncOrderingChange(const std::string& extension_id); 49 void SyncOrderingChange(const std::string& extension_id);
52 50
53 // Notifies Sync (if needed) of a newly-installed extension or a change to 51 // Notifies Sync (if needed) of a newly-installed extension or a change to
54 // an existing extension. 52 // an existing extension.
55 void SyncExtensionChangeIfNeeded(const extensions::Extension& extension); 53 void SyncExtensionChangeIfNeeded(const extensions::Extension& extension);
56 54
57 // syncer::SyncableService implementation. 55 // syncer::SyncableService implementation.
58 syncer::SyncMergeResult MergeDataAndStartSyncing( 56 syncer::SyncMergeResult MergeDataAndStartSyncing(
59 syncer::ModelType type, 57 syncer::ModelType type,
60 const syncer::SyncDataList& initial_sync_data, 58 const syncer::SyncDataList& initial_sync_data,
61 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, 59 scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
62 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) override; 60 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) override;
63 void StopSyncing(syncer::ModelType type) override; 61 void StopSyncing(syncer::ModelType type) override;
64 syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const override; 62 syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const override;
65 syncer::SyncError ProcessSyncChanges( 63 syncer::SyncError ProcessSyncChanges(
66 const tracked_objects::Location& from_here, 64 const tracked_objects::Location& from_here,
67 const syncer::SyncChangeList& change_list) override; 65 const syncer::SyncChangeList& change_list) override;
68 66
69 // Creates the ExtensionSyncData for the given app/extension.
70 extensions::ExtensionSyncData CreateSyncData(
71 const extensions::Extension& extension) const;
72
73 // Applies the change specified passed in by either ExtensionSyncData to the 67 // Applies the change specified passed in by either ExtensionSyncData to the
74 // current system. 68 // current system.
75 // Returns false if the changes were not completely applied and were added 69 // Returns false if the changes were not completely applied and were added
76 // to the pending list to be tried again. 70 // to the pending list to be tried again.
77 bool ApplySyncData(const extensions::ExtensionSyncData& extension_sync_data); 71 bool ApplySyncData(const extensions::ExtensionSyncData& extension_sync_data);
78 72
79 // |flare| provides a StartSyncFlare to the SyncableService. See 73 // |flare| provides a StartSyncFlare to the SyncableService. See
80 // sync_start_util for more. Public for testing. 74 // sync_start_util for more. Public for testing.
81 void SetSyncStartFlare(const syncer::SyncableService::StartSyncFlare& flare); 75 void SetSyncStartFlare(const syncer::SyncableService::StartSyncFlare& flare);
82 76
83 private: 77 private:
84 // Whether the given extension has been enabled before sync has started.
85 bool IsPendingEnable(const std::string& extension_id) const;
86
87 // Gets the SyncBundle for the given |type|. 78 // Gets the SyncBundle for the given |type|.
88 extensions::SyncBundle* GetSyncBundle(syncer::ModelType type); 79 extensions::SyncBundle* GetSyncBundle(syncer::ModelType type);
89 const extensions::SyncBundle* GetSyncBundle(syncer::ModelType type) const; 80 const extensions::SyncBundle* GetSyncBundle(syncer::ModelType type) const;
90 81
91 // Gets the PendingEnables for apps/extensions. 82 // Creates the ExtensionSyncData for the given app/extension.
92 extensions::PendingEnables* GetPendingEnables(bool for_apps); 83 extensions::ExtensionSyncData CreateSyncData(
84 const extensions::Extension& extension) const;
93 85
94 // Gets the ExtensionSyncData for all apps or extensions. 86 // Gets the ExtensionSyncData for all apps or extensions.
95 std::vector<extensions::ExtensionSyncData> GetSyncDataList( 87 std::vector<extensions::ExtensionSyncData> GetSyncDataList(
96 syncer::ModelType type) const; 88 syncer::ModelType type) const;
97 89
98 void FillSyncDataList( 90 void FillSyncDataList(
99 const extensions::ExtensionSet& extensions, 91 const extensions::ExtensionSet& extensions,
100 syncer::ModelType type, 92 syncer::ModelType type,
101 std::vector<extensions::ExtensionSyncData>* sync_data_list) const; 93 std::vector<extensions::ExtensionSyncData>* sync_data_list) const;
102 94
(...skipping 13 matching lines...) Expand all
116 Profile* profile_; 108 Profile* profile_;
117 109
118 // Preferences for the owning profile. 110 // Preferences for the owning profile.
119 extensions::ExtensionPrefs* extension_prefs_; 111 extensions::ExtensionPrefs* extension_prefs_;
120 112
121 ExtensionService* extension_service_; 113 ExtensionService* extension_service_;
122 114
123 extensions::SyncBundle app_sync_bundle_; 115 extensions::SyncBundle app_sync_bundle_;
124 extensions::SyncBundle extension_sync_bundle_; 116 extensions::SyncBundle extension_sync_bundle_;
125 117
126 // Set of extensions/apps that have been enabled before sync has started.
127 // TODO(treib,kalman): This seems wrong. Why are enables special, as opposed
128 // to disables, or any other changes?
129 extensions::PendingEnables pending_app_enables_;
130 extensions::PendingEnables pending_extension_enables_;
131
132 // Run()ning tells sync to try and start soon, because syncable changes 118 // Run()ning tells sync to try and start soon, because syncable changes
133 // have started happening. It will cause sync to call us back 119 // have started happening. It will cause sync to call us back
134 // asynchronously via MergeDataAndStartSyncing as soon as possible. 120 // asynchronously via MergeDataAndStartSyncing as soon as possible.
135 syncer::SyncableService::StartSyncFlare flare_; 121 syncer::SyncableService::StartSyncFlare flare_;
136 122
137 DISALLOW_COPY_AND_ASSIGN(ExtensionSyncService); 123 DISALLOW_COPY_AND_ASSIGN(ExtensionSyncService);
138 }; 124 };
139 125
140 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SYNC_SERVICE_H_ 126 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SYNC_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698