| 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 22 matching lines...) Expand all Loading... |
| 33 // | 33 // |
| 34 // Thus, InfoBarDelegate and InfoBar implementations can assume they share | 34 // Thus, InfoBarDelegate and InfoBar implementations can assume they share |
| 35 // lifetimes, and not NULL-check each other; but if one needs to reach back into | 35 // lifetimes, and not NULL-check each other; but if one needs to reach back into |
| 36 // the owning InfoBarManager, it must check whether that's still possible. | 36 // the owning InfoBarManager, it must check whether that's still possible. |
| 37 class InfoBar : public gfx::AnimationDelegate { | 37 class InfoBar : public gfx::AnimationDelegate { |
| 38 public: | 38 public: |
| 39 // These are the types passed as Details for infobar-related notifications. | 39 // These are the types passed as Details for infobar-related notifications. |
| 40 typedef InfoBar AddedDetails; | 40 typedef InfoBar AddedDetails; |
| 41 typedef std::pair<InfoBar*, bool> RemovedDetails; | 41 typedef std::pair<InfoBar*, bool> RemovedDetails; |
| 42 | 42 |
| 43 // Platforms must define these. | |
| 44 static const int kDefaultBarTargetHeight; | |
| 45 static const int kSeparatorLineHeight; | |
| 46 static const int kDefaultArrowTargetHeight; | |
| 47 static const int kMaximumArrowTargetHeight; | |
| 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. | |
| 50 static const int kDefaultArrowTargetHalfWidth; | |
| 51 static const int kMaximumArrowTargetHalfWidth; | |
| 52 | |
| 53 explicit InfoBar(scoped_ptr<InfoBarDelegate> delegate); | 43 explicit InfoBar(scoped_ptr<InfoBarDelegate> delegate); |
| 54 ~InfoBar() override; | 44 ~InfoBar() override; |
| 55 | 45 |
| 56 static SkColor GetTopColor(InfoBarDelegate::Type infobar_type); | 46 static SkColor GetTopColor(InfoBarDelegate::Type infobar_type); |
| 57 static SkColor GetBottomColor(InfoBarDelegate::Type infobar_type); | 47 static SkColor GetBottomColor(InfoBarDelegate::Type infobar_type); |
| 58 | 48 |
| 59 InfoBarManager* owner() { return owner_; } | 49 InfoBarManager* owner() { return owner_; } |
| 60 InfoBarDelegate* delegate() const { return delegate_.get(); } | 50 InfoBarDelegate* delegate() const { return delegate_.get(); } |
| 61 void set_container(InfoBarContainer* container) { container_ = container; } | 51 void set_container(InfoBarContainer* container) { container_ = container; } |
| 62 | 52 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 // itself. | 119 // itself. |
| 130 void MaybeDelete(); | 120 void MaybeDelete(); |
| 131 | 121 |
| 132 InfoBarManager* owner_; | 122 InfoBarManager* owner_; |
| 133 scoped_ptr<InfoBarDelegate> delegate_; | 123 scoped_ptr<InfoBarDelegate> delegate_; |
| 134 InfoBarContainer* container_; | 124 InfoBarContainer* container_; |
| 135 gfx::SlideAnimation animation_; | 125 gfx::SlideAnimation animation_; |
| 136 | 126 |
| 137 // The current and target heights of the arrow and bar portions, and half the | 127 // The current and target heights of the arrow and bar portions, and half the |
| 138 // current arrow width. (It's easier to work in half-widths as we draw the | 128 // current arrow width. (It's easier to work in half-widths as we draw the |
| 139 // arrow as two halves on either side of a center point.) | 129 // arrow as two halves on either side of a center point.) All these values |
| 130 // scale in unison to the container delegate's default and maximum values. |
| 140 int arrow_height_; // Includes both fill and top stroke. | 131 int arrow_height_; // Includes both fill and top stroke. |
| 141 int arrow_target_height_; | 132 int arrow_target_height_; // Should always be set by the time we read it. |
| 142 int arrow_half_width_; // Includes only fill. | 133 int arrow_half_width_; // Includes only fill. |
| 143 int bar_height_; // Includes both fill and bottom separator. | 134 int bar_height_; // Includes both fill and bottom separator. |
| 144 int bar_target_height_; | 135 int bar_target_height_; // May be left as -1, meaning "use default". |
| 145 | 136 |
| 146 DISALLOW_COPY_AND_ASSIGN(InfoBar); | 137 DISALLOW_COPY_AND_ASSIGN(InfoBar); |
| 147 }; | 138 }; |
| 148 | 139 |
| 149 } // namespace infobars | 140 } // namespace infobars |
| 150 | 141 |
| 151 #endif // COMPONENTS_INFOBARS_CORE_INFOBAR_H_ | 142 #endif // COMPONENTS_INFOBARS_CORE_INFOBAR_H_ |
| OLD | NEW |