OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/browser_bubble.h" | 5 #include "chrome/browser/views/browser_bubble.h" |
6 | 6 |
7 #include "app/l10n_util_win.h" | 7 #include "app/l10n_util_win.h" |
8 #include "chrome/browser/views/frame/browser_view.h" | 8 #include "chrome/browser/views/frame/browser_view.h" |
9 #include "views/widget/root_view.h" | 9 #include "views/widget/root_view.h" |
10 #include "views/widget/widget_win.h" | 10 #include "views/widget/widget_win.h" |
11 #include "views/window/window.h" | 11 #include "views/window/window.h" |
12 | 12 |
13 class BubbleWidget : public views::WidgetWin | 13 class BubbleWidget : public views::WidgetWin |
14 { | 14 { |
15 public: | 15 public: |
16 BubbleWidget(BrowserBubble* bubble) : bubble_(bubble), closed_(false) { | 16 BubbleWidget(BrowserBubble* bubble) : bubble_(bubble), closed_(false) { |
17 } | 17 } |
18 | 18 |
19 void Show(bool activate) { | 19 void Show(bool activate) { |
20 if (activate) | 20 if (activate) |
21 ShowWindow(SW_SHOW); | 21 ShowWindow(SW_SHOW); |
22 else | 22 else |
23 views::WidgetWin::Show(); | 23 views::WidgetWin::Show(); |
24 } | 24 } |
25 | 25 |
26 void Close() { | 26 void Close() { |
27 if (closed_) | 27 if (closed_) |
28 return; | 28 return; |
29 closed_ = true; | 29 closed_ = true; |
| 30 if (IsActive()) { |
| 31 BrowserBubble::Delegate* delegate = bubble_->delegate(); |
| 32 if (delegate) |
| 33 delegate->BubbleLostFocus(bubble_); |
| 34 } |
30 views::WidgetWin::Close(); | 35 views::WidgetWin::Close(); |
31 } | 36 } |
32 | 37 |
| 38 void Hide() { |
| 39 if (IsActive()) { |
| 40 BrowserBubble::Delegate* delegate = bubble_->delegate(); |
| 41 if (delegate) |
| 42 delegate->BubbleLostFocus(bubble_); |
| 43 } |
| 44 views::WidgetWin::Hide(); |
| 45 } |
| 46 |
33 void OnActivate(UINT action, BOOL minimized, HWND window) { | 47 void OnActivate(UINT action, BOOL minimized, HWND window) { |
34 BrowserBubble::Delegate* delegate = bubble_->delegate(); | 48 BrowserBubble::Delegate* delegate = bubble_->delegate(); |
35 if (!delegate) | 49 if (!delegate) |
36 return; | 50 return; |
37 | 51 |
38 if (action == WA_INACTIVE && !closed_) { | 52 if (action == WA_INACTIVE && !closed_) { |
39 delegate->BubbleLostFocus(bubble_); | 53 delegate->BubbleLostFocus(bubble_); |
40 } else if (action == WA_ACTIVE) { | 54 } else if (action == WA_ACTIVE) { |
41 delegate->BubbleGotFocus(bubble_); | 55 delegate->BubbleGotFocus(bubble_); |
42 } | 56 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 visible_ = true; | 101 visible_ = true; |
88 } | 102 } |
89 | 103 |
90 void BrowserBubble::Hide() { | 104 void BrowserBubble::Hide() { |
91 if (!visible_) | 105 if (!visible_) |
92 return; | 106 return; |
93 views::WidgetWin* pop = static_cast<views::WidgetWin*>(popup_); | 107 views::WidgetWin* pop = static_cast<views::WidgetWin*>(popup_); |
94 pop->Hide(); | 108 pop->Hide(); |
95 visible_ = false; | 109 visible_ = false; |
96 } | 110 } |
OLD | NEW |