| 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()->AsWindow()->GetNonClientView()->UseNativeFrame()) | 402 if (GetWidget()->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()->AsWindow()->GetNonClientView()->UseNativeFrame() ? | 557 (GetWidget()->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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 876 popup_bounds.set_y(popup_bounds.y()); | 876 popup_bounds.set_y(popup_bounds.y()); |
| 877 popup_bounds.set_width(popup_bounds.width()); | 877 popup_bounds.set_width(popup_bounds.width()); |
| 878 // Inset the bounds a little, since the buttons on either edge of the omnibox | 878 // Inset the bounds a little, since the buttons on either edge of the omnibox |
| 879 // have invisible padding that makes the popup appear too wide. | 879 // have invisible padding that makes the popup appear too wide. |
| 880 popup_bounds.Inset(kOmniboxButtonsHorizontalMargin, 0); | 880 popup_bounds.Inset(kOmniboxButtonsHorizontalMargin, 0); |
| 881 return popup_bounds; | 881 return popup_bounds; |
| 882 } | 882 } |
| 883 | 883 |
| 884 // static | 884 // static |
| 885 int BrowserToolbarView::PopupTopSpacing() { | 885 int BrowserToolbarView::PopupTopSpacing() { |
| 886 return GetWidget()->AsWindow()->GetNonClientView()->UseNativeFrame() ? | 886 return GetWidget()->GetWindow()->GetNonClientView()->UseNativeFrame() ? |
| 887 0 : kPopupTopSpacingNonGlass; | 887 0 : kPopupTopSpacingNonGlass; |
| 888 } | 888 } |
| 889 | 889 |
| 890 void BrowserToolbarView::Observe(NotificationType type, | 890 void BrowserToolbarView::Observe(NotificationType type, |
| 891 const NotificationSource& source, | 891 const NotificationSource& source, |
| 892 const NotificationDetails& details) { | 892 const NotificationDetails& details) { |
| 893 if (type == NotificationType::PREF_CHANGED) { | 893 if (type == NotificationType::PREF_CHANGED) { |
| 894 std::wstring* pref_name = Details<std::wstring>(details).ptr(); | 894 std::wstring* pref_name = Details<std::wstring>(details).ptr(); |
| 895 if (*pref_name == prefs::kShowHomeButton) { | 895 if (*pref_name == prefs::kShowHomeButton) { |
| 896 Layout(); | 896 Layout(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 911 case IDC_COPY: | 911 case IDC_COPY: |
| 912 *accel = views::Accelerator(L'C', false, true, false); | 912 *accel = views::Accelerator(L'C', false, true, false); |
| 913 return true; | 913 return true; |
| 914 case IDC_PASTE: | 914 case IDC_PASTE: |
| 915 *accel = views::Accelerator(L'V', false, true, false); | 915 *accel = views::Accelerator(L'V', false, true, false); |
| 916 return true; | 916 return true; |
| 917 } | 917 } |
| 918 // Else, we retrieve the accelerator information from the frame. | 918 // Else, we retrieve the accelerator information from the frame. |
| 919 return GetWidget()->GetAccelerator(id, accel); | 919 return GetWidget()->GetAccelerator(id, accel); |
| 920 } | 920 } |
| OLD | NEW |