| 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 #ifndef CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_VIEW_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "components/infobars/core/infobar.h" | 10 #include "components/infobars/core/infobar.h" |
| 11 #include "components/infobars/core/infobar_container.h" | 11 #include "components/infobars/core/infobar_container.h" |
| 12 #include "third_party/skia/include/core/SkPath.h" | 12 #include "third_party/skia/include/core/SkPath.h" |
| 13 #include "ui/views/controls/button/button.h" | 13 #include "ui/views/controls/button/button.h" |
| 14 #include "ui/views/controls/button/vector_icon_button_delegate.h" | |
| 15 #include "ui/views/controls/menu/menu_types.h" | 14 #include "ui/views/controls/menu/menu_types.h" |
| 16 #include "ui/views/focus/external_focus_tracker.h" | 15 #include "ui/views/focus/external_focus_tracker.h" |
| 17 #include "ui/views/view_targeter_delegate.h" | 16 #include "ui/views/view_targeter_delegate.h" |
| 18 | 17 |
| 19 namespace views { | 18 namespace views { |
| 19 class ImageButton; |
| 20 class ImageView; | 20 class ImageView; |
| 21 class Label; | 21 class Label; |
| 22 class Link; | 22 class Link; |
| 23 class LinkListener; | 23 class LinkListener; |
| 24 class MenuRunner; | 24 class MenuRunner; |
| 25 class VectorIconButton; | |
| 26 } // namespace views | 25 } // namespace views |
| 27 | 26 |
| 28 class InfoBarView : public infobars::InfoBar, | 27 class InfoBarView : public infobars::InfoBar, |
| 29 public views::View, | 28 public views::View, |
| 30 public views::VectorIconButtonDelegate, | 29 public views::ButtonListener, |
| 31 public views::ExternalFocusTracker, | 30 public views::ExternalFocusTracker, |
| 32 public views::ViewTargeterDelegate { | 31 public views::ViewTargeterDelegate { |
| 33 public: | 32 public: |
| 34 explicit InfoBarView(std::unique_ptr<infobars::InfoBarDelegate> delegate); | 33 explicit InfoBarView(std::unique_ptr<infobars::InfoBarDelegate> delegate); |
| 35 | 34 |
| 36 const infobars::InfoBarContainer::Delegate* container_delegate() const; | 35 const infobars::InfoBarContainer::Delegate* container_delegate() const; |
| 37 | 36 |
| 38 protected: | 37 protected: |
| 39 typedef std::vector<views::Label*> Labels; | 38 typedef std::vector<views::Label*> Labels; |
| 40 | 39 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 52 // each label's size so that the longest label shrinks until it reaches the | 51 // each label's size so that the longest label shrinks until it reaches the |
| 53 // length of the next-longest label, then both shrink until reaching the | 52 // length of the next-longest label, then both shrink until reaching the |
| 54 // length of the next-longest, and so forth. | 53 // length of the next-longest, and so forth. |
| 55 static void AssignWidths(Labels* labels, int available_width); | 54 static void AssignWidths(Labels* labels, int available_width); |
| 56 | 55 |
| 57 // views::View: | 56 // views::View: |
| 58 void Layout() override; | 57 void Layout() override; |
| 59 void ViewHierarchyChanged( | 58 void ViewHierarchyChanged( |
| 60 const ViewHierarchyChangedDetails& details) override; | 59 const ViewHierarchyChangedDetails& details) override; |
| 61 | 60 |
| 62 // views::VectorIconButtonDelegate: | 61 // views::ButtonListener: |
| 63 // NOTE: This must not be called if we're unowned. (Subclasses should ignore | 62 // NOTE: This must not be called if we're unowned. (Subclasses should ignore |
| 64 // calls to ButtonPressed() in this case.) | 63 // calls to ButtonPressed() in this case.) |
| 65 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 64 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| 66 SkColor GetVectorIconBaseColor() const override; | |
| 67 | 65 |
| 68 // Returns the minimum width the content (that is, everything between the icon | 66 // Returns the minimum width the content (that is, everything between the icon |
| 69 // and the close button) can be shrunk to. This is used to prevent the close | 67 // and the close button) can be shrunk to. This is used to prevent the close |
| 70 // button from overlapping views that cannot be shrunk any further. | 68 // button from overlapping views that cannot be shrunk any further. |
| 71 virtual int ContentMinimumWidth() const; | 69 virtual int ContentMinimumWidth() const; |
| 72 | 70 |
| 73 // These return x coordinates delimiting the usable area for subclasses to lay | 71 // These return x coordinates delimiting the usable area for subclasses to lay |
| 74 // out their controls. | 72 // out their controls. |
| 75 int StartX() const; | 73 int StartX() const; |
| 76 int EndX() const; | 74 int EndX() const; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 107 const gfx::Rect& rect) const override; | 105 const gfx::Rect& rect) const override; |
| 108 | 106 |
| 109 // This container holds the children and clips their painting during | 107 // This container holds the children and clips their painting during |
| 110 // animation. | 108 // animation. |
| 111 views::View* child_container_; | 109 views::View* child_container_; |
| 112 | 110 |
| 113 // The optional icon at the left edge of the InfoBar. | 111 // The optional icon at the left edge of the InfoBar. |
| 114 views::ImageView* icon_; | 112 views::ImageView* icon_; |
| 115 | 113 |
| 116 // The close button at the right edge of the InfoBar. | 114 // The close button at the right edge of the InfoBar. |
| 117 views::VectorIconButton* close_button_; | 115 views::ImageButton* close_button_; |
| 118 | 116 |
| 119 // Used to run the menu. | 117 // Used to run the menu. |
| 120 std::unique_ptr<views::MenuRunner> menu_runner_; | 118 std::unique_ptr<views::MenuRunner> menu_runner_; |
| 121 | 119 |
| 122 DISALLOW_COPY_AND_ASSIGN(InfoBarView); | 120 DISALLOW_COPY_AND_ASSIGN(InfoBarView); |
| 123 }; | 121 }; |
| 124 | 122 |
| 125 #endif // CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_VIEW_H_ | 123 #endif // CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_VIEW_H_ |
| OLD | NEW |