blob: da49395354a934f1f5b21dfe9a42fe8f8c3350b6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/notifications/balloon.h"
#include "base/gfx/rect.h"
#include "base/logging.h"
#include "chrome/browser/notifications/balloon_collection.h"
#include "chrome/browser/renderer_host/site_instance.h"
Balloon::Balloon(const Notification& notification, Profile* profile,
BalloonCollection* collection)
: profile_(profile),
notification_(notification),
collection_(collection) {
}
Balloon::~Balloon() {
}
void Balloon::SetPosition(const gfx::Point& upper_left, bool reposition) {
position_ = upper_left;
if (reposition && balloon_view_.get())
balloon_view_->RepositionToBalloon();
}
void Balloon::SetContentPreferredSize(const gfx::Size& size) {
collection_->ResizeBalloon(this, size);
}
void Balloon::set_view(BalloonView* balloon_view) {
balloon_view_.reset(balloon_view);
}
void Balloon::Show() {
notification_.Display();
if (balloon_view_.get()) {
balloon_view_->Show(this);
}
}
void Balloon::OnClose(bool by_user) {
notification_.Close(by_user);
collection_->OnBalloonClosed(this);
}
void Balloon::CloseByScript() {
// A user-initiated close begins with the view and then closes this object;
// we simulate that with a script-initiated close but pass |by_user|=false.
DCHECK(balloon_view_.get());
balloon_view_->Close(false);
}
|