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

Unified Diff: chrome/browser/chromeos/login/helper.cc

Issue 5709001: Place the spinner in the right corner of the controls window. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/browser/chromeos/login
Patch Set: Merged with trunk. Created 10 years 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/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
-

Powered by Google App Engine
This is Rietveld 408576698