Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / sync / profile_sync_components_factory_impl.h
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 CHROME_BROWSER_SYNC_PROFILE_SYNC_COMPONENTS_FACTORY_IMPL_H__
6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_COMPONENTS_FACTORY_IMPL_H__
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/memory/weak_ptr.h"
13 #include "chrome/browser/sync/profile_sync_components_factory.h"
14 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
15 #include "google_apis/gaia/oauth2_token_service.h"
16
17 class Profile;
18
19 namespace base {
20 class CommandLine;
21 }
22
23 namespace extensions {
24 class ExtensionSystem;
25 }
26
27 class ProfileSyncComponentsFactoryImpl : public ProfileSyncComponentsFactory {
28  public:
29   // Constructs a ProfileSyncComponentsFactoryImpl.
30   //
31   // |sync_service_url| is the base URL of the sync server.
32   //
33   // |token_service| must outlive the ProfileSyncComponentsFactoryImpl.
34   //
35   // |url_request_context_getter| must outlive the
36   // ProfileSyncComponentsFactoryImpl.
37   ProfileSyncComponentsFactoryImpl(
38       Profile* profile,
39       base::CommandLine* command_line,
40       const GURL& sync_service_url,
41       OAuth2TokenService* token_service,
42       net::URLRequestContextGetter* url_request_context_getter);
43   ~ProfileSyncComponentsFactoryImpl() override;
44
45   void RegisterDataTypes(ProfileSyncService* pss) override;
46
47   sync_driver::DataTypeManager* CreateDataTypeManager(
48       const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>&
49           debug_info_listener,
50       const sync_driver::DataTypeController::TypeMap* controllers,
51       const sync_driver::DataTypeEncryptionHandler* encryption_handler,
52       browser_sync::SyncBackendHost* backend,
53       sync_driver::DataTypeManagerObserver* observer) override;
54
55   browser_sync::SyncBackendHost* CreateSyncBackendHost(
56       const std::string& name,
57       Profile* profile,
58       invalidation::InvalidationService* invalidator,
59       const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs,
60       const base::FilePath& sync_folder) override;
61
62   scoped_ptr<sync_driver::LocalDeviceInfoProvider>
63   CreateLocalDeviceInfoProvider() override;
64
65   base::WeakPtr<syncer::SyncableService> GetSyncableServiceForType(
66       syncer::ModelType type) override;
67   scoped_ptr<syncer::AttachmentService> CreateAttachmentService(
68       const scoped_refptr<syncer::AttachmentStore>& attachment_store,
69       const syncer::UserShare& user_share,
70       syncer::AttachmentService::Delegate* delegate) override;
71
72   // Legacy datatypes that need to be converted to the SyncableService API.
73   SyncComponents CreateBookmarkSyncComponents(
74       ProfileSyncService* profile_sync_service,
75       sync_driver::DataTypeErrorHandler* error_handler) override;
76   SyncComponents CreateTypedUrlSyncComponents(
77       ProfileSyncService* profile_sync_service,
78       history::HistoryBackend* history_backend,
79       sync_driver::DataTypeErrorHandler* error_handler) override;
80
81  private:
82   // Register data types which are enabled on desktop platforms only.
83   // |disabled_types| and |enabled_types| correspond only to those types
84   // being explicitly enabled/disabled by the command line.
85   void RegisterDesktopDataTypes(syncer::ModelTypeSet disabled_types,
86                                 syncer::ModelTypeSet enabled_types,
87                                 ProfileSyncService* pss);
88   // Register data types which are enabled on both desktop and mobile.
89   // |disabled_types| and |enabled_types| correspond only to those types
90   // being explicitly enabled/disabled by the command line.
91   void RegisterCommonDataTypes(syncer::ModelTypeSet disabled_types,
92                                syncer::ModelTypeSet enabled_types,
93                                ProfileSyncService* pss);
94   // Used to bind a callback to give to DataTypeControllers to disable
95   // data types.
96   sync_driver::DataTypeController::DisableTypeCallback
97       MakeDisableCallbackFor(syncer::ModelType type);
98   void DisableBrokenType(syncer::ModelType type,
99                          const tracked_objects::Location& from_here,
100                          const std::string& message);
101
102   Profile* profile_;
103   base::CommandLine* command_line_;
104   scoped_refptr<autofill::AutofillWebDataService> web_data_service_;
105
106   const GURL sync_service_url_;
107   OAuth2TokenService* const token_service_;
108   net::URLRequestContextGetter* const url_request_context_getter_;
109
110   base::WeakPtrFactory<ProfileSyncComponentsFactoryImpl> weak_factory_;
111
112   DISALLOW_COPY_AND_ASSIGN(ProfileSyncComponentsFactoryImpl);
113 };
114
115 #endif  // CHROME_BROWSER_SYNC_PROFILE_SYNC_COMPONENTS_FACTORY_IMPL_H__