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