| 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 |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "chrome/browser/ui/infobar_container_delegate.h" | 13 #include "chrome/browser/ui/infobar_container_delegate.h" |
| 14 #include "chrome/browser/ui/views/bar_control_button.h" | |
| 15 #include "chrome/browser/ui/views/infobars/infobar_background.h" | 14 #include "chrome/browser/ui/views/infobars/infobar_background.h" |
| 16 #include "chrome/grit/generated_resources.h" | 15 #include "chrome/grit/generated_resources.h" |
| 17 #include "chrome/grit/theme_resources.h" | 16 #include "chrome/grit/theme_resources.h" |
| 18 #include "components/infobars/core/infobar_delegate.h" | 17 #include "components/infobars/core/infobar_delegate.h" |
| 19 #include "components/strings/grit/components_strings.h" | 18 #include "components/strings/grit/components_strings.h" |
| 20 #include "third_party/skia/include/effects/SkGradientShader.h" | 19 #include "third_party/skia/include/effects/SkGradientShader.h" |
| 21 #include "ui/accessibility/ax_view_state.h" | 20 #include "ui/accessibility/ax_view_state.h" |
| 22 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
| 23 #include "ui/base/material_design/material_design_controller.h" | 22 #include "ui/base/material_design/material_design_controller.h" |
| 24 #include "ui/base/resource/resource_bundle.h" | 23 #include "ui/base/resource/resource_bundle.h" |
| 25 #include "ui/gfx/canvas.h" | 24 #include "ui/gfx/canvas.h" |
| 26 #include "ui/gfx/color_palette.h" | 25 #include "ui/gfx/color_palette.h" |
| 27 #include "ui/gfx/image/image.h" | 26 #include "ui/gfx/image/image.h" |
| 28 #include "ui/gfx/paint_vector_icon.h" | 27 #include "ui/gfx/paint_vector_icon.h" |
| 29 #include "ui/gfx/vector_icons_public.h" | 28 #include "ui/gfx/vector_icons_public.h" |
| 30 #include "ui/native_theme/common_theme.h" | 29 #include "ui/native_theme/common_theme.h" |
| 31 #include "ui/native_theme/native_theme.h" | 30 #include "ui/native_theme/native_theme.h" |
| 32 #include "ui/resources/grit/ui_resources.h" | 31 #include "ui/resources/grit/ui_resources.h" |
| 33 #include "ui/views/controls/button/image_button.h" | 32 #include "ui/views/controls/button/image_button.h" |
| 34 #include "ui/views/controls/button/label_button.h" | 33 #include "ui/views/controls/button/label_button.h" |
| 35 #include "ui/views/controls/button/label_button_border.h" | 34 #include "ui/views/controls/button/label_button_border.h" |
| 36 #include "ui/views/controls/button/md_text_button.h" | 35 #include "ui/views/controls/button/md_text_button.h" |
| 37 #include "ui/views/controls/button/menu_button.h" | 36 #include "ui/views/controls/button/menu_button.h" |
| 37 #include "ui/views/controls/button/vector_icon_button.h" |
| 38 #include "ui/views/controls/image_view.h" | 38 #include "ui/views/controls/image_view.h" |
| 39 #include "ui/views/controls/label.h" | 39 #include "ui/views/controls/label.h" |
| 40 #include "ui/views/controls/link.h" | 40 #include "ui/views/controls/link.h" |
| 41 #include "ui/views/controls/menu/menu_runner.h" | 41 #include "ui/views/controls/menu/menu_runner.h" |
| 42 #include "ui/views/layout/layout_constants.h" | 42 #include "ui/views/layout/layout_constants.h" |
| 43 #include "ui/views/widget/widget.h" | 43 #include "ui/views/widget/widget.h" |
| 44 #include "ui/views/window/non_client_view.h" | 44 #include "ui/views/window/non_client_view.h" |
| 45 | 45 |
| 46 | 46 |
| 47 // Helpers -------------------------------------------------------------------- | 47 // Helpers -------------------------------------------------------------------- |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 if (details.is_add && (details.child == this) && (close_button_ == NULL)) { | 256 if (details.is_add && (details.child == this) && (close_button_ == NULL)) { |
| 257 gfx::Image image = delegate()->GetIcon(); | 257 gfx::Image image = delegate()->GetIcon(); |
| 258 if (!image.IsEmpty()) { | 258 if (!image.IsEmpty()) { |
| 259 icon_ = new views::ImageView; | 259 icon_ = new views::ImageView; |
| 260 icon_->SetImage(image.ToImageSkia()); | 260 icon_->SetImage(image.ToImageSkia()); |
| 261 icon_->SizeToPreferredSize(); | 261 icon_->SizeToPreferredSize(); |
| 262 child_container_->AddChildView(icon_); | 262 child_container_->AddChildView(icon_); |
| 263 } | 263 } |
| 264 | 264 |
| 265 if (ui::MaterialDesignController::IsModeMaterial()) { | 265 if (ui::MaterialDesignController::IsModeMaterial()) { |
| 266 BarControlButton* close = new BarControlButton(this); | 266 views::VectorIconButton* close = new views::VectorIconButton(this); |
| 267 close->SetIcon(gfx::VectorIconId::BAR_CLOSE, | 267 close->SetIcon(gfx::VectorIconId::BAR_CLOSE, |
| 268 base::Bind(&GetInfobarTextColor)); | 268 base::Bind(&GetInfobarTextColor)); |
| 269 close_button_ = close; | 269 close_button_ = close; |
| 270 } else { | 270 } else { |
| 271 close_button_ = new views::ImageButton(this); | 271 close_button_ = new views::ImageButton(this); |
| 272 close_button_->set_request_focus_on_press(true); | 272 close_button_->set_request_focus_on_press(true); |
| 273 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 273 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 274 close_button_->SetImage(views::CustomButton::STATE_NORMAL, | 274 close_button_->SetImage(views::CustomButton::STATE_NORMAL, |
| 275 rb.GetImageNamed(IDR_CLOSE_1).ToImageSkia()); | 275 rb.GetImageNamed(IDR_CLOSE_1).ToImageSkia()); |
| 276 close_button_->SetImage(views::CustomButton::STATE_HOVERED, | 276 close_button_->SetImage(views::CustomButton::STATE_HOVERED, |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 } | 427 } |
| 428 | 428 |
| 429 bool InfoBarView::DoesIntersectRect(const View* target, | 429 bool InfoBarView::DoesIntersectRect(const View* target, |
| 430 const gfx::Rect& rect) const { | 430 const gfx::Rect& rect) const { |
| 431 DCHECK_EQ(this, target); | 431 DCHECK_EQ(this, target); |
| 432 // Only events that intersect the portion below the arrow are interesting. | 432 // Only events that intersect the portion below the arrow are interesting. |
| 433 gfx::Rect non_arrow_bounds = GetLocalBounds(); | 433 gfx::Rect non_arrow_bounds = GetLocalBounds(); |
| 434 non_arrow_bounds.Inset(0, arrow_height(), 0, 0); | 434 non_arrow_bounds.Inset(0, arrow_height(), 0, 0); |
| 435 return rect.Intersects(non_arrow_bounds); | 435 return rect.Intersects(non_arrow_bounds); |
| 436 } | 436 } |
| OLD | NEW |