| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/browser/chromeos/printing/printers_manager_factory.h" | 5 #include "chrome/browser/chromeos/printing/printers_manager_factory.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/debug/dump_without_crashing.h" | 10 #include "base/debug/dump_without_crashing.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "chrome/browser/chromeos/printing/printers_sync_bridge.h" | 12 #include "chrome/browser/chromeos/printing/printers_sync_bridge.h" |
| 13 #include "chrome/browser/profiles/incognito_helpers.h" | 13 #include "chrome/browser/profiles/incognito_helpers.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/sync/profile_sync_service_factory.h" | 15 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 16 #include "components/browser_sync/profile_sync_service.h" | 16 #include "components/browser_sync/profile_sync_service.h" |
| 17 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 17 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 18 #include "content/public/browser/browser_context.h" | 18 #include "content/public/browser/browser_context.h" |
| 19 #include "content/public/browser/browser_thread.h" |
| 19 | 20 |
| 20 namespace chromeos { | 21 namespace chromeos { |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| 23 | 24 |
| 24 base::LazyInstance<PrintersManagerFactory>::DestructorAtExit | 25 base::LazyInstance<PrintersManagerFactory>::DestructorAtExit |
| 25 g_printers_manager = LAZY_INSTANCE_INITIALIZER; | 26 g_printers_manager = LAZY_INSTANCE_INITIALIZER; |
| 26 | 27 |
| 27 } // namespace | 28 } // namespace |
| 28 | 29 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 47 : BrowserContextKeyedServiceFactory( | 48 : BrowserContextKeyedServiceFactory( |
| 48 "PrintersManager", | 49 "PrintersManager", |
| 49 BrowserContextDependencyManager::GetInstance()) {} | 50 BrowserContextDependencyManager::GetInstance()) {} |
| 50 | 51 |
| 51 PrintersManagerFactory::~PrintersManagerFactory() {} | 52 PrintersManagerFactory::~PrintersManagerFactory() {} |
| 52 | 53 |
| 53 PrintersManager* PrintersManagerFactory::BuildServiceInstanceFor( | 54 PrintersManager* PrintersManagerFactory::BuildServiceInstanceFor( |
| 54 content::BrowserContext* browser_context) const { | 55 content::BrowserContext* browser_context) const { |
| 55 Profile* profile = Profile::FromBrowserContext(browser_context); | 56 Profile* profile = Profile::FromBrowserContext(browser_context); |
| 56 | 57 |
| 57 browser_sync::ProfileSyncService* sync_service = | |
| 58 ProfileSyncServiceFactory::GetForProfile(profile); | |
| 59 | |
| 60 // TODO(skym): After crbug.com/688533 is fixed, this should not use | |
| 61 // CreateInMemoryStoreForTest, but rather a ModelTypeStore creation mechanism | |
| 62 // that's agnostic to the existence of sync infrastructure. | |
| 63 const syncer::ModelTypeStoreFactory& store_factory = | 58 const syncer::ModelTypeStoreFactory& store_factory = |
| 64 sync_service ? sync_service->GetModelTypeStoreFactory(syncer::PRINTERS) | 59 browser_sync::ProfileSyncService::GetModelTypeStoreFactory( |
| 65 : base::BindRepeating( | 60 syncer::PRINTERS, profile->GetPath(), |
| 66 syncer::ModelTypeStore::CreateInMemoryStoreForTest, | 61 content::BrowserThread::GetBlockingPool()); |
| 67 syncer::PRINTERS); | |
| 68 | 62 |
| 69 std::unique_ptr<PrintersSyncBridge> sync_bridge = | 63 std::unique_ptr<PrintersSyncBridge> sync_bridge = |
| 70 base::MakeUnique<PrintersSyncBridge>( | 64 base::MakeUnique<PrintersSyncBridge>( |
| 71 store_factory, | 65 store_factory, |
| 72 base::BindRepeating( | 66 base::BindRepeating( |
| 73 base::IgnoreResult(&base::debug::DumpWithoutCrashing))); | 67 base::IgnoreResult(&base::debug::DumpWithoutCrashing))); |
| 74 | 68 |
| 75 return new PrintersManager(profile, std::move(sync_bridge)); | 69 return new PrintersManager(profile, std::move(sync_bridge)); |
| 76 } | 70 } |
| 77 | 71 |
| 78 } // namespace chromeos | 72 } // namespace chromeos |
| OLD | NEW |