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

Side by Side Diff: chrome/browser/ui/views/notifications/balloon_collection_views.cc

Issue 231213003: notification balloons: Remove views and cocoa implementations of BalloonCollection. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 8 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 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/notifications/balloon_collection_impl.h"
6
7 #include "chrome/browser/notifications/balloon.h"
8 #include "chrome/browser/ui/views/notifications/balloon_view_views.h"
9 #include "ui/events/event_constants.h"
10 #include "ui/events/event_utils.h"
11 #include "ui/gfx/rect.h"
12 #include "ui/gfx/screen.h"
13
14 Balloon* BalloonCollectionImpl::MakeBalloon(const Notification& notification,
15 Profile* profile) {
16 Balloon* balloon = new Balloon(notification, profile, this);
17 balloon->set_view(new BalloonViewImpl(this));
18 gfx::Size size(layout_.min_balloon_width(), layout_.min_balloon_height());
19 balloon->set_content_size(size);
20 return balloon;
21 }
22
23 int BalloonCollectionImpl::Layout::InterBalloonMargin() const {
24 return 3;
25 }
26
27 int BalloonCollectionImpl::Layout::HorizontalEdgeMargin() const {
28 return 2;
29 }
30
31 int BalloonCollectionImpl::Layout::VerticalEdgeMargin() const {
32 return 0;
33 }
34
35 bool BalloonCollectionImpl::Layout::NeedToMoveAboveLeftSidePanels() const {
36 return placement_ == VERTICALLY_FROM_BOTTOM_LEFT;
37 }
38
39 bool BalloonCollectionImpl::Layout::NeedToMoveAboveRightSidePanels() const {
40 return placement_ == VERTICALLY_FROM_BOTTOM_RIGHT;
41 }
42
43 void BalloonCollectionImpl::PositionBalloons(bool reposition) {
44 PositionBalloonsInternal(reposition);
45 }
46
47 void BalloonCollectionImpl::WillProcessEvent(const base::NativeEvent& event) {}
48
49 void BalloonCollectionImpl::DidProcessEvent(const base::NativeEvent& event) {
50 #if defined(OS_WIN)
51 switch (event.message) {
52 case WM_MOUSEMOVE:
53 case WM_MOUSELEAVE:
54 case WM_NCMOUSELEAVE:
55 HandleMouseMoveEvent();
56 break;
57 }
58 #elif defined(USE_AURA)
59 // This is deliberately used only in linux. For an aura build on windows, the
60 // above block of code is fine.
61 switch (ui::EventTypeFromNative(event)) {
62 case ui::ET_MOUSE_MOVED:
63 case ui::ET_MOUSE_DRAGGED:
64 case ui::ET_MOUSE_EXITED:
65 HandleMouseMoveEvent();
66 break;
67 default:
68 break;
69 }
70 #else
71 NOTIMPLEMENTED();
72 #endif
73 }
74
75 bool BalloonCollectionImpl::IsCursorInBalloonCollection() const {
76 #if defined(OS_WIN)
77 gfx::Point cursor(GetMessagePos());
78 #else
79 // TODO(saintlou): Not sure if this is correct because on Windows at least
80 // the following call is GetCursorPos() not GetMessagePos().
81 // TODO(scottmg): NativeScreen might be wrong. http://crbug.com/133312
82 gfx::Point cursor(gfx::Screen::GetNativeScreen()->GetCursorScreenPoint());
83 #endif
84 return GetBalloonsBoundingBox().Contains(cursor);
85 }
86
87 void BalloonCollectionImpl::SetPositionPreference(
88 PositionPreference position) {
89 if (position == DEFAULT_POSITION)
90 position = LOWER_RIGHT;
91
92 // All positioning schemes are vertical, and windows
93 // uses the normal screen orientation.
94 if (position == UPPER_RIGHT)
95 layout_.set_placement(Layout::VERTICALLY_FROM_TOP_RIGHT);
96 else if (position == UPPER_LEFT)
97 layout_.set_placement(Layout::VERTICALLY_FROM_TOP_LEFT);
98 else if (position == LOWER_LEFT)
99 layout_.set_placement(Layout::VERTICALLY_FROM_BOTTOM_LEFT);
100 else if (position == LOWER_RIGHT)
101 layout_.set_placement(Layout::VERTICALLY_FROM_BOTTOM_RIGHT);
102 else
103 NOTREACHED();
104
105 layout_.ComputeOffsetToMoveAbovePanels();
106 PositionBalloons(true);
107 }
108
109 // static
110 BalloonCollection* BalloonCollection::Create() {
111 return new BalloonCollectionImpl();
112 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/notifications/OWNERS ('k') | chrome/browser/ui/views/notifications/balloon_view_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698