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 "views/accessibility/view_accessibility.h" | 5 #include "views/accessibility/view_accessibility.h" |
6 | 6 |
7 #include "views/accessibility/view_accessibility_wrapper.h" | 7 #include "views/accessibility/view_accessibility_wrapper.h" |
8 #include "views/widget/widget.h" | 8 #include "views/widget/widget.h" |
9 | 9 |
10 HRESULT ViewAccessibility::Initialize(views::View* view) { | 10 HRESULT ViewAccessibility::Initialize(views::View* view) { |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 if (var_id.lVal == CHILDID_SELF) { | 319 if (var_id.lVal == CHILDID_SELF) { |
320 view_->GetAccessibleDefaultAction(&temp_action); | 320 view_->GetAccessibleDefaultAction(&temp_action); |
321 } else { | 321 } else { |
322 if (!IsValidChild((var_id.lVal - 1), view_)) { | 322 if (!IsValidChild((var_id.lVal - 1), view_)) { |
323 return E_INVALIDARG; | 323 return E_INVALIDARG; |
324 } | 324 } |
325 view_->GetChildViewAt(var_id.lVal - 1)-> | 325 view_->GetChildViewAt(var_id.lVal - 1)-> |
326 GetAccessibleDefaultAction(&temp_action); | 326 GetAccessibleDefaultAction(&temp_action); |
327 } | 327 } |
328 if (!temp_action.empty()) { | 328 if (!temp_action.empty()) { |
329 *def_action = CComBSTR(temp_action.c_str()).Detach(); | 329 *def_action = SysAllocString(temp_action.c_str()); |
330 } else { | 330 } else { |
331 return S_FALSE; | 331 return S_FALSE; |
332 } | 332 } |
333 | 333 |
334 return S_OK; | 334 return S_OK; |
335 } | 335 } |
336 | 336 |
337 STDMETHODIMP ViewAccessibility::get_accDescription(VARIANT var_id, BSTR* desc) { | 337 STDMETHODIMP ViewAccessibility::get_accDescription(VARIANT var_id, BSTR* desc) { |
338 if (var_id.vt != VT_I4 || !desc) { | 338 if (var_id.vt != VT_I4 || !desc) { |
339 return E_INVALIDARG; | 339 return E_INVALIDARG; |
340 } | 340 } |
341 | 341 |
342 std::wstring temp_desc; | 342 std::wstring temp_desc; |
343 | 343 |
344 if (var_id.lVal == CHILDID_SELF) { | 344 if (var_id.lVal == CHILDID_SELF) { |
345 view_->GetTooltipText(0, 0, &temp_desc); | 345 view_->GetTooltipText(0, 0, &temp_desc); |
346 } else { | 346 } else { |
347 if (!IsValidChild((var_id.lVal - 1), view_)) { | 347 if (!IsValidChild((var_id.lVal - 1), view_)) { |
348 return E_INVALIDARG; | 348 return E_INVALIDARG; |
349 } | 349 } |
350 view_->GetChildViewAt(var_id.lVal - 1)->GetTooltipText(0, 0, &temp_desc); | 350 view_->GetChildViewAt(var_id.lVal - 1)->GetTooltipText(0, 0, &temp_desc); |
351 } | 351 } |
352 if (!temp_desc.empty()) { | 352 if (!temp_desc.empty()) { |
353 *desc = CComBSTR(temp_desc.c_str()).Detach(); | 353 *desc = SysAllocString(temp_desc.c_str()); |
354 } else { | 354 } else { |
355 return S_FALSE; | 355 return S_FALSE; |
356 } | 356 } |
357 | 357 |
358 return S_OK; | 358 return S_OK; |
359 } | 359 } |
360 | 360 |
361 STDMETHODIMP ViewAccessibility::get_accFocus(VARIANT* focus_child) { | 361 STDMETHODIMP ViewAccessibility::get_accFocus(VARIANT* focus_child) { |
362 if (!focus_child) { | 362 if (!focus_child) { |
363 return E_INVALIDARG; | 363 return E_INVALIDARG; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 if (var_id.lVal == CHILDID_SELF) { | 406 if (var_id.lVal == CHILDID_SELF) { |
407 view_->GetAccessibleKeyboardShortcut(&temp_key); | 407 view_->GetAccessibleKeyboardShortcut(&temp_key); |
408 } else { | 408 } else { |
409 if (!IsValidChild((var_id.lVal - 1), view_)) { | 409 if (!IsValidChild((var_id.lVal - 1), view_)) { |
410 return E_INVALIDARG; | 410 return E_INVALIDARG; |
411 } | 411 } |
412 view_->GetChildViewAt(var_id.lVal - 1)-> | 412 view_->GetChildViewAt(var_id.lVal - 1)-> |
413 GetAccessibleKeyboardShortcut(&temp_key); | 413 GetAccessibleKeyboardShortcut(&temp_key); |
414 } | 414 } |
415 if (!temp_key.empty()) { | 415 if (!temp_key.empty()) { |
416 *acc_key = CComBSTR(temp_key.c_str()).Detach(); | 416 *acc_key = SysAllocString(temp_key.c_str()); |
417 } else { | 417 } else { |
418 return S_FALSE; | 418 return S_FALSE; |
419 } | 419 } |
420 | 420 |
421 return S_OK; | 421 return S_OK; |
422 } | 422 } |
423 | 423 |
424 STDMETHODIMP ViewAccessibility::get_accName(VARIANT var_id, BSTR* name) { | 424 STDMETHODIMP ViewAccessibility::get_accName(VARIANT var_id, BSTR* name) { |
425 if (var_id.vt != VT_I4 || !name) { | 425 if (var_id.vt != VT_I4 || !name) { |
426 return E_INVALIDARG; | 426 return E_INVALIDARG; |
427 } | 427 } |
428 | 428 |
429 std::wstring temp_name; | 429 std::wstring temp_name; |
430 | 430 |
431 if (var_id.lVal == CHILDID_SELF) { | 431 if (var_id.lVal == CHILDID_SELF) { |
432 // Retrieve the parent view's name. | 432 // Retrieve the parent view's name. |
433 view_->GetAccessibleName(&temp_name); | 433 view_->GetAccessibleName(&temp_name); |
434 } else { | 434 } else { |
435 if (!IsValidChild((var_id.lVal - 1), view_)) { | 435 if (!IsValidChild((var_id.lVal - 1), view_)) { |
436 return E_INVALIDARG; | 436 return E_INVALIDARG; |
437 } | 437 } |
438 // Retrieve the child view's name. | 438 // Retrieve the child view's name. |
439 view_->GetChildViewAt(var_id.lVal - 1)->GetAccessibleName(&temp_name); | 439 view_->GetChildViewAt(var_id.lVal - 1)->GetAccessibleName(&temp_name); |
440 } | 440 } |
441 if (!temp_name.empty()) { | 441 if (!temp_name.empty()) { |
442 // Return name retrieved. | 442 // Return name retrieved. |
443 *name = CComBSTR(temp_name.c_str()).Detach(); | 443 *name = SysAllocString(temp_name.c_str()); |
444 } else { | 444 } else { |
445 // If view has no name, return S_FALSE. | 445 // If view has no name, return S_FALSE. |
446 return S_FALSE; | 446 return S_FALSE; |
447 } | 447 } |
448 | 448 |
449 return S_OK; | 449 return S_OK; |
450 } | 450 } |
451 | 451 |
452 STDMETHODIMP ViewAccessibility::get_accParent(IDispatch** disp_parent) { | 452 STDMETHODIMP ViewAccessibility::get_accParent(IDispatch** disp_parent) { |
453 if (!disp_parent) { | 453 if (!disp_parent) { |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 | 701 |
702 STDMETHODIMP ViewAccessibility::put_accName(VARIANT var_id, BSTR put_name) { | 702 STDMETHODIMP ViewAccessibility::put_accName(VARIANT var_id, BSTR put_name) { |
703 // Deprecated. | 703 // Deprecated. |
704 return E_NOTIMPL; | 704 return E_NOTIMPL; |
705 } | 705 } |
706 | 706 |
707 STDMETHODIMP ViewAccessibility::put_accValue(VARIANT var_id, BSTR put_val) { | 707 STDMETHODIMP ViewAccessibility::put_accValue(VARIANT var_id, BSTR put_val) { |
708 // Deprecated. | 708 // Deprecated. |
709 return E_NOTIMPL; | 709 return E_NOTIMPL; |
710 } | 710 } |
OLD | NEW |