| 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/views/toolbar_view.h" | 5 #include "chrome/browser/views/toolbar_view.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 // For glass, we need to draw a black line below the location bar to separate | 351 // For glass, we need to draw a black line below the location bar to separate |
| 352 // it from the content area. For non-glass, the NonClientView draws the | 352 // it from the content area. For non-glass, the NonClientView draws the |
| 353 // toolbar background below the location bar for us. | 353 // toolbar background below the location bar for us. |
| 354 if (win_util::ShouldUseVistaFrame()) | 354 if (win_util::ShouldUseVistaFrame()) |
| 355 canvas->FillRectInt(SK_ColorBLACK, 0, height() - 1, width(), 1); | 355 canvas->FillRectInt(SK_ColorBLACK, 0, height() - 1, width(), 1); |
| 356 } | 356 } |
| 357 | 357 |
| 358 void BrowserToolbarView::DidGainFocus() { | 358 void BrowserToolbarView::DidGainFocus() { |
| 359 // Check to see if MSAA focus should be restored to previously focused button, | 359 // Check to see if MSAA focus should be restored to previously focused button, |
| 360 // and if button is an enabled, visibled child of toolbar. | 360 // and if button is an enabled, visibled child of toolbar. |
| 361 if (!acc_focused_view() || | 361 if (!acc_focused_view_ || |
| 362 (acc_focused_view()->GetParent()->GetID() != VIEW_ID_TOOLBAR) || | 362 (acc_focused_view_->GetParent()->GetID() != VIEW_ID_TOOLBAR) || |
| 363 !acc_focused_view()->IsEnabled() || | 363 !acc_focused_view_->IsEnabled() || |
| 364 !acc_focused_view()->IsVisible()) { | 364 !acc_focused_view_->IsVisible()) { |
| 365 // Find first accessible child (-1 to start search at parent). | 365 // Find first accessible child (-1 to start search at parent). |
| 366 int first_acc_child = GetNextAccessibleViewIndex(-1, false); | 366 int first_acc_child = GetNextAccessibleViewIndex(-1, false); |
| 367 | 367 |
| 368 // No buttons enabled or visible. | 368 // No buttons enabled or visible. |
| 369 if (first_acc_child == -1) | 369 if (first_acc_child == -1) |
| 370 return; | 370 return; |
| 371 | 371 |
| 372 set_acc_focused_view(GetChildViewAt(first_acc_child)); | 372 set_acc_focused_view(GetChildViewAt(first_acc_child)); |
| 373 } | 373 } |
| 374 | 374 |
| 375 // Default focus is on the toolbar. | 375 // Default focus is on the toolbar. |
| 376 int view_index = VIEW_ID_TOOLBAR; | 376 int view_index = VIEW_ID_TOOLBAR; |
| 377 | 377 |
| 378 // Set hot-tracking for child, and update focused_view for MSAA focus event. | 378 // Set hot-tracking for child, and update focused_view for MSAA focus event. |
| 379 if (acc_focused_view()) { | 379 if (acc_focused_view_) { |
| 380 acc_focused_view()->SetHotTracked(true); | 380 acc_focused_view_->SetHotTracked(true); |
| 381 | 381 |
| 382 // Show the tooltip for the view that got the focus. | 382 // Show the tooltip for the view that got the focus. |
| 383 if (GetWidget()->GetTooltipManager()) | 383 if (GetWidget()->GetTooltipManager()) |
| 384 GetWidget()->GetTooltipManager()->ShowKeyboardTooltip(acc_focused_view_); | 384 GetWidget()->GetTooltipManager()->ShowKeyboardTooltip(acc_focused_view_); |
| 385 | 385 |
| 386 // Update focused_view with MSAA-adjusted child id. | 386 // Update focused_view with MSAA-adjusted child id. |
| 387 view_index = acc_focused_view()->GetID(); | 387 view_index = acc_focused_view_->GetID(); |
| 388 } | 388 } |
| 389 | 389 |
| 390 HWND hwnd = GetWidget()->GetHWND(); | 390 HWND hwnd = GetWidget()->GetHWND(); |
| 391 | 391 |
| 392 // Notify Access Technology that there was a change in keyboard focus. | 392 // Notify Access Technology that there was a change in keyboard focus. |
| 393 ::NotifyWinEvent(EVENT_OBJECT_FOCUS, hwnd, OBJID_CLIENT, | 393 ::NotifyWinEvent(EVENT_OBJECT_FOCUS, hwnd, OBJID_CLIENT, |
| 394 static_cast<LONG>(view_index)); | 394 static_cast<LONG>(view_index)); |
| 395 } | 395 } |
| 396 | 396 |
| 397 void BrowserToolbarView::WillLoseFocus() { | 397 void BrowserToolbarView::WillLoseFocus() { |
| 398 if (acc_focused_view()) { | 398 if (acc_focused_view_) { |
| 399 // Resetting focus state. | 399 // Resetting focus state. |
| 400 acc_focused_view()->SetHotTracked(false); | 400 acc_focused_view_->SetHotTracked(false); |
| 401 } | 401 } |
| 402 // Any tooltips that are active should be hidden when toolbar loses focus. | 402 // Any tooltips that are active should be hidden when toolbar loses focus. |
| 403 if (GetWidget() && GetWidget()->GetTooltipManager()) | 403 if (GetWidget() && GetWidget()->GetTooltipManager()) |
| 404 GetWidget()->GetTooltipManager()->HideKeyboardTooltip(); | 404 GetWidget()->GetTooltipManager()->HideKeyboardTooltip(); |
| 405 } | 405 } |
| 406 | 406 |
| 407 bool BrowserToolbarView::OnKeyPressed(const views::KeyEvent& e) { | 407 bool BrowserToolbarView::OnKeyPressed(const views::KeyEvent& e) { |
| 408 // Paranoia check, button should be initialized upon toolbar gaining focus. | 408 // Paranoia check, button should be initialized upon toolbar gaining focus. |
| 409 if (!acc_focused_view_) | 409 if (!acc_focused_view_) |
| 410 return false; | 410 return false; |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 IDC_SELECT_PROFILE, l10n_util::GetString(IDS_SELECT_PROFILE)); | 668 IDC_SELECT_PROFILE, l10n_util::GetString(IDS_SELECT_PROFILE)); |
| 669 } | 669 } |
| 670 | 670 |
| 671 // Always show a link to select a new profile. | 671 // Always show a link to select a new profile. |
| 672 profiles_menu_->AppendSeparator(); | 672 profiles_menu_->AppendSeparator(); |
| 673 profiles_menu_->AppendMenuItemWithLabel( | 673 profiles_menu_->AppendMenuItemWithLabel( |
| 674 IDC_NEW_PROFILE, | 674 IDC_NEW_PROFILE, |
| 675 l10n_util::GetString(IDS_SELECT_PROFILE_DIALOG_NEW_PROFILE_ENTRY)); | 675 l10n_util::GetString(IDS_SELECT_PROFILE_DIALOG_NEW_PROFILE_ENTRY)); |
| 676 } | 676 } |
| 677 | 677 |
| 678 bool BrowserToolbarView::GetAccessibleName(std::wstring* name) { |
| 679 if (!accessible_name_.empty()) { |
| 680 (*name).assign(accessible_name_); |
| 681 return true; |
| 682 } |
| 683 return false; |
| 684 } |
| 685 |
| 678 bool BrowserToolbarView::GetAccessibleRole(VARIANT* role) { | 686 bool BrowserToolbarView::GetAccessibleRole(VARIANT* role) { |
| 679 DCHECK(role); | 687 DCHECK(role); |
| 680 | 688 |
| 681 role->vt = VT_I4; | 689 role->vt = VT_I4; |
| 682 role->lVal = ROLE_SYSTEM_TOOLBAR; | 690 role->lVal = ROLE_SYSTEM_TOOLBAR; |
| 683 return true; | 691 return true; |
| 684 } | 692 } |
| 685 | 693 |
| 686 bool BrowserToolbarView::GetAccessibleName(std::wstring* name) { | |
| 687 if (!accessible_name_.empty()) { | |
| 688 (*name).assign(accessible_name_); | |
| 689 return true; | |
| 690 } | |
| 691 return false; | |
| 692 } | |
| 693 | |
| 694 void BrowserToolbarView::SetAccessibleName(const std::wstring& name) { | 694 void BrowserToolbarView::SetAccessibleName(const std::wstring& name) { |
| 695 accessible_name_.assign(name); | 695 accessible_name_.assign(name); |
| 696 } | 696 } |
| 697 | 697 |
| 698 int BrowserToolbarView::GetNextAccessibleViewIndex(int view_index, | 698 int BrowserToolbarView::GetNextAccessibleViewIndex(int view_index, |
| 699 bool nav_left) { | 699 bool nav_left) { |
| 700 int modifier = 1; | 700 int modifier = 1; |
| 701 | 701 |
| 702 if (nav_left) | 702 if (nav_left) |
| 703 modifier = -1; | 703 modifier = -1; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 717 // Update view_index with the available button index found. | 717 // Update view_index with the available button index found. |
| 718 view_index = current_view_index; | 718 view_index = current_view_index; |
| 719 break; | 719 break; |
| 720 } | 720 } |
| 721 // Returns the next available button index, or if no button is available in | 721 // Returns the next available button index, or if no button is available in |
| 722 // the specified direction, remains where it was. | 722 // the specified direction, remains where it was. |
| 723 return view_index; | 723 return view_index; |
| 724 } | 724 } |
| 725 | 725 |
| 726 void BrowserToolbarView::ShowContextMenu(int x, int y, bool is_mouse_gesture) { | 726 void BrowserToolbarView::ShowContextMenu(int x, int y, bool is_mouse_gesture) { |
| 727 if (GetAccFocusedChildView()) | 727 if (acc_focused_view_) |
| 728 GetAccFocusedChildView()->ShowContextMenu(x, y, is_mouse_gesture); | 728 acc_focused_view_->ShowContextMenu(x, y, is_mouse_gesture); |
| 729 } | 729 } |
| 730 | 730 |
| 731 int BrowserToolbarView::GetDragOperations(views::View* sender, int x, int y) { | 731 int BrowserToolbarView::GetDragOperations(views::View* sender, int x, int y) { |
| 732 DCHECK(sender == star_); | 732 DCHECK(sender == star_); |
| 733 if (model_->input_in_progress() || !tab_ || !tab_->ShouldDisplayURL() || | 733 if (model_->input_in_progress() || !tab_ || !tab_->ShouldDisplayURL() || |
| 734 !tab_->GetURL().is_valid()) { | 734 !tab_->GetURL().is_valid()) { |
| 735 return DragDropTypes::DRAG_NONE; | 735 return DragDropTypes::DRAG_NONE; |
| 736 } | 736 } |
| 737 if (profile_ && profile_->GetBookmarkModel() && | 737 if (profile_ && profile_->GetBookmarkModel() && |
| 738 profile_->GetBookmarkModel()->IsBookmarked(tab_->GetURL())) { | 738 profile_->GetBookmarkModel()->IsBookmarked(tab_->GetURL())) { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 *accel = views::Accelerator(L'C', false, true, false); | 828 *accel = views::Accelerator(L'C', false, true, false); |
| 829 return true; | 829 return true; |
| 830 case IDC_PASTE: | 830 case IDC_PASTE: |
| 831 *accel = views::Accelerator(L'V', false, true, false); | 831 *accel = views::Accelerator(L'V', false, true, false); |
| 832 return true; | 832 return true; |
| 833 } | 833 } |
| 834 // Else, we retrieve the accelerator information from the frame. | 834 // Else, we retrieve the accelerator information from the frame. |
| 835 return GetWidget()->GetAccelerator(id, accel); | 835 return GetWidget()->GetAccelerator(id, accel); |
| 836 } | 836 } |
| 837 | 837 |
| OLD | NEW |