OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/browser_accessibility.h" | 5 #include "chrome/browser/browser_accessibility.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/browser_accessibility_manager.h" | 8 #include "chrome/browser/browser_accessibility_manager.h" |
9 | 9 |
10 using webkit_glue::WebAccessibility; | 10 using webkit_glue::WebAccessibility; |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 if (!RequestAccessibilityInfo(WebAccessibility::FUNCTION_DEFAULTACTION, | 247 if (!RequestAccessibilityInfo(WebAccessibility::FUNCTION_DEFAULTACTION, |
248 var_id, NULL, NULL)) { | 248 var_id, NULL, NULL)) { |
249 return E_FAIL; | 249 return E_FAIL; |
250 } | 250 } |
251 | 251 |
252 if (!response().return_code) { | 252 if (!response().return_code) { |
253 // No string found. | 253 // No string found. |
254 return S_FALSE; | 254 return S_FALSE; |
255 } | 255 } |
256 | 256 |
257 *def_action = CComBSTR(response().output_string.c_str()).Detach(); | 257 *def_action = SysAllocString(response().output_string.c_str()); |
258 | 258 |
259 DCHECK(*def_action); | 259 DCHECK(*def_action); |
260 return S_OK; | 260 return S_OK; |
261 } | 261 } |
262 | 262 |
263 STDMETHODIMP BrowserAccessibility::get_accDescription(VARIANT var_id, | 263 STDMETHODIMP BrowserAccessibility::get_accDescription(VARIANT var_id, |
264 BSTR* desc) { | 264 BSTR* desc) { |
265 if (!instance_active()) { | 265 if (!instance_active()) { |
266 // Instance no longer active, fail gracefully. | 266 // Instance no longer active, fail gracefully. |
267 return E_FAIL; | 267 return E_FAIL; |
268 } | 268 } |
269 | 269 |
270 if (var_id.vt != VT_I4 || !desc) | 270 if (var_id.vt != VT_I4 || !desc) |
271 return E_INVALIDARG; | 271 return E_INVALIDARG; |
272 | 272 |
273 if (!RequestAccessibilityInfo(WebAccessibility::FUNCTION_DESCRIPTION, var_id, | 273 if (!RequestAccessibilityInfo(WebAccessibility::FUNCTION_DESCRIPTION, var_id, |
274 NULL, NULL)) { | 274 NULL, NULL)) { |
275 return E_FAIL; | 275 return E_FAIL; |
276 } | 276 } |
277 | 277 |
278 if (!response().return_code) { | 278 if (!response().return_code) { |
279 // No string found. | 279 // No string found. |
280 return S_FALSE; | 280 return S_FALSE; |
281 } | 281 } |
282 | 282 |
283 *desc = CComBSTR(response().output_string.c_str()).Detach(); | 283 *desc = SysAllocString(response().output_string.c_str()); |
284 | 284 |
285 DCHECK(*desc); | 285 DCHECK(*desc); |
286 return S_OK; | 286 return S_OK; |
287 } | 287 } |
288 | 288 |
289 STDMETHODIMP BrowserAccessibility::get_accFocus(VARIANT* focus_child) { | 289 STDMETHODIMP BrowserAccessibility::get_accFocus(VARIANT* focus_child) { |
290 if (!instance_active()) { | 290 if (!instance_active()) { |
291 // Instance no longer active, fail gracefully. | 291 // Instance no longer active, fail gracefully. |
292 return E_FAIL; | 292 return E_FAIL; |
293 } | 293 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 if (!RequestAccessibilityInfo(WebAccessibility::FUNCTION_HELPTEXT, var_id, | 335 if (!RequestAccessibilityInfo(WebAccessibility::FUNCTION_HELPTEXT, var_id, |
336 NULL, NULL)) { | 336 NULL, NULL)) { |
337 return E_FAIL; | 337 return E_FAIL; |
338 } | 338 } |
339 | 339 |
340 if (!response().return_code || response().output_string.empty()) { | 340 if (!response().return_code || response().output_string.empty()) { |
341 // No string found. | 341 // No string found. |
342 return S_FALSE; | 342 return S_FALSE; |
343 } | 343 } |
344 | 344 |
345 *help = CComBSTR(response().output_string.c_str()).Detach(); | 345 *help = SysAllocString(response().output_string.c_str()); |
346 | 346 |
347 DCHECK(*help); | 347 DCHECK(*help); |
348 return S_OK; | 348 return S_OK; |
349 } | 349 } |
350 | 350 |
351 STDMETHODIMP BrowserAccessibility::get_accKeyboardShortcut(VARIANT var_id, | 351 STDMETHODIMP BrowserAccessibility::get_accKeyboardShortcut(VARIANT var_id, |
352 BSTR* acc_key) { | 352 BSTR* acc_key) { |
353 if (!instance_active()) { | 353 if (!instance_active()) { |
354 // Instance no longer active, fail gracefully. | 354 // Instance no longer active, fail gracefully. |
355 return E_FAIL; | 355 return E_FAIL; |
356 } | 356 } |
357 | 357 |
358 if (var_id.vt != VT_I4 || !acc_key) | 358 if (var_id.vt != VT_I4 || !acc_key) |
359 return E_INVALIDARG; | 359 return E_INVALIDARG; |
360 | 360 |
361 if (!RequestAccessibilityInfo(WebAccessibility::FUNCTION_KEYBOARDSHORTCUT, | 361 if (!RequestAccessibilityInfo(WebAccessibility::FUNCTION_KEYBOARDSHORTCUT, |
362 var_id, NULL, NULL)) { | 362 var_id, NULL, NULL)) { |
363 return E_FAIL; | 363 return E_FAIL; |
364 } | 364 } |
365 | 365 |
366 if (!response().return_code) { | 366 if (!response().return_code) { |
367 // No string found. | 367 // No string found. |
368 return S_FALSE; | 368 return S_FALSE; |
369 } | 369 } |
370 | 370 |
371 *acc_key = CComBSTR(response().output_string.c_str()).Detach(); | 371 *acc_key = SysAllocString(response().output_string.c_str()); |
372 | 372 |
373 DCHECK(*acc_key); | 373 DCHECK(*acc_key); |
374 return S_OK; | 374 return S_OK; |
375 } | 375 } |
376 | 376 |
377 STDMETHODIMP BrowserAccessibility::get_accName(VARIANT var_id, BSTR* name) { | 377 STDMETHODIMP BrowserAccessibility::get_accName(VARIANT var_id, BSTR* name) { |
378 if (!instance_active()) { | 378 if (!instance_active()) { |
379 // Instance no longer active, fail gracefully. | 379 // Instance no longer active, fail gracefully. |
380 return E_FAIL; | 380 return E_FAIL; |
381 } | 381 } |
382 | 382 |
383 if (var_id.vt != VT_I4 || !name) | 383 if (var_id.vt != VT_I4 || !name) |
384 return E_INVALIDARG; | 384 return E_INVALIDARG; |
385 | 385 |
386 if (!RequestAccessibilityInfo(WebAccessibility::FUNCTION_NAME, var_id, NULL, | 386 if (!RequestAccessibilityInfo(WebAccessibility::FUNCTION_NAME, var_id, NULL, |
387 NULL)) { | 387 NULL)) { |
388 return E_FAIL; | 388 return E_FAIL; |
389 } | 389 } |
390 | 390 |
391 if (!response().return_code) { | 391 if (!response().return_code) { |
392 // No string found. | 392 // No string found. |
393 return S_FALSE; | 393 return S_FALSE; |
394 } | 394 } |
395 | 395 |
396 *name = CComBSTR(response().output_string.c_str()).Detach(); | 396 *name = SysAllocString(response().output_string.c_str()); |
397 | 397 |
398 DCHECK(*name); | 398 DCHECK(*name); |
399 return S_OK; | 399 return S_OK; |
400 } | 400 } |
401 | 401 |
402 STDMETHODIMP BrowserAccessibility::get_accParent(IDispatch** disp_parent) { | 402 STDMETHODIMP BrowserAccessibility::get_accParent(IDispatch** disp_parent) { |
403 if (!instance_active()) { | 403 if (!instance_active()) { |
404 // Instance no longer active, fail gracefully. | 404 // Instance no longer active, fail gracefully. |
405 return E_FAIL; | 405 return E_FAIL; |
406 } | 406 } |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 if (!RequestAccessibilityInfo(WebAccessibility::FUNCTION_VALUE, var_id, NULL, | 497 if (!RequestAccessibilityInfo(WebAccessibility::FUNCTION_VALUE, var_id, NULL, |
498 NULL)) { | 498 NULL)) { |
499 return E_FAIL; | 499 return E_FAIL; |
500 } | 500 } |
501 | 501 |
502 if (!response().return_code || response().output_string.empty()) { | 502 if (!response().return_code || response().output_string.empty()) { |
503 // No string found. | 503 // No string found. |
504 return S_FALSE; | 504 return S_FALSE; |
505 } | 505 } |
506 | 506 |
507 *value = CComBSTR(response().output_string.c_str()).Detach(); | 507 *value = SysAllocString(response().output_string.c_str()); |
508 | 508 |
509 DCHECK(*value); | 509 DCHECK(*value); |
510 return S_OK; | 510 return S_OK; |
511 } | 511 } |
512 | 512 |
513 STDMETHODIMP BrowserAccessibility::get_accHelpTopic(BSTR* help_file, | 513 STDMETHODIMP BrowserAccessibility::get_accHelpTopic(BSTR* help_file, |
514 VARIANT var_id, | 514 VARIANT var_id, |
515 LONG* topic_id) { | 515 LONG* topic_id) { |
516 if (help_file) | 516 if (help_file) |
517 *help_file = NULL; | 517 *help_file = NULL; |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 state |= STATE_SYSTEM_READONLY; | 666 state |= STATE_SYSTEM_READONLY; |
667 | 667 |
668 if ((browser_accessibility_state >> WebAccessibility::STATE_TRAVERSED) & 1) | 668 if ((browser_accessibility_state >> WebAccessibility::STATE_TRAVERSED) & 1) |
669 state |= STATE_SYSTEM_TRAVERSED; | 669 state |= STATE_SYSTEM_TRAVERSED; |
670 | 670 |
671 if ((browser_accessibility_state >> WebAccessibility::STATE_UNAVAILABLE) & 1) | 671 if ((browser_accessibility_state >> WebAccessibility::STATE_UNAVAILABLE) & 1) |
672 state |= STATE_SYSTEM_UNAVAILABLE; | 672 state |= STATE_SYSTEM_UNAVAILABLE; |
673 | 673 |
674 return state; | 674 return state; |
675 } | 675 } |
OLD | NEW |