| OLD | NEW | 
|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/views/toolbar_view.h" | 5 #include "chrome/browser/ui/views/toolbar_view.h" | 
| 6 | 6 | 
| 7 #include "base/i18n/number_formatting.h" | 7 #include "base/i18n/number_formatting.h" | 
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" | 
| 9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" | 
| 10 #include "chrome/browser/accessibility/browser_accessibility_state.h" | 10 #include "chrome/browser/accessibility/browser_accessibility_state.h" | 
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 459     static SkBitmap normal_background; | 459     static SkBitmap normal_background; | 
| 460     if (normal_background.isNull()) { | 460     if (normal_background.isNull()) { | 
| 461       ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 461       ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 
| 462       normal_background = *rb.GetBitmapNamed(IDR_CONTENT_TOP_CENTER); | 462       normal_background = *rb.GetBitmapNamed(IDR_CONTENT_TOP_CENTER); | 
| 463     } | 463     } | 
| 464 | 464 | 
| 465     return gfx::Size(min_width, normal_background.height()); | 465     return gfx::Size(min_width, normal_background.height()); | 
| 466   } | 466   } | 
| 467 | 467 | 
| 468   int vertical_spacing = PopupTopSpacing() + | 468   int vertical_spacing = PopupTopSpacing() + | 
| 469       (GetWindow()->ShouldUseNativeFrame() ? | 469       (GetWindow()->non_client_view()->UseNativeFrame() ? | 
| 470           kPopupBottomSpacingGlass : kPopupBottomSpacingNonGlass); | 470           kPopupBottomSpacingGlass : kPopupBottomSpacingNonGlass); | 
| 471   return gfx::Size(0, location_bar_->GetPreferredSize().height() + | 471   return gfx::Size(0, location_bar_->GetPreferredSize().height() + | 
| 472       vertical_spacing); | 472       vertical_spacing); | 
| 473 } | 473 } | 
| 474 | 474 | 
| 475 void ToolbarView::Layout() { | 475 void ToolbarView::Layout() { | 
| 476   // If we have not been initialized yet just do nothing. | 476   // If we have not been initialized yet just do nothing. | 
| 477   if (back_ == NULL) | 477   if (back_ == NULL) | 
| 478     return; | 478     return; | 
| 479 | 479 | 
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 559     int top_spacing = PopupTopSpacing(); | 559     int top_spacing = PopupTopSpacing(); | 
| 560     canvas->DrawBitmapInt(*kPopupBackgroundEdge, 0, top_spacing); | 560     canvas->DrawBitmapInt(*kPopupBackgroundEdge, 0, top_spacing); | 
| 561     canvas->DrawBitmapInt(*kPopupBackgroundEdge, | 561     canvas->DrawBitmapInt(*kPopupBackgroundEdge, | 
| 562                           width() - kPopupBackgroundEdge->width(), top_spacing); | 562                           width() - kPopupBackgroundEdge->width(), top_spacing); | 
| 563   } | 563   } | 
| 564 | 564 | 
| 565   // For glass, we need to draw a black line below the location bar to separate | 565   // For glass, we need to draw a black line below the location bar to separate | 
| 566   // it from the content area.  For non-glass, the NonClientView draws the | 566   // it from the content area.  For non-glass, the NonClientView draws the | 
| 567   // toolbar background below the location bar for us. | 567   // toolbar background below the location bar for us. | 
| 568   // NOTE: Keep this in sync with BrowserView::GetInfoBarSeparatorColor()! | 568   // NOTE: Keep this in sync with BrowserView::GetInfoBarSeparatorColor()! | 
| 569   if (GetWindow()->ShouldUseNativeFrame()) | 569   if (GetWindow()->non_client_view()->UseNativeFrame()) | 
| 570     canvas->FillRectInt(SK_ColorBLACK, 0, height() - 1, width(), 1); | 570     canvas->FillRectInt(SK_ColorBLACK, 0, height() - 1, width(), 1); | 
| 571 } | 571 } | 
| 572 | 572 | 
| 573 // Note this method is ignored on Windows, but needs to be implemented for | 573 // Note this method is ignored on Windows, but needs to be implemented for | 
| 574 // linux, where it is called before CanDrop(). | 574 // linux, where it is called before CanDrop(). | 
| 575 bool ToolbarView::GetDropFormats( | 575 bool ToolbarView::GetDropFormats( | 
| 576     int* formats, | 576     int* formats, | 
| 577     std::set<OSExchangeData::CustomFormat>* custom_formats) { | 577     std::set<OSExchangeData::CustomFormat>* custom_formats) { | 
| 578   *formats = ui::OSExchangeData::URL | ui::OSExchangeData::STRING; | 578   *formats = ui::OSExchangeData::URL | ui::OSExchangeData::STRING; | 
| 579   return true; | 579   return true; | 
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 639 | 639 | 
| 640 int ToolbarView::PopupTopSpacing() const { | 640 int ToolbarView::PopupTopSpacing() const { | 
| 641   // TODO(beng): For some reason GetWindow() returns NULL here in some | 641   // TODO(beng): For some reason GetWindow() returns NULL here in some | 
| 642   //             unidentified circumstances on ChromeOS. This means GetWidget() | 642   //             unidentified circumstances on ChromeOS. This means GetWidget() | 
| 643   //             succeeded but we were (probably) unable to locate a WidgetGtk* | 643   //             succeeded but we were (probably) unable to locate a WidgetGtk* | 
| 644   //             on it using NativeWidget::GetNativeWidgetForNativeView. | 644   //             on it using NativeWidget::GetNativeWidgetForNativeView. | 
| 645   //             I am throwing in a NULL check for now to stop the hurt, but | 645   //             I am throwing in a NULL check for now to stop the hurt, but | 
| 646   //             it's possible the crash may just show up somewhere else. | 646   //             it's possible the crash may just show up somewhere else. | 
| 647   const views::Window* window = GetWindow(); | 647   const views::Window* window = GetWindow(); | 
| 648   DCHECK(window) << "If you hit this please talk to beng"; | 648   DCHECK(window) << "If you hit this please talk to beng"; | 
| 649   return window && window->ShouldUseNativeFrame() ? | 649   return window && window->non_client_view()->UseNativeFrame() ? | 
| 650       0 : kPopupTopSpacingNonGlass; | 650       0 : kPopupTopSpacingNonGlass; | 
| 651 } | 651 } | 
| 652 | 652 | 
| 653 void ToolbarView::LoadImages() { | 653 void ToolbarView::LoadImages() { | 
| 654   ui::ThemeProvider* tp = GetThemeProvider(); | 654   ui::ThemeProvider* tp = GetThemeProvider(); | 
| 655 | 655 | 
| 656   back_->SetImage(views::CustomButton::BS_NORMAL, tp->GetBitmapNamed(IDR_BACK)); | 656   back_->SetImage(views::CustomButton::BS_NORMAL, tp->GetBitmapNamed(IDR_BACK)); | 
| 657   back_->SetImage(views::CustomButton::BS_HOT, tp->GetBitmapNamed(IDR_BACK_H)); | 657   back_->SetImage(views::CustomButton::BS_HOT, tp->GetBitmapNamed(IDR_BACK_H)); | 
| 658   back_->SetImage(views::CustomButton::BS_PUSHED, | 658   back_->SetImage(views::CustomButton::BS_PUSHED, | 
| 659       tp->GetBitmapNamed(IDR_BACK_P)); | 659       tp->GetBitmapNamed(IDR_BACK_P)); | 
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 693   app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::BS_HOT)); | 693   app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::BS_HOT)); | 
| 694   app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::BS_PUSHED)); | 694   app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::BS_PUSHED)); | 
| 695 } | 695 } | 
| 696 | 696 | 
| 697 void ToolbarView::UpdateAppMenuBadge() { | 697 void ToolbarView::UpdateAppMenuBadge() { | 
| 698   app_menu_->SetIcon(GetAppMenuIcon(views::CustomButton::BS_NORMAL)); | 698   app_menu_->SetIcon(GetAppMenuIcon(views::CustomButton::BS_NORMAL)); | 
| 699   app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::BS_HOT)); | 699   app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::BS_HOT)); | 
| 700   app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::BS_PUSHED)); | 700   app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::BS_PUSHED)); | 
| 701   SchedulePaint(); | 701   SchedulePaint(); | 
| 702 } | 702 } | 
| OLD | NEW | 
|---|