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 17class Profile; 18 19namespace base { 20class CommandLine; 21} 22 23namespace extensions { 24class ExtensionSystem; 25} 26 27class 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 virtual ~ProfileSyncComponentsFactoryImpl(); 44 45 virtual void RegisterDataTypes(ProfileSyncService* pss) OVERRIDE; 46 47 virtual 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) 54 OVERRIDE; 55 56 virtual browser_sync::SyncBackendHost* CreateSyncBackendHost( 57 const std::string& name, 58 Profile* profile, 59 invalidation::InvalidationService* invalidator, 60 const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs, 61 const base::FilePath& sync_folder) OVERRIDE; 62 63 virtual scoped_ptr<sync_driver::LocalDeviceInfoProvider> 64 CreateLocalDeviceInfoProvider() OVERRIDE; 65 66 virtual base::WeakPtr<syncer::SyncableService> GetSyncableServiceForType( 67 syncer::ModelType type) OVERRIDE; 68 virtual scoped_ptr<syncer::AttachmentService> CreateAttachmentService( 69 const scoped_refptr<syncer::AttachmentStore>& attachment_store, 70 const syncer::UserShare& user_share, 71 syncer::AttachmentService::Delegate* delegate) OVERRIDE; 72 73 // Legacy datatypes that need to be converted to the SyncableService API. 74 virtual SyncComponents CreateBookmarkSyncComponents( 75 ProfileSyncService* profile_sync_service, 76 sync_driver::DataTypeErrorHandler* error_handler) OVERRIDE; 77 virtual SyncComponents CreateTypedUrlSyncComponents( 78 ProfileSyncService* profile_sync_service, 79 history::HistoryBackend* history_backend, 80 sync_driver::DataTypeErrorHandler* error_handler) OVERRIDE; 81 82 private: 83 // Register data types which are enabled on desktop platforms only. 84 // |disabled_types| and |enabled_types| correspond only to those types 85 // being explicitly enabled/disabled by the command line. 86 void RegisterDesktopDataTypes(syncer::ModelTypeSet disabled_types, 87 syncer::ModelTypeSet enabled_types, 88 ProfileSyncService* pss); 89 // Register data types which are enabled on both desktop and mobile. 90 // |disabled_types| and |enabled_types| correspond only to those types 91 // being explicitly enabled/disabled by the command line. 92 void RegisterCommonDataTypes(syncer::ModelTypeSet disabled_types, 93 syncer::ModelTypeSet enabled_types, 94 ProfileSyncService* pss); 95 // Used to bind a callback to give to DataTypeControllers to disable 96 // data types. 97 sync_driver::DataTypeController::DisableTypeCallback 98 MakeDisableCallbackFor(syncer::ModelType type); 99 void DisableBrokenType(syncer::ModelType type, 100 const tracked_objects::Location& from_here, 101 const std::string& message); 102 103 Profile* profile_; 104 base::CommandLine* command_line_; 105 scoped_refptr<autofill::AutofillWebDataService> web_data_service_; 106 107 const GURL sync_service_url_; 108 OAuth2TokenService* const token_service_; 109 net::URLRequestContextGetter* const url_request_context_getter_; 110 111 base::WeakPtrFactory<ProfileSyncComponentsFactoryImpl> weak_factory_; 112 113 DISALLOW_COPY_AND_ASSIGN(ProfileSyncComponentsFactoryImpl); 114}; 115 116#endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_COMPONENTS_FACTORY_IMPL_H__ 117