| 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 28 matching lines...) Expand all Loading... |
| 39 #include "chrome/common/win_util.h" | 39 #include "chrome/common/win_util.h" |
| 40 #ifdef CHROME_PERSONALIZATION | 40 #ifdef CHROME_PERSONALIZATION |
| 41 #include "chrome/personalization/personalization.h" | 41 #include "chrome/personalization/personalization.h" |
| 42 #endif | 42 #endif |
| 43 #include "chrome/views/background.h" | 43 #include "chrome/views/background.h" |
| 44 #include "chrome/views/button_dropdown.h" | 44 #include "chrome/views/button_dropdown.h" |
| 45 #include "chrome/views/hwnd_view.h" | 45 #include "chrome/views/hwnd_view.h" |
| 46 #include "chrome/views/label.h" | 46 #include "chrome/views/label.h" |
| 47 #include "chrome/views/non_client_view.h" | 47 #include "chrome/views/non_client_view.h" |
| 48 #include "chrome/views/tooltip_manager.h" | 48 #include "chrome/views/tooltip_manager.h" |
| 49 #include "chrome/views/widget.h" | 49 #include "chrome/views/window.h" |
| 50 #include "grit/chromium_strings.h" | 50 #include "grit/chromium_strings.h" |
| 51 #include "grit/generated_resources.h" | 51 #include "grit/generated_resources.h" |
| 52 #include "grit/theme_resources.h" | 52 #include "grit/theme_resources.h" |
| 53 #include "net/base/net_util.h" | 53 #include "net/base/net_util.h" |
| 54 | 54 |
| 55 static const int kControlHorizOffset = 4; | 55 static const int kControlHorizOffset = 4; |
| 56 static const int kControlVertOffset = 6; | 56 static const int kControlVertOffset = 6; |
| 57 static const int kControlIndent = 3; | 57 static const int kControlIndent = 3; |
| 58 static const int kStatusBubbleWidth = 480; | 58 static const int kStatusBubbleWidth = 480; |
| 59 | 59 |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 if (!browser_->window() || !browser_->window()->IsMaximized()) { | 346 if (!browser_->window() || !browser_->window()->IsMaximized()) { |
| 347 int top_spacing = PopupTopSpacing(); | 347 int top_spacing = PopupTopSpacing(); |
| 348 canvas->DrawBitmapInt(*kPopupBackgroundEdge, 0, top_spacing); | 348 canvas->DrawBitmapInt(*kPopupBackgroundEdge, 0, top_spacing); |
| 349 canvas->DrawBitmapInt(*kPopupBackgroundEdge, | 349 canvas->DrawBitmapInt(*kPopupBackgroundEdge, |
| 350 width() - kPopupBackgroundEdge->width(), top_spacing); | 350 width() - kPopupBackgroundEdge->width(), top_spacing); |
| 351 } | 351 } |
| 352 | 352 |
| 353 // For glass, we need to draw a black line below the location bar to separate | 353 // For glass, we need to draw a black line below the location bar to separate |
| 354 // it from the content area. For non-glass, the NonClientView draws the | 354 // it from the content area. For non-glass, the NonClientView draws the |
| 355 // toolbar background below the location bar for us. | 355 // toolbar background below the location bar for us. |
| 356 if (win_util::ShouldUseVistaFrame()) | 356 if (GetWidget()->AsWindow()->UseNativeFrame()) |
| 357 canvas->FillRectInt(SK_ColorBLACK, 0, height() - 1, width(), 1); | 357 canvas->FillRectInt(SK_ColorBLACK, 0, height() - 1, width(), 1); |
| 358 } | 358 } |
| 359 | 359 |
| 360 void BrowserToolbarView::DidGainFocus() { | 360 void BrowserToolbarView::DidGainFocus() { |
| 361 // Check to see if MSAA focus should be restored to previously focused button, | 361 // Check to see if MSAA focus should be restored to previously focused button, |
| 362 // and if button is an enabled, visibled child of toolbar. | 362 // and if button is an enabled, visibled child of toolbar. |
| 363 if (!acc_focused_view_ || | 363 if (!acc_focused_view_ || |
| 364 (acc_focused_view_->GetParent()->GetID() != VIEW_ID_TOOLBAR) || | 364 (acc_focused_view_->GetParent()->GetID() != VIEW_ID_TOOLBAR) || |
| 365 !acc_focused_view_->IsEnabled() || | 365 !acc_focused_view_->IsEnabled() || |
| 366 !acc_focused_view_->IsVisible()) { | 366 !acc_focused_view_->IsVisible()) { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 gfx::Size BrowserToolbarView::GetPreferredSize() { | 489 gfx::Size BrowserToolbarView::GetPreferredSize() { |
| 490 if (IsDisplayModeNormal()) { | 490 if (IsDisplayModeNormal()) { |
| 491 static SkBitmap normal_background; | 491 static SkBitmap normal_background; |
| 492 if (normal_background.isNull()) { | 492 if (normal_background.isNull()) { |
| 493 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 493 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 494 normal_background = *rb.GetBitmapNamed(IDR_CONTENT_TOP_CENTER); | 494 normal_background = *rb.GetBitmapNamed(IDR_CONTENT_TOP_CENTER); |
| 495 } | 495 } |
| 496 return gfx::Size(0, normal_background.height()); | 496 return gfx::Size(0, normal_background.height()); |
| 497 } | 497 } |
| 498 | 498 |
| 499 int vertical_spacing = PopupTopSpacing() + (win_util::ShouldUseVistaFrame() ? | 499 int vertical_spacing = PopupTopSpacing() + |
| 500 kPopupBottomSpacingGlass : kPopupBottomSpacingNonGlass); | 500 (GetWidget()->AsWindow()->UseNativeFrame() ? kPopupBottomSpacingGlass |
| 501 : kPopupBottomSpacingNonGlass); |
| 501 return gfx::Size(0, location_bar_->GetPreferredSize().height() + | 502 return gfx::Size(0, location_bar_->GetPreferredSize().height() + |
| 502 vertical_spacing); | 503 vertical_spacing); |
| 503 } | 504 } |
| 504 | 505 |
| 505 void BrowserToolbarView::RunPageMenu(const CPoint& pt, HWND hwnd) { | 506 void BrowserToolbarView::RunPageMenu(const CPoint& pt, HWND hwnd) { |
| 506 Menu::AnchorPoint anchor = Menu::TOPRIGHT; | 507 Menu::AnchorPoint anchor = Menu::TOPRIGHT; |
| 507 if (UILayoutIsRightToLeft()) | 508 if (UILayoutIsRightToLeft()) |
| 508 anchor = Menu::TOPLEFT; | 509 anchor = Menu::TOPLEFT; |
| 509 | 510 |
| 510 Menu menu(this, anchor, hwnd); | 511 Menu menu(this, anchor, hwnd); |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 798 if (button) | 799 if (button) |
| 799 button->SetEnabled(enabled); | 800 button->SetEnabled(enabled); |
| 800 } | 801 } |
| 801 | 802 |
| 802 void BrowserToolbarView::ButtonPressed(views::BaseButton* sender) { | 803 void BrowserToolbarView::ButtonPressed(views::BaseButton* sender) { |
| 803 browser_->ExecuteCommand(sender->GetTag()); | 804 browser_->ExecuteCommand(sender->GetTag()); |
| 804 } | 805 } |
| 805 | 806 |
| 806 // static | 807 // static |
| 807 int BrowserToolbarView::PopupTopSpacing() { | 808 int BrowserToolbarView::PopupTopSpacing() { |
| 808 return win_util::ShouldUseVistaFrame() ? 0 : kPopupTopSpacingNonGlass; | 809 return GetWidget()->AsWindow()->UseNativeFrame() ? 0 |
| 810 : kPopupTopSpacingNonGlass; |
| 809 } | 811 } |
| 810 | 812 |
| 811 void BrowserToolbarView::Observe(NotificationType type, | 813 void BrowserToolbarView::Observe(NotificationType type, |
| 812 const NotificationSource& source, | 814 const NotificationSource& source, |
| 813 const NotificationDetails& details) { | 815 const NotificationDetails& details) { |
| 814 if (type == NotificationType::PREF_CHANGED) { | 816 if (type == NotificationType::PREF_CHANGED) { |
| 815 std::wstring* pref_name = Details<std::wstring>(details).ptr(); | 817 std::wstring* pref_name = Details<std::wstring>(details).ptr(); |
| 816 if (*pref_name == prefs::kShowHomeButton) { | 818 if (*pref_name == prefs::kShowHomeButton) { |
| 817 Layout(); | 819 Layout(); |
| 818 SchedulePaint(); | 820 SchedulePaint(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 833 *accel = views::Accelerator(L'C', false, true, false); | 835 *accel = views::Accelerator(L'C', false, true, false); |
| 834 return true; | 836 return true; |
| 835 case IDC_PASTE: | 837 case IDC_PASTE: |
| 836 *accel = views::Accelerator(L'V', false, true, false); | 838 *accel = views::Accelerator(L'V', false, true, false); |
| 837 return true; | 839 return true; |
| 838 } | 840 } |
| 839 // Else, we retrieve the accelerator information from the frame. | 841 // Else, we retrieve the accelerator information from the frame. |
| 840 return GetWidget()->GetAccelerator(id, accel); | 842 return GetWidget()->GetAccelerator(id, accel); |
| 841 } | 843 } |
| 842 | 844 |
| OLD | NEW |