| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef EXTENSIONS_BROWSER_API_IDLE_IDLE_MANAGER_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_IDLE_IDLE_MANAGER_H_ |
| 6 #define EXTENSIONS_BROWSER_API_IDLE_IDLE_MANAGER_H_ | 6 #define EXTENSIONS_BROWSER_API_IDLE_IDLE_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
| 13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/scoped_observer.h" | 16 #include "base/scoped_observer.h" |
| 17 #include "base/threading/thread_checker.h" | 17 #include "base/threading/thread_checker.h" |
| 18 #include "base/timer/timer.h" | 18 #include "base/timer/timer.h" |
| 19 #include "components/keyed_service/core/keyed_service.h" | 19 #include "components/keyed_service/core/keyed_service.h" |
| 20 #include "extensions/browser/event_router.h" | 20 #include "extensions/browser/event_router.h" |
| 21 #include "extensions/browser/extension_registry_observer.h" | 21 #include "extensions/browser/extension_registry_observer.h" |
| 22 #include "ui/base/idle/idle.h" | 22 #include "ui/base/idle/idle.h" |
| 23 | 23 |
| 24 namespace base { | 24 namespace base { |
| 25 class Value; | 25 class Value; |
| 26 using StringValue = Value; | |
| 27 } // namespace base | 26 } // namespace base |
| 28 | 27 |
| 29 namespace content { | 28 namespace content { |
| 30 class BrowserContext; | 29 class BrowserContext; |
| 31 } // namespace content | 30 } // namespace content |
| 32 | 31 |
| 33 namespace extensions { | 32 namespace extensions { |
| 34 class ExtensionRegistry; | 33 class ExtensionRegistry; |
| 35 | 34 |
| 36 typedef base::Callback<void(ui::IdleState)> QueryStateCallback; | 35 typedef base::Callback<void(ui::IdleState)> QueryStateCallback; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 void OnExtensionUnloaded(content::BrowserContext* browser_context, | 84 void OnExtensionUnloaded(content::BrowserContext* browser_context, |
| 86 const Extension* extension, | 85 const Extension* extension, |
| 87 UnloadedExtensionInfo::Reason reason) override; | 86 UnloadedExtensionInfo::Reason reason) override; |
| 88 | 87 |
| 89 // EventRouter::Observer implementation. | 88 // EventRouter::Observer implementation. |
| 90 void OnListenerAdded(const EventListenerInfo& details) override; | 89 void OnListenerAdded(const EventListenerInfo& details) override; |
| 91 void OnListenerRemoved(const EventListenerInfo& details) override; | 90 void OnListenerRemoved(const EventListenerInfo& details) override; |
| 92 | 91 |
| 93 void QueryState(int threshold, const QueryStateCallback& notify); | 92 void QueryState(int threshold, const QueryStateCallback& notify); |
| 94 void SetThreshold(const std::string& extension_id, int threshold); | 93 void SetThreshold(const std::string& extension_id, int threshold); |
| 95 static std::unique_ptr<base::StringValue> CreateIdleValue( | 94 static std::unique_ptr<base::Value> CreateIdleValue(ui::IdleState idle_state); |
| 96 ui::IdleState idle_state); | |
| 97 | 95 |
| 98 // Override default event class. Callee assumes ownership. Used for testing. | 96 // Override default event class. Callee assumes ownership. Used for testing. |
| 99 void SetEventDelegateForTest(std::unique_ptr<EventDelegate> event_delegate); | 97 void SetEventDelegateForTest(std::unique_ptr<EventDelegate> event_delegate); |
| 100 | 98 |
| 101 // Override default idle time calculations. Callee assumes ownership. Used | 99 // Override default idle time calculations. Callee assumes ownership. Used |
| 102 // for testing. | 100 // for testing. |
| 103 void SetIdleTimeProviderForTest( | 101 void SetIdleTimeProviderForTest( |
| 104 std::unique_ptr<IdleTimeProvider> idle_provider); | 102 std::unique_ptr<IdleTimeProvider> idle_provider); |
| 105 | 103 |
| 106 private: | 104 private: |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 extension_registry_observer_; | 141 extension_registry_observer_; |
| 144 | 142 |
| 145 base::WeakPtrFactory<IdleManager> weak_factory_; | 143 base::WeakPtrFactory<IdleManager> weak_factory_; |
| 146 | 144 |
| 147 DISALLOW_COPY_AND_ASSIGN(IdleManager); | 145 DISALLOW_COPY_AND_ASSIGN(IdleManager); |
| 148 }; | 146 }; |
| 149 | 147 |
| 150 } // namespace extensions | 148 } // namespace extensions |
| 151 | 149 |
| 152 #endif // EXTENSIONS_BROWSER_API_IDLE_IDLE_MANAGER_H_ | 150 #endif // EXTENSIONS_BROWSER_API_IDLE_IDLE_MANAGER_H_ |
| OLD | NEW |