Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(581)

Side by Side Diff: chrome/browser/ui/views/message_center/notification_bubble_wrapper_win.cc

Issue 11819048: Implement message center on Windows (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Use notification manager instead of balloon view, remove singleton-ness from MessageCenterTray. Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 ui {
17
18 namespace internal {
19
20 NotificationBubbleWrapperWin::NotificationBubbleWrapperWin(
21 WebNotificationTrayWin* tray,
22 message_center::MessageBubbleBase* bubble,
23 AnchorType anchor_type)
24 : tray_(tray) {
25 bubble_.reset(bubble);
26
27 // Windows-specific initialization.
28 views::TrayBubbleView::AnchorAlignment anchor_alignment =
29 tray->GetAnchorAlignment();
30 views::TrayBubbleView::InitParams init_params =
31 bubble->GetInitParams(anchor_alignment);
32 init_params.anchor_type = anchor_type;
33 init_params.close_on_deactivate = false;
34 init_params.arrow_alignment =
35 views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR;
36 // TODO(dewittj): Show big shadow without blocking clicks.
37 init_params.shadow = views::BubbleBorder::NO_SHADOW;
38
39 bubble_view_ = views::TrayBubbleView::Create(
40 tray->GetBubbleWindowContainer(), NULL, this, &init_params);
41
42 bubble_widget_ = views::BubbleDelegateView::CreateBubble(bubble_view_);
43 bubble_widget_->AddObserver(this);
44 bubble_widget_->StackAtTop();
45 bubble_widget_->SetAlwaysOnTop(true);
46 bubble_widget_->Activate();
47 bubble_view_->InitializeAndShowBubble();
48
49 bubble_view_->set_close_on_deactivate(true);
50 bubble->InitializeContents(bubble_view_);
51 }
52
53 NotificationBubbleWrapperWin::~NotificationBubbleWrapperWin() {
54 bubble_.reset();
55 if (bubble_widget_) {
56 bubble_widget_->RemoveObserver(this);
57 bubble_widget_->Close();
58 bubble_widget_ = NULL;
59 }
60 }
61
62 void NotificationBubbleWrapperWin::OnWidgetClosing(views::Widget* widget) {
63 bubble_widget_->RemoveObserver(this);
64 bubble_widget_ = NULL;
65 tray_->HideBubbleWithView(bubble_view_);
66 }
67
68 void NotificationBubbleWrapperWin::BubbleViewDestroyed() {
69 bubble_->BubbleViewDestroyed();
70 }
71
72 void NotificationBubbleWrapperWin::OnMouseEnteredView() {
73 bubble_->OnMouseEnteredView();
74 };
75
76 void NotificationBubbleWrapperWin::OnMouseExitedView() {
77 bubble_->OnMouseExitedView();
78 }
79
80 string16 NotificationBubbleWrapperWin::GetAccessibleNameForBubble() {
81 // TODO(dewittj): Get a string resource.
82 return ASCIIToUTF16("Windows Notification Center");
83 }
84
85 gfx::Rect NotificationBubbleWrapperWin::GetAnchorRect(
86 views::Widget* anchor_widget,
87 AnchorType anchor_type,
88 AnchorAlignment anchor_alignment) {
89 gfx::Size size = bubble_view_->GetPreferredSize();
90 return tray_->GetAnchorRect(size,
91 anchor_type,
92 anchor_alignment);
93 }
94
95 void NotificationBubbleWrapperWin::HideBubble(
96 const views::TrayBubbleView* bubble_view) {
97 tray_->HideBubbleWithView(bubble_view);
98 }
99
100 } // namespace internal
101
102 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698