From 5ec61d49aa4a91049c58615279b1b491d8d7a722 Mon Sep 17 00:00:00 2001 From: "dmazzoni@chromium.org" Date: Sat, 6 Apr 2013 10:23:18 +0000 Subject: Fix launcher and system tray accessibility. Fix AccessiblePaneView's logic when "Escape" is pressed: now it restores focus to the last focused view but only if it's within the same window and not within this pane - in practice, that only happens within the browser window. Otherwise, it deactivates the current window - so pressing Escape while focused on the launcher or status area will restore activation to the browser window. Also adds an accessible notification when the system tray opens. BUG=225920 Review URL: https://chromiumcodereview.appspot.com/13471014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@192734 0039d316-1c4b-4281-b951-d872f2087c98 --- ui/views/accessible_pane_view.cc | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'ui/views/accessible_pane_view.cc') diff --git a/ui/views/accessible_pane_view.cc b/ui/views/accessible_pane_view.cc index 5ec5f43..21e9076 100644 --- a/ui/views/accessible_pane_view.cc +++ b/ui/views/accessible_pane_view.cc @@ -51,6 +51,7 @@ AccessiblePaneView::AccessiblePaneView() left_key_(ui::VKEY_LEFT, ui::EF_NONE), right_key_(ui::VKEY_RIGHT, ui::EF_NONE) { focus_search_.reset(new AccessiblePaneViewFocusSearch(this)); + last_focused_view_storage_id_ = ViewStorage::GetInstance()->CreateStorageID(); } AccessiblePaneView::~AccessiblePaneView() { @@ -66,7 +67,12 @@ bool AccessiblePaneView::SetPaneFocus(views::View* initial_focus) { if (!focus_manager_) focus_manager_ = GetFocusManager(); - focus_manager_->StoreFocusedView(true); + View* focused_view = focus_manager_->GetFocusedView(); + if (focused_view && !ContainsForFocusSearch(this, focused_view)) { + ViewStorage* view_storage = ViewStorage::GetInstance(); + view_storage->RemoveView(last_focused_view_storage_id_); + view_storage->StoreView(last_focused_view_storage_id_, focused_view); + } // Use the provided initial focus if it's visible and enabled, otherwise // use the first focusable child. @@ -162,12 +168,18 @@ bool AccessiblePaneView::AcceleratorPressed( return false; switch (accelerator.key_code()) { - case ui::VKEY_ESCAPE: + case ui::VKEY_ESCAPE: { RemovePaneFocus(); - if (!focus_manager_->RestoreFocusedView() && - allow_deactivate_on_esc_) + View* last_focused_view = ViewStorage::GetInstance()->RetrieveView( + last_focused_view_storage_id_); + if (last_focused_view) { + focus_manager_->SetFocusedViewWithReason( + last_focused_view, FocusManager::kReasonFocusRestore); + } else if (allow_deactivate_on_esc_) { focused_view->GetWidget()->Deactivate(); + } return true; + } case ui::VKEY_LEFT: focus_manager_->AdvanceFocus(true); return true; -- cgit v1.1