OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extension_tabs_module.h" | 5 #include "chrome/browser/extensions/extension_tabs_module.h" |
6 | 6 |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/extensions/extension_accessibility_api.h" | 10 #include "chrome/browser/extensions/extension_accessibility_api.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 content::NotificationService::AllSources()); | 58 content::NotificationService::AllSources()); |
59 registrar_.Add(this, | 59 registrar_.Add(this, |
60 chrome::NOTIFICATION_ACCESSIBILITY_MENU_OPENED, | 60 chrome::NOTIFICATION_ACCESSIBILITY_MENU_OPENED, |
61 content::NotificationService::AllSources()); | 61 content::NotificationService::AllSources()); |
62 registrar_.Add(this, | 62 registrar_.Add(this, |
63 chrome::NOTIFICATION_ACCESSIBILITY_MENU_CLOSED, | 63 chrome::NOTIFICATION_ACCESSIBILITY_MENU_CLOSED, |
64 content::NotificationService::AllSources()); | 64 content::NotificationService::AllSources()); |
65 registrar_.Add(this, | 65 registrar_.Add(this, |
66 chrome::NOTIFICATION_ACCESSIBILITY_VOLUME_CHANGED, | 66 chrome::NOTIFICATION_ACCESSIBILITY_VOLUME_CHANGED, |
67 content::NotificationService::AllSources()); | 67 content::NotificationService::AllSources()); |
| 68 registrar_.Add(this, |
| 69 chrome::NOTIFICATION_ACCESSIBILITY_SCREEN_UNLOCKED, |
| 70 content::NotificationService::AllSources()); |
| 71 registrar_.Add(this, |
| 72 chrome::NOTIFICATION_ACCESSIBILITY_WOKE_UP, |
| 73 content::NotificationService::AllSources()); |
68 } | 74 } |
69 | 75 |
70 ExtensionAccessibilityEventRouter::~ExtensionAccessibilityEventRouter() { | 76 ExtensionAccessibilityEventRouter::~ExtensionAccessibilityEventRouter() { |
71 } | 77 } |
72 | 78 |
73 void ExtensionAccessibilityEventRouter::Observe( | 79 void ExtensionAccessibilityEventRouter::Observe( |
74 int type, | 80 int type, |
75 const content::NotificationSource& source, | 81 const content::NotificationSource& source, |
76 const content::NotificationDetails& details) { | 82 const content::NotificationDetails& details) { |
77 switch (type) { | 83 switch (type) { |
(...skipping 22 matching lines...) Expand all Loading... |
100 content::Details<const AccessibilityMenuInfo>(details).ptr()); | 106 content::Details<const AccessibilityMenuInfo>(details).ptr()); |
101 break; | 107 break; |
102 case chrome::NOTIFICATION_ACCESSIBILITY_MENU_CLOSED: | 108 case chrome::NOTIFICATION_ACCESSIBILITY_MENU_CLOSED: |
103 OnMenuClosed( | 109 OnMenuClosed( |
104 content::Details<const AccessibilityMenuInfo>(details).ptr()); | 110 content::Details<const AccessibilityMenuInfo>(details).ptr()); |
105 break; | 111 break; |
106 case chrome::NOTIFICATION_ACCESSIBILITY_VOLUME_CHANGED: | 112 case chrome::NOTIFICATION_ACCESSIBILITY_VOLUME_CHANGED: |
107 OnVolumeChanged( | 113 OnVolumeChanged( |
108 content::Details<const AccessibilityVolumeInfo>(details).ptr()); | 114 content::Details<const AccessibilityVolumeInfo>(details).ptr()); |
109 break; | 115 break; |
| 116 case chrome::NOTIFICATION_ACCESSIBILITY_SCREEN_UNLOCKED: |
| 117 OnScreenUnlocked( |
| 118 content::Details<const ScreenUnlockedEventInfo>(details).ptr()); |
| 119 break; |
| 120 case chrome::NOTIFICATION_ACCESSIBILITY_WOKE_UP: |
| 121 OnWokeUp( |
| 122 content::Details<const WokeUpEventInfo>(details).ptr()); |
| 123 break; |
110 default: | 124 default: |
111 NOTREACHED(); | 125 NOTREACHED(); |
112 } | 126 } |
113 } | 127 } |
114 | 128 |
115 void ExtensionAccessibilityEventRouter::SetAccessibilityEnabled(bool enabled) { | 129 void ExtensionAccessibilityEventRouter::SetAccessibilityEnabled(bool enabled) { |
116 enabled_ = enabled; | 130 enabled_ = enabled; |
117 } | 131 } |
118 | 132 |
119 bool ExtensionAccessibilityEventRouter::IsAccessibilityEnabled() const { | 133 bool ExtensionAccessibilityEventRouter::IsAccessibilityEnabled() const { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 std::string json_args = ControlInfoToJsonString(info); | 177 std::string json_args = ControlInfoToJsonString(info); |
164 DispatchEvent(info->profile(), keys::kOnMenuClosed, json_args); | 178 DispatchEvent(info->profile(), keys::kOnMenuClosed, json_args); |
165 } | 179 } |
166 | 180 |
167 void ExtensionAccessibilityEventRouter::OnVolumeChanged( | 181 void ExtensionAccessibilityEventRouter::OnVolumeChanged( |
168 const AccessibilityVolumeInfo* info) { | 182 const AccessibilityVolumeInfo* info) { |
169 std::string json_args = ControlInfoToJsonString(info); | 183 std::string json_args = ControlInfoToJsonString(info); |
170 DispatchEvent(info->profile(), keys::kOnVolumeChanged, json_args); | 184 DispatchEvent(info->profile(), keys::kOnVolumeChanged, json_args); |
171 } | 185 } |
172 | 186 |
| 187 void ExtensionAccessibilityEventRouter::OnScreenUnlocked( |
| 188 const ScreenUnlockedEventInfo* info) { |
| 189 std::string json_args = ControlInfoToJsonString(info); |
| 190 DispatchEvent(info->profile(), keys::kOnScreenUnlocked, json_args); |
| 191 } |
| 192 |
| 193 void ExtensionAccessibilityEventRouter::OnWokeUp(const WokeUpEventInfo* info) { |
| 194 std::string json_args = ControlInfoToJsonString(info); |
| 195 DispatchEvent(info->profile(), keys::kOnWokeUp, json_args); |
| 196 } |
| 197 |
173 void ExtensionAccessibilityEventRouter::DispatchEvent( | 198 void ExtensionAccessibilityEventRouter::DispatchEvent( |
174 Profile* profile, | 199 Profile* profile, |
175 const char* event_name, | 200 const char* event_name, |
176 const std::string& json_args) { | 201 const std::string& json_args) { |
177 if (enabled_ && profile && profile->GetExtensionEventRouter()) { | 202 if (enabled_ && profile && profile->GetExtensionEventRouter()) { |
178 profile->GetExtensionEventRouter()->DispatchEventToRenderers( | 203 profile->GetExtensionEventRouter()->DispatchEventToRenderers( |
179 event_name, json_args, NULL, GURL()); | 204 event_name, json_args, NULL, GURL()); |
180 } | 205 } |
181 } | 206 } |
182 | 207 |
(...skipping 13 matching lines...) Expand all Loading... |
196 ExtensionAccessibilityEventRouter::GetInstance(); | 221 ExtensionAccessibilityEventRouter::GetInstance(); |
197 DictionaryValue *last_focused_control_dict = | 222 DictionaryValue *last_focused_control_dict = |
198 accessibility_event_router->last_focused_control_dict(); | 223 accessibility_event_router->last_focused_control_dict(); |
199 if (last_focused_control_dict->size()) { | 224 if (last_focused_control_dict->size()) { |
200 result_.reset(last_focused_control_dict->DeepCopyWithoutEmptyChildren()); | 225 result_.reset(last_focused_control_dict->DeepCopyWithoutEmptyChildren()); |
201 } else { | 226 } else { |
202 result_.reset(Value::CreateNullValue()); | 227 result_.reset(Value::CreateNullValue()); |
203 } | 228 } |
204 return true; | 229 return true; |
205 } | 230 } |
OLD | NEW |