Chromium Code Reviews| 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/bubble/bubble_view.h" | |
| 11 #include "views/widget/widget.h" | |
| 10 | 12 |
| 11 namespace chromeos { | 13 namespace chromeos { |
| 12 | 14 |
| 13 VolumeBubble::VolumeBubble() | 15 VolumeBubble::VolumeBubble() : widget_(NULL) {} |
| 14 : SettingLevelBubble( | 16 |
| 15 ResourceBundle::GetSharedInstance().GetBitmapNamed( | 17 VolumeBubble::~VolumeBubble() { |
| 16 IDR_VOLUME_BUBBLE_UP_ICON), | 18 if (widget_) |
| 17 ResourceBundle::GetSharedInstance().GetBitmapNamed( | 19 delete widget_; |
| 18 IDR_VOLUME_BUBBLE_DOWN_ICON), | 20 } |
| 19 ResourceBundle::GetSharedInstance().GetBitmapNamed( | 21 |
| 20 IDR_VOLUME_BUBBLE_MUTE_ICON)) { | 22 void VolumeBubble::ShowBubble(double percent, bool enabled) { |
| 23 if (!widget_) { | |
| 24 widget_= SettingLevelBubble::CreateSettingLevelBubble( | |
| 25 ResourceBundle::GetSharedInstance().GetBitmapNamed( | |
| 26 IDR_VOLUME_BUBBLE_UP_ICON), | |
| 27 ResourceBundle::GetSharedInstance().GetBitmapNamed( | |
| 28 IDR_VOLUME_BUBBLE_DOWN_ICON), | |
| 29 ResourceBundle::GetSharedInstance().GetBitmapNamed( | |
| 30 IDR_VOLUME_BUBBLE_MUTE_ICON), | |
| 31 percent, | |
| 32 enabled); | |
| 33 } else { | |
| 34 static_cast<SettingLevelBubble*>(widget_->widget_delegate()) | |
|
Daniel Erat
2011/10/20 15:43:39
i think that there's a decent amount of duplicated
alicet1
2011/10/20 22:36:30
moved.
| |
| 35 ->UpdateSetting(percent, enabled); | |
| 36 } | |
| 37 // Starts a new fade out animation and show. | |
| 38 widget_->client_view()->AsBubbleView()->StartFade(/*fade_in=*/false); | |
| 39 static_cast<SettingLevelBubble*>(widget_->widget_delegate()) | |
| 40 ->StartHideTimer(); | |
| 41 } | |
| 42 | |
| 43 void VolumeBubble::HideBubble() { | |
|
msw
2011/10/20 19:36:13
Is this used at all?
alicet1
2011/10/20 22:36:30
ya. in brightness_observer.cc BrightnessChanged. I
| |
| 44 if (widget_) | |
| 45 widget_->Close(); | |
| 21 } | 46 } |
| 22 | 47 |
| 23 // static | 48 // static |
| 24 VolumeBubble* VolumeBubble::GetInstance() { | 49 VolumeBubble* VolumeBubble::GetInstance() { |
| 25 return Singleton<VolumeBubble>::get(); | 50 return Singleton<VolumeBubble>::get(); |
| 26 } | 51 } |
| 27 | 52 |
| 28 } // namespace chromeos | 53 } // namespace chromeos |
| OLD | NEW |