OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/notifications/balloon.h" |
| 6 |
| 7 #include "base/gfx/rect.h" |
| 8 #include "base/logging.h" |
| 9 #include "chrome/browser/notifications/balloon_collection.h" |
| 10 #include "chrome/browser/renderer_host/site_instance.h" |
| 11 |
| 12 Balloon::Balloon(const Notification& notification, Profile* profile, |
| 13 BalloonCloseListener* listener) |
| 14 : profile_(profile), |
| 15 notification_(notification), |
| 16 close_listener_(listener) { |
| 17 } |
| 18 |
| 19 Balloon::~Balloon() { |
| 20 } |
| 21 |
| 22 void Balloon::SetPosition(const gfx::Point& upper_left, bool reposition) { |
| 23 position_ = upper_left; |
| 24 if (reposition && balloon_view_.get()) |
| 25 balloon_view_->RepositionToBalloon(); |
| 26 } |
| 27 |
| 28 void Balloon::set_view(BalloonView* balloon_view) { |
| 29 balloon_view_.reset(balloon_view); |
| 30 } |
| 31 |
| 32 void Balloon::Show() { |
| 33 notification_.Display(); |
| 34 if (balloon_view_.get()) { |
| 35 balloon_view_->Show(this); |
| 36 } |
| 37 } |
| 38 |
| 39 void Balloon::Close(bool by_user) { |
| 40 notification_.Close(by_user); |
| 41 if (close_listener_) |
| 42 close_listener_->OnBalloonClosed(this); |
| 43 } |
OLD | NEW |