OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef COMPONENTS_BROWSER_SYNC_BROWSER_PROFILE_SYNC_COMPONENTS_FACTORY_IMPL_H__ | |
6 #define COMPONENTS_BROWSER_SYNC_BROWSER_PROFILE_SYNC_COMPONENTS_FACTORY_IMPL_H__ | |
7 | |
8 #include <memory> | |
9 #include <string> | |
10 | |
11 #include "base/command_line.h" | |
12 #include "base/compiler_specific.h" | |
13 #include "base/macros.h" | |
14 #include "base/memory/weak_ptr.h" | |
15 #include "components/sync/base/model_type.h" | |
16 #include "components/sync/driver/sync_api_component_factory.h" | |
17 #include "components/version_info/version_info.h" | |
18 #include "url/gurl.h" | |
19 | |
20 class OAuth2TokenService; | |
21 class Profile; | |
22 | |
23 namespace autofill { | |
24 class AutofillWebDataService; | |
25 } | |
26 | |
27 namespace password_manager { | |
28 class PasswordStore; | |
29 } | |
30 | |
31 namespace net { | |
32 class URLRequestContextGetter; | |
33 } | |
34 | |
35 class ProfileSyncComponentsFactoryImpl | |
36 : public sync_driver::SyncApiComponentFactory { | |
37 public: | |
38 // Constructs a ProfileSyncComponentsFactoryImpl. | |
39 // | |
40 // |sync_service_url| is the base URL of the sync server. | |
41 // | |
42 // |token_service| must outlive the ProfileSyncComponentsFactoryImpl. | |
43 // | |
44 // |url_request_context_getter| must outlive the | |
45 // ProfileSyncComponentsFactoryImpl. | |
46 ProfileSyncComponentsFactoryImpl( | |
47 sync_driver::SyncClient* sync_client, | |
48 version_info::Channel channel, | |
49 const std::string& version, | |
50 bool is_tablet, | |
51 const base::CommandLine& command_line, | |
52 const char* history_disabled_pref, | |
53 const GURL& sync_service_url, | |
54 const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread, | |
55 const scoped_refptr<base::SingleThreadTaskRunner>& db_thread, | |
56 OAuth2TokenService* token_service, | |
57 net::URLRequestContextGetter* url_request_context_getter, | |
58 const scoped_refptr<autofill::AutofillWebDataService>& web_data_service, | |
59 const scoped_refptr<password_manager::PasswordStore>& password_store); | |
60 ~ProfileSyncComponentsFactoryImpl() override; | |
61 | |
62 // SyncApiComponentFactory implementation: | |
63 void RegisterDataTypes( | |
64 sync_driver::SyncService* sync_service, | |
65 const RegisterDataTypesMethod& register_platform_types_method) override; | |
66 sync_driver::DataTypeManager* CreateDataTypeManager( | |
67 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& | |
68 debug_info_listener, | |
69 const sync_driver::DataTypeController::TypeMap* controllers, | |
70 const sync_driver::DataTypeEncryptionHandler* encryption_handler, | |
71 browser_sync::SyncBackendHost* backend, | |
72 sync_driver::DataTypeManagerObserver* observer) override; | |
73 browser_sync::SyncBackendHost* CreateSyncBackendHost( | |
74 const std::string& name, | |
75 invalidation::InvalidationService* invalidator, | |
76 const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs, | |
77 const base::FilePath& sync_folder) override; | |
78 std::unique_ptr<sync_driver::LocalDeviceInfoProvider> | |
79 CreateLocalDeviceInfoProvider() override; | |
80 std::unique_ptr<syncer::AttachmentService> CreateAttachmentService( | |
81 std::unique_ptr<syncer::AttachmentStoreForSync> attachment_store, | |
82 const syncer::UserShare& user_share, | |
83 const std::string& store_birthday, | |
84 syncer::ModelType model_type, | |
85 syncer::AttachmentService::Delegate* delegate) override; | |
86 sync_driver::SyncApiComponentFactory::SyncComponents | |
87 CreateBookmarkSyncComponents( | |
88 sync_driver::SyncService* sync_service, | |
89 std::unique_ptr<syncer::DataTypeErrorHandler> error_handler) override; | |
90 | |
91 // Sets a bit that determines whether PREFERENCES should be registered with a | |
92 // ModelTypeController for testing purposes. | |
93 static void OverridePrefsForUssTest(bool use_uss); | |
94 | |
95 private: | |
96 // Register data types which are enabled on both desktop and mobile. | |
97 // |disabled_types| and |enabled_types| correspond only to those types | |
98 // being explicitly enabled/disabled by the command line. | |
99 void RegisterCommonDataTypes(sync_driver::SyncService* sync_service, | |
100 syncer::ModelTypeSet disabled_types, | |
101 syncer::ModelTypeSet enabled_types); | |
102 | |
103 void DisableBrokenType(syncer::ModelType type, | |
104 const tracked_objects::Location& from_here, | |
105 const std::string& message); | |
106 | |
107 // Client/platform specific members. | |
108 sync_driver::SyncClient* const sync_client_; | |
109 const version_info::Channel channel_; | |
110 const std::string version_; | |
111 const bool is_tablet_; | |
112 const base::CommandLine command_line_; | |
113 const char* history_disabled_pref_; | |
114 const GURL sync_service_url_; | |
115 const scoped_refptr<base::SingleThreadTaskRunner> ui_thread_; | |
116 const scoped_refptr<base::SingleThreadTaskRunner> db_thread_; | |
117 OAuth2TokenService* const token_service_; | |
118 net::URLRequestContextGetter* const url_request_context_getter_; | |
119 const scoped_refptr<autofill::AutofillWebDataService> web_data_service_; | |
120 const scoped_refptr<password_manager::PasswordStore> password_store_; | |
121 | |
122 base::WeakPtrFactory<ProfileSyncComponentsFactoryImpl> weak_factory_; | |
123 | |
124 // Whether to override PREFERENCES to use USS. | |
125 static bool override_prefs_controller_to_uss_for_test_; | |
126 | |
127 DISALLOW_COPY_AND_ASSIGN(ProfileSyncComponentsFactoryImpl); | |
128 }; | |
129 | |
130 #endif // COMPONENTS_BROWSER_SYNC_BROWSER_PROFILE_SYNC_COMPONENTS_FACTORY_IMPL_
H__ | |
OLD | NEW |