Remove unused parameter.
[chromium-blink-merge.git] / ui / message_center / views / message_bubble_base.cc
blob3f1755abe4160d0d9832d64d015ed199b374c2b0
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.
5 #include "ui/message_center/views/message_bubble_base.h"
7 #include "base/bind.h"
8 #include "ui/message_center/message_center_style.h"
9 #include "ui/views/widget/widget.h"
10 #include "ui/views/widget/widget_observer.h"
12 namespace {
13 // Delay laying out the MessageBubbleBase until all notifications have been
14 // added and icons have had a chance to load.
15 const int kUpdateDelayMs = 50;
16 const int kMessageBubbleBaseDefaultMaxHeight = 400;
19 namespace message_center {
21 const SkColor MessageBubbleBase::kBackgroundColor =
22 SkColorSetRGB(0xfe, 0xfe, 0xfe);
24 MessageBubbleBase::MessageBubbleBase(MessageCenter* message_center,
25 MessageCenterTray* tray)
26 : message_center_(message_center),
27 tray_(tray),
28 bubble_view_(NULL),
29 max_height_(kMessageBubbleBaseDefaultMaxHeight),
30 weak_ptr_factory_(this) {
33 MessageBubbleBase::~MessageBubbleBase() {
34 if (bubble_view_)
35 bubble_view_->reset_delegate();
38 void MessageBubbleBase::BubbleViewDestroyed() {
39 bubble_view_ = NULL;
40 OnBubbleViewDestroyed();
43 void MessageBubbleBase::ScheduleUpdate() {
44 weak_ptr_factory_.InvalidateWeakPtrs(); // Cancel any pending update.
45 base::MessageLoop::current()->PostDelayedTask(
46 FROM_HERE,
47 base::Bind(&MessageBubbleBase::UpdateBubbleView,
48 weak_ptr_factory_.GetWeakPtr()),
49 base::TimeDelta::FromMilliseconds(kUpdateDelayMs));
52 bool MessageBubbleBase::IsVisible() const {
53 return bubble_view() && bubble_view()->GetWidget()->IsVisible();
56 void MessageBubbleBase::SetMaxHeight(int height) {
57 // Maximum height makes sense only for the new design.
58 if (height == 0)
59 height = kMessageBubbleBaseDefaultMaxHeight;
60 if (height == max_height_)
61 return;
63 max_height_ = height;
64 if (bubble_view_)
65 bubble_view_->SetMaxHeight(max_height_);
68 views::TrayBubbleView::InitParams MessageBubbleBase::GetDefaultInitParams(
69 views::TrayBubbleView::AnchorAlignment anchor_alignment) {
70 views::TrayBubbleView::InitParams init_params(
71 views::TrayBubbleView::ANCHOR_TYPE_TRAY,
72 anchor_alignment,
73 kNotificationWidth,
74 kNotificationWidth);
75 init_params.arrow_color = kBackgroundDarkColor;
76 return init_params;
79 } // namespace message_center