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/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 if (!browser_->window() || !browser_->window()->IsMaximized()) { | 392 if (!browser_->window() || !browser_->window()->IsMaximized()) { |
393 int top_spacing = PopupTopSpacing(); | 393 int top_spacing = PopupTopSpacing(); |
394 canvas->DrawBitmapInt(*kPopupBackgroundEdge, 0, top_spacing); | 394 canvas->DrawBitmapInt(*kPopupBackgroundEdge, 0, top_spacing); |
395 canvas->DrawBitmapInt(*kPopupBackgroundEdge, | 395 canvas->DrawBitmapInt(*kPopupBackgroundEdge, |
396 width() - kPopupBackgroundEdge->width(), top_spacing); | 396 width() - kPopupBackgroundEdge->width(), top_spacing); |
397 } | 397 } |
398 | 398 |
399 // For glass, we need to draw a black line below the location bar to separate | 399 // For glass, we need to draw a black line below the location bar to separate |
400 // it from the content area. For non-glass, the NonClientView draws the | 400 // it from the content area. For non-glass, the NonClientView draws the |
401 // toolbar background below the location bar for us. | 401 // toolbar background below the location bar for us. |
402 if (GetWidget()->GetWindow()->GetNonClientView()->UseNativeFrame()) | 402 if (GetWindow()->GetNonClientView()->UseNativeFrame()) |
403 canvas->FillRectInt(SK_ColorBLACK, 0, height() - 1, width(), 1); | 403 canvas->FillRectInt(SK_ColorBLACK, 0, height() - 1, width(), 1); |
404 } | 404 } |
405 | 405 |
406 void BrowserToolbarView::DidGainFocus() { | 406 void BrowserToolbarView::DidGainFocus() { |
407 // Check to see if MSAA focus should be restored to previously focused button, | 407 // Check to see if MSAA focus should be restored to previously focused button, |
408 // and if button is an enabled, visibled child of toolbar. | 408 // and if button is an enabled, visibled child of toolbar. |
409 if (!acc_focused_view_ || | 409 if (!acc_focused_view_ || |
410 (acc_focused_view_->GetParent()->GetID() != VIEW_ID_TOOLBAR) || | 410 (acc_focused_view_->GetParent()->GetID() != VIEW_ID_TOOLBAR) || |
411 !acc_focused_view_->IsEnabled() || | 411 !acc_focused_view_->IsEnabled() || |
412 !acc_focused_view_->IsVisible()) { | 412 !acc_focused_view_->IsVisible()) { |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 static SkBitmap normal_background; | 547 static SkBitmap normal_background; |
548 if (normal_background.isNull()) { | 548 if (normal_background.isNull()) { |
549 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 549 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
550 normal_background = *rb.GetBitmapNamed(IDR_CONTENT_TOP_CENTER); | 550 normal_background = *rb.GetBitmapNamed(IDR_CONTENT_TOP_CENTER); |
551 } | 551 } |
552 | 552 |
553 return gfx::Size(min_width, normal_background.height()); | 553 return gfx::Size(min_width, normal_background.height()); |
554 } | 554 } |
555 | 555 |
556 int vertical_spacing = PopupTopSpacing() + | 556 int vertical_spacing = PopupTopSpacing() + |
557 (GetWidget()->GetWindow()->GetNonClientView()->UseNativeFrame() ? | 557 (GetWindow()->GetNonClientView()->UseNativeFrame() ? |
558 kPopupBottomSpacingGlass : kPopupBottomSpacingNonGlass); | 558 kPopupBottomSpacingGlass : kPopupBottomSpacingNonGlass); |
559 return gfx::Size(0, location_bar_->GetPreferredSize().height() + | 559 return gfx::Size(0, location_bar_->GetPreferredSize().height() + |
560 vertical_spacing); | 560 vertical_spacing); |
561 } | 561 } |
562 | 562 |
563 void BrowserToolbarView::RunPageMenu(const CPoint& pt, HWND hwnd) { | 563 void BrowserToolbarView::RunPageMenu(const CPoint& pt, HWND hwnd) { |
564 Menu::AnchorPoint anchor = Menu::TOPRIGHT; | 564 Menu::AnchorPoint anchor = Menu::TOPRIGHT; |
565 if (UILayoutIsRightToLeft()) | 565 if (UILayoutIsRightToLeft()) |
566 anchor = Menu::TOPLEFT; | 566 anchor = Menu::TOPLEFT; |
567 | 567 |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
881 popup_bounds.set_y(popup_bounds.y()); | 881 popup_bounds.set_y(popup_bounds.y()); |
882 popup_bounds.set_width(popup_bounds.width()); | 882 popup_bounds.set_width(popup_bounds.width()); |
883 // Inset the bounds a little, since the buttons on either edge of the omnibox | 883 // Inset the bounds a little, since the buttons on either edge of the omnibox |
884 // have invisible padding that makes the popup appear too wide. | 884 // have invisible padding that makes the popup appear too wide. |
885 popup_bounds.Inset(kOmniboxButtonsHorizontalMargin, 0); | 885 popup_bounds.Inset(kOmniboxButtonsHorizontalMargin, 0); |
886 return popup_bounds; | 886 return popup_bounds; |
887 } | 887 } |
888 | 888 |
889 // static | 889 // static |
890 int BrowserToolbarView::PopupTopSpacing() { | 890 int BrowserToolbarView::PopupTopSpacing() { |
891 return GetWidget()->GetWindow()->GetNonClientView()->UseNativeFrame() ? | 891 return GetWindow()->GetNonClientView()->UseNativeFrame() ? |
892 0 : kPopupTopSpacingNonGlass; | 892 0 : kPopupTopSpacingNonGlass; |
893 } | 893 } |
894 | 894 |
895 void BrowserToolbarView::Observe(NotificationType type, | 895 void BrowserToolbarView::Observe(NotificationType type, |
896 const NotificationSource& source, | 896 const NotificationSource& source, |
897 const NotificationDetails& details) { | 897 const NotificationDetails& details) { |
898 if (type == NotificationType::PREF_CHANGED) { | 898 if (type == NotificationType::PREF_CHANGED) { |
899 std::wstring* pref_name = Details<std::wstring>(details).ptr(); | 899 std::wstring* pref_name = Details<std::wstring>(details).ptr(); |
900 if (*pref_name == prefs::kShowHomeButton) { | 900 if (*pref_name == prefs::kShowHomeButton) { |
901 Layout(); | 901 Layout(); |
(...skipping 14 matching lines...) Expand all Loading... |
916 case IDC_COPY: | 916 case IDC_COPY: |
917 *accel = views::Accelerator(L'C', false, true, false); | 917 *accel = views::Accelerator(L'C', false, true, false); |
918 return true; | 918 return true; |
919 case IDC_PASTE: | 919 case IDC_PASTE: |
920 *accel = views::Accelerator(L'V', false, true, false); | 920 *accel = views::Accelerator(L'V', false, true, false); |
921 return true; | 921 return true; |
922 } | 922 } |
923 // Else, we retrieve the accelerator information from the frame. | 923 // Else, we retrieve the accelerator information from the frame. |
924 return GetWidget()->GetAccelerator(id, accel); | 924 return GetWidget()->GetAccelerator(id, accel); |
925 } | 925 } |
OLD | NEW |