File: message_bubble_base.h

package info (click to toggle)
chromium-browser 57.0.2987.98-1~deb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 2,637,852 kB
  • ctags: 2,544,394
  • sloc: cpp: 12,815,961; ansic: 3,676,222; python: 1,147,112; asm: 526,608; java: 523,212; xml: 286,794; perl: 92,654; sh: 86,408; objc: 73,271; makefile: 27,698; cs: 18,487; yacc: 13,031; tcl: 12,957; pascal: 4,875; ml: 4,716; lex: 3,904; sql: 3,862; ruby: 1,982; lisp: 1,508; php: 1,368; exp: 404; awk: 325; csh: 117; jsp: 39; sed: 37
file content (83 lines) | stat: -rw-r--r-- 2,801 bytes parent folder | download
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Copyright (c) 2012 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.

#ifndef UI_MESSAGE_CENTER_VIEWS_MESSAGE_BUBBLE_BASE_H_
#define UI_MESSAGE_CENTER_VIEWS_MESSAGE_BUBBLE_BASE_H_

#include <memory>

#include "base/macros.h"
#include "ui/message_center/message_center.h"
#include "ui/message_center/message_center_export.h"
#include "ui/views/bubble/tray_bubble_view.h"

namespace message_center {
class MessageCenterTray;

class MESSAGE_CENTER_EXPORT MessageBubbleBase {
 public:
  MessageBubbleBase(MessageCenter* message_center, MessageCenterTray* tray);

  virtual ~MessageBubbleBase();

  // Gets called when the bubble view associated with this bubble is
  // destroyed. Clears |bubble_view_| and calls OnBubbleViewDestroyed.
  void BubbleViewDestroyed();

  // Sets/Gets the maximum height of the bubble view. Setting 0 changes the
  // bubble to the default size. max_height() will return the default size
  // if SetMaxHeight() has not been called yet.
  void SetMaxHeight(int height);
  int max_height() const { return max_height_; }

  // Gets the init params for the implementation.
  virtual views::TrayBubbleView::InitParams GetInitParams(
      views::TrayBubbleView::AnchorAlignment anchor_alignment) = 0;

  // Called after the bubble view has been constructed. Creates and initializes
  // the bubble contents.
  virtual void InitializeContents(views::TrayBubbleView* bubble_view) = 0;

  // Called from BubbleViewDestroyed for implementation specific details.
  virtual void OnBubbleViewDestroyed() = 0;

  // Updates the bubble; implementation dependent.
  virtual void UpdateBubbleView() = 0;

  // Called when the mouse enters/exists the view.
  virtual void OnMouseEnteredView() = 0;
  virtual void OnMouseExitedView() = 0;

  // Schedules bubble for layout after all notifications have been
  // added and icons have had a chance to load.
  void ScheduleUpdate();

  bool IsVisible() const;

  views::TrayBubbleView* bubble_view() const { return bubble_view_; }

  static const SkColor kBackgroundColor;

 protected:
  views::TrayBubbleView::InitParams GetDefaultInitParams(
      views::TrayBubbleView::AnchorAlignment anchor_alignment);
  MessageCenter* message_center() { return message_center_; }
  MessageCenterTray* tray() { return tray_; }
  void set_bubble_view(views::TrayBubbleView* bubble_view) {
    bubble_view_ = bubble_view;
  }

 private:
  MessageCenter* message_center_;
  MessageCenterTray* tray_;
  views::TrayBubbleView* bubble_view_;
  int max_height_;
  base::WeakPtrFactory<MessageBubbleBase> weak_ptr_factory_;

  DISALLOW_COPY_AND_ASSIGN(MessageBubbleBase);
};

}  // namespace message_center

#endif // UI_MESSAGE_CENTER_VIEWS_MESSAGE_BUBBLE_BASE_H_