Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/views/message_center/notification_bubble_wrapper_win .h" | |
| 6 | |
| 7 #include "base/utf_string_conversions.h" | |
| 8 #include "chrome/browser/ui/views/message_center/web_notification_tray_win.h" | |
| 9 #include "ui/gfx/size.h" | |
| 10 #include "ui/message_center/message_bubble_base.h" | |
| 11 #include "ui/views/bubble/bubble_delegate.h" | |
| 12 #include "ui/views/bubble/tray_bubble_view.h" | |
| 13 #include "ui/views/widget/widget.h" | |
| 14 #include "ui/views/widget/widget_observer.h" | |
| 15 | |
| 16 namespace { | |
| 17 | |
| 18 const char kAccessibleNameForBubble[] = "Windows Notification Center"; | |
| 19 | |
| 20 } | |
| 21 | |
| 22 namespace message_center { | |
| 23 | |
| 24 namespace internal { | |
| 25 | |
| 26 NotificationBubbleWrapperWin::NotificationBubbleWrapperWin( | |
| 27 WebNotificationTrayWin* tray, | |
| 28 message_center::MessageBubbleBase* bubble, | |
| 29 AnchorType anchor_type) | |
| 30 : tray_(tray) { | |
|
sky
2013/01/30 14:38:17
ember initialize other methods to NULL (in case so
dewittj
2013/01/30 23:08:32
Done.
| |
| 31 bubble_.reset(bubble); | |
| 32 | |
| 33 // Windows-specific initialization. | |
| 34 views::TrayBubbleView::AnchorAlignment anchor_alignment = | |
| 35 tray->GetAnchorAlignment(); | |
| 36 views::TrayBubbleView::InitParams init_params = | |
| 37 bubble->GetInitParams(anchor_alignment); | |
| 38 init_params.anchor_type = anchor_type; | |
| 39 init_params.close_on_deactivate = false; | |
| 40 init_params.arrow_alignment = | |
| 41 views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR; | |
| 42 // TODO(dewittj): Show big shadow without blocking clicks. | |
| 43 init_params.shadow = views::BubbleBorder::NO_SHADOW; | |
| 44 | |
| 45 bubble_view_ = views::TrayBubbleView::Create( | |
| 46 tray->GetBubbleWindowContainer(), NULL, this, &init_params); | |
| 47 | |
| 48 bubble_widget_ = views::BubbleDelegateView::CreateBubble(bubble_view_); | |
| 49 bubble_widget_->AddObserver(this); | |
| 50 bubble_widget_->StackAtTop(); | |
|
sky
2013/01/30 14:38:17
You sure this is needed? Won't SetAlwaysOnTop forc
dewittj
2013/01/30 23:08:32
Perhaps this is my relative newness to Windows, bu
| |
| 51 bubble_widget_->SetAlwaysOnTop(true); | |
| 52 bubble_widget_->Activate(); | |
| 53 bubble_view_->InitializeAndShowBubble(); | |
| 54 | |
| 55 bubble_view_->set_close_on_deactivate(true); | |
| 56 bubble->InitializeContents(bubble_view_); | |
| 57 } | |
| 58 | |
| 59 NotificationBubbleWrapperWin::~NotificationBubbleWrapperWin() { | |
| 60 bubble_.reset(); | |
| 61 if (bubble_widget_) { | |
| 62 bubble_widget_->RemoveObserver(this); | |
| 63 bubble_widget_->Close(); | |
| 64 } | |
| 65 } | |
| 66 | |
| 67 void NotificationBubbleWrapperWin::OnWidgetClosing(views::Widget* widget) { | |
| 68 DCHECK(widget == bubble_widget_); | |
|
sky
2013/01/30 14:38:17
DCHECK_EQ
dewittj
2013/01/30 23:08:32
Done.
| |
| 69 bubble_widget_->RemoveObserver(this); | |
| 70 bubble_widget_ = NULL; | |
| 71 tray_->HideBubbleWithView(bubble_view_); | |
| 72 } | |
| 73 | |
| 74 void NotificationBubbleWrapperWin::BubbleViewDestroyed() { | |
| 75 bubble_->BubbleViewDestroyed(); | |
| 76 } | |
| 77 | |
| 78 void NotificationBubbleWrapperWin::OnMouseEnteredView() { | |
| 79 bubble_->OnMouseEnteredView(); | |
| 80 }; | |
|
sky
2013/01/30 14:38:17
remove ;
dewittj
2013/01/30 23:08:32
Done.
| |
| 81 | |
| 82 void NotificationBubbleWrapperWin::OnMouseExitedView() { | |
| 83 bubble_->OnMouseExitedView(); | |
| 84 } | |
| 85 | |
| 86 string16 NotificationBubbleWrapperWin::GetAccessibleNameForBubble() { | |
| 87 // TODO(dewittj): Get a string resource. | |
| 88 return ASCIIToUTF16(kAccessibleNameForBubble); | |
| 89 } | |
| 90 | |
| 91 gfx::Rect NotificationBubbleWrapperWin::GetAnchorRect( | |
| 92 views::Widget* anchor_widget, | |
| 93 AnchorType anchor_type, | |
| 94 AnchorAlignment anchor_alignment) { | |
| 95 gfx::Size size = bubble_view_->GetPreferredSize(); | |
| 96 return tray_->GetAnchorRect(size, | |
| 97 anchor_type, | |
| 98 anchor_alignment); | |
| 99 } | |
| 100 | |
| 101 void NotificationBubbleWrapperWin::HideBubble( | |
| 102 const views::TrayBubbleView* bubble_view) { | |
| 103 tray_->HideBubbleWithView(bubble_view); | |
| 104 } | |
| 105 | |
| 106 } // namespace internal | |
| 107 | |
| 108 } // namespace message_center | |
| OLD | NEW |