summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/views/infobars
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-09 00:55:51 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-09 00:55:51 +0000
commitd8ede05564c868d640f56c5b94a21acb080079df (patch)
treefaa4fdbdf305210330510e2c402879ea369fab0e /chrome/browser/ui/views/infobars
parent32183ebb716f4085762d05058bf7ae38ffde1e6a (diff)
downloadchromium_src-d8ede05564c868d640f56c5b94a21acb080079df.zip
chromium_src-d8ede05564c868d640f56c5b94a21acb080079df.tar.gz
chromium_src-d8ede05564c868d640f56c5b94a21acb080079df.tar.bz2
Misc. cleanup bits I missed in my last pass.
I apparently forgot to convert an automation message declaration from int to size_t, not sure how everything compiled cleanly everywhere... BUG=none TEST=none Review URL: http://codereview.chromium.org/6465003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74217 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/views/infobars')
-rw-r--r--chrome/browser/ui/views/infobars/after_translate_infobar.cc13
-rw-r--r--chrome/browser/ui/views/infobars/after_translate_infobar.h7
-rw-r--r--chrome/browser/ui/views/infobars/before_translate_infobar.cc3
-rw-r--r--chrome/browser/ui/views/infobars/before_translate_infobar.h2
-rw-r--r--chrome/browser/ui/views/infobars/confirm_infobar.cc9
-rw-r--r--chrome/browser/ui/views/infobars/confirm_infobar.h4
-rw-r--r--chrome/browser/ui/views/infobars/infobar_container.cc12
-rw-r--r--chrome/browser/ui/views/infobars/infobar_container.h6
-rw-r--r--chrome/browser/ui/views/infobars/infobar_view.cc62
-rw-r--r--chrome/browser/ui/views/infobars/infobar_view.h13
-rw-r--r--chrome/browser/ui/views/infobars/link_infobar.cc5
-rw-r--r--chrome/browser/ui/views/infobars/translate_infobar_base.cc3
-rw-r--r--chrome/browser/ui/views/infobars/translate_infobar_base.h2
13 files changed, 60 insertions, 81 deletions
diff --git a/chrome/browser/ui/views/infobars/after_translate_infobar.cc b/chrome/browser/ui/views/infobars/after_translate_infobar.cc
index 5a91252..2971f67 100644
--- a/chrome/browser/ui/views/infobars/after_translate_infobar.cc
+++ b/chrome/browser/ui/views/infobars/after_translate_infobar.cc
@@ -117,8 +117,7 @@ void AfterTranslateInfoBar::ButtonPressed(views::Button* sender,
TranslateInfoBarBase::ButtonPressed(sender, event);
}
-void AfterTranslateInfoBar::RunMenu(views::View* source,
- const gfx::Point& pt) {
+void AfterTranslateInfoBar::RunMenu(View* source, const gfx::Point& pt) {
if (source == original_language_menu_button_) {
if (!original_language_menu_.get()) {
original_language_menu_.reset(
@@ -126,11 +125,11 @@ void AfterTranslateInfoBar::RunMenu(views::View* source,
}
original_language_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPRIGHT);
} else if (source == target_language_menu_button_) {
- if (!target_language_menu_.get()) {
- target_language_menu_.reset(
- new views::Menu2(&target_language_menu_model_));
- }
- target_language_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPRIGHT);
+ if (!target_language_menu_.get()) {
+ target_language_menu_.reset(
+ new views::Menu2(&target_language_menu_model_));
+ }
+ target_language_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPRIGHT);
} else {
DCHECK_EQ(options_menu_button_, source);
if (!options_menu_.get())
diff --git a/chrome/browser/ui/views/infobars/after_translate_infobar.h b/chrome/browser/ui/views/infobars/after_translate_infobar.h
index 977e629..063b304 100644
--- a/chrome/browser/ui/views/infobars/after_translate_infobar.h
+++ b/chrome/browser/ui/views/infobars/after_translate_infobar.h
@@ -32,7 +32,7 @@ class AfterTranslateInfoBar : public TranslateInfoBarBase,
virtual void OriginalLanguageChanged();
virtual void TargetLanguageChanged();
- // views::ViewMenuDelegate:
+ // ViewMenuDelegate:
virtual void RunMenu(View* source, const gfx::Point& pt);
// Sets the text of the original or target language menu buttons to reflect
@@ -41,9 +41,8 @@ class AfterTranslateInfoBar : public TranslateInfoBarBase,
// The text displayed in the infobar is something like:
// "Translated from <lang1> to <lang2> [more text in some languages]"
- // ...where <lang1> and <lang2> are comboboxes.
- // So the text is split in 3 chunks, each one displayed in one of the labels
- // below.
+ // ...where <lang1> and <lang2> are comboboxes. So the text is split in 3
+ // chunks, each one displayed in one of the labels below.
views::Label* label_1_;
views::Label* label_2_;
views::Label* label_3_;
diff --git a/chrome/browser/ui/views/infobars/before_translate_infobar.cc b/chrome/browser/ui/views/infobars/before_translate_infobar.cc
index 0159cb4..ef55eef 100644
--- a/chrome/browser/ui/views/infobars/before_translate_infobar.cc
+++ b/chrome/browser/ui/views/infobars/before_translate_infobar.cc
@@ -137,8 +137,7 @@ void BeforeTranslateInfoBar::OriginalLanguageChanged() {
UpdateOriginalButtonText();
}
-void BeforeTranslateInfoBar::RunMenu(views::View* source,
- const gfx::Point& pt) {
+void BeforeTranslateInfoBar::RunMenu(View* source, const gfx::Point& pt) {
if (source == language_menu_button_) {
if (!languages_menu_.get())
languages_menu_.reset(new views::Menu2(&languages_menu_model_));
diff --git a/chrome/browser/ui/views/infobars/before_translate_infobar.h b/chrome/browser/ui/views/infobars/before_translate_infobar.h
index c0beea7..f7443ec 100644
--- a/chrome/browser/ui/views/infobars/before_translate_infobar.h
+++ b/chrome/browser/ui/views/infobars/before_translate_infobar.h
@@ -31,7 +31,7 @@ class BeforeTranslateInfoBar : public TranslateInfoBarBase,
virtual void ButtonPressed(views::Button* sender, const views::Event& event);
virtual void OriginalLanguageChanged();
- // Overridden from views::ViewMenuDelegate:
+ // views::ViewMenuDelegate:
virtual void RunMenu(View* source, const gfx::Point& pt);
// Sets the text of the original language menu button to reflect the current
diff --git a/chrome/browser/ui/views/infobars/confirm_infobar.cc b/chrome/browser/ui/views/infobars/confirm_infobar.cc
index bfc306b..d9737d5 100644
--- a/chrome/browser/ui/views/infobars/confirm_infobar.cc
+++ b/chrome/browser/ui/views/infobars/confirm_infobar.cc
@@ -132,8 +132,8 @@ void ConfirmInfoBar::Layout() {
}
void ConfirmInfoBar::ViewHierarchyChanged(bool is_add,
- views::View* parent,
- views::View* child) {
+ View* parent,
+ View* child) {
if (is_add && child == this && !initialized_) {
AddChildView(ok_button_);
AddChildView(cancel_button_);
@@ -166,12 +166,9 @@ void ConfirmInfoBar::ButtonPressed(views::Button* sender,
void ConfirmInfoBar::LinkActivated(views::Link* source, int event_flags) {
DCHECK_EQ(link_, source);
- DCHECK(link_->IsVisible());
- DCHECK(!link_->GetText().empty());
if (GetDelegate()->LinkClicked(
- event_utils::DispositionFromEventFlags(event_flags))) {
+ event_utils::DispositionFromEventFlags(event_flags)))
RemoveInfoBar();
- }
}
ConfirmInfoBarDelegate* ConfirmInfoBar::GetDelegate() {
diff --git a/chrome/browser/ui/views/infobars/confirm_infobar.h b/chrome/browser/ui/views/infobars/confirm_infobar.h
index 0905bcc..15aac4b 100644
--- a/chrome/browser/ui/views/infobars/confirm_infobar.h
+++ b/chrome/browser/ui/views/infobars/confirm_infobar.h
@@ -50,9 +50,7 @@ class ConfirmInfoBar : public AlertInfoBar,
// InfoBarView:
virtual void Layout();
- virtual void ViewHierarchyChanged(bool is_add,
- views::View* parent,
- views::View* child);
+ virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child);
virtual int GetAvailableWidth() const;
virtual void ButtonPressed(views::Button* sender, const views::Event& event);
diff --git a/chrome/browser/ui/views/infobars/infobar_container.cc b/chrome/browser/ui/views/infobars/infobar_container.cc
index b0c7f37..4a2ed5c 100644
--- a/chrome/browser/ui/views/infobars/infobar_container.cc
+++ b/chrome/browser/ui/views/infobars/infobar_container.cc
@@ -58,7 +58,7 @@ void InfoBarContainer::RemoveDelegate(InfoBarDelegate* delegate) {
}
void InfoBarContainer::PaintInfoBarArrows(gfx::Canvas* canvas,
- views::View* outer_view,
+ View* outer_view,
int arrow_center_x) {
for (int i = 0; i < GetChildViewCount(); ++i) {
InfoBarView* infobar = static_cast<InfoBarView*>(GetChildViewAt(i));
@@ -68,8 +68,8 @@ void InfoBarContainer::PaintInfoBarArrows(gfx::Canvas* canvas,
gfx::Size InfoBarContainer::GetPreferredSize() {
// We do not have a preferred width (we will expand to fit the available width
- // of the delegate). Our preferred height is the sum of the preferred
- // heights of the InfoBars contained within us.
+ // of the delegate). Our preferred height is the sum of the preferred heights
+ // of the InfoBars contained within us.
int height = 0;
for (int i = 0; i < GetChildViewCount(); ++i)
height += GetChildViewAt(i)->GetPreferredSize().height();
@@ -79,7 +79,7 @@ gfx::Size InfoBarContainer::GetPreferredSize() {
void InfoBarContainer::Layout() {
int top = 0;
for (int i = 0; i < GetChildViewCount(); ++i) {
- views::View* child = GetChildViewAt(i);
+ View* child = GetChildViewAt(i);
gfx::Size ps = child->GetPreferredSize();
child->SetBounds(0, top, width(), ps.height());
top += ps.height();
@@ -91,8 +91,8 @@ AccessibilityTypes::Role InfoBarContainer::GetAccessibleRole() {
}
void InfoBarContainer::ViewHierarchyChanged(bool is_add,
- views::View* parent,
- views::View* child) {
+ View* parent,
+ View* child) {
if (parent == this && child->GetParent() == this) {
if (delegate_) {
// An InfoBar child was added or removed. Tell the delegate it needs to
diff --git a/chrome/browser/ui/views/infobars/infobar_container.h b/chrome/browser/ui/views/infobars/infobar_container.h
index 6b82b5f..9d03acb 100644
--- a/chrome/browser/ui/views/infobars/infobar_container.h
+++ b/chrome/browser/ui/views/infobars/infobar_container.h
@@ -48,7 +48,7 @@ class InfoBarContainer : public AccessiblePaneView,
// the desired location of the center of the arrow in the
// |outer_view| coordinate system.
void PaintInfoBarArrows(gfx::Canvas* canvas,
- views::View* outer_view,
+ View* outer_view,
int arrow_center_x);
private:
@@ -56,9 +56,7 @@ class InfoBarContainer : public AccessiblePaneView,
virtual gfx::Size GetPreferredSize();
virtual void Layout();
virtual AccessibilityTypes::Role GetAccessibleRole();
- virtual void ViewHierarchyChanged(bool is_add,
- views::View* parent,
- views::View* child);
+ virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child);
// NotificationObserver:
virtual void Observe(NotificationType type,
diff --git a/chrome/browser/ui/views/infobars/infobar_view.cc b/chrome/browser/ui/views/infobars/infobar_view.cc
index 5871c96..ea80f87 100644
--- a/chrome/browser/ui/views/infobars/infobar_view.cc
+++ b/chrome/browser/ui/views/infobars/infobar_view.cc
@@ -32,8 +32,6 @@ const int InfoBarView::kHorizontalPadding = 6;
const int InfoBarView::kIconLabelSpacing = 6;
const int InfoBarView::kButtonButtonSpacing = 10;
const int InfoBarView::kEndOfLabelSpacing = 16;
-const int InfoBarView::kCloseButtonSpacing = 12;
-const int InfoBarView::kButtonInLabelSpacing = 5;
InfoBarView::InfoBarView(InfoBarDelegate* delegate)
: InfoBar(delegate),
@@ -42,8 +40,7 @@ InfoBarView::InfoBarView(InfoBarDelegate* delegate)
close_button_(new views::ImageButton(this))),
ALLOW_THIS_IN_INITIALIZER_LIST(delete_factory_(this)),
target_height_(kDefaultTargetHeight) {
- // InfoBar deletes itself at the appropriate time.
- set_parent_owned(false);
+ set_parent_owned(false); // InfoBar deletes itself at the appropriate time.
InfoBarDelegate::Type infobar_type = delegate->GetInfoBarType();
set_background(new InfoBarBackground(infobar_type));
@@ -85,9 +82,8 @@ void InfoBarView::AnimateClose() {
// Do not restore focus (and active state with it) on Windows if some other
// top-level window became active.
if (GetWidget() &&
- !ui::DoesWindowBelongToActiveWindow(GetWidget()->GetNativeView())) {
+ !ui::DoesWindowBelongToActiveWindow(GetWidget()->GetNativeView()))
restore_focus = false;
- }
#endif // defined(OS_WIN)
DestroyFocusTracker(restore_focus);
animation_->Hide();
@@ -105,11 +101,27 @@ void InfoBarView::Close() {
}
void InfoBarView::PaintArrow(gfx::Canvas* canvas,
- views::View* outer_view,
+ View* outer_view,
int arrow_center_x) {
gfx::Point infobar_top(0, y());
ConvertPointToView(GetParent(), outer_view, &infobar_top);
int infobar_top_y = infobar_top.y();
+ SkPoint gradient_points[2] = {
+ {SkIntToScalar(0), SkIntToScalar(infobar_top_y)},
+ {SkIntToScalar(0), SkIntToScalar(infobar_top_y + target_height_)}
+ };
+ InfoBarDelegate::Type infobar_type = delegate_->GetInfoBarType();
+ SkColor gradient_colors[2] = {
+ InfoBarBackground::GetTopColor(infobar_type),
+ InfoBarBackground::GetBottomColor(infobar_type),
+ };
+ SkShader* gradient_shader = SkGradientShader::CreateLinear(gradient_points,
+ gradient_colors, NULL, 2, SkShader::kMirror_TileMode);
+ SkPaint paint;
+ paint.setStrokeWidth(1);
+ paint.setStyle(SkPaint::kFill_Style);
+ paint.setShader(gradient_shader);
+ gradient_shader->unref();
// The size of the arrow (its height; also half its width). The
// arrow area is |arrow_size| ^ 2. By taking the square root of the
@@ -118,7 +130,6 @@ void InfoBarView::PaintArrow(gfx::Canvas* canvas,
const int kArrowSize = 10;
int arrow_size = static_cast<int>(kArrowSize *
sqrt(animation_->GetCurrentValue()));
-
SkPath fill_path;
fill_path.moveTo(SkPoint::Make(SkIntToScalar(arrow_center_x - arrow_size),
SkIntToScalar(infobar_top_y)));
@@ -126,32 +137,12 @@ void InfoBarView::PaintArrow(gfx::Canvas* canvas,
fill_path.rLineTo(SkIntToScalar(arrow_size), SkIntToScalar(arrow_size));
SkPath border_path(fill_path);
fill_path.close();
-
- SkPaint paint;
- paint.setStrokeWidth(1);
- paint.setStyle(SkPaint::kFill_Style);
-
- SkPoint grad_points[2];
- grad_points[0].set(SkIntToScalar(0), SkIntToScalar(infobar_top_y));
- grad_points[1].set(SkIntToScalar(0),
- SkIntToScalar(infobar_top_y + target_height_));
-
- SkColor grad_colors[2];
- grad_colors[0] = InfoBarBackground::GetTopColor(delegate_->GetInfoBarType());
- grad_colors[1] =
- InfoBarBackground::GetBottomColor(delegate_->GetInfoBarType());
-
- SkShader* gradient_shader = SkGradientShader::CreateLinear(
- grad_points, grad_colors, NULL, 2, SkShader::kMirror_TileMode);
- paint.setShader(gradient_shader);
- gradient_shader->unref();
-
gfx::CanvasSkia* canvas_skia = canvas->AsCanvasSkia();
canvas_skia->drawPath(fill_path, paint);
paint.setShader(NULL);
paint.setColor(SkColorSetA(ResourceBundle::toolbar_separator_color,
- SkColorGetA(grad_colors[0])));
+ SkColorGetA(gradient_colors[0])));
paint.setStyle(SkPaint::kStroke_Style);
canvas_skia->drawPath(border_path, paint);
}
@@ -166,9 +157,9 @@ void InfoBarView::Layout() {
button_size.height());
}
-void InfoBarView::ViewHierarchyChanged(bool is_add,
- views::View* parent,
- views::View* child) {
+void InfoBarView::ViewHierarchyChanged(bool is_add, View* parent, View* child) {
+ View::ViewHierarchyChanged(is_add, parent, child);
+
if (child == this) {
if (is_add) {
// The container_ pointer must be set before adding to the view hierarchy.
@@ -225,6 +216,7 @@ void InfoBarView::AnimationProgressed(const ui::Animation* animation) {
}
int InfoBarView::GetAvailableWidth() const {
+ const int kCloseButtonSpacing = 12;
return close_button_->x() - kCloseButtonSpacing;
}
@@ -237,7 +229,7 @@ int InfoBarView::CenterY(const gfx::Size prefsize) const {
return std::max((target_height_ - prefsize.height()) / 2, 0);
}
-int InfoBarView::OffsetY(views::View* parent, const gfx::Size prefsize) const {
+int InfoBarView::OffsetY(View* parent, const gfx::Size prefsize) const {
return CenterY(prefsize) - (target_height_ - parent->height());
}
@@ -246,8 +238,8 @@ AccessibilityTypes::Role InfoBarView::GetAccessibleRole() {
}
gfx::Size InfoBarView::GetPreferredSize() {
- int height = static_cast<int>(target_height_ * animation_->GetCurrentValue());
- return gfx::Size(0, height);
+ return gfx::Size(0,
+ static_cast<int>(target_height_ * animation_->GetCurrentValue()));
}
void InfoBarView::FocusWillChange(View* focused_before, View* focused_now) {
diff --git a/chrome/browser/ui/views/infobars/infobar_view.h b/chrome/browser/ui/views/infobars/infobar_view.h
index b3d5606..dc62f25 100644
--- a/chrome/browser/ui/views/infobars/infobar_view.h
+++ b/chrome/browser/ui/views/infobars/infobar_view.h
@@ -71,29 +71,22 @@ class InfoBarView : public InfoBar,
// Paint the arrow on |canvas|. |arrow_center_x| indicates the
// desired location of the center of the arrow in the |outer_view|
// coordinate system.
- void PaintArrow(gfx::Canvas* canvas,
- views::View* outer_view,
- int arrow_center_x);
+ void PaintArrow(gfx::Canvas* canvas, View* outer_view, int arrow_center_x);
protected:
// The target height of the InfoBar, regardless of what its current height
// is (due to animation).
static const int kDefaultTargetHeight;
-
static const int kHorizontalPadding;
static const int kIconLabelSpacing;
static const int kButtonButtonSpacing;
static const int kEndOfLabelSpacing;
- static const int kCloseButtonSpacing;
- static const int kButtonInLabelSpacing;
virtual ~InfoBarView();
// views::View:
virtual void Layout();
- virtual void ViewHierarchyChanged(bool is_add,
- views::View* parent,
- views::View* child);
+ virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child);
// views::ButtonListener:
virtual void ButtonPressed(views::Button* sender, const views::Event& event);
@@ -121,7 +114,7 @@ class InfoBarView : public InfoBar,
// |prefsize| within the standard InfoBar height, adjusted according to the
// current amount of animation offset the |parent| InfoBar currently has.
// Changes during an animation.
- int OffsetY(views::View* parent, const gfx::Size prefsize) const;
+ int OffsetY(View* parent, const gfx::Size prefsize) const;
private:
// views::View:
diff --git a/chrome/browser/ui/views/infobars/link_infobar.cc b/chrome/browser/ui/views/infobars/link_infobar.cc
index 7049e3d..64105ee 100644
--- a/chrome/browser/ui/views/infobars/link_infobar.cc
+++ b/chrome/browser/ui/views/infobars/link_infobar.cc
@@ -100,11 +100,10 @@ void LinkInfoBar::Layout() {
}
void LinkInfoBar::LinkActivated(views::Link* source, int event_flags) {
- DCHECK(source == link_);
+ DCHECK_EQ(link_, source);
if (GetDelegate()->LinkClicked(
- event_utils::DispositionFromEventFlags(event_flags))) {
+ event_utils::DispositionFromEventFlags(event_flags)))
RemoveInfoBar();
- }
}
LinkInfoBarDelegate* LinkInfoBar::GetDelegate() {
diff --git a/chrome/browser/ui/views/infobars/translate_infobar_base.cc b/chrome/browser/ui/views/infobars/translate_infobar_base.cc
index 2dbdacb..1196c43 100644
--- a/chrome/browser/ui/views/infobars/translate_infobar_base.cc
+++ b/chrome/browser/ui/views/infobars/translate_infobar_base.cc
@@ -42,6 +42,9 @@ InfoBar* TranslateInfoBarDelegate::CreateInfoBar() {
// TranslateInfoBarBase -------------------------------------------------------
+// static
+const int TranslateInfoBarBase::kButtonInLabelSpacing = 5;
+
TranslateInfoBarBase::TranslateInfoBarBase(TranslateInfoBarDelegate* delegate)
: InfoBarView(delegate),
normal_background_(InfoBarDelegate::PAGE_ACTION_TYPE),
diff --git a/chrome/browser/ui/views/infobars/translate_infobar_base.h b/chrome/browser/ui/views/infobars/translate_infobar_base.h
index d6d8255..3fd0dce 100644
--- a/chrome/browser/ui/views/infobars/translate_infobar_base.h
+++ b/chrome/browser/ui/views/infobars/translate_infobar_base.h
@@ -26,6 +26,8 @@ class TranslateInfoBarBase : public TranslateInfoBarView,
virtual ~TranslateInfoBarBase();
protected:
+ static const int kButtonInLabelSpacing;
+
// Creates a label with the appropriate font and color for the translate
// infobars.
static views::Label* CreateLabel(const string16& text);