OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 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/media/chrome_midi_permission_context_factory.h" |
| 6 |
| 7 #include "chrome/browser/media/chrome_midi_permission_context.h" |
| 8 #include "chrome/browser/profiles/incognito_helpers.h" |
| 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" |
| 11 |
| 12 namespace { |
| 13 |
| 14 class Service : public BrowserContextKeyedService { |
| 15 public: |
| 16 explicit Service(Profile* profile) { |
| 17 context_ = new ChromeMIDIPermissionContext(profile); |
| 18 } |
| 19 |
| 20 ChromeMIDIPermissionContext* context() { |
| 21 return context_.get(); |
| 22 } |
| 23 |
| 24 virtual void Shutdown() OVERRIDE { |
| 25 context()->ShutdownOnUIThread(); |
| 26 } |
| 27 |
| 28 private: |
| 29 scoped_refptr<ChromeMIDIPermissionContext> context_; |
| 30 |
| 31 DISALLOW_COPY_AND_ASSIGN(Service); |
| 32 }; |
| 33 |
| 34 } // namespace |
| 35 |
| 36 // static |
| 37 ChromeMIDIPermissionContext* |
| 38 ChromeMIDIPermissionContextFactory::GetForProfile(Profile* profile) { |
| 39 return static_cast<Service*>( |
| 40 GetInstance()->GetServiceForBrowserContext(profile, true))->context(); |
| 41 } |
| 42 |
| 43 // static |
| 44 ChromeMIDIPermissionContextFactory* |
| 45 ChromeMIDIPermissionContextFactory::GetInstance() { |
| 46 return Singleton<ChromeMIDIPermissionContextFactory>::get(); |
| 47 } |
| 48 |
| 49 ChromeMIDIPermissionContextFactory:: |
| 50 ChromeMIDIPermissionContextFactory() |
| 51 : BrowserContextKeyedServiceFactory( |
| 52 "ChromeMIDIPermissionContext", |
| 53 BrowserContextDependencyManager::GetInstance()) { |
| 54 } |
| 55 |
| 56 ChromeMIDIPermissionContextFactory:: |
| 57 ~ChromeMIDIPermissionContextFactory() { |
| 58 } |
| 59 |
| 60 BrowserContextKeyedService* |
| 61 ChromeMIDIPermissionContextFactory::BuildServiceInstanceFor( |
| 62 content::BrowserContext* profile) const { |
| 63 return new Service(static_cast<Profile*>(profile)); |
| 64 } |
| 65 |
| 66 content::BrowserContext* |
| 67 ChromeMIDIPermissionContextFactory::GetBrowserContextToUse( |
| 68 content::BrowserContext* context) const { |
| 69 return chrome::GetBrowserContextOwnInstanceInIncognito(context); |
| 70 } |
OLD | NEW |