| Index: chrome/browser/ui/views/infobars/infobar_view.cc
|
| diff --git a/chrome/browser/ui/views/infobars/infobar_view.cc b/chrome/browser/ui/views/infobars/infobar_view.cc
|
| index fc620e9997c2fe8f49ea55967ffc09ece30e3f84..9d89ed3123b96b518bb3cd0b80d8b6f9ac537144 100644
|
| --- a/chrome/browser/ui/views/infobars/infobar_view.cc
|
| +++ b/chrome/browser/ui/views/infobars/infobar_view.cc
|
| @@ -8,6 +8,7 @@
|
|
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| +#include "chrome/browser/infobars/infobar_service.h"
|
| #include "chrome/browser/ui/views/infobars/infobar_background.h"
|
| #include "chrome/grit/generated_resources.h"
|
| #include "components/infobars/core/infobar_delegate.h"
|
| @@ -48,18 +49,6 @@ bool SortLabelsByDecreasingWidth(views::Label* label_1, views::Label* label_2) {
|
| } // namespace
|
|
|
|
|
| -// InfoBar --------------------------------------------------------------------
|
| -
|
| -// static
|
| -const int infobars::InfoBar::kSeparatorLineHeight =
|
| - views::NonClientFrameView::kClientEdgeThickness;
|
| -const int infobars::InfoBar::kDefaultArrowTargetHeight = 9;
|
| -const int infobars::InfoBar::kMaximumArrowTargetHeight = 24;
|
| -const int infobars::InfoBar::kDefaultArrowTargetHalfWidth =
|
| - kDefaultArrowTargetHeight;
|
| -const int infobars::InfoBar::kMaximumArrowTargetHalfWidth = 14;
|
| -const int infobars::InfoBar::kDefaultBarTargetHeight = 36;
|
| -
|
| // InfoBarView ----------------------------------------------------------------
|
|
|
| // static
|
| @@ -68,9 +57,9 @@ const int InfoBarView::kEndOfLabelSpacing = views::kItemLabelSpacing;
|
|
|
| InfoBarView::InfoBarView(scoped_ptr<infobars::InfoBarDelegate> delegate)
|
| : infobars::InfoBar(delegate.Pass()),
|
| - views::ExternalFocusTracker(this, NULL),
|
| - icon_(NULL),
|
| - close_button_(NULL) {
|
| + views::ExternalFocusTracker(this, nullptr),
|
| + icon_(nullptr),
|
| + close_button_(nullptr) {
|
| set_owned_by_client(); // InfoBar deletes itself at the appropriate time.
|
| set_background(
|
| new InfoBarBackground(infobars::InfoBar::delegate()->GetInfoBarType()));
|
| @@ -149,15 +138,17 @@ void InfoBarView::Layout() {
|
| // width is changed, which affects both paths.
|
| stroke_path_.rewind();
|
| fill_path_.rewind();
|
| + DCHECK(owner());
|
| + const infobars::InfoBarConstants& constants = owner()->GetInfoBarConstants();
|
| const infobars::InfoBarContainer::Delegate* delegate = container_delegate();
|
| if (delegate) {
|
| static_cast<InfoBarBackground*>(background())->set_separator_color(
|
| delegate->GetInfoBarSeparatorColor());
|
| int arrow_x;
|
| - SkScalar arrow_fill_height =
|
| - SkIntToScalar(std::max(arrow_height() - kSeparatorLineHeight, 0));
|
| + SkScalar arrow_fill_height = SkIntToScalar(
|
| + std::max(arrow_height() - constants.separator_line_height, 0));
|
| SkScalar arrow_fill_half_width = SkIntToScalar(arrow_half_width());
|
| - SkScalar separator_height = SkIntToScalar(kSeparatorLineHeight);
|
| + SkScalar separator_height = SkIntToScalar(constants.separator_line_height);
|
| if (delegate->DrawInfoBarArrows(&arrow_x) && arrow_fill_height) {
|
| // Skia pixel centers are at the half-values, so the arrow is horizontally
|
| // centered at |arrow_x| + 0.5. Vertically, the stroke path is the center
|
| @@ -184,12 +175,13 @@ void InfoBarView::Layout() {
|
| }
|
| }
|
| if (bar_height()) {
|
| - fill_path_.addRect(0.0, SkIntToScalar(arrow_height()),
|
| - SkIntToScalar(width()), SkIntToScalar(height() - kSeparatorLineHeight));
|
| + fill_path_.addRect(
|
| + 0.0, SkIntToScalar(arrow_height()), SkIntToScalar(width()),
|
| + SkIntToScalar(height() - constants.separator_line_height));
|
| }
|
|
|
| int start_x = kEdgeItemPadding;
|
| - if (icon_ != NULL) {
|
| + if (icon_) {
|
| icon_->SetPosition(gfx::Point(start_x, OffsetY(icon_)));
|
| start_x = icon_->bounds().right() + kIconToLabelSpacing;
|
| }
|
| @@ -207,7 +199,7 @@ void InfoBarView::ViewHierarchyChanged(
|
| const ViewHierarchyChangedDetails& details) {
|
| View::ViewHierarchyChanged(details);
|
|
|
| - if (details.is_add && (details.child == this) && (close_button_ == NULL)) {
|
| + if (details.is_add && (details.child == this) && !close_button_) {
|
| gfx::Image image = delegate()->GetIcon();
|
| if (!image.IsEmpty()) {
|
| icon_ = new views::ImageView;
|
| @@ -229,17 +221,20 @@ void InfoBarView::ViewHierarchyChanged(
|
| l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE));
|
| close_button_->SetFocusable(true);
|
| AddChildView(close_button_);
|
| - } else if ((close_button_ != NULL) && (details.parent == this) &&
|
| - (details.child != close_button_) && (close_button_->parent() == this) &&
|
| - (child_at(child_count() - 1) != close_button_)) {
|
| + } else if (close_button_ && (details.parent == this) &&
|
| + (details.child != close_button_) &&
|
| + (close_button_->parent() == this) &&
|
| + (child_at(child_count() - 1) != close_button_)) {
|
| // For accessibility, ensure the close button is the last child view.
|
| RemoveChildView(close_button_);
|
| AddChildView(close_button_);
|
| }
|
|
|
| + DCHECK(owner());
|
| + const infobars::InfoBarConstants& constants = owner()->GetInfoBarConstants();
|
| // Ensure the infobar is tall enough to display its contents.
|
| const int kMinimumVerticalPadding = 6;
|
| - int height = kDefaultBarTargetHeight;
|
| + int height = constants.default_bar_target_height;
|
| for (int i = 0; i < child_count(); ++i) {
|
| const int child_height = child_at(i)->height();
|
| height = std::max(height, child_height + kMinimumVerticalPadding);
|
| @@ -281,8 +276,9 @@ int InfoBarView::StartX() const {
|
| // Ensure we don't return a value greater than EndX(), so children can safely
|
| // set something's width to "EndX() - StartX()" without risking that being
|
| // negative.
|
| - return std::min(EndX(), (icon_ != NULL) ?
|
| - (icon_->bounds().right() + kIconToLabelSpacing) : kEdgeItemPadding);
|
| + return std::min(EndX(), icon_
|
| + ? (icon_->bounds().right() + kIconToLabelSpacing)
|
| + : kEdgeItemPadding);
|
| }
|
|
|
| int InfoBarView::EndX() const {
|
| @@ -298,7 +294,7 @@ int InfoBarView::OffsetY(views::View* view) const {
|
| const infobars::InfoBarContainer::Delegate* InfoBarView::container_delegate()
|
| const {
|
| const infobars::InfoBarContainer* infobar_container = container();
|
| - return infobar_container ? infobar_container->delegate() : NULL;
|
| + return infobar_container ? infobar_container->delegate() : nullptr;
|
| }
|
|
|
| void InfoBarView::RunMenuAt(ui::MenuModel* menu_model,
|
| @@ -348,7 +344,7 @@ void InfoBarView::PlatformSpecificHide(bool animate) {
|
|
|
| // It's possible to be called twice (once with |animate| true and once with it
|
| // false); in this case the second SetFocusManager() call will silently no-op.
|
| - SetFocusManager(NULL);
|
| + SetFocusManager(nullptr);
|
|
|
| if (!animate)
|
| return;
|
|
|