Chromium Code Reviews| Index: chrome/browser/sync/sessions/sync_sessions_web_contents_router_factory.cc |
| diff --git a/chrome/browser/sync/sessions/sync_sessions_web_contents_router_factory.cc b/chrome/browser/sync/sessions/sync_sessions_web_contents_router_factory.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..824a29218bcb261b968cf7a2ef0810128d5a05fd |
| --- /dev/null |
| +++ b/chrome/browser/sync/sessions/sync_sessions_web_contents_router_factory.cc |
| @@ -0,0 +1,48 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| +#include "chrome/browser/sync/sessions/sync_sessions_web_contents_router_factory.h" |
| + |
| +#include "base/logging.h" |
| +#include "base/memory/singleton.h" |
| +#include "chrome/browser/profiles/profile.h" |
| +#include "chrome/browser/sync/sessions/sync_sessions_web_contents_router.h" |
| +#if !defined(OS_ANDROID) |
| +#include "chrome/browser/sync/sessions/sync_sessions_multi_windowed_web_contents_router.h" |
| +#endif // !defined(OS_ANDROID) |
| + |
| +#include "components/keyed_service/content/browser_context_dependency_manager.h" |
| + |
| +namespace sync_sessions { |
| + |
| +// static |
| +SyncSessionsWebContentsRouter* |
| +SyncSessionsWebContentsRouterFactory::GetForProfile(Profile* profile) { |
| + return static_cast<SyncSessionsWebContentsRouter*>( |
| + GetInstance()->GetServiceForBrowserContext(profile, true)); |
| +} |
| + |
| +// static |
| +SyncSessionsWebContentsRouterFactory* |
| +SyncSessionsWebContentsRouterFactory::GetInstance() { |
| + return base::Singleton<SyncSessionsWebContentsRouterFactory>::get(); |
| +} |
| + |
| +SyncSessionsWebContentsRouterFactory::SyncSessionsWebContentsRouterFactory() |
| + : BrowserContextKeyedServiceFactory( |
| + "SyncSessionsWebContentsRouter", |
| + BrowserContextDependencyManager::GetInstance()) {} |
| + |
| +SyncSessionsWebContentsRouterFactory::~SyncSessionsWebContentsRouterFactory() {} |
| + |
| +KeyedService* SyncSessionsWebContentsRouterFactory::BuildServiceInstanceFor( |
| + content::BrowserContext* context) const { |
| +#if !defined(OS_ANDROID) |
|
Nicolas Zea
2017/03/20 18:14:50
nit: prefer have the positive version of the condi
Patrick Noland
2017/03/21 22:54:31
With composition, this seemed no longer possible w
|
| + return new SyncSessionsMultiWindowedWebContentsRouter( |
| + static_cast<Profile*>(context)); |
| +#else |
| + return new SyncSessionsWebContentsRouter(static_cast<Profile*>(context)); |
| +#endif // !defined(OS_ANDROID) |
| +} |
| + |
| +} // namespace sync_sessions |