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 <memory> | 8 #include <memory> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 false, views::Button::STATE_HOVERED, | 153 false, views::Button::STATE_HOVERED, |
154 views::Painter::CreateImageGridPainter(kHoveredImageSet)); | 154 views::Painter::CreateImageGridPainter(kHoveredImageSet)); |
155 const int kPressedImageSet[] = IMAGE_GRID(IDR_INFOBARBUTTON_PRESSED); | 155 const int kPressedImageSet[] = IMAGE_GRID(IDR_INFOBARBUTTON_PRESSED); |
156 button_border->SetPainter( | 156 button_border->SetPainter( |
157 false, views::Button::STATE_PRESSED, | 157 false, views::Button::STATE_PRESSED, |
158 views::Painter::CreateImageGridPainter(kPressedImageSet)); | 158 views::Painter::CreateImageGridPainter(kPressedImageSet)); |
159 button->SetBorder(std::move(button_border)); | 159 button->SetBorder(std::move(button_border)); |
160 button->set_animate_on_state_change(false); | 160 button->set_animate_on_state_change(false); |
161 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 161 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
162 button->SetFontList(rb.GetFontList(ui::ResourceBundle::MediumFont)); | 162 button->SetFontList(rb.GetFontList(ui::ResourceBundle::MediumFont)); |
163 button->SetFocusBehavior(FocusBehavior::ALWAYS); | 163 views::Button::ConfigureDefaultFocus(button); |
164 button->SetTextColor(views::Button::STATE_NORMAL, GetInfobarTextColor()); | 164 button->SetTextColor(views::Button::STATE_NORMAL, GetInfobarTextColor()); |
165 button->SetTextColor(views::Button::STATE_HOVERED, GetInfobarTextColor()); | 165 button->SetTextColor(views::Button::STATE_HOVERED, GetInfobarTextColor()); |
166 return button; | 166 return button; |
167 } | 167 } |
168 | 168 |
169 views::MdTextButton* InfoBarView::CreateMdTextButton( | 169 views::MdTextButton* InfoBarView::CreateMdTextButton( |
170 views::ButtonListener* listener, | 170 views::ButtonListener* listener, |
171 const base::string16& text) { | 171 const base::string16& text) { |
172 DCHECK(ui::MaterialDesignController::IsModeMaterial()); | 172 DCHECK(ui::MaterialDesignController::IsModeMaterial()); |
173 views::MdTextButton* button = | 173 views::MdTextButton* button = |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 282 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
283 close_button_->SetImage(views::CustomButton::STATE_NORMAL, | 283 close_button_->SetImage(views::CustomButton::STATE_NORMAL, |
284 rb.GetImageNamed(IDR_CLOSE_1).ToImageSkia()); | 284 rb.GetImageNamed(IDR_CLOSE_1).ToImageSkia()); |
285 close_button_->SetImage(views::CustomButton::STATE_HOVERED, | 285 close_button_->SetImage(views::CustomButton::STATE_HOVERED, |
286 rb.GetImageNamed(IDR_CLOSE_1_H).ToImageSkia()); | 286 rb.GetImageNamed(IDR_CLOSE_1_H).ToImageSkia()); |
287 close_button_->SetImage(views::CustomButton::STATE_PRESSED, | 287 close_button_->SetImage(views::CustomButton::STATE_PRESSED, |
288 rb.GetImageNamed(IDR_CLOSE_1_P).ToImageSkia()); | 288 rb.GetImageNamed(IDR_CLOSE_1_P).ToImageSkia()); |
289 } | 289 } |
290 close_button_->SetAccessibleName( | 290 close_button_->SetAccessibleName( |
291 l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE)); | 291 l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE)); |
292 close_button_->SetFocusBehavior(FocusBehavior::ALWAYS); | 292 views::Button::ConfigureDefaultFocus(close_button_); |
293 // Subclasses should already be done adding child views by this point (see | 293 // Subclasses should already be done adding child views by this point (see |
294 // related DCHECK in Layout()). | 294 // related DCHECK in Layout()). |
295 child_container_->AddChildView(close_button_); | 295 child_container_->AddChildView(close_button_); |
296 } | 296 } |
297 | 297 |
298 // Ensure the infobar is tall enough to display its contents. | 298 // Ensure the infobar is tall enough to display its contents. |
299 int height = ui::MaterialDesignController::IsModeMaterial() | 299 int height = ui::MaterialDesignController::IsModeMaterial() |
300 ? InfoBarContainerDelegate::kDefaultBarTargetHeightMd | 300 ? InfoBarContainerDelegate::kDefaultBarTargetHeightMd |
301 : InfoBarContainerDelegate::kDefaultBarTargetHeight; | 301 : InfoBarContainerDelegate::kDefaultBarTargetHeight; |
302 const int kMinimumVerticalPadding = 6; | 302 const int kMinimumVerticalPadding = 6; |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 } | 436 } |
437 | 437 |
438 bool InfoBarView::DoesIntersectRect(const View* target, | 438 bool InfoBarView::DoesIntersectRect(const View* target, |
439 const gfx::Rect& rect) const { | 439 const gfx::Rect& rect) const { |
440 DCHECK_EQ(this, target); | 440 DCHECK_EQ(this, target); |
441 // Only events that intersect the portion below the arrow are interesting. | 441 // Only events that intersect the portion below the arrow are interesting. |
442 gfx::Rect non_arrow_bounds = GetLocalBounds(); | 442 gfx::Rect non_arrow_bounds = GetLocalBounds(); |
443 non_arrow_bounds.Inset(0, arrow_height(), 0, 0); | 443 non_arrow_bounds.Inset(0, arrow_height(), 0, 0); |
444 return rect.Intersects(non_arrow_bounds); | 444 return rect.Intersects(non_arrow_bounds); |
445 } | 445 } |
OLD | NEW |