OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/notifications/balloon.h" | 5 #include "chrome/browser/notifications/balloon.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/notifications/balloon_collection.h" | 8 #include "chrome/browser/notifications/balloon_collection.h" |
9 #include "chrome/browser/notifications/notification.h" | 9 #include "chrome/browser/notifications/notification.h" |
10 #include "ui/gfx/rect.h" | 10 #include "ui/gfx/rect.h" |
11 #include "ui/gfx/size.h" | 11 #include "ui/gfx/size.h" |
12 | 12 |
13 Balloon::Balloon(const Notification& notification, Profile* profile, | 13 Balloon::Balloon(const Notification& notification, Profile* profile, |
14 BalloonCollection* collection) | 14 BalloonCollection* collection) |
15 : profile_(profile), | 15 : profile_(profile), |
16 notification_(new Notification(notification)), | 16 notification_(new Notification(notification)), |
17 collection_(collection) { | 17 collection_(collection) { |
18 } | 18 } |
19 | 19 |
20 Balloon::~Balloon() { | 20 Balloon::~Balloon() { |
21 } | 21 } |
22 | 22 |
23 void Balloon::SetPosition(const gfx::Point& upper_left, bool reposition) { | 23 void Balloon::SetPosition(const gfx::Point& upper_left, bool reposition) { |
24 position_ = upper_left; | 24 position_ = upper_left; |
25 if (reposition && balloon_view_.get()) | 25 if (reposition && balloon_view_.get()) |
26 balloon_view_->RepositionToBalloon(); | 26 balloon_view_->RepositionToBalloon(); |
27 } | 27 } |
28 | 28 |
29 void Balloon::SetContentPreferredSize(const gfx::Size& size) { | 29 void Balloon::ResizeDueToAutoResize(const gfx::Size& size) { |
30 collection_->ResizeBalloon(this, size); | 30 collection_->ResizeBalloon(this, size); |
31 } | 31 } |
32 | 32 |
33 void Balloon::set_view(BalloonView* balloon_view) { | 33 void Balloon::set_view(BalloonView* balloon_view) { |
34 balloon_view_.reset(balloon_view); | 34 balloon_view_.reset(balloon_view); |
35 } | 35 } |
36 | 36 |
37 void Balloon::Show() { | 37 void Balloon::Show() { |
38 notification_->Display(); | 38 notification_->Display(); |
39 if (balloon_view_.get()) { | 39 if (balloon_view_.get()) { |
(...skipping 19 matching lines...) Expand all Loading... |
59 notification_->Close(by_user); | 59 notification_->Close(by_user); |
60 collection_->OnBalloonClosed(this); | 60 collection_->OnBalloonClosed(this); |
61 } | 61 } |
62 | 62 |
63 void Balloon::CloseByScript() { | 63 void Balloon::CloseByScript() { |
64 // A user-initiated close begins with the view and then closes this object; | 64 // A user-initiated close begins with the view and then closes this object; |
65 // we simulate that with a script-initiated close but pass |by_user|=false. | 65 // we simulate that with a script-initiated close but pass |by_user|=false. |
66 DCHECK(balloon_view_.get()); | 66 DCHECK(balloon_view_.get()); |
67 balloon_view_->Close(false); | 67 balloon_view_->Close(false); |
68 } | 68 } |
OLD | NEW |