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