| 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" | |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |