| 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/info_bubble.h" | 5 #include "chrome/browser/views/info_bubble.h" |
| 6 | 6 |
| 7 #include "base/keyboard_codes.h" | 7 #include "base/keyboard_codes.h" |
| 8 #include "chrome/browser/window_sizer.h" | 8 #include "chrome/browser/window_sizer.h" |
| 9 #include "chrome/common/notification_service.h" | 9 #include "chrome/common/notification_service.h" |
| 10 #include "gfx/canvas.h" | 10 #include "gfx/canvas.h" |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 BubbleBorder::ArrowLocation arrow_location, | 242 BubbleBorder::ArrowLocation arrow_location, |
| 243 views::View* contents, | 243 views::View* contents, |
| 244 InfoBubbleDelegate* delegate) { | 244 InfoBubbleDelegate* delegate) { |
| 245 InfoBubble* window = new InfoBubble; | 245 InfoBubble* window = new InfoBubble; |
| 246 window->Init(parent, position_relative_to, arrow_location, | 246 window->Init(parent, position_relative_to, arrow_location, |
| 247 contents, delegate); | 247 contents, delegate); |
| 248 return window; | 248 return window; |
| 249 } | 249 } |
| 250 | 250 |
| 251 void InfoBubble::Close() { | 251 void InfoBubble::Close() { |
| 252 GetFocusManager()->UnregisterAccelerator( | |
| 253 views::Accelerator(base::VKEY_ESCAPE, false, false, false), this); | |
| 254 | |
| 255 if (fade_away_on_close_) | 252 if (fade_away_on_close_) |
| 256 FadeOut(); | 253 FadeOut(); |
| 257 else | 254 else |
| 258 Close(false); | 255 Close(false); |
| 259 } | 256 } |
| 260 | 257 |
| 261 void InfoBubble::AnimationEnded(const Animation* animation) { | 258 void InfoBubble::AnimationEnded(const Animation* animation) { |
| 262 if (static_cast<int>(animation_->GetCurrentValue()) == 0) { | 259 if (static_cast<int>(animation_->GetCurrentValue()) == 0) { |
| 263 // When fading out we just need to close the bubble at the end | 260 // When fading out we just need to close the bubble at the end |
| 264 Close(false); | 261 Close(false); |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 void InfoBubble::IsActiveChanged() { | 465 void InfoBubble::IsActiveChanged() { |
| 469 if (!IsActive()) | 466 if (!IsActive()) |
| 470 Close(); | 467 Close(); |
| 471 } | 468 } |
| 472 #endif | 469 #endif |
| 473 | 470 |
| 474 void InfoBubble::Close(bool closed_by_escape) { | 471 void InfoBubble::Close(bool closed_by_escape) { |
| 475 if (closed_) | 472 if (closed_) |
| 476 return; | 473 return; |
| 477 | 474 |
| 475 GetFocusManager()->UnregisterAccelerator( |
| 476 views::Accelerator(base::VKEY_ESCAPE, false, false, false), this); |
| 478 if (delegate_) | 477 if (delegate_) |
| 479 delegate_->InfoBubbleClosing(this, closed_by_escape); | 478 delegate_->InfoBubbleClosing(this, closed_by_escape); |
| 480 closed_ = true; | 479 closed_ = true; |
| 481 #if defined(OS_WIN) | 480 #if defined(OS_WIN) |
| 482 border_->Close(); | 481 border_->Close(); |
| 483 WidgetWin::Close(); | 482 WidgetWin::Close(); |
| 484 #elif defined(OS_LINUX) | 483 #elif defined(OS_LINUX) |
| 485 WidgetGtk::Close(); | 484 WidgetGtk::Close(); |
| 486 #endif | 485 #endif |
| 487 } | 486 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 516 animation_->Hide(); | 515 animation_->Hide(); |
| 517 } | 516 } |
| 518 | 517 |
| 519 bool InfoBubble::AcceleratorPressed(const views::Accelerator& accelerator) { | 518 bool InfoBubble::AcceleratorPressed(const views::Accelerator& accelerator) { |
| 520 if (!delegate_ || delegate_->CloseOnEscape()) { | 519 if (!delegate_ || delegate_->CloseOnEscape()) { |
| 521 Close(true); | 520 Close(true); |
| 522 return true; | 521 return true; |
| 523 } | 522 } |
| 524 return false; | 523 return false; |
| 525 } | 524 } |
| OLD | NEW |