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 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 static SkBitmap normal_background; | 455 static SkBitmap normal_background; |
456 if (normal_background.isNull()) { | 456 if (normal_background.isNull()) { |
457 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 457 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
458 normal_background = *rb.GetBitmapNamed(IDR_CONTENT_TOP_CENTER); | 458 normal_background = *rb.GetBitmapNamed(IDR_CONTENT_TOP_CENTER); |
459 } | 459 } |
460 | 460 |
461 return gfx::Size(min_width, normal_background.height()); | 461 return gfx::Size(min_width, normal_background.height()); |
462 } | 462 } |
463 | 463 |
464 int vertical_spacing = PopupTopSpacing() + | 464 int vertical_spacing = PopupTopSpacing() + |
465 (GetWindow()->ShouldUseNativeFrame() ? | 465 (GetWidget()->ShouldUseNativeFrame() ? |
466 kPopupBottomSpacingGlass : kPopupBottomSpacingNonGlass); | 466 kPopupBottomSpacingGlass : kPopupBottomSpacingNonGlass); |
467 return gfx::Size(0, location_bar_->GetPreferredSize().height() + | 467 return gfx::Size(0, location_bar_->GetPreferredSize().height() + |
468 vertical_spacing); | 468 vertical_spacing); |
469 } | 469 } |
470 | 470 |
471 void ToolbarView::Layout() { | 471 void ToolbarView::Layout() { |
472 // If we have not been initialized yet just do nothing. | 472 // If we have not been initialized yet just do nothing. |
473 if (back_ == NULL) | 473 if (back_ == NULL) |
474 return; | 474 return; |
475 | 475 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 int top_spacing = PopupTopSpacing(); | 555 int top_spacing = PopupTopSpacing(); |
556 canvas->DrawBitmapInt(*kPopupBackgroundEdge, 0, top_spacing); | 556 canvas->DrawBitmapInt(*kPopupBackgroundEdge, 0, top_spacing); |
557 canvas->DrawBitmapInt(*kPopupBackgroundEdge, | 557 canvas->DrawBitmapInt(*kPopupBackgroundEdge, |
558 width() - kPopupBackgroundEdge->width(), top_spacing); | 558 width() - kPopupBackgroundEdge->width(), top_spacing); |
559 } | 559 } |
560 | 560 |
561 // For glass, we need to draw a black line below the location bar to separate | 561 // For glass, we need to draw a black line below the location bar to separate |
562 // it from the content area. For non-glass, the NonClientView draws the | 562 // it from the content area. For non-glass, the NonClientView draws the |
563 // toolbar background below the location bar for us. | 563 // toolbar background below the location bar for us. |
564 // NOTE: Keep this in sync with BrowserView::GetInfoBarSeparatorColor()! | 564 // NOTE: Keep this in sync with BrowserView::GetInfoBarSeparatorColor()! |
565 if (GetWindow()->ShouldUseNativeFrame()) | 565 if (GetWidget()->ShouldUseNativeFrame()) |
566 canvas->FillRectInt(SK_ColorBLACK, 0, height() - 1, width(), 1); | 566 canvas->FillRectInt(SK_ColorBLACK, 0, height() - 1, width(), 1); |
567 } | 567 } |
568 | 568 |
569 // Note this method is ignored on Windows, but needs to be implemented for | 569 // Note this method is ignored on Windows, but needs to be implemented for |
570 // linux, where it is called before CanDrop(). | 570 // linux, where it is called before CanDrop(). |
571 bool ToolbarView::GetDropFormats( | 571 bool ToolbarView::GetDropFormats( |
572 int* formats, | 572 int* formats, |
573 std::set<OSExchangeData::CustomFormat>* custom_formats) { | 573 std::set<OSExchangeData::CustomFormat>* custom_formats) { |
574 *formats = ui::OSExchangeData::URL | ui::OSExchangeData::STRING; | 574 *formats = ui::OSExchangeData::URL | ui::OSExchangeData::STRING; |
575 return true; | 575 return true; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 bool ToolbarView::ShouldShowIncompatibilityWarning() { | 626 bool ToolbarView::ShouldShowIncompatibilityWarning() { |
627 #if defined(OS_WIN) | 627 #if defined(OS_WIN) |
628 EnumerateModulesModel* loaded_modules = EnumerateModulesModel::GetInstance(); | 628 EnumerateModulesModel* loaded_modules = EnumerateModulesModel::GetInstance(); |
629 return loaded_modules->ShouldShowConflictWarning(); | 629 return loaded_modules->ShouldShowConflictWarning(); |
630 #else | 630 #else |
631 return false; | 631 return false; |
632 #endif | 632 #endif |
633 } | 633 } |
634 | 634 |
635 int ToolbarView::PopupTopSpacing() const { | 635 int ToolbarView::PopupTopSpacing() const { |
636 // TODO(beng): For some reason GetWindow() returns NULL here in some | 636 // TODO(beng): For some reason GetWidget() returns NULL here in some |
637 // unidentified circumstances on ChromeOS. This means GetWidget() | 637 // unidentified circumstances on ChromeOS. This means GetWidget() |
638 // succeeded but we were (probably) unable to locate a | 638 // succeeded but we were (probably) unable to locate a |
639 // NativeWidgetGtk* on it using | 639 // NativeWidgetGtk* on it using |
640 // NativeWidget::GetNativeWidgetForNativeView. | 640 // NativeWidget::GetNativeWidgetForNativeView. |
641 // I am throwing in a NULL check for now to stop the hurt, but | 641 // I am throwing in a NULL check for now to stop the hurt, but |
642 // it's possible the crash may just show up somewhere else. | 642 // it's possible the crash may just show up somewhere else. |
643 const views::Window* window = GetWindow(); | 643 const views::Widget* widget = GetWidget(); |
644 DCHECK(window) << "If you hit this please talk to beng"; | 644 DCHECK(widget) << "If you hit this please talk to beng"; |
645 return window && window->ShouldUseNativeFrame() ? | 645 return widget && widget->ShouldUseNativeFrame() ? |
646 0 : kPopupTopSpacingNonGlass; | 646 0 : kPopupTopSpacingNonGlass; |
647 } | 647 } |
648 | 648 |
649 void ToolbarView::LoadImages() { | 649 void ToolbarView::LoadImages() { |
650 ui::ThemeProvider* tp = GetThemeProvider(); | 650 ui::ThemeProvider* tp = GetThemeProvider(); |
651 | 651 |
652 back_->SetImage(views::CustomButton::BS_NORMAL, tp->GetBitmapNamed(IDR_BACK)); | 652 back_->SetImage(views::CustomButton::BS_NORMAL, tp->GetBitmapNamed(IDR_BACK)); |
653 back_->SetImage(views::CustomButton::BS_HOT, tp->GetBitmapNamed(IDR_BACK_H)); | 653 back_->SetImage(views::CustomButton::BS_HOT, tp->GetBitmapNamed(IDR_BACK_H)); |
654 back_->SetImage(views::CustomButton::BS_PUSHED, | 654 back_->SetImage(views::CustomButton::BS_PUSHED, |
655 tp->GetBitmapNamed(IDR_BACK_P)); | 655 tp->GetBitmapNamed(IDR_BACK_P)); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::BS_HOT)); | 689 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::BS_HOT)); |
690 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::BS_PUSHED)); | 690 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::BS_PUSHED)); |
691 } | 691 } |
692 | 692 |
693 void ToolbarView::UpdateAppMenuBadge() { | 693 void ToolbarView::UpdateAppMenuBadge() { |
694 app_menu_->SetIcon(GetAppMenuIcon(views::CustomButton::BS_NORMAL)); | 694 app_menu_->SetIcon(GetAppMenuIcon(views::CustomButton::BS_NORMAL)); |
695 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::BS_HOT)); | 695 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::BS_HOT)); |
696 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::BS_PUSHED)); | 696 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::BS_PUSHED)); |
697 SchedulePaint(); | 697 SchedulePaint(); |
698 } | 698 } |
OLD | NEW |