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 <memory> |
8 #include <utility> | 9 #include <utility> |
9 | 10 |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "components/infobars/core/infobar_delegate.h" | 12 #include "components/infobars/core/infobar_delegate.h" |
13 #include "third_party/skia/include/core/SkColor.h" | 13 #include "third_party/skia/include/core/SkColor.h" |
14 #include "ui/gfx/animation/animation_delegate.h" | 14 #include "ui/gfx/animation/animation_delegate.h" |
15 #include "ui/gfx/animation/slide_animation.h" | 15 #include "ui/gfx/animation/slide_animation.h" |
16 #include "ui/gfx/geometry/size.h" | 16 #include "ui/gfx/geometry/size.h" |
17 | 17 |
18 namespace infobars { | 18 namespace infobars { |
19 | 19 |
20 class InfoBarContainer; | 20 class InfoBarContainer; |
21 class InfoBarManager; | 21 class InfoBarManager; |
(...skipping 12 matching lines...) Expand all Loading... |
34 // | 34 // |
35 // Thus, InfoBarDelegate and InfoBar implementations can assume they share | 35 // Thus, InfoBarDelegate and InfoBar implementations can assume they share |
36 // lifetimes, and not NULL-check each other; but if one needs to reach back into | 36 // lifetimes, and not NULL-check each other; but if one needs to reach back into |
37 // the owning InfoBarManager, it must check whether that's still possible. | 37 // the owning InfoBarManager, it must check whether that's still possible. |
38 class InfoBar : public gfx::AnimationDelegate { | 38 class InfoBar : public gfx::AnimationDelegate { |
39 public: | 39 public: |
40 // These are the types passed as Details for infobar-related notifications. | 40 // These are the types passed as Details for infobar-related notifications. |
41 typedef InfoBar AddedDetails; | 41 typedef InfoBar AddedDetails; |
42 typedef std::pair<InfoBar*, bool> RemovedDetails; | 42 typedef std::pair<InfoBar*, bool> RemovedDetails; |
43 | 43 |
44 explicit InfoBar(scoped_ptr<InfoBarDelegate> delegate); | 44 explicit InfoBar(std::unique_ptr<InfoBarDelegate> delegate); |
45 ~InfoBar() override; | 45 ~InfoBar() override; |
46 | 46 |
47 static SkColor GetTopColor(InfoBarDelegate::Type infobar_type); | 47 static SkColor GetTopColor(InfoBarDelegate::Type infobar_type); |
48 static SkColor GetBottomColor(InfoBarDelegate::Type infobar_type); | 48 static SkColor GetBottomColor(InfoBarDelegate::Type infobar_type); |
49 | 49 |
50 InfoBarManager* owner() { return owner_; } | 50 InfoBarManager* owner() { return owner_; } |
51 InfoBarDelegate* delegate() const { return delegate_.get(); } | 51 InfoBarDelegate* delegate() const { return delegate_.get(); } |
52 void set_container(InfoBarContainer* container) { container_ = container; } | 52 void set_container(InfoBarContainer* container) { container_ = container; } |
53 | 53 |
54 // Sets |owner_|. This also sets the nav entry ID on |delegate_|. This must | 54 // Sets |owner_|. This also sets the nav entry ID on |delegate_|. This must |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 // container our state has changed if either the heights have changed or | 114 // container our state has changed if either the heights have changed or |
115 // |force_notify| is set. | 115 // |force_notify| is set. |
116 void RecalculateHeights(bool force_notify); | 116 void RecalculateHeights(bool force_notify); |
117 | 117 |
118 // Checks whether the infobar is unowned and done with all animations. If so, | 118 // Checks whether the infobar is unowned and done with all animations. If so, |
119 // notifies the container that it should remove this infobar, and deletes | 119 // notifies the container that it should remove this infobar, and deletes |
120 // itself. | 120 // itself. |
121 void MaybeDelete(); | 121 void MaybeDelete(); |
122 | 122 |
123 InfoBarManager* owner_; | 123 InfoBarManager* owner_; |
124 scoped_ptr<InfoBarDelegate> delegate_; | 124 std::unique_ptr<InfoBarDelegate> delegate_; |
125 InfoBarContainer* container_; | 125 InfoBarContainer* container_; |
126 gfx::SlideAnimation animation_; | 126 gfx::SlideAnimation animation_; |
127 | 127 |
128 // The current and target heights of the arrow and bar portions, and half the | 128 // The current and target heights of the arrow and bar portions, and half the |
129 // current arrow width. (It's easier to work in half-widths as we draw the | 129 // current arrow width. (It's easier to work in half-widths as we draw the |
130 // arrow as two halves on either side of a center point.) All these values | 130 // arrow as two halves on either side of a center point.) All these values |
131 // scale in unison to the container delegate's default and maximum values. | 131 // scale in unison to the container delegate's default and maximum values. |
132 int arrow_height_; // Includes both fill and top stroke. | 132 int arrow_height_; // Includes both fill and top stroke. |
133 int arrow_target_height_; // Should always be set by the time we read it. | 133 int arrow_target_height_; // Should always be set by the time we read it. |
134 int arrow_half_width_; // Includes only fill. | 134 int arrow_half_width_; // Includes only fill. |
135 int bar_height_; // Includes both fill and bottom separator. | 135 int bar_height_; // Includes both fill and bottom separator. |
136 int bar_target_height_; // May be left as -1, meaning "use default". | 136 int bar_target_height_; // May be left as -1, meaning "use default". |
137 | 137 |
138 DISALLOW_COPY_AND_ASSIGN(InfoBar); | 138 DISALLOW_COPY_AND_ASSIGN(InfoBar); |
139 }; | 139 }; |
140 | 140 |
141 } // namespace infobars | 141 } // namespace infobars |
142 | 142 |
143 #endif // COMPONENTS_INFOBARS_CORE_INFOBAR_H_ | 143 #endif // COMPONENTS_INFOBARS_CORE_INFOBAR_H_ |
OLD | NEW |