OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #include "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "build/build_config.h" | 6 #include "build/build_config.h" |
7 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 7 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
8 #include "chrome/browser/bookmarks/enhanced_bookmarks_features.h" | 8 #include "chrome/browser/bookmarks/enhanced_bookmarks_features.h" |
9 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" | 9 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" |
10 #include "chrome/browser/history/history_service.h" | 10 #include "chrome/browser/history/history_service.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 #include "components/password_manager/core/browser/password_store.h" | 53 #include "components/password_manager/core/browser/password_store.h" |
54 #include "components/signin/core/browser/signin_manager.h" | 54 #include "components/signin/core/browser/signin_manager.h" |
55 #include "components/sync_driver/data_type_manager_impl.h" | 55 #include "components/sync_driver/data_type_manager_impl.h" |
56 #include "components/sync_driver/data_type_manager_observer.h" | 56 #include "components/sync_driver/data_type_manager_observer.h" |
57 #include "components/sync_driver/generic_change_processor.h" | 57 #include "components/sync_driver/generic_change_processor.h" |
58 #include "components/sync_driver/proxy_data_type_controller.h" | 58 #include "components/sync_driver/proxy_data_type_controller.h" |
59 #include "components/sync_driver/shared_change_processor.h" | 59 #include "components/sync_driver/shared_change_processor.h" |
60 #include "components/sync_driver/ui_data_type_controller.h" | 60 #include "components/sync_driver/ui_data_type_controller.h" |
61 #include "content/public/browser/browser_thread.h" | 61 #include "content/public/browser/browser_thread.h" |
62 #include "extensions/browser/extension_system.h" | 62 #include "extensions/browser/extension_system.h" |
63 #include "google_apis/gaia/oauth2_token_service_request.h" | |
64 #include "net/url_request/url_request_context_getter.h" | |
63 #include "sync/api/attachments/attachment_service.h" | 65 #include "sync/api/attachments/attachment_service.h" |
64 #include "sync/api/attachments/attachment_service_impl.h" | 66 #include "sync/api/attachments/attachment_service_impl.h" |
65 #include "sync/api/syncable_service.h" | 67 #include "sync/api/syncable_service.h" |
68 #include "sync/internal_api/public/attachments/attachment_uploader_impl.h" | |
66 #include "sync/internal_api/public/attachments/fake_attachment_downloader.h" | 69 #include "sync/internal_api/public/attachments/fake_attachment_downloader.h" |
67 #include "sync/internal_api/public/attachments/fake_attachment_store.h" | 70 #include "sync/internal_api/public/attachments/fake_attachment_store.h" |
68 #include "sync/internal_api/public/attachments/fake_attachment_uploader.h" | |
69 | 71 |
70 #if defined(ENABLE_EXTENSIONS) | 72 #if defined(ENABLE_EXTENSIONS) |
71 #include "chrome/browser/extensions/api/storage/settings_sync_util.h" | 73 #include "chrome/browser/extensions/api/storage/settings_sync_util.h" |
72 #include "chrome/browser/extensions/api/synced_notifications_private/synced_noti fications_shim.h" | 74 #include "chrome/browser/extensions/api/synced_notifications_private/synced_noti fications_shim.h" |
73 #include "chrome/browser/extensions/extension_sync_service.h" | 75 #include "chrome/browser/extensions/extension_sync_service.h" |
74 #endif | 76 #endif |
75 | 77 |
76 #if defined(ENABLE_APP_LIST) | 78 #if defined(ENABLE_APP_LIST) |
77 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" | 79 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" |
78 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" | 80 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
135 syncer::ModelTypeSet enabled_types; | 137 syncer::ModelTypeSet enabled_types; |
136 if (command_line.HasSwitch(switches::kEnableSyncSyncedNotifications)) { | 138 if (command_line.HasSwitch(switches::kEnableSyncSyncedNotifications)) { |
137 enabled_types.Put(syncer::SYNCED_NOTIFICATIONS); | 139 enabled_types.Put(syncer::SYNCED_NOTIFICATIONS); |
138 } | 140 } |
139 return enabled_types; | 141 return enabled_types; |
140 } | 142 } |
141 | 143 |
142 } // namespace | 144 } // namespace |
143 | 145 |
144 ProfileSyncComponentsFactoryImpl::ProfileSyncComponentsFactoryImpl( | 146 ProfileSyncComponentsFactoryImpl::ProfileSyncComponentsFactoryImpl( |
145 Profile* profile, CommandLine* command_line) | 147 Profile* profile, |
148 CommandLine* command_line, | |
149 const GURL& sync_service_url, | |
150 const std::string& account_id, | |
151 const OAuth2TokenService::ScopeSet& scope_set, | |
152 OAuth2TokenService* token_service, | |
153 net::URLRequestContextGetter* url_request_context_getter) | |
146 : profile_(profile), | 154 : profile_(profile), |
147 command_line_(command_line), | 155 command_line_(command_line), |
148 extension_system_(extensions::ExtensionSystem::Get(profile)), | 156 extension_system_(extensions::ExtensionSystem::Get(profile)), |
149 web_data_service_( | 157 web_data_service_(WebDataServiceFactory::GetAutofillWebDataForProfile( |
150 WebDataServiceFactory::GetAutofillWebDataForProfile( | 158 profile_, Profile::EXPLICIT_ACCESS)), |
151 profile_, Profile::EXPLICIT_ACCESS)), | 159 sync_service_url_(sync_service_url), |
160 account_id_(account_id), | |
161 scope_set_(scope_set), | |
162 token_service_(token_service), | |
163 url_request_context_getter_(url_request_context_getter), | |
152 weak_factory_(this) { | 164 weak_factory_(this) { |
165 DCHECK(token_service_); | |
166 DCHECK(url_request_context_getter_); | |
153 } | 167 } |
154 | 168 |
155 ProfileSyncComponentsFactoryImpl::~ProfileSyncComponentsFactoryImpl() { | 169 ProfileSyncComponentsFactoryImpl::~ProfileSyncComponentsFactoryImpl() { |
156 } | 170 } |
157 | 171 |
158 void ProfileSyncComponentsFactoryImpl::RegisterDataTypes( | 172 void ProfileSyncComponentsFactoryImpl::RegisterDataTypes( |
159 ProfileSyncService* pss) { | 173 ProfileSyncService* pss) { |
160 syncer::ModelTypeSet disabled_types = | 174 syncer::ModelTypeSet disabled_types = |
161 GetDisabledTypesFromCommandLine(*command_line_); | 175 GetDisabledTypesFromCommandLine(*command_line_); |
162 syncer::ModelTypeSet enabled_types = | 176 syncer::ModelTypeSet enabled_types = |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
569 default: | 583 default: |
570 // The following datatypes still need to be transitioned to the | 584 // The following datatypes still need to be transitioned to the |
571 // syncer::SyncableService API: | 585 // syncer::SyncableService API: |
572 // Bookmarks | 586 // Bookmarks |
573 // Typed URLs | 587 // Typed URLs |
574 NOTREACHED(); | 588 NOTREACHED(); |
575 return base::WeakPtr<syncer::SyncableService>(); | 589 return base::WeakPtr<syncer::SyncableService>(); |
576 } | 590 } |
577 } | 591 } |
578 | 592 |
593 class TokenServiceProvider | |
594 : public OAuth2TokenServiceRequest::TokenServiceProvider { | |
595 public: | |
596 TokenServiceProvider( | |
597 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | |
598 OAuth2TokenService* token_service); | |
599 virtual ~TokenServiceProvider(); | |
600 | |
601 // OAuth2TokenServiceRequest::TokenServiceProvider implementation. | |
602 virtual scoped_refptr<base::SingleThreadTaskRunner> | |
603 GetTokenServiceTaskRunner() OVERRIDE; | |
604 virtual OAuth2TokenService* GetTokenService() OVERRIDE; | |
605 | |
606 private: | |
607 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | |
608 OAuth2TokenService* token_service_; | |
609 }; | |
610 | |
611 TokenServiceProvider::TokenServiceProvider( | |
612 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | |
613 OAuth2TokenService* token_service) | |
614 : task_runner_(task_runner), token_service_(token_service) { | |
615 } | |
616 | |
617 TokenServiceProvider::~TokenServiceProvider() { | |
618 } | |
619 | |
620 scoped_refptr<base::SingleThreadTaskRunner> | |
621 TokenServiceProvider::GetTokenServiceTaskRunner() { | |
622 return task_runner_; | |
623 } | |
624 | |
625 OAuth2TokenService* TokenServiceProvider::GetTokenService() { | |
626 return token_service_; | |
627 } | |
628 | |
579 scoped_ptr<syncer::AttachmentService> | 629 scoped_ptr<syncer::AttachmentService> |
580 ProfileSyncComponentsFactoryImpl::CreateAttachmentService( | 630 ProfileSyncComponentsFactoryImpl::CreateAttachmentService( |
581 syncer::AttachmentService::Delegate* delegate) { | 631 syncer::AttachmentService::Delegate* delegate) { |
582 // TODO(maniscalco): Use a shared (one per profile) thread-safe instances of | 632 std::string url_prefix = sync_service_url_.spec() + "/attachments/"; |
tim (not reviewing)
2014/06/18 02:59:47
Can "/attachments" be a const somewhere? And bett
maniscalco
2014/06/18 03:56:43
Done.
| |
633 scoped_ptr<OAuth2TokenServiceRequest::TokenServiceProvider> | |
634 token_service_provider(new TokenServiceProvider( | |
635 content::BrowserThread::GetMessageLoopProxyForThread( | |
636 content::BrowserThread::UI), | |
637 token_service_)); | |
638 | |
639 // TODO(maniscalco): Use shared (one per profile) thread-safe instances of | |
583 // AttachmentUploader and AttachmentDownloader instead of creating a new one | 640 // AttachmentUploader and AttachmentDownloader instead of creating a new one |
584 // per AttachmentService (bug 369536). | 641 // per AttachmentService (bug 369536). |
585 scoped_ptr<syncer::AttachmentUploader> attachment_uploader( | 642 scoped_ptr<syncer::AttachmentUploader> attachment_uploader( |
586 new syncer::FakeAttachmentUploader); | 643 new syncer::AttachmentUploaderImpl(url_prefix, |
644 url_request_context_getter_, | |
645 account_id_, | |
646 scope_set_, | |
647 token_service_provider.Pass())); | |
648 | |
587 scoped_ptr<syncer::AttachmentDownloader> attachment_downloader( | 649 scoped_ptr<syncer::AttachmentDownloader> attachment_downloader( |
588 new syncer::FakeAttachmentDownloader()); | 650 new syncer::FakeAttachmentDownloader()); |
589 | 651 |
590 scoped_ptr<syncer::AttachmentStore> attachment_store( | 652 scoped_ptr<syncer::AttachmentStore> attachment_store( |
591 new syncer::FakeAttachmentStore( | 653 new syncer::FakeAttachmentStore( |
592 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE))); | 654 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE))); |
593 | 655 |
594 scoped_ptr<syncer::AttachmentService> attachment_service( | 656 scoped_ptr<syncer::AttachmentService> attachment_service( |
595 new syncer::AttachmentServiceImpl(attachment_store.Pass(), | 657 new syncer::AttachmentServiceImpl(attachment_store.Pass(), |
596 attachment_uploader.Pass(), | 658 attachment_uploader.Pass(), |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
635 new TypedUrlModelAssociator(profile_sync_service, | 697 new TypedUrlModelAssociator(profile_sync_service, |
636 history_backend, | 698 history_backend, |
637 error_handler); | 699 error_handler); |
638 TypedUrlChangeProcessor* change_processor = | 700 TypedUrlChangeProcessor* change_processor = |
639 new TypedUrlChangeProcessor(profile_, | 701 new TypedUrlChangeProcessor(profile_, |
640 model_associator, | 702 model_associator, |
641 history_backend, | 703 history_backend, |
642 error_handler); | 704 error_handler); |
643 return SyncComponents(model_associator, change_processor); | 705 return SyncComponents(model_associator, change_processor); |
644 } | 706 } |
OLD | NEW |