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

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 sky/msw comments + rebase. Created 7 years, 10 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 scoped_ptr<message_center::MessageBubbleBase> bubble,
29 AnchorType anchor_type)
30 : bubble_(bubble.Pass()),
31 bubble_view_(NULL),
32 bubble_widget_(NULL),
33 tray_(tray) {
34 // Windows-specific initialization.
35 views::TrayBubbleView::AnchorAlignment anchor_alignment =
36 tray->GetAnchorAlignment();
37 views::TrayBubbleView::InitParams init_params =
38 bubble_->GetInitParams(anchor_alignment);
39 init_params.anchor_type = anchor_type;
40 init_params.close_on_deactivate = false;
41 init_params.arrow_alignment =
42 views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR;
43 // TODO(dewittj): Show big shadow without blocking clicks.
44 init_params.shadow = views::BubbleBorder::NO_SHADOW;
45
46 bubble_view_ = views::TrayBubbleView::Create(
47 tray->GetBubbleWindowContainer(), NULL, this, &init_params);
48
49 bubble_widget_ = views::BubbleDelegateView::CreateBubble(bubble_view_);
50 bubble_widget_->AddObserver(this);
51 bubble_widget_->StackAtTop();
52 bubble_widget_->SetAlwaysOnTop(true);
53 bubble_widget_->Activate();
54 bubble_view_->InitializeAndShowBubble();
55
56 bubble_view_->set_close_on_deactivate(true);
57 bubble_->InitializeContents(bubble_view_);
58 }
59
60 NotificationBubbleWrapperWin::~NotificationBubbleWrapperWin() {
61 bubble_.reset();
62 if (bubble_widget_) {
63 bubble_widget_->RemoveObserver(this);
64 bubble_widget_->Close();
65 }
66 }
67
68 void NotificationBubbleWrapperWin::OnWidgetClosing(views::Widget* widget) {
69 DCHECK_EQ(widget, bubble_widget_);
70 bubble_widget_->RemoveObserver(this);
71 bubble_widget_ = NULL;
72 tray_->HideBubbleWithView(bubble_view_);
73 }
74
75 void NotificationBubbleWrapperWin::BubbleViewDestroyed() {
76 bubble_->BubbleViewDestroyed();
77 }
78
79 void NotificationBubbleWrapperWin::OnMouseEnteredView() {
80 bubble_->OnMouseEnteredView();
81 }
82
83 void NotificationBubbleWrapperWin::OnMouseExitedView() {
84 bubble_->OnMouseExitedView();
85 }
86
87 string16 NotificationBubbleWrapperWin::GetAccessibleNameForBubble() {
88 // TODO(dewittj): Get a string resource.
89 return ASCIIToUTF16(kAccessibleNameForBubble);
90 }
91
92 gfx::Rect NotificationBubbleWrapperWin::GetAnchorRect(
93 views::Widget* anchor_widget,
94 AnchorType anchor_type,
95 AnchorAlignment anchor_alignment) {
96 gfx::Size size = bubble_view_->GetPreferredSize();
97 return tray_->GetAnchorRect(size,
98 anchor_type,
99 anchor_alignment);
100 }
101
102 void NotificationBubbleWrapperWin::HideBubble(
103 const views::TrayBubbleView* bubble_view) {
104 tray_->HideBubbleWithView(bubble_view);
105 }
106
107 } // namespace internal
108
109 } // namespace message_center
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698