summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/volume_bubble.h
blob: c2da38e37ce788b90af95c44205d663c1c794c59 (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
54
55
56
57
58
59
60
61
// Copyright (c) 2010 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 CHROME_BROWSER_CHROMEOS_VOLUME_BUBBLE_H_
#define CHROME_BROWSER_CHROMEOS_VOLUME_BUBBLE_H_
#pragma once

#include "app/slide_animation.h"
#include "base/singleton.h"
#include "chrome/browser/views/info_bubble.h"

namespace chromeos {

class VolumeBubbleView;

// Singleton class controlling volume bubble.
class VolumeBubble : public InfoBubbleDelegate,
                     public AnimationDelegate {
 public:
  static VolumeBubble* instance() {
    return Singleton<VolumeBubble>::get();
  }

  void ShowVolumeBubble(int percent);

 private:
  friend struct DefaultSingletonTraits<VolumeBubble>;

  VolumeBubble();
  void OnTimeout();

  // Overridden from InfoBubbleDelegate.
  virtual void InfoBubbleClosing(InfoBubble* info_bubble,
                                 bool closed_by_escape);
  virtual bool CloseOnEscape() { return true; }
  virtual bool FadeInOnShow() { return false; }

  // Overridden from AnimationDelegate.
  virtual void AnimationEnded(const Animation* animation);
  virtual void AnimationProgressed(const Animation* animation);

  // Previous and current volume percentages, -1 if not yet shown.
  int previous_percent_;
  int current_percent_;

  // Currently shown bubble or NULL.
  InfoBubble* bubble_;

  // Its contents view, owned by InfoBubble.
  VolumeBubbleView* view_;

  SlideAnimation animation_;
  base::OneShotTimer<VolumeBubble> timeout_timer_;

  DISALLOW_COPY_AND_ASSIGN(VolumeBubble);
};

}  // namespace

#endif  // CHROME_BROWSER_CHROMEOS_VOLUME_BUBBLE_H_