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

Unified Diff: chrome/browser/chromeos/brightness_bubble.cc

Issue 8319008: aura: brightness and volume bubble. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: update the icon Created 9 years, 2 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/brightness_bubble.cc
diff --git a/chrome/browser/chromeos/brightness_bubble.cc b/chrome/browser/chromeos/brightness_bubble.cc
index 7c149aacde2b3e23cb1fcf20960756688df41a0c..68b91f3300da3f405aa1c4bbd30846ec53cd8ae5 100644
--- a/chrome/browser/chromeos/brightness_bubble.cc
+++ b/chrome/browser/chromeos/brightness_bubble.cc
@@ -7,22 +7,65 @@
#include "base/memory/singleton.h"
#include "grit/theme_resources.h"
#include "ui/base/resource/resource_bundle.h"
+#include "views/widget/widget.h"
namespace chromeos {
-BrightnessBubble::BrightnessBubble()
- : SettingLevelBubble(
- ResourceBundle::GetSharedInstance().GetBitmapNamed(
- IDR_BRIGHTNESS_BUBBLE_ICON),
- ResourceBundle::GetSharedInstance().GetBitmapNamed(
- IDR_BRIGHTNESS_BUBBLE_ICON),
- ResourceBundle::GetSharedInstance().GetBitmapNamed(
- IDR_BRIGHTNESS_BUBBLE_ICON)) {
-}
-
// static
BrightnessBubble* BrightnessBubble::GetInstance() {
return Singleton<BrightnessBubble>::get();
}
+void BrightnessBubble::OnWidgetClosing(views::Widget* widget) {
+ // Bubble faded out.
+ if (widget_ == widget)
+ widget_closed_ = true;
+}
+
+void BrightnessBubble::ShowBubble(double percent, bool enabled) {
+ if (!widget_ || widget_closed_) {
Daniel Erat 2011/10/21 18:24:34 are you leaking widget_ in the closed case? if it
alicet1 2011/10/24 15:46:38 the latter, this bubble shouldnt need to delete. r
+ widget_ = SettingLevelBubble::CreateBubble(
+ ResourceBundle::GetSharedInstance().GetBitmapNamed(
+ IDR_BRIGHTNESS_BUBBLE_ICON),
+ ResourceBundle::GetSharedInstance().GetBitmapNamed(
+ IDR_BRIGHTNESS_BUBBLE_ICON),
+ ResourceBundle::GetSharedInstance().GetBitmapNamed(
+ IDR_BRIGHTNESS_BUBBLE_ICON),
+ percent,
+ enabled);
+ widget_->AddObserver(this);
+ widget_closed_ = false;
+ }
+ if (!widget_closed_) {
Daniel Erat 2011/10/21 18:24:34 how can widget_closed_ ever be true here?
alicet1 2011/10/24 15:46:38 removed.
+ SettingLevelBubble::ShowBubble(widget_, percent, enabled);
+ }
+}
+
+void BrightnessBubble::UpdateWithoutShowingBubble(double percent,
+ bool enabled) {
+ if (widget_)
+ static_cast<SettingLevelBubble*>(widget_->widget_delegate())
+ ->UpdateWithoutShowingBubble(percent, enabled);
+}
+
+void BrightnessBubble::HideBubble() {
+ if (widget_) {
+ widget_->RemoveObserver(this);
+ widget_->Close();
+ widget_closed_ = true;
+ }
+}
+
+BrightnessBubble::BrightnessBubble()
+ : widget_(NULL),
+ widget_closed_(false) {}
+
+BrightnessBubble::~BrightnessBubble() {
+ if (widget_) {
+ widget_->RemoveObserver(this);
+ delete widget_;
msw 2011/10/22 00:44:48 Should |widget_| be closed first? I actually don't
alicet1 2011/10/24 15:46:38 actually, just need to set widget_ to null.
+ widget_ = NULL;
+ }
+}
+
} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698