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

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: Address petewil & stevenjb comments. Move MessageCenterTrayDelegate to its own class. 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 {
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) {
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();
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 bubble_widget_ = NULL;
miket_OOO 2013/01/25 17:14:48 If you feel strongly about this NULL, go ahead and
dewittj 2013/01/25 19:38:46 Done.
65 }
66 }
67
68 void NotificationBubbleWrapperWin::OnWidgetClosing(views::Widget* widget) {
69 bubble_widget_->RemoveObserver(this);
miket_OOO 2013/01/25 17:14:48 Did you want to call Close() after this?
dewittj 2013/01/25 19:38:46 I was under the impression that the widget is alre
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 };
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698