Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "chrome/browser/ui/views/infobars/infobar_view.h" | 5 #include "chrome/browser/ui/views/infobars/infobar_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 203 | 203 |
| 204 gfx::Size button_size = close_button_->GetPreferredSize(); | 204 gfx::Size button_size = close_button_->GetPreferredSize(); |
| 205 close_button_->SetBounds(std::max(start_x + ContentMinimumWidth(), | 205 close_button_->SetBounds(std::max(start_x + ContentMinimumWidth(), |
| 206 width() - kHorizontalPadding - button_size.width()), OffsetY(button_size), | 206 width() - kHorizontalPadding - button_size.width()), OffsetY(button_size), |
| 207 button_size.width(), button_size.height()); | 207 button_size.width(), button_size.height()); |
| 208 } | 208 } |
| 209 | 209 |
| 210 void InfoBarView::ViewHierarchyChanged(bool is_add, View* parent, View* child) { | 210 void InfoBarView::ViewHierarchyChanged(bool is_add, View* parent, View* child) { |
| 211 View::ViewHierarchyChanged(is_add, parent, child); | 211 View::ViewHierarchyChanged(is_add, parent, child); |
| 212 | 212 |
| 213 if (is_add && (child == this) && (close_button_ == NULL)) { | 213 if (!is_add && (child == this)) { |
| 214 // We're being removed. Cancel any menus we may have open. | |
|
Peter Kasting
2011/09/12 18:06:00
Do this at the top of PlatformSpecificHide() inste
| |
| 215 CancelMenu(); | |
| 216 } else if (is_add && (child == this) && (close_button_ == NULL)) { | |
| 214 gfx::Image* image = delegate()->GetIcon(); | 217 gfx::Image* image = delegate()->GetIcon(); |
| 215 if (image) { | 218 if (image) { |
| 216 icon_ = new views::ImageView; | 219 icon_ = new views::ImageView; |
| 217 icon_->SetImage(image->ToSkBitmap()); | 220 icon_->SetImage(image->ToSkBitmap()); |
| 218 AddChildView(icon_); | 221 AddChildView(icon_); |
| 219 } | 222 } |
| 220 | 223 |
| 221 close_button_ = new views::ImageButton(this); | 224 close_button_ = new views::ImageButton(this); |
| 222 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 225 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 223 close_button_->SetImage(views::CustomButton::BS_NORMAL, | 226 close_button_->SetImage(views::CustomButton::BS_NORMAL, |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 351 | 354 |
| 352 void InfoBarView::FocusWillChange(View* focused_before, View* focused_now) { | 355 void InfoBarView::FocusWillChange(View* focused_before, View* focused_now) { |
| 353 // This will trigger some screen readers to read the entire contents of this | 356 // This will trigger some screen readers to read the entire contents of this |
| 354 // infobar. | 357 // infobar. |
| 355 if (focused_before && focused_now && !Contains(focused_before) && | 358 if (focused_before && focused_now && !Contains(focused_before) && |
| 356 Contains(focused_now) && GetWidget()) { | 359 Contains(focused_now) && GetWidget()) { |
| 357 GetWidget()->NotifyAccessibilityEvent( | 360 GetWidget()->NotifyAccessibilityEvent( |
| 358 this, ui::AccessibilityTypes::EVENT_ALERT, true); | 361 this, ui::AccessibilityTypes::EVENT_ALERT, true); |
| 359 } | 362 } |
| 360 } | 363 } |
| OLD | NEW |