OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_INFOBARS_CORE_INFOBAR_H_ | 5 #ifndef COMPONENTS_INFOBARS_CORE_INFOBAR_H_ |
6 #define COMPONENTS_INFOBARS_CORE_INFOBAR_H_ | 6 #define COMPONENTS_INFOBARS_CORE_INFOBAR_H_ |
7 | 7 |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 static const int kDefaultBarTargetHeight; | 44 static const int kDefaultBarTargetHeight; |
45 static const int kSeparatorLineHeight; | 45 static const int kSeparatorLineHeight; |
46 static const int kDefaultArrowTargetHeight; | 46 static const int kDefaultArrowTargetHeight; |
47 static const int kMaximumArrowTargetHeight; | 47 static const int kMaximumArrowTargetHeight; |
48 // The half-width (see comments on |arrow_half_width_| below) scales to its | 48 // The half-width (see comments on |arrow_half_width_| below) scales to its |
49 // default and maximum values proportionally to how the height scales to its. | 49 // default and maximum values proportionally to how the height scales to its. |
50 static const int kDefaultArrowTargetHalfWidth; | 50 static const int kDefaultArrowTargetHalfWidth; |
51 static const int kMaximumArrowTargetHalfWidth; | 51 static const int kMaximumArrowTargetHalfWidth; |
52 | 52 |
53 explicit InfoBar(scoped_ptr<InfoBarDelegate> delegate); | 53 explicit InfoBar(scoped_ptr<InfoBarDelegate> delegate); |
54 virtual ~InfoBar(); | 54 ~InfoBar() override; |
55 | 55 |
56 static SkColor GetTopColor(InfoBarDelegate::Type infobar_type); | 56 static SkColor GetTopColor(InfoBarDelegate::Type infobar_type); |
57 static SkColor GetBottomColor(InfoBarDelegate::Type infobar_type); | 57 static SkColor GetBottomColor(InfoBarDelegate::Type infobar_type); |
58 | 58 |
59 InfoBarManager* owner() { return owner_; } | 59 InfoBarManager* owner() { return owner_; } |
60 InfoBarDelegate* delegate() const { return delegate_.get(); } | 60 InfoBarDelegate* delegate() const { return delegate_.get(); } |
61 void set_container(InfoBarContainer* container) { container_ = container; } | 61 void set_container(InfoBarContainer* container) { container_ = container; } |
62 | 62 |
63 // Sets |owner_|. This also calls StoreActiveEntryUniqueID() on |delegate_|. | 63 // Sets |owner_|. This also calls StoreActiveEntryUniqueID() on |delegate_|. |
64 // This must only be called once as there's no way to extract an infobar from | 64 // This must only be called once as there's no way to extract an infobar from |
(...skipping 26 matching lines...) Expand all Loading... |
91 void SetBarTargetHeight(int height); | 91 void SetBarTargetHeight(int height); |
92 | 92 |
93 const gfx::SlideAnimation& animation() const { return animation_; } | 93 const gfx::SlideAnimation& animation() const { return animation_; } |
94 int arrow_height() const { return arrow_height_; } | 94 int arrow_height() const { return arrow_height_; } |
95 int arrow_target_height() const { return arrow_target_height_; } | 95 int arrow_target_height() const { return arrow_target_height_; } |
96 int arrow_half_width() const { return arrow_half_width_; } | 96 int arrow_half_width() const { return arrow_half_width_; } |
97 int total_height() const { return arrow_height_ + bar_height_; } | 97 int total_height() const { return arrow_height_ + bar_height_; } |
98 | 98 |
99 protected: | 99 protected: |
100 // gfx::AnimationDelegate: | 100 // gfx::AnimationDelegate: |
101 virtual void AnimationProgressed(const gfx::Animation* animation) override; | 101 void AnimationProgressed(const gfx::Animation* animation) override; |
102 | 102 |
103 const InfoBarContainer* container() const { return container_; } | 103 const InfoBarContainer* container() const { return container_; } |
104 InfoBarContainer* container() { return container_; } | 104 InfoBarContainer* container() { return container_; } |
105 gfx::SlideAnimation* animation() { return &animation_; } | 105 gfx::SlideAnimation* animation() { return &animation_; } |
106 int bar_height() const { return bar_height_; } | 106 int bar_height() const { return bar_height_; } |
107 int bar_target_height() const { return bar_target_height_; } | 107 int bar_target_height() const { return bar_target_height_; } |
108 | 108 |
109 // Platforms may optionally override these if they need to do work during | 109 // Platforms may optionally override these if they need to do work during |
110 // processing of the given calls. | 110 // processing of the given calls. |
111 virtual void PlatformSpecificSetOwner() {} | 111 virtual void PlatformSpecificSetOwner() {} |
112 virtual void PlatformSpecificShow(bool animate) {} | 112 virtual void PlatformSpecificShow(bool animate) {} |
113 virtual void PlatformSpecificHide(bool animate) {} | 113 virtual void PlatformSpecificHide(bool animate) {} |
114 virtual void PlatformSpecificOnCloseSoon() {} | 114 virtual void PlatformSpecificOnCloseSoon() {} |
115 virtual void PlatformSpecificOnHeightsRecalculated() {} | 115 virtual void PlatformSpecificOnHeightsRecalculated() {} |
116 | 116 |
117 private: | 117 private: |
118 // gfx::AnimationDelegate: | 118 // gfx::AnimationDelegate: |
119 virtual void AnimationEnded(const gfx::Animation* animation) override; | 119 void AnimationEnded(const gfx::Animation* animation) override; |
120 | 120 |
121 // Finds the new desired arrow and bar heights, and if they differ from the | 121 // Finds the new desired arrow and bar heights, and if they differ from the |
122 // current ones, calls PlatformSpecificOnHeightRecalculated(). Informs our | 122 // current ones, calls PlatformSpecificOnHeightRecalculated(). Informs our |
123 // container our state has changed if either the heights have changed or | 123 // container our state has changed if either the heights have changed or |
124 // |force_notify| is set. | 124 // |force_notify| is set. |
125 void RecalculateHeights(bool force_notify); | 125 void RecalculateHeights(bool force_notify); |
126 | 126 |
127 // Checks whether the infobar is unowned and done with all animations. If so, | 127 // Checks whether the infobar is unowned and done with all animations. If so, |
128 // notifies the container that it should remove this infobar, and deletes | 128 // notifies the container that it should remove this infobar, and deletes |
129 // itself. | 129 // itself. |
(...skipping 12 matching lines...) Expand all Loading... |
142 int arrow_half_width_; // Includes only fill. | 142 int arrow_half_width_; // Includes only fill. |
143 int bar_height_; // Includes both fill and bottom separator. | 143 int bar_height_; // Includes both fill and bottom separator. |
144 int bar_target_height_; | 144 int bar_target_height_; |
145 | 145 |
146 DISALLOW_COPY_AND_ASSIGN(InfoBar); | 146 DISALLOW_COPY_AND_ASSIGN(InfoBar); |
147 }; | 147 }; |
148 | 148 |
149 } // namespace infobars | 149 } // namespace infobars |
150 | 150 |
151 #endif // COMPONENTS_INFOBARS_CORE_INFOBAR_H_ | 151 #endif // COMPONENTS_INFOBARS_CORE_INFOBAR_H_ |
OLD | NEW |