Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(478)

Side by Side Diff: chrome/browser/extensions/api/idle/idle_api.cc

Issue 11232066: Remove GetExtensionEventRouter from Profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rerebase Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_api.h" 5 #include "chrome/browser/extensions/api/idle/idle_api.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/json/json_writer.h" 13 #include "base/json/json_writer.h"
14 #include "base/message_loop.h" 14 #include "base/message_loop.h"
15 #include "base/stl_util.h" 15 #include "base/stl_util.h"
16 #include "base/time.h" 16 #include "base/time.h"
17 #include "chrome/browser/extensions/event_router.h" 17 #include "chrome/browser/extensions/event_router.h"
18 #include "chrome/browser/extensions/extension_host.h" 18 #include "chrome/browser/extensions/extension_host.h"
19 #include "chrome/browser/extensions/api/idle/idle_api_constants.h" 19 #include "chrome/browser/extensions/api/idle/idle_api_constants.h"
20 #include "chrome/browser/extensions/extension_service.h" 20 #include "chrome/browser/extensions/extension_service.h"
21 #include "chrome/browser/extensions/extension_system.h"
21 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/common/extensions/extension.h" 23 #include "chrome/common/extensions/extension.h"
23 #include "content/public/browser/render_view_host.h" 24 #include "content/public/browser/render_view_host.h"
24 25
25 using extensions::ExtensionIdleCache; 26 using extensions::ExtensionIdleCache;
26 using extensions::ExtensionIdleEventRouter; 27 using extensions::ExtensionIdleEventRouter;
27 using extensions::ExtensionIdleQueryStateFunction; 28 using extensions::ExtensionIdleQueryStateFunction;
28 29
29 namespace keys = extensions::idle_api_constants; 30 namespace keys = extensions::idle_api_constants;
30 31
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 } 141 }
141 142
142 } // namespace 143 } // namespace
143 144
144 void ExtensionIdleEventRouter::OnIdleStateChange(Profile* profile, 145 void ExtensionIdleEventRouter::OnIdleStateChange(Profile* profile,
145 IdleState state) { 146 IdleState state) {
146 // Prepare the single argument of the current state. 147 // Prepare the single argument of the current state.
147 scoped_ptr<ListValue> args(new ListValue()); 148 scoped_ptr<ListValue> args(new ListValue());
148 args->Append(CreateIdleValue(state)); 149 args->Append(CreateIdleValue(state));
149 150
150 profile->GetExtensionEventRouter()->DispatchEventToRenderers( 151 extensions::ExtensionSystem::Get(profile)->event_router()->
151 keys::kOnStateChanged, args.Pass(), profile, 152 DispatchEventToRenderers(keys::kOnStateChanged, args.Pass(), profile,
152 GURL(), extensions::EventFilteringInfo()); 153 GURL(), extensions::EventFilteringInfo());
153 } 154 }
154 155
155 bool ExtensionIdleQueryStateFunction::RunImpl() { 156 bool ExtensionIdleQueryStateFunction::RunImpl() {
156 int threshold; 157 int threshold;
157 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &threshold)); 158 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &threshold));
158 threshold = CheckThresholdBounds(threshold); 159 threshold = CheckThresholdBounds(threshold);
159 160
160 IdleState state = ExtensionIdleCache::CalculateIdleState(threshold); 161 IdleState state = ExtensionIdleCache::CalculateIdleState(threshold);
161 if (state != IDLE_STATE_UNKNOWN) { 162 if (state != IDLE_STATE_UNKNOWN) {
162 SetResult(CreateIdleValue(state)); 163 SetResult(CreateIdleValue(state));
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 } 267 }
267 } 268 }
268 269
269 int ExtensionIdleCache::get_min_threshold() { 270 int ExtensionIdleCache::get_min_threshold() {
270 return kMinThreshold; 271 return kMinThreshold;
271 } 272 }
272 273
273 double ExtensionIdleCache::get_throttle_interval() { 274 double ExtensionIdleCache::get_throttle_interval() {
274 return static_cast<double>(kThrottleInterval); 275 return static_cast<double>(kThrottleInterval);
275 } 276 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/downloads/downloads_api.cc ('k') | chrome/browser/extensions/api/input_ime/input_ime_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698