Index: chrome/browser/wake_lock/chrome_wake_lock_permission_context_factory.cc |
diff --git a/chrome/browser/wake_lock/chrome_wake_lock_permission_context_factory.cc b/chrome/browser/wake_lock/chrome_wake_lock_permission_context_factory.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a9c330ee0c70912d3eb8f6928a759bffe7ed25ea |
--- /dev/null |
+++ b/chrome/browser/wake_lock/chrome_wake_lock_permission_context_factory.cc |
@@ -0,0 +1,63 @@ |
+// Copyright (c) 2014 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/wake_lock/chrome_wake_lock_permission_context_factory.h" |
+ |
+#include "chrome/browser/profiles/profile.h" |
+#include "chrome/browser/wake_lock/chrome_wake_lock_permission_context.h" |
+#include "components/keyed_service/content/browser_context_dependency_manager.h" |
+ |
+namespace { |
+ |
+class Service : public KeyedService { |
+ public: |
+ explicit Service(Profile* profile) { |
+ context_ = new ChromeWakeLockPermissionContext(profile); |
+ } |
+ |
+ ChromeWakeLockPermissionContext* context() { |
+ return context_.get(); |
+ } |
+ |
+ virtual void Shutdown() OVERRIDE { |
+ context()->ShutdownOnUIThread(); |
+ } |
+ |
+ private: |
+ scoped_refptr<ChromeWakeLockPermissionContext> context_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(Service); |
+}; |
+ |
+} // namespace |
+ |
+// static |
+ChromeWakeLockPermissionContext* |
+ChromeWakeLockPermissionContextFactory::GetForProfile(Profile* profile) { |
+ return static_cast<Service*>( |
+ GetInstance()->GetServiceForBrowserContext(profile, true))->context(); |
+} |
+ |
+// static |
+ChromeWakeLockPermissionContextFactory* |
+ChromeWakeLockPermissionContextFactory::GetInstance() { |
+ return Singleton<ChromeWakeLockPermissionContextFactory>::get(); |
+} |
+ |
+ChromeWakeLockPermissionContextFactory:: |
+ChromeWakeLockPermissionContextFactory() |
+ : BrowserContextKeyedServiceFactory( |
+ "ChromeWakeLockPermissionContext", |
+ BrowserContextDependencyManager::GetInstance()) { |
+} |
+ |
+ChromeWakeLockPermissionContextFactory:: |
+~ChromeWakeLockPermissionContextFactory() { |
+} |
+ |
+KeyedService* |
+ChromeWakeLockPermissionContextFactory::BuildServiceInstanceFor( |
+ content::BrowserContext* profile) const { |
+ return new Service(static_cast<Profile*>(profile)); |
+} |