Index: chrome/browser/chromeos/login/helper.cc |
diff --git a/chrome/browser/chromeos/login/helper.cc b/chrome/browser/chromeos/login/helper.cc |
index 1b7ebbaaaeabee35eb8cfcd7dd0c3b05bcfe8b21..a1c609723dc6211aedb006200d082c8e0c7c30bd 100644 |
--- a/chrome/browser/chromeos/login/helper.cc |
+++ b/chrome/browser/chromeos/login/helper.cc |
@@ -17,6 +17,7 @@ |
#include "views/controls/throbber.h" |
#include "views/painter.h" |
#include "views/screen.h" |
+#include "views/widget/widget.h" |
namespace chromeos { |
@@ -67,6 +68,59 @@ class BackgroundPainter : public views::Painter { |
} // namespace |
+ThrobberManager::ThrobberManager() : throbber_widget_(NULL) { |
+} |
+ |
+ThrobberManager::~ThrobberManager() { |
+ Stop(); |
+} |
+ |
+void ThrobberManager::StartShow(views::Widget* host, |
+ views::Throbber* throbber, |
+ int right_shift) { |
+ if (throbber_widget_) { |
+ delete throbber; |
+ return; |
whywhat
2010/12/09 16:20:18
Shouldn't this be a check? Also, why delete throbb
altimofeev
2010/12/10 16:37:40
Changed the behavior. Now, previously created thro
|
+ } |
+ |
+ gfx::Rect host_bounds; |
+ host->GetBounds(&host_bounds, false); |
+ gfx::Rect bounds(throbber->GetPreferredSize()); |
+ bounds.set_x(host_bounds.width() - right_shift - bounds.width()); |
+ bounds.set_y((host_bounds.height() - bounds.height()) / 2); |
+ StartShow(host, throbber, bounds); |
+} |
+ |
+void ThrobberManager::StartShow(views::Widget* host, |
+ views::Throbber* throbber, |
+ const gfx::Rect relative_bounds) { |
+ if (throbber_widget_) { |
+ delete throbber; |
+ return; |
+ } |
+ |
+ throbber_widget_ = |
+ views::Widget::CreatePopupWidget(views::Widget::Transparent, |
+ views::Widget::NotAcceptEvents, |
+ views::Widget::DeleteOnDestroy, |
+ views::Widget::DontMirrorOriginInRTL); |
+ gfx::Rect host_bounds; |
+ host->GetBounds(&host_bounds, false); |
+ gfx::Rect bounds = relative_bounds; |
+ bounds.Offset(host_bounds.origin()); |
+ throbber_widget_->InitWithWidget(host, bounds); |
+ throbber_widget_->SetContentsView(throbber); |
+ throbber_widget_->Show(); |
+ throbber->Start(); |
+} |
+ |
+void ThrobberManager::Stop() { |
+ if (throbber_widget_) { |
+ throbber_widget_->Close(); |
whywhat
2010/12/09 16:20:18
So we delete it in Start, but Close in Stop? Why t
altimofeev
2010/12/10 16:37:40
In Start we have been deleting |throbber| which wa
|
+ throbber_widget_ = NULL; |
+ } |
+} |
+ |
views::Throbber* CreateDefaultSmoothedThrobber() { |
views::SmoothedThrobber* throbber = |
new views::SmoothedThrobber(kThrobberFrameMs); |
@@ -138,4 +192,3 @@ gfx::Size WideButton::GetPreferredSize() { |
} // namespace login |
} // namespace chromeos |
- |