| 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 #include "chrome/browser/extensions/api/idle/idle_manager.h" | 5 #include "chrome/browser/extensions/api/idle/idle_manager.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 idle_time_provider_->CalculateIdleState(threshold, notify); | 182 idle_time_provider_->CalculateIdleState(threshold, notify); |
| 183 } | 183 } |
| 184 | 184 |
| 185 void IdleManager::SetThreshold(const std::string& extension_id, | 185 void IdleManager::SetThreshold(const std::string& extension_id, |
| 186 int threshold) { | 186 int threshold) { |
| 187 DCHECK(thread_checker_.CalledOnValidThread()); | 187 DCHECK(thread_checker_.CalledOnValidThread()); |
| 188 GetMonitor(extension_id)->threshold = threshold; | 188 GetMonitor(extension_id)->threshold = threshold; |
| 189 } | 189 } |
| 190 | 190 |
| 191 // static | 191 // static |
| 192 StringValue* IdleManager::CreateIdleValue(IdleState idle_state) { | 192 base::StringValue* IdleManager::CreateIdleValue(IdleState idle_state) { |
| 193 const char* description; | 193 const char* description; |
| 194 | 194 |
| 195 if (idle_state == IDLE_STATE_ACTIVE) { | 195 if (idle_state == IDLE_STATE_ACTIVE) { |
| 196 description = keys::kStateActive; | 196 description = keys::kStateActive; |
| 197 } else if (idle_state == IDLE_STATE_IDLE) { | 197 } else if (idle_state == IDLE_STATE_IDLE) { |
| 198 description = keys::kStateIdle; | 198 description = keys::kStateIdle; |
| 199 } else { | 199 } else { |
| 200 description = keys::kStateLocked; | 200 description = keys::kStateLocked; |
| 201 } | 201 } |
| 202 | 202 |
| 203 return new StringValue(description); | 203 return new base::StringValue(description); |
| 204 } | 204 } |
| 205 | 205 |
| 206 void IdleManager::SetEventDelegateForTest( | 206 void IdleManager::SetEventDelegateForTest( |
| 207 scoped_ptr<EventDelegate> event_delegate) { | 207 scoped_ptr<EventDelegate> event_delegate) { |
| 208 DCHECK(thread_checker_.CalledOnValidThread()); | 208 DCHECK(thread_checker_.CalledOnValidThread()); |
| 209 event_delegate_ = event_delegate.Pass(); | 209 event_delegate_ = event_delegate.Pass(); |
| 210 } | 210 } |
| 211 | 211 |
| 212 void IdleManager::SetIdleTimeProviderForTest( | 212 void IdleManager::SetIdleTimeProviderForTest( |
| 213 scoped_ptr<IdleTimeProvider> idle_time_provider) { | 213 scoped_ptr<IdleTimeProvider> idle_time_provider) { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 event_delegate_->OnStateChanged(it->first, new_state); | 275 event_delegate_->OnStateChanged(it->first, new_state); |
| 276 } | 276 } |
| 277 } | 277 } |
| 278 | 278 |
| 279 if (listener_count == 0) { | 279 if (listener_count == 0) { |
| 280 StopPolling(); | 280 StopPolling(); |
| 281 } | 281 } |
| 282 } | 282 } |
| 283 | 283 |
| 284 } // namespace extensions | 284 } // namespace extensions |
| OLD | NEW |