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 #ifndef CHROME_BROWSER_EXTENSIONS_PENDING_ENABLES_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_PENDING_ENABLES_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_PENDING_ENABLES_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_PENDING_ENABLES_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 // Included for syncer::ModelType, which is in | 10 // Included for syncer::ModelType, which is in |
11 // sync/internal_api/public/base/model_type.h but that is disallowed by | 11 // sync/internal_api/public/base/model_type.h but that is disallowed by |
12 // chrome/browser/DEPS. | 12 // chrome/browser/DEPS. |
13 #include "sync/api/syncable_service.h" | 13 #include "sync/api/syncable_service.h" |
14 | 14 |
15 class ExtensionService; | 15 class ExtensionService; |
16 class ProfileSyncService; | 16 class ProfileSyncService; |
17 | 17 |
18 namespace browser_sync { | 18 namespace sync_driver { |
19 class SyncPrefs; | 19 class SyncPrefs; |
20 } | 20 } |
21 | 21 |
22 namespace extensions { | 22 namespace extensions { |
23 | 23 |
24 class SyncBundle; | 24 class SyncBundle; |
25 | 25 |
26 // A pending enable is when an app or extension is enabled locally before sync | 26 // A pending enable is when an app or extension is enabled locally before sync |
27 // has started. We track these to prevent sync data arriving and clobbering | 27 // has started. We track these to prevent sync data arriving and clobbering |
28 // local state, and also to ensure that these early enables get synced to the | 28 // local state, and also to ensure that these early enables get synced to the |
29 // server when sync does start. | 29 // server when sync does start. |
30 class PendingEnables { | 30 class PendingEnables { |
31 public: | 31 public: |
32 PendingEnables(scoped_ptr<browser_sync::SyncPrefs> sync_prefs, | 32 PendingEnables(scoped_ptr<sync_driver::SyncPrefs> sync_prefs, |
33 SyncBundle* sync_bundle, | 33 SyncBundle* sync_bundle, |
34 syncer::ModelType enable_type); | 34 syncer::ModelType enable_type); |
35 ~PendingEnables(); | 35 ~PendingEnables(); |
36 | 36 |
37 // Called when an extension is enabled / disabled locally. | 37 // Called when an extension is enabled / disabled locally. |
38 // These will check the sync state and figure out whether the change | 38 // These will check the sync state and figure out whether the change |
39 // needs to be remembered for syncing when syncing starts. | 39 // needs to be remembered for syncing when syncing starts. |
40 void OnExtensionEnabled(const std::string& extension_id); | 40 void OnExtensionEnabled(const std::string& extension_id); |
41 void OnExtensionDisabled(const std::string& extension_id); | 41 void OnExtensionDisabled(const std::string& extension_id); |
42 | 42 |
43 // Called when |sync_bundle_| is ready to accept sync changes. | 43 // Called when |sync_bundle_| is ready to accept sync changes. |
44 // Uses |service| to look up extensions from extension ids. | 44 // Uses |service| to look up extensions from extension ids. |
45 void OnSyncStarted(ExtensionService* service); | 45 void OnSyncStarted(ExtensionService* service); |
46 | 46 |
47 // Whether |extension_id| has a pending enable. | 47 // Whether |extension_id| has a pending enable. |
48 bool Contains(const std::string& extension_id) const; | 48 bool Contains(const std::string& extension_id) const; |
49 | 49 |
50 private: | 50 private: |
51 bool IsSyncEnabled(); | 51 bool IsSyncEnabled(); |
52 bool IsWaitingForSync(); | 52 bool IsWaitingForSync(); |
53 | 53 |
54 scoped_ptr<browser_sync::SyncPrefs> sync_prefs_; | 54 scoped_ptr<sync_driver::SyncPrefs> sync_prefs_; |
55 SyncBundle* sync_bundle_; | 55 SyncBundle* sync_bundle_; |
56 syncer::ModelType enable_type_; | 56 syncer::ModelType enable_type_; |
57 std::set<std::string> ids_; | 57 std::set<std::string> ids_; |
58 | 58 |
59 bool is_sync_enabled_for_test_; | 59 bool is_sync_enabled_for_test_; |
60 | 60 |
61 DISALLOW_COPY_AND_ASSIGN(PendingEnables); | 61 DISALLOW_COPY_AND_ASSIGN(PendingEnables); |
62 }; | 62 }; |
63 | 63 |
64 } // namespace extensions | 64 } // namespace extensions |
65 | 65 |
66 #endif // CHROME_BROWSER_EXTENSIONS_PENDING_ENABLES_H_ | 66 #endif // CHROME_BROWSER_EXTENSIONS_PENDING_ENABLES_H_ |
OLD | NEW |