| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/chromeos/login/ui/shared_web_view_factory.h" |
| 6 |
| 7 #include "chrome/browser/chromeos/login/ui/shared_web_view.h" |
| 8 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 9 #include "chrome/browser/profiles/incognito_helpers.h" |
| 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 12 |
| 13 namespace chromeos { |
| 14 |
| 15 // static |
| 16 SharedWebView* SharedWebViewFactory::GetForProfile(Profile* profile) { |
| 17 auto result = static_cast<SharedWebView*>( |
| 18 GetInstance()->GetServiceForBrowserContext(profile, true)); |
| 19 return result; |
| 20 } |
| 21 |
| 22 // static |
| 23 SharedWebViewFactory* SharedWebViewFactory::GetInstance() { |
| 24 return base::Singleton<SharedWebViewFactory>::get(); |
| 25 } |
| 26 |
| 27 SharedWebViewFactory::SharedWebViewFactory() |
| 28 : BrowserContextKeyedServiceFactory( |
| 29 "SharedWebViewFactory", |
| 30 BrowserContextDependencyManager::GetInstance()) {} |
| 31 |
| 32 SharedWebViewFactory::~SharedWebViewFactory() {} |
| 33 |
| 34 content::BrowserContext* SharedWebViewFactory::GetBrowserContextToUse( |
| 35 content::BrowserContext* context) const { |
| 36 // Make sure that only the SigninProfile is using a shared webview. |
| 37 if (Profile::FromBrowserContext(context) != ProfileHelper::GetSigninProfile()) |
| 38 return nullptr; |
| 39 |
| 40 return context; |
| 41 } |
| 42 |
| 43 KeyedService* SharedWebViewFactory::BuildServiceInstanceFor( |
| 44 content::BrowserContext* context) const { |
| 45 return new SharedWebView(Profile::FromBrowserContext(context)); |
| 46 } |
| 47 |
| 48 } // namespace chromeos |
| OLD | NEW |