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/system/system_api.h" | 5 #include "chrome/browser/extensions/system/system_api.h" |
6 | 6 |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/extensions/extension_event_router.h" | 9 #include "chrome/browser/extensions/event_router.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" | 12 #include "chrome/browser/profiles/profile_manager.h" |
13 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
14 | 14 |
15 #if defined(OS_CHROMEOS) | 15 #if defined(OS_CHROMEOS) |
16 #include "chromeos/dbus/dbus_thread_manager.h" | 16 #include "chromeos/dbus/dbus_thread_manager.h" |
17 #include "chromeos/dbus/update_engine_client.h" | 17 #include "chromeos/dbus/update_engine_client.h" |
18 #else | 18 #else |
19 #include "chrome/browser/upgrade_detector.h" | 19 #include "chrome/browser/upgrade_detector.h" |
(...skipping 26 matching lines...) Expand all Loading... |
46 const char kOnBrightnessChanged[] = "systemPrivate.onBrightnessChanged"; | 46 const char kOnBrightnessChanged[] = "systemPrivate.onBrightnessChanged"; |
47 const char kOnVolumeChanged[] = "systemPrivate.onVolumeChanged"; | 47 const char kOnVolumeChanged[] = "systemPrivate.onVolumeChanged"; |
48 const char kOnScreenUnlocked[] = "systemPrivate.onScreenUnlocked"; | 48 const char kOnScreenUnlocked[] = "systemPrivate.onScreenUnlocked"; |
49 const char kOnWokeUp[] = "systemPrivate.onWokeUp"; | 49 const char kOnWokeUp[] = "systemPrivate.onWokeUp"; |
50 | 50 |
51 // Dispatches an extension event with |args| | 51 // Dispatches an extension event with |args| |
52 void DispatchEvent(const std::string& event_name, const ListValue& args) { | 52 void DispatchEvent(const std::string& event_name, const ListValue& args) { |
53 Profile* profile = ProfileManager::GetDefaultProfile(); | 53 Profile* profile = ProfileManager::GetDefaultProfile(); |
54 if (!profile) | 54 if (!profile) |
55 return; | 55 return; |
56 ExtensionEventRouter* extension_event_router = | 56 extensions::EventRouter* extension_event_router = |
57 profile->GetExtensionEventRouter(); | 57 profile->GetExtensionEventRouter(); |
58 if (!extension_event_router) | 58 if (!extension_event_router) |
59 return; | 59 return; |
60 std::string json_args; | 60 std::string json_args; |
61 base::JSONWriter::Write(&args, &json_args); | 61 base::JSONWriter::Write(&args, &json_args); |
62 extension_event_router->DispatchEventToRenderers( | 62 extension_event_router->DispatchEventToRenderers( |
63 event_name, json_args, NULL, GURL(), extensions::EventFilteringInfo()); | 63 event_name, json_args, NULL, GURL(), extensions::EventFilteringInfo()); |
64 } | 64 } |
65 | 65 |
66 } // namespace | 66 } // namespace |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 ListValue args; | 160 ListValue args; |
161 DispatchEvent(kOnScreenUnlocked, args); | 161 DispatchEvent(kOnScreenUnlocked, args); |
162 } | 162 } |
163 | 163 |
164 void DispatchWokeUpEvent() { | 164 void DispatchWokeUpEvent() { |
165 ListValue args; | 165 ListValue args; |
166 DispatchEvent(kOnWokeUp, args); | 166 DispatchEvent(kOnWokeUp, args); |
167 } | 167 } |
168 | 168 |
169 } // namespace extensions | 169 } // namespace extensions |
OLD | NEW |