Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(451)

Side by Side Diff: chrome/browser/chromeos/volume_bubble.cc

Issue 8319008: aura: brightness and volume bubble. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: update, and added tests. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/volume_bubble.h" 5 #include "chrome/browser/chromeos/volume_bubble.h"
6 6
7 #include "base/memory/singleton.h" 7 #include "base/memory/singleton.h"
8 #include "grit/theme_resources.h" 8 #include "grit/theme_resources.h"
9 #include "ui/base/resource/resource_bundle.h" 9 #include "ui/base/resource/resource_bundle.h"
10 #include "views/widget/widget.h"
10 11
11 namespace chromeos { 12 namespace chromeos {
12 13
13 VolumeBubble::VolumeBubble()
14 : SettingLevelBubble(
15 ResourceBundle::GetSharedInstance().GetBitmapNamed(
16 IDR_VOLUME_BUBBLE_UP_ICON),
17 ResourceBundle::GetSharedInstance().GetBitmapNamed(
18 IDR_VOLUME_BUBBLE_DOWN_ICON),
19 ResourceBundle::GetSharedInstance().GetBitmapNamed(
20 IDR_VOLUME_BUBBLE_MUTE_ICON)) {
21 }
22
23 // static 14 // static
24 VolumeBubble* VolumeBubble::GetInstance() { 15 VolumeBubble* VolumeBubble::GetInstance() {
25 return Singleton<VolumeBubble>::get(); 16 return Singleton<VolumeBubble>::get();
26 } 17 }
27 18
19 void VolumeBubble::OnWidgetClosing(views::Widget* widget) {
20 // Bubble faded out.
21 if (widget_ == widget)
22 widget_closed_ = true;
23 }
24
25 void VolumeBubble::ShowBubble(double percent, bool enabled) {
26 if (widget_closed_ || !widget_) {
27 widget_ = SettingLevelBubble::CreateBubble(
28 ResourceBundle::GetSharedInstance().GetBitmapNamed(
29 IDR_VOLUME_BUBBLE_UP_ICON),
30 ResourceBundle::GetSharedInstance().GetBitmapNamed(
31 IDR_VOLUME_BUBBLE_DOWN_ICON),
32 ResourceBundle::GetSharedInstance().GetBitmapNamed(
33 IDR_VOLUME_BUBBLE_MUTE_ICON),
34 percent,
35 enabled);
36 widget_->AddObserver(this);
37 widget_closed_ = false;
38 }
39 SettingLevelBubble::ShowBubble(widget_, percent, enabled);
40 }
41
42 void VolumeBubble::HideBubble() {
43 if (widget_ && !widget_closed_) {
44 widget_->RemoveObserver(this);
45 widget_->Close();
46 widget_closed_ = true;
47 }
48 }
49
50 VolumeBubble::VolumeBubble()
51 : widget_(NULL),
52 widget_closed_(false) {}
53
54 VolumeBubble::~VolumeBubble() {
55 if (widget_ && !widget_closed_) {
56 widget_->RemoveObserver(this);
57 widget_closed_ = true;
58 widget_ = NULL;
59 }
60 }
61
28 } // namespace chromeos 62 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698