| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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-inl.h" | 8 #include "base/stl_util-inl.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 break; | 79 break; |
| 80 case NotificationType::ACCESSIBILITY_CONTROL_FOCUSED: | 80 case NotificationType::ACCESSIBILITY_CONTROL_FOCUSED: |
| 81 OnControlFocused(Details<const AccessibilityControlInfo>(details).ptr()); | 81 OnControlFocused(Details<const AccessibilityControlInfo>(details).ptr()); |
| 82 break; | 82 break; |
| 83 case NotificationType::ACCESSIBILITY_CONTROL_ACTION: | 83 case NotificationType::ACCESSIBILITY_CONTROL_ACTION: |
| 84 OnControlAction(Details<const AccessibilityControlInfo>(details).ptr()); | 84 OnControlAction(Details<const AccessibilityControlInfo>(details).ptr()); |
| 85 break; | 85 break; |
| 86 case NotificationType::ACCESSIBILITY_TEXT_CHANGED: | 86 case NotificationType::ACCESSIBILITY_TEXT_CHANGED: |
| 87 OnTextChanged(Details<const AccessibilityControlInfo>(details).ptr()); | 87 OnTextChanged(Details<const AccessibilityControlInfo>(details).ptr()); |
| 88 break; | 88 break; |
| 89 case NotificationType::ACCESSIBILITY_MENU_OPENED: |
| 90 OnMenuOpened(Details<const AccessibilityMenuInfo>(details).ptr()); |
| 91 break; |
| 92 case NotificationType::ACCESSIBILITY_MENU_CLOSED: |
| 93 OnMenuClosed(Details<const AccessibilityMenuInfo>(details).ptr()); |
| 94 break; |
| 89 default: | 95 default: |
| 90 NOTREACHED(); | 96 NOTREACHED(); |
| 91 } | 97 } |
| 92 } | 98 } |
| 93 | 99 |
| 94 void ExtensionAccessibilityEventRouter::SetAccessibilityEnabled(bool enabled) { | 100 void ExtensionAccessibilityEventRouter::SetAccessibilityEnabled(bool enabled) { |
| 95 if (enabled_ != enabled) { | 101 if (enabled_ != enabled) { |
| 96 enabled_ = enabled; | 102 enabled_ = enabled; |
| 97 if (enabled_) { | 103 if (enabled_) { |
| 98 for (unsigned int i = 0; i < on_enabled_listeners_.size(); i++) { | 104 for (unsigned int i = 0; i < on_enabled_listeners_.size(); i++) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 std::string json_args = ControlInfoToJsonString(info); | 151 std::string json_args = ControlInfoToJsonString(info); |
| 146 DispatchEvent(info->profile(), keys::kOnControlAction, json_args); | 152 DispatchEvent(info->profile(), keys::kOnControlAction, json_args); |
| 147 } | 153 } |
| 148 | 154 |
| 149 void ExtensionAccessibilityEventRouter::OnTextChanged( | 155 void ExtensionAccessibilityEventRouter::OnTextChanged( |
| 150 const AccessibilityControlInfo* info) { | 156 const AccessibilityControlInfo* info) { |
| 151 std::string json_args = ControlInfoToJsonString(info); | 157 std::string json_args = ControlInfoToJsonString(info); |
| 152 DispatchEvent(info->profile(), keys::kOnTextChanged, json_args); | 158 DispatchEvent(info->profile(), keys::kOnTextChanged, json_args); |
| 153 } | 159 } |
| 154 | 160 |
| 161 void ExtensionAccessibilityEventRouter::OnMenuOpened( |
| 162 const AccessibilityMenuInfo* info) { |
| 163 std::string json_args = ControlInfoToJsonString(info); |
| 164 DispatchEvent(info->profile(), keys::kOnMenuOpened, json_args); |
| 165 } |
| 166 |
| 167 void ExtensionAccessibilityEventRouter::OnMenuClosed( |
| 168 const AccessibilityMenuInfo* info) { |
| 169 std::string json_args = ControlInfoToJsonString(info); |
| 170 DispatchEvent(info->profile(), keys::kOnMenuClosed, json_args); |
| 171 } |
| 172 |
| 155 void ExtensionAccessibilityEventRouter::DispatchEvent( | 173 void ExtensionAccessibilityEventRouter::DispatchEvent( |
| 156 Profile* profile, | 174 Profile* profile, |
| 157 const char* event_name, | 175 const char* event_name, |
| 158 const std::string& json_args) { | 176 const std::string& json_args) { |
| 159 if (enabled_ && profile && profile->GetExtensionMessageService()) { | 177 if (enabled_ && profile && profile->GetExtensionMessageService()) { |
| 160 profile->GetExtensionMessageService()->DispatchEventToRenderers( | 178 profile->GetExtensionMessageService()->DispatchEventToRenderers( |
| 161 event_name, json_args, profile->IsOffTheRecord()); | 179 event_name, json_args, profile->IsOffTheRecord()); |
| 162 } | 180 } |
| 163 } | 181 } |
| 164 | 182 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 178 ExtensionAccessibilityEventRouter::GetInstance(); | 196 ExtensionAccessibilityEventRouter::GetInstance(); |
| 179 DictionaryValue *last_focused_control_dict = | 197 DictionaryValue *last_focused_control_dict = |
| 180 accessibility_event_router->last_focused_control_dict(); | 198 accessibility_event_router->last_focused_control_dict(); |
| 181 if (last_focused_control_dict->size()) { | 199 if (last_focused_control_dict->size()) { |
| 182 result_.reset(last_focused_control_dict->DeepCopyWithoutEmptyChildren()); | 200 result_.reset(last_focused_control_dict->DeepCopyWithoutEmptyChildren()); |
| 183 } else { | 201 } else { |
| 184 result_.reset(Value::CreateNullValue()); | 202 result_.reset(Value::CreateNullValue()); |
| 185 } | 203 } |
| 186 return true; | 204 return true; |
| 187 } | 205 } |
| OLD | NEW |