| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/views/infobars/infobars.h" | 5 #include "chrome/browser/views/infobars/infobars.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "app/slide_animation.h" | 9 #include "app/slide_animation.h" |
| 10 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 // InfoBar, views::ButtonListener implementation: ------------------ | 178 // InfoBar, views::ButtonListener implementation: ------------------ |
| 179 | 179 |
| 180 void InfoBar::ButtonPressed(views::Button* sender, const views::Event& event) { | 180 void InfoBar::ButtonPressed(views::Button* sender, const views::Event& event) { |
| 181 if (sender == close_button_) { | 181 if (sender == close_button_) { |
| 182 if (delegate_) | 182 if (delegate_) |
| 183 delegate_->InfoBarDismissed(); | 183 delegate_->InfoBarDismissed(); |
| 184 RemoveInfoBar(); | 184 RemoveInfoBar(); |
| 185 } | 185 } |
| 186 } | 186 } |
| 187 | 187 |
| 188 // InfoBar, views::FocusChangeListener implementation: ------------------ |
| 189 |
| 190 void InfoBar::FocusWillChange(View* focused_before, View* focused_now) { |
| 191 if (focused_before && focused_now && |
| 192 !this->IsParentOf(focused_before) && this->IsParentOf(focused_now)) { |
| 193 NotifyAccessibilityEvent(AccessibilityTypes::EVENT_ALERT); |
| 194 } |
| 195 } |
| 196 |
| 188 // InfoBar, AnimationDelegate implementation: ---------------------------------- | 197 // InfoBar, AnimationDelegate implementation: ---------------------------------- |
| 189 | 198 |
| 190 void InfoBar::AnimationProgressed(const Animation* animation) { | 199 void InfoBar::AnimationProgressed(const Animation* animation) { |
| 191 if (container_) | 200 if (container_) |
| 192 container_->InfoBarAnimated(true); | 201 container_->InfoBarAnimated(true); |
| 193 } | 202 } |
| 194 | 203 |
| 195 void InfoBar::AnimationEnded(const Animation* animation) { | 204 void InfoBar::AnimationEnded(const Animation* animation) { |
| 196 if (container_) { | 205 if (container_) { |
| 197 container_->InfoBarAnimated(false); | 206 container_->InfoBarAnimated(false); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 // When we're added to a view hierarchy within a widget, we create an | 256 // When we're added to a view hierarchy within a widget, we create an |
| 248 // external focus tracker to track what was focused in case we obtain | 257 // external focus tracker to track what was focused in case we obtain |
| 249 // focus so that we can restore focus when we're removed. | 258 // focus so that we can restore focus when we're removed. |
| 250 views::Widget* widget = GetWidget(); | 259 views::Widget* widget = GetWidget(); |
| 251 if (widget) { | 260 if (widget) { |
| 252 focus_tracker_.reset(new views::ExternalFocusTracker(this, | 261 focus_tracker_.reset(new views::ExternalFocusTracker(this, |
| 253 GetFocusManager())); | 262 GetFocusManager())); |
| 254 } | 263 } |
| 255 #endif | 264 #endif |
| 256 | 265 |
| 266 if (GetFocusManager()) |
| 267 GetFocusManager()->AddFocusChangeListener(this); |
| 268 |
| 257 NotifyAccessibilityEvent(AccessibilityTypes::EVENT_ALERT); | 269 NotifyAccessibilityEvent(AccessibilityTypes::EVENT_ALERT); |
| 258 } | 270 } |
| 259 | 271 |
| 260 void InfoBar::InfoBarRemoved() { | 272 void InfoBar::InfoBarRemoved() { |
| 261 DestroyFocusTracker(false); | 273 DestroyFocusTracker(false); |
| 262 // NULL our container_ pointer so that if Animation::Stop results in | 274 // NULL our container_ pointer so that if Animation::Stop results in |
| 263 // AnimationEnded being called, we do not try and delete ourselves twice. | 275 // AnimationEnded being called, we do not try and delete ourselves twice. |
| 264 container_ = NULL; | 276 container_ = NULL; |
| 265 animation_->Stop(); | 277 animation_->Stop(); |
| 266 // Finally, clean ourselves up when we're removed from the view hierarchy | 278 // Finally, clean ourselves up when we're removed from the view hierarchy |
| 267 // since no-one refers to us now. | 279 // since no-one refers to us now. |
| 268 MessageLoop::current()->PostTask(FROM_HERE, | 280 MessageLoop::current()->PostTask(FROM_HERE, |
| 269 delete_factory_.NewRunnableMethod(&InfoBar::DeleteSelf)); | 281 delete_factory_.NewRunnableMethod(&InfoBar::DeleteSelf)); |
| 282 |
| 283 if (GetFocusManager()) |
| 284 GetFocusManager()->RemoveFocusChangeListener(this); |
| 270 } | 285 } |
| 271 | 286 |
| 272 void InfoBar::DestroyFocusTracker(bool restore_focus) { | 287 void InfoBar::DestroyFocusTracker(bool restore_focus) { |
| 273 if (focus_tracker_.get()) { | 288 if (focus_tracker_.get()) { |
| 274 if (restore_focus) | 289 if (restore_focus) |
| 275 focus_tracker_->FocusLastFocusedExternalView(); | 290 focus_tracker_->FocusLastFocusedExternalView(); |
| 276 focus_tracker_->SetFocusManager(NULL); | 291 focus_tracker_->SetFocusManager(NULL); |
| 277 focus_tracker_.reset(NULL); | 292 focus_tracker_.reset(NULL); |
| 278 } | 293 } |
| 279 } | 294 } |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 | 593 |
| 579 InfoBar* LinkInfoBarDelegate::CreateInfoBar() { | 594 InfoBar* LinkInfoBarDelegate::CreateInfoBar() { |
| 580 return new LinkInfoBar(this); | 595 return new LinkInfoBar(this); |
| 581 } | 596 } |
| 582 | 597 |
| 583 // ConfirmInfoBarDelegate, InfoBarDelegate overrides: -------------------------- | 598 // ConfirmInfoBarDelegate, InfoBarDelegate overrides: -------------------------- |
| 584 | 599 |
| 585 InfoBar* ConfirmInfoBarDelegate::CreateInfoBar() { | 600 InfoBar* ConfirmInfoBarDelegate::CreateInfoBar() { |
| 586 return new ConfirmInfoBar(this); | 601 return new ConfirmInfoBar(this); |
| 587 } | 602 } |
| OLD | NEW |