| 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/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 NotificationService::AllSources()); | 66 NotificationService::AllSources()); |
| 67 registrar_.Add(this, | 67 registrar_.Add(this, |
| 68 chrome::NOTIFICATION_ACCESSIBILITY_TEXT_CHANGED, | 68 chrome::NOTIFICATION_ACCESSIBILITY_TEXT_CHANGED, |
| 69 NotificationService::AllSources()); | 69 NotificationService::AllSources()); |
| 70 registrar_.Add(this, | 70 registrar_.Add(this, |
| 71 chrome::NOTIFICATION_ACCESSIBILITY_MENU_OPENED, | 71 chrome::NOTIFICATION_ACCESSIBILITY_MENU_OPENED, |
| 72 NotificationService::AllSources()); | 72 NotificationService::AllSources()); |
| 73 registrar_.Add(this, | 73 registrar_.Add(this, |
| 74 chrome::NOTIFICATION_ACCESSIBILITY_MENU_CLOSED, | 74 chrome::NOTIFICATION_ACCESSIBILITY_MENU_CLOSED, |
| 75 NotificationService::AllSources()); | 75 NotificationService::AllSources()); |
| 76 registrar_.Add(this, |
| 77 chrome::NOTIFICATION_ACCESSIBILITY_VOLUME_UP, |
| 78 NotificationService::AllSources()); |
| 79 registrar_.Add(this, |
| 80 chrome::NOTIFICATION_ACCESSIBILITY_VOLUME_DOWN, |
| 81 NotificationService::AllSources()); |
| 82 registrar_.Add(this, |
| 83 chrome::NOTIFICATION_ACCESSIBILITY_VOLUME_MUTE, |
| 84 NotificationService::AllSources()); |
| 76 } | 85 } |
| 77 } | 86 } |
| 78 | 87 |
| 79 void ExtensionAccessibilityEventRouter::Observe( | 88 void ExtensionAccessibilityEventRouter::Observe( |
| 80 int type, | 89 int type, |
| 81 const NotificationSource& source, | 90 const NotificationSource& source, |
| 82 const NotificationDetails& details) { | 91 const NotificationDetails& details) { |
| 83 switch (type) { | 92 switch (type) { |
| 84 case chrome::NOTIFICATION_ACCESSIBILITY_WINDOW_OPENED: | 93 case chrome::NOTIFICATION_ACCESSIBILITY_WINDOW_OPENED: |
| 85 OnWindowOpened(Details<const AccessibilityWindowInfo>(details).ptr()); | 94 OnWindowOpened(Details<const AccessibilityWindowInfo>(details).ptr()); |
| 86 break; | 95 break; |
| 87 case chrome::NOTIFICATION_ACCESSIBILITY_WINDOW_CLOSED: | 96 case chrome::NOTIFICATION_ACCESSIBILITY_WINDOW_CLOSED: |
| 88 OnWindowClosed(Details<const AccessibilityWindowInfo>(details).ptr()); | 97 OnWindowClosed(Details<const AccessibilityWindowInfo>(details).ptr()); |
| 89 break; | 98 break; |
| 90 case chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_FOCUSED: | 99 case chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_FOCUSED: |
| 91 OnControlFocused(Details<const AccessibilityControlInfo>(details).ptr()); | 100 OnControlFocused(Details<const AccessibilityControlInfo>(details).ptr()); |
| 92 break; | 101 break; |
| 93 case chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_ACTION: | 102 case chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_ACTION: |
| 94 OnControlAction(Details<const AccessibilityControlInfo>(details).ptr()); | 103 OnControlAction(Details<const AccessibilityControlInfo>(details).ptr()); |
| 95 break; | 104 break; |
| 96 case chrome::NOTIFICATION_ACCESSIBILITY_TEXT_CHANGED: | 105 case chrome::NOTIFICATION_ACCESSIBILITY_TEXT_CHANGED: |
| 97 OnTextChanged(Details<const AccessibilityControlInfo>(details).ptr()); | 106 OnTextChanged(Details<const AccessibilityControlInfo>(details).ptr()); |
| 98 break; | 107 break; |
| 99 case chrome::NOTIFICATION_ACCESSIBILITY_MENU_OPENED: | 108 case chrome::NOTIFICATION_ACCESSIBILITY_MENU_OPENED: |
| 100 OnMenuOpened(Details<const AccessibilityMenuInfo>(details).ptr()); | 109 OnMenuOpened(Details<const AccessibilityMenuInfo>(details).ptr()); |
| 101 break; | 110 break; |
| 102 case chrome::NOTIFICATION_ACCESSIBILITY_MENU_CLOSED: | 111 case chrome::NOTIFICATION_ACCESSIBILITY_MENU_CLOSED: |
| 103 OnMenuClosed(Details<const AccessibilityMenuInfo>(details).ptr()); | 112 OnMenuClosed(Details<const AccessibilityMenuInfo>(details).ptr()); |
| 104 break; | 113 break; |
| 114 case chrome::NOTIFICATION_ACCESSIBILITY_VOLUME_UP: |
| 115 OnVolumeUp(Details<const AccessibilityVolumeInfo>(details).ptr()); |
| 116 break; |
| 117 case chrome::NOTIFICATION_ACCESSIBILITY_VOLUME_DOWN: |
| 118 OnVolumeDown(Details<const AccessibilityVolumeInfo>(details).ptr()); |
| 119 break; |
| 120 case chrome::NOTIFICATION_ACCESSIBILITY_VOLUME_MUTE: |
| 121 OnVolumeMute(Details<const AccessibilityVolumeInfo>(details).ptr()); |
| 122 break; |
| 105 default: | 123 default: |
| 106 NOTREACHED(); | 124 NOTREACHED(); |
| 107 } | 125 } |
| 108 } | 126 } |
| 109 | 127 |
| 110 void ExtensionAccessibilityEventRouter::SetAccessibilityEnabled(bool enabled) { | 128 void ExtensionAccessibilityEventRouter::SetAccessibilityEnabled(bool enabled) { |
| 111 if (enabled_ != enabled) { | 129 if (enabled_ != enabled) { |
| 112 enabled_ = enabled; | 130 enabled_ = enabled; |
| 113 if (enabled_) { | 131 if (enabled_) { |
| 114 for (unsigned int i = 0; i < on_enabled_listeners_.size(); i++) { | 132 for (unsigned int i = 0; i < on_enabled_listeners_.size(); i++) { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 std::string json_args = ControlInfoToJsonString(info); | 191 std::string json_args = ControlInfoToJsonString(info); |
| 174 DispatchEvent(info->profile(), keys::kOnMenuOpened, json_args); | 192 DispatchEvent(info->profile(), keys::kOnMenuOpened, json_args); |
| 175 } | 193 } |
| 176 | 194 |
| 177 void ExtensionAccessibilityEventRouter::OnMenuClosed( | 195 void ExtensionAccessibilityEventRouter::OnMenuClosed( |
| 178 const AccessibilityMenuInfo* info) { | 196 const AccessibilityMenuInfo* info) { |
| 179 std::string json_args = ControlInfoToJsonString(info); | 197 std::string json_args = ControlInfoToJsonString(info); |
| 180 DispatchEvent(info->profile(), keys::kOnMenuClosed, json_args); | 198 DispatchEvent(info->profile(), keys::kOnMenuClosed, json_args); |
| 181 } | 199 } |
| 182 | 200 |
| 201 void ExtensionAccessibilityEventRouter::OnVolumeUp( |
| 202 const AccessibilityVolumeInfo* info) { |
| 203 std::string json_args = ControlInfoToJsonString(info); |
| 204 DispatchEvent(info->profile(), keys::kOnVolumeUp, json_args); |
| 205 } |
| 206 |
| 207 void ExtensionAccessibilityEventRouter::OnVolumeDown( |
| 208 const AccessibilityVolumeInfo* info) { |
| 209 std::string json_args = ControlInfoToJsonString(info); |
| 210 DispatchEvent(info->profile(), keys::kOnVolumeDown, json_args); |
| 211 } |
| 212 |
| 213 void ExtensionAccessibilityEventRouter::OnVolumeMute( |
| 214 const AccessibilityVolumeInfo* info) { |
| 215 std::string json_args = ControlInfoToJsonString(info); |
| 216 DispatchEvent(info->profile(), keys::kOnVolumeMute, json_args); |
| 217 } |
| 218 |
| 183 void ExtensionAccessibilityEventRouter::DispatchEvent( | 219 void ExtensionAccessibilityEventRouter::DispatchEvent( |
| 184 Profile* profile, | 220 Profile* profile, |
| 185 const char* event_name, | 221 const char* event_name, |
| 186 const std::string& json_args) { | 222 const std::string& json_args) { |
| 187 if (enabled_ && profile && profile->GetExtensionEventRouter()) { | 223 if (enabled_ && profile && profile->GetExtensionEventRouter()) { |
| 188 profile->GetExtensionEventRouter()->DispatchEventToRenderers( | 224 profile->GetExtensionEventRouter()->DispatchEventToRenderers( |
| 189 event_name, json_args, NULL, GURL()); | 225 event_name, json_args, NULL, GURL()); |
| 190 } | 226 } |
| 191 } | 227 } |
| 192 | 228 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 206 ExtensionAccessibilityEventRouter::GetInstance(); | 242 ExtensionAccessibilityEventRouter::GetInstance(); |
| 207 DictionaryValue *last_focused_control_dict = | 243 DictionaryValue *last_focused_control_dict = |
| 208 accessibility_event_router->last_focused_control_dict(); | 244 accessibility_event_router->last_focused_control_dict(); |
| 209 if (last_focused_control_dict->size()) { | 245 if (last_focused_control_dict->size()) { |
| 210 result_.reset(last_focused_control_dict->DeepCopyWithoutEmptyChildren()); | 246 result_.reset(last_focused_control_dict->DeepCopyWithoutEmptyChildren()); |
| 211 } else { | 247 } else { |
| 212 result_.reset(Value::CreateNullValue()); | 248 result_.reset(Value::CreateNullValue()); |
| 213 } | 249 } |
| 214 return true; | 250 return true; |
| 215 } | 251 } |
| OLD | NEW |