| 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 std::string json_args = ControlInfoToJsonString(info); | 170 std::string json_args = ControlInfoToJsonString(info); |
| 171 DispatchEvent(info->profile(), keys::kOnMenuClosed, json_args); | 171 DispatchEvent(info->profile(), keys::kOnMenuClosed, json_args); |
| 172 } | 172 } |
| 173 | 173 |
| 174 void ExtensionAccessibilityEventRouter::DispatchEvent( | 174 void ExtensionAccessibilityEventRouter::DispatchEvent( |
| 175 Profile* profile, | 175 Profile* profile, |
| 176 const char* event_name, | 176 const char* event_name, |
| 177 const std::string& json_args) { | 177 const std::string& json_args) { |
| 178 if (enabled_ && profile && profile->GetExtensionMessageService()) { | 178 if (enabled_ && profile && profile->GetExtensionMessageService()) { |
| 179 profile->GetExtensionMessageService()->DispatchEventToRenderers( | 179 profile->GetExtensionMessageService()->DispatchEventToRenderers( |
| 180 event_name, json_args, profile->IsOffTheRecord(), GURL()); | 180 event_name, json_args, profile, GURL()); |
| 181 } | 181 } |
| 182 } | 182 } |
| 183 | 183 |
| 184 bool SetAccessibilityEnabledFunction::RunImpl() { | 184 bool SetAccessibilityEnabledFunction::RunImpl() { |
| 185 bool enabled; | 185 bool enabled; |
| 186 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(0, &enabled)); | 186 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(0, &enabled)); |
| 187 ExtensionAccessibilityEventRouter::GetInstance() | 187 ExtensionAccessibilityEventRouter::GetInstance() |
| 188 ->SetAccessibilityEnabled(enabled); | 188 ->SetAccessibilityEnabled(enabled); |
| 189 return true; | 189 return true; |
| 190 } | 190 } |
| 191 | 191 |
| 192 bool GetFocusedControlFunction::RunImpl() { | 192 bool GetFocusedControlFunction::RunImpl() { |
| 193 // Get the serialized dict from the last focused control and return it. | 193 // Get the serialized dict from the last focused control and return it. |
| 194 // However, if the dict is empty, that means we haven't seen any focus | 194 // However, if the dict is empty, that means we haven't seen any focus |
| 195 // events yet, so return null instead. | 195 // events yet, so return null instead. |
| 196 ExtensionAccessibilityEventRouter *accessibility_event_router = | 196 ExtensionAccessibilityEventRouter *accessibility_event_router = |
| 197 ExtensionAccessibilityEventRouter::GetInstance(); | 197 ExtensionAccessibilityEventRouter::GetInstance(); |
| 198 DictionaryValue *last_focused_control_dict = | 198 DictionaryValue *last_focused_control_dict = |
| 199 accessibility_event_router->last_focused_control_dict(); | 199 accessibility_event_router->last_focused_control_dict(); |
| 200 if (last_focused_control_dict->size()) { | 200 if (last_focused_control_dict->size()) { |
| 201 result_.reset(last_focused_control_dict->DeepCopyWithoutEmptyChildren()); | 201 result_.reset(last_focused_control_dict->DeepCopyWithoutEmptyChildren()); |
| 202 } else { | 202 } else { |
| 203 result_.reset(Value::CreateNullValue()); | 203 result_.reset(Value::CreateNullValue()); |
| 204 } | 204 } |
| 205 return true; | 205 return true; |
| 206 } | 206 } |
| OLD | NEW |