OLD | NEW |
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 views::Widget* VolumeBubble::widget_ = NULL; |
14 : SettingLevelBubble( | 15 |
15 ResourceBundle::GetSharedInstance().GetBitmapNamed( | 16 VolumeBubble::VolumeBubble() {} |
16 IDR_VOLUME_BUBBLE_UP_ICON), | 17 |
17 ResourceBundle::GetSharedInstance().GetBitmapNamed( | 18 void VolumeBubble::ShowBubble(double percent, bool enabled) { |
18 IDR_VOLUME_BUBBLE_DOWN_ICON), | 19 if (!widget_) { |
19 ResourceBundle::GetSharedInstance().GetBitmapNamed( | 20 widget_= SettingLevelBubble::ConstructSettingLevelBubble( |
20 IDR_VOLUME_BUBBLE_MUTE_ICON)) { | 21 ResourceBundle::GetSharedInstance().GetBitmapNamed( |
| 22 IDR_VOLUME_BUBBLE_UP_ICON), |
| 23 ResourceBundle::GetSharedInstance().GetBitmapNamed( |
| 24 IDR_VOLUME_BUBBLE_DOWN_ICON), |
| 25 ResourceBundle::GetSharedInstance().GetBitmapNamed( |
| 26 IDR_VOLUME_BUBBLE_MUTE_ICON), |
| 27 percent, |
| 28 enabled); |
| 29 } else { |
| 30 static_cast<SettingLevelBubble*>(widget_->widget_delegate()) |
| 31 ->UpdateSettingLevelInternal(percent, enabled); |
| 32 } |
| 33 widget_->Show(); |
| 34 static_cast<SettingLevelBubble*>(widget_->widget_delegate()) |
| 35 ->StartHideTimer(); |
| 36 } |
| 37 |
| 38 void VolumeBubble::HideBubble() { |
| 39 if (widget_) |
| 40 widget_->Close(); |
21 } | 41 } |
22 | 42 |
23 // static | 43 // static |
24 VolumeBubble* VolumeBubble::GetInstance() { | 44 VolumeBubble* VolumeBubble::GetInstance() { |
25 return Singleton<VolumeBubble>::get(); | 45 return Singleton<VolumeBubble>::get(); |
26 } | 46 } |
27 | 47 |
28 } // namespace chromeos | 48 } // namespace chromeos |
OLD | NEW |