| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/infobars/infobar_view.h" | 5 #include "chrome/browser/ui/views/infobars/infobar_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 11 #include "chrome/browser/ui/infobar_container_delegate.h" | 12 #include "chrome/browser/ui/infobar_container_delegate.h" |
| 12 #include "chrome/browser/ui/views/bar_control_button.h" | 13 #include "chrome/browser/ui/views/bar_control_button.h" |
| 13 #include "chrome/browser/ui/views/infobars/infobar_background.h" | 14 #include "chrome/browser/ui/views/infobars/infobar_background.h" |
| 14 #include "chrome/grit/generated_resources.h" | 15 #include "chrome/grit/generated_resources.h" |
| 15 #include "components/infobars/core/infobar_delegate.h" | 16 #include "components/infobars/core/infobar_delegate.h" |
| 16 #include "grit/theme_resources.h" | 17 #include "grit/theme_resources.h" |
| 17 #include "third_party/skia/include/effects/SkGradientShader.h" | 18 #include "third_party/skia/include/effects/SkGradientShader.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 } // namespace | 69 } // namespace |
| 69 | 70 |
| 70 | 71 |
| 71 // InfoBarView ---------------------------------------------------------------- | 72 // InfoBarView ---------------------------------------------------------------- |
| 72 | 73 |
| 73 // static | 74 // static |
| 74 const int InfoBarView::kButtonButtonSpacing = views::kRelatedButtonHSpacing; | 75 const int InfoBarView::kButtonButtonSpacing = views::kRelatedButtonHSpacing; |
| 75 const int InfoBarView::kEndOfLabelSpacing = views::kItemLabelSpacing; | 76 const int InfoBarView::kEndOfLabelSpacing = views::kItemLabelSpacing; |
| 76 | 77 |
| 77 InfoBarView::InfoBarView(scoped_ptr<infobars::InfoBarDelegate> delegate) | 78 InfoBarView::InfoBarView(scoped_ptr<infobars::InfoBarDelegate> delegate) |
| 78 : infobars::InfoBar(delegate.Pass()), | 79 : infobars::InfoBar(std::move(delegate)), |
| 79 views::ExternalFocusTracker(this, NULL), | 80 views::ExternalFocusTracker(this, NULL), |
| 80 icon_(NULL), | 81 icon_(NULL), |
| 81 close_button_(NULL) { | 82 close_button_(NULL) { |
| 82 set_owned_by_client(); // InfoBar deletes itself at the appropriate time. | 83 set_owned_by_client(); // InfoBar deletes itself at the appropriate time. |
| 83 set_background( | 84 set_background( |
| 84 new InfoBarBackground(infobars::InfoBar::delegate()->GetInfoBarType())); | 85 new InfoBarBackground(infobars::InfoBar::delegate()->GetInfoBarType())); |
| 85 } | 86 } |
| 86 | 87 |
| 87 InfoBarView::~InfoBarView() { | 88 InfoBarView::~InfoBarView() { |
| 88 // We should have closed any open menus in PlatformSpecificHide(), then | 89 // We should have closed any open menus in PlatformSpecificHide(), then |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 views::Painter::CreateImageGridPainter(kNormalImageSet)); | 128 views::Painter::CreateImageGridPainter(kNormalImageSet)); |
| 128 const int kHoveredImageSet[] = IMAGE_GRID(IDR_INFOBARBUTTON_HOVER); | 129 const int kHoveredImageSet[] = IMAGE_GRID(IDR_INFOBARBUTTON_HOVER); |
| 129 button_border->SetPainter( | 130 button_border->SetPainter( |
| 130 false, views::Button::STATE_HOVERED, | 131 false, views::Button::STATE_HOVERED, |
| 131 views::Painter::CreateImageGridPainter(kHoveredImageSet)); | 132 views::Painter::CreateImageGridPainter(kHoveredImageSet)); |
| 132 const int kPressedImageSet[] = IMAGE_GRID(IDR_INFOBARBUTTON_PRESSED); | 133 const int kPressedImageSet[] = IMAGE_GRID(IDR_INFOBARBUTTON_PRESSED); |
| 133 button_border->SetPainter( | 134 button_border->SetPainter( |
| 134 false, views::Button::STATE_PRESSED, | 135 false, views::Button::STATE_PRESSED, |
| 135 views::Painter::CreateImageGridPainter(kPressedImageSet)); | 136 views::Painter::CreateImageGridPainter(kPressedImageSet)); |
| 136 | 137 |
| 137 button->SetBorder(button_border.Pass()); | 138 button->SetBorder(std::move(button_border)); |
| 138 button->set_animate_on_state_change(false); | 139 button->set_animate_on_state_change(false); |
| 139 button->SetTextColor(views::Button::STATE_NORMAL, GetInfobarTextColor()); | 140 button->SetTextColor(views::Button::STATE_NORMAL, GetInfobarTextColor()); |
| 140 button->SetTextColor(views::Button::STATE_HOVERED, GetInfobarTextColor()); | 141 button->SetTextColor(views::Button::STATE_HOVERED, GetInfobarTextColor()); |
| 141 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 142 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 142 button->SetFontList(rb.GetFontList(ui::ResourceBundle::MediumFont)); | 143 button->SetFontList(rb.GetFontList(ui::ResourceBundle::MediumFont)); |
| 143 } | 144 } |
| 144 button->SetFocusable(true); | 145 button->SetFocusable(true); |
| 145 return button; | 146 return button; |
| 146 } | 147 } |
| 147 | 148 |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 void InfoBarView::OnWillChangeFocus(View* focused_before, View* focused_now) { | 405 void InfoBarView::OnWillChangeFocus(View* focused_before, View* focused_now) { |
| 405 views::ExternalFocusTracker::OnWillChangeFocus(focused_before, focused_now); | 406 views::ExternalFocusTracker::OnWillChangeFocus(focused_before, focused_now); |
| 406 | 407 |
| 407 // This will trigger some screen readers to read the entire contents of this | 408 // This will trigger some screen readers to read the entire contents of this |
| 408 // infobar. | 409 // infobar. |
| 409 if (focused_before && focused_now && !Contains(focused_before) && | 410 if (focused_before && focused_now && !Contains(focused_before) && |
| 410 Contains(focused_now)) { | 411 Contains(focused_now)) { |
| 411 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); | 412 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); |
| 412 } | 413 } |
| 413 } | 414 } |
| OLD | NEW |