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

Side by Side Diff: chrome/browser/extensions/system/system_api.cc

Issue 10905250: chromeos: Use EventRouterForwarder to disptch systemPrivate extension events (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unneeded newlines Created 8 years, 3 months 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
« no previous file with comments | « chrome/browser/extensions/system/system_api.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/system/system_api.h" 5 #include "chrome/browser/extensions/system/system_api.h"
6 6
7 #include "base/json/json_writer.h"
8 #include "base/values.h" 7 #include "base/values.h"
9 #include "chrome/browser/extensions/event_router.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/extensions/event_router_forwarder.h"
10 #include "chrome/browser/prefs/pref_service.h" 10 #include "chrome/browser/prefs/pref_service.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/profiles/profile_manager.h"
13 #include "chrome/common/pref_names.h" 12 #include "chrome/common/pref_names.h"
14 13
15 #if defined(OS_CHROMEOS) 14 #if defined(OS_CHROMEOS)
16 #include "chromeos/dbus/dbus_thread_manager.h" 15 #include "chromeos/dbus/dbus_thread_manager.h"
17 #include "chromeos/dbus/update_engine_client.h" 16 #include "chromeos/dbus/update_engine_client.h"
18 #else 17 #else
19 #include "chrome/browser/upgrade_detector.h" 18 #include "chrome/browser/upgrade_detector.h"
20 #endif 19 #endif
21 20
22 namespace { 21 namespace {
(...skipping 18 matching lines...) Expand all
41 const char kNotAvailableState[] = "NotAvailable"; 40 const char kNotAvailableState[] = "NotAvailable";
42 const char kUpdatingState[] = "Updating"; 41 const char kUpdatingState[] = "Updating";
43 const char kNeedRestartState[] = "NeedRestart"; 42 const char kNeedRestartState[] = "NeedRestart";
44 43
45 // Event names. 44 // Event names.
46 const char kOnBrightnessChanged[] = "systemPrivate.onBrightnessChanged"; 45 const char kOnBrightnessChanged[] = "systemPrivate.onBrightnessChanged";
47 const char kOnVolumeChanged[] = "systemPrivate.onVolumeChanged"; 46 const char kOnVolumeChanged[] = "systemPrivate.onVolumeChanged";
48 const char kOnScreenUnlocked[] = "systemPrivate.onScreenUnlocked"; 47 const char kOnScreenUnlocked[] = "systemPrivate.onScreenUnlocked";
49 const char kOnWokeUp[] = "systemPrivate.onWokeUp"; 48 const char kOnWokeUp[] = "systemPrivate.onWokeUp";
50 49
51 // Dispatches an extension event with |args| 50 // Dispatches an extension event with |argument|
52 void DispatchEvent(const std::string& event_name, base::Value* argument) { 51 void DispatchEvent(const std::string& event_name, base::Value* argument) {
53 Profile* profile = ProfileManager::GetDefaultProfile();
54 if (!profile)
55 return;
56 extensions::EventRouter* extension_event_router =
57 profile->GetExtensionEventRouter();
58 if (!extension_event_router)
59 return;
60
61 scoped_ptr<base::ListValue> list_args(new base::ListValue()); 52 scoped_ptr<base::ListValue> list_args(new base::ListValue());
62 if (argument) { 53 if (argument) {
63 list_args->Append(argument); 54 list_args->Append(argument);
64 } 55 }
65 extension_event_router->DispatchEventToRenderers( 56 g_browser_process->extension_event_router_forwarder()->
66 event_name, list_args.Pass(), NULL, GURL(), 57 BroadcastEventToRenderers(event_name, list_args.Pass(), GURL());
67 extensions::EventFilteringInfo());
68 } 58 }
69 59
70 } // namespace 60 } // namespace
71 61
72 namespace extensions { 62 namespace extensions {
73 63
74 bool GetIncognitoModeAvailabilityFunction::RunImpl() { 64 bool GetIncognitoModeAvailabilityFunction::RunImpl() {
75 PrefService* prefs = profile_->GetPrefs(); 65 PrefService* prefs = profile_->GetPrefs();
76 int value = prefs->GetInteger(prefs::kIncognitoModeAvailability); 66 int value = prefs->GetInteger(prefs::kIncognitoModeAvailability);
77 EXTENSION_FUNCTION_VALIDATE( 67 EXTENSION_FUNCTION_VALIDATE(
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 148
159 void DispatchScreenUnlockedEvent() { 149 void DispatchScreenUnlockedEvent() {
160 DispatchEvent(kOnScreenUnlocked, NULL); 150 DispatchEvent(kOnScreenUnlocked, NULL);
161 } 151 }
162 152
163 void DispatchWokeUpEvent() { 153 void DispatchWokeUpEvent() {
164 DispatchEvent(kOnWokeUp, NULL); 154 DispatchEvent(kOnWokeUp, NULL);
165 } 155 }
166 156
167 } // namespace extensions 157 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/system/system_api.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698