| 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 using browser_sync::SyncBackendHost; | 117 using browser_sync::SyncBackendHost; |
| 118 using browser_sync::ThemeDataTypeController; | 118 using browser_sync::ThemeDataTypeController; |
| 119 using browser_sync::TypedUrlChangeProcessor; | 119 using browser_sync::TypedUrlChangeProcessor; |
| 120 using browser_sync::TypedUrlDataTypeController; | 120 using browser_sync::TypedUrlDataTypeController; |
| 121 using browser_sync::TypedUrlModelAssociator; | 121 using browser_sync::TypedUrlModelAssociator; |
| 122 using browser_sync::UIDataTypeController; | 122 using browser_sync::UIDataTypeController; |
| 123 using content::BrowserThread; | 123 using content::BrowserThread; |
| 124 | 124 |
| 125 namespace { | 125 namespace { |
| 126 | 126 |
| 127 const char kAttachmentsPath[] = "/attachments/"; | |
| 128 | |
| 129 syncer::ModelTypeSet GetDisabledTypesFromCommandLine( | 127 syncer::ModelTypeSet GetDisabledTypesFromCommandLine( |
| 130 const CommandLine& command_line) { | 128 const CommandLine& command_line) { |
| 131 syncer::ModelTypeSet disabled_types; | 129 syncer::ModelTypeSet disabled_types; |
| 132 std::string disabled_types_str = | 130 std::string disabled_types_str = |
| 133 command_line.GetSwitchValueASCII(switches::kDisableSyncTypes); | 131 command_line.GetSwitchValueASCII(switches::kDisableSyncTypes); |
| 134 disabled_types = syncer::ModelTypeSetFromString(disabled_types_str); | 132 disabled_types = syncer::ModelTypeSetFromString(disabled_types_str); |
| 135 return disabled_types; | 133 return disabled_types; |
| 136 } | 134 } |
| 137 | 135 |
| 138 syncer::ModelTypeSet GetEnabledTypesFromCommandLine( | 136 syncer::ModelTypeSet GetEnabledTypesFromCommandLine( |
| 139 const CommandLine& command_line) { | 137 const CommandLine& command_line) { |
| 140 syncer::ModelTypeSet enabled_types; | 138 syncer::ModelTypeSet enabled_types; |
| 141 if (command_line.HasSwitch(switches::kEnableSyncSyncedNotifications)) { | 139 if (command_line.HasSwitch(switches::kEnableSyncSyncedNotifications)) { |
| 142 enabled_types.Put(syncer::SYNCED_NOTIFICATIONS); | 140 enabled_types.Put(syncer::SYNCED_NOTIFICATIONS); |
| 143 } | 141 } |
| 144 return enabled_types; | 142 return enabled_types; |
| 145 } | 143 } |
| 146 | 144 |
| 147 // Returns the base URL for attachments. | |
| 148 std::string GetSyncServiceAttachmentsURL(const GURL& sync_service_url) { | |
| 149 return sync_service_url.spec() + kAttachmentsPath; | |
| 150 } | |
| 151 | |
| 152 } // namespace | 145 } // namespace |
| 153 | 146 |
| 154 ProfileSyncComponentsFactoryImpl::ProfileSyncComponentsFactoryImpl( | 147 ProfileSyncComponentsFactoryImpl::ProfileSyncComponentsFactoryImpl( |
| 155 Profile* profile, | 148 Profile* profile, |
| 156 CommandLine* command_line, | 149 CommandLine* command_line, |
| 157 const GURL& sync_service_url, | 150 const GURL& sync_service_url, |
| 158 const std::string& account_id, | 151 const std::string& account_id, |
| 159 const OAuth2TokenService::ScopeSet& scope_set, | 152 const OAuth2TokenService::ScopeSet& scope_set, |
| 160 OAuth2TokenService* token_service, | 153 OAuth2TokenService* token_service, |
| 161 net::URLRequestContextGetter* url_request_context_getter) | 154 net::URLRequestContextGetter* url_request_context_getter) |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 return task_runner_; | 617 return task_runner_; |
| 625 } | 618 } |
| 626 | 619 |
| 627 OAuth2TokenService* TokenServiceProvider::GetTokenService() { | 620 OAuth2TokenService* TokenServiceProvider::GetTokenService() { |
| 628 return token_service_; | 621 return token_service_; |
| 629 } | 622 } |
| 630 | 623 |
| 631 scoped_ptr<syncer::AttachmentService> | 624 scoped_ptr<syncer::AttachmentService> |
| 632 ProfileSyncComponentsFactoryImpl::CreateAttachmentService( | 625 ProfileSyncComponentsFactoryImpl::CreateAttachmentService( |
| 633 syncer::AttachmentService::Delegate* delegate) { | 626 syncer::AttachmentService::Delegate* delegate) { |
| 634 std::string url_prefix = GetSyncServiceAttachmentsURL(sync_service_url_); | |
| 635 scoped_ptr<OAuth2TokenServiceRequest::TokenServiceProvider> | 627 scoped_ptr<OAuth2TokenServiceRequest::TokenServiceProvider> |
| 636 token_service_provider(new TokenServiceProvider( | 628 token_service_provider(new TokenServiceProvider( |
| 637 content::BrowserThread::GetMessageLoopProxyForThread( | 629 content::BrowserThread::GetMessageLoopProxyForThread( |
| 638 content::BrowserThread::UI), | 630 content::BrowserThread::UI), |
| 639 token_service_)); | 631 token_service_)); |
| 640 | 632 |
| 641 // TODO(maniscalco): Use shared (one per profile) thread-safe instances of | 633 // TODO(maniscalco): Use shared (one per profile) thread-safe instances of |
| 642 // AttachmentUploader and AttachmentDownloader instead of creating a new one | 634 // AttachmentUploader and AttachmentDownloader instead of creating a new one |
| 643 // per AttachmentService (bug 369536). | 635 // per AttachmentService (bug 369536). |
| 644 scoped_ptr<syncer::AttachmentUploader> attachment_uploader( | 636 scoped_ptr<syncer::AttachmentUploader> attachment_uploader( |
| 645 new syncer::AttachmentUploaderImpl(url_prefix, | 637 new syncer::AttachmentUploaderImpl(sync_service_url_, |
| 646 url_request_context_getter_, | 638 url_request_context_getter_, |
| 647 account_id_, | 639 account_id_, |
| 648 scope_set_, | 640 scope_set_, |
| 649 token_service_provider.Pass())); | 641 token_service_provider.Pass())); |
| 650 | 642 |
| 651 scoped_ptr<syncer::AttachmentDownloader> attachment_downloader( | 643 scoped_ptr<syncer::AttachmentDownloader> attachment_downloader( |
| 652 new syncer::FakeAttachmentDownloader()); | 644 new syncer::FakeAttachmentDownloader()); |
| 653 | 645 |
| 654 scoped_ptr<syncer::AttachmentStore> attachment_store( | 646 scoped_ptr<syncer::AttachmentStore> attachment_store( |
| 655 new syncer::FakeAttachmentStore( | 647 new syncer::FakeAttachmentStore( |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 new TypedUrlModelAssociator(profile_sync_service, | 691 new TypedUrlModelAssociator(profile_sync_service, |
| 700 history_backend, | 692 history_backend, |
| 701 error_handler); | 693 error_handler); |
| 702 TypedUrlChangeProcessor* change_processor = | 694 TypedUrlChangeProcessor* change_processor = |
| 703 new TypedUrlChangeProcessor(profile_, | 695 new TypedUrlChangeProcessor(profile_, |
| 704 model_associator, | 696 model_associator, |
| 705 history_backend, | 697 history_backend, |
| 706 error_handler); | 698 error_handler); |
| 707 return SyncComponents(model_associator, change_processor); | 699 return SyncComponents(model_associator, change_processor); |
| 708 } | 700 } |
| OLD | NEW |