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

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

Issue 10919299: Revert 156744 - chromeos: Use EventRouterForwarder to disptch systemPrivate extension events (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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"
7 #include "base/values.h" 8 #include "base/values.h"
8 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/extensions/event_router.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"
12 #include "chrome/common/pref_names.h" 13 #include "chrome/common/pref_names.h"
13 14
14 #if defined(OS_CHROMEOS) 15 #if defined(OS_CHROMEOS)
15 #include "chromeos/dbus/dbus_thread_manager.h" 16 #include "chromeos/dbus/dbus_thread_manager.h"
16 #include "chromeos/dbus/update_engine_client.h" 17 #include "chromeos/dbus/update_engine_client.h"
17 #else 18 #else
18 #include "chrome/browser/upgrade_detector.h" 19 #include "chrome/browser/upgrade_detector.h"
19 #endif 20 #endif
20 21
21 namespace { 22 namespace {
(...skipping 18 matching lines...) Expand all
40 const char kNotAvailableState[] = "NotAvailable"; 41 const char kNotAvailableState[] = "NotAvailable";
41 const char kUpdatingState[] = "Updating"; 42 const char kUpdatingState[] = "Updating";
42 const char kNeedRestartState[] = "NeedRestart"; 43 const char kNeedRestartState[] = "NeedRestart";
43 44
44 // Event names. 45 // Event names.
45 const char kOnBrightnessChanged[] = "systemPrivate.onBrightnessChanged"; 46 const char kOnBrightnessChanged[] = "systemPrivate.onBrightnessChanged";
46 const char kOnVolumeChanged[] = "systemPrivate.onVolumeChanged"; 47 const char kOnVolumeChanged[] = "systemPrivate.onVolumeChanged";
47 const char kOnScreenUnlocked[] = "systemPrivate.onScreenUnlocked"; 48 const char kOnScreenUnlocked[] = "systemPrivate.onScreenUnlocked";
48 const char kOnWokeUp[] = "systemPrivate.onWokeUp"; 49 const char kOnWokeUp[] = "systemPrivate.onWokeUp";
49 50
50 // Dispatches an extension event with |argument| 51 // Dispatches an extension event with |args|
51 void DispatchEvent(const std::string& event_name, base::Value* argument) { 52 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
52 scoped_ptr<base::ListValue> list_args(new base::ListValue()); 61 scoped_ptr<base::ListValue> list_args(new base::ListValue());
53 if (argument) { 62 if (argument) {
54 list_args->Append(argument); 63 list_args->Append(argument);
55 } 64 }
56 g_browser_process->extension_event_router_forwarder()-> 65 extension_event_router->DispatchEventToRenderers(
57 BroadcastEventToRenderers(event_name, list_args.Pass(), GURL()); 66 event_name, list_args.Pass(), NULL, GURL(),
67 extensions::EventFilteringInfo());
58 } 68 }
59 69
60 } // namespace 70 } // namespace
61 71
62 namespace extensions { 72 namespace extensions {
63 73
64 bool GetIncognitoModeAvailabilityFunction::RunImpl() { 74 bool GetIncognitoModeAvailabilityFunction::RunImpl() {
65 PrefService* prefs = profile_->GetPrefs(); 75 PrefService* prefs = profile_->GetPrefs();
66 int value = prefs->GetInteger(prefs::kIncognitoModeAvailability); 76 int value = prefs->GetInteger(prefs::kIncognitoModeAvailability);
67 EXTENSION_FUNCTION_VALIDATE( 77 EXTENSION_FUNCTION_VALIDATE(
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 158
149 void DispatchScreenUnlockedEvent() { 159 void DispatchScreenUnlockedEvent() {
150 DispatchEvent(kOnScreenUnlocked, NULL); 160 DispatchEvent(kOnScreenUnlocked, NULL);
151 } 161 }
152 162
153 void DispatchWokeUpEvent() { 163 void DispatchWokeUpEvent() {
154 DispatchEvent(kOnWokeUp, NULL); 164 DispatchEvent(kOnWokeUp, NULL);
155 } 165 }
156 166
157 } // namespace extensions 167 } // 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