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

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: code review 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..343bfae83db1d694e2a3f6df3852b7f2e67346df 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,52 @@ class BackgroundPainter : public views::Painter {
} // namespace
+ThrobberManager::ThrobberManager() : throbber_widget_(NULL) {
+}
+
+ThrobberManager::~ThrobberManager() {
+ StopAndClose();
+}
+
+void ThrobberManager::CreateAndStart(views::Widget* host,
+ views::Throbber* throbber,
+ int right_margin) {
+ gfx::Rect host_bounds;
+ host->GetBounds(&host_bounds, false);
+ gfx::Rect bounds(throbber->GetPreferredSize());
+ bounds.set_x(host_bounds.width() - right_margin - bounds.width());
+ bounds.set_y((host_bounds.height() - bounds.height()) / 2);
+ CreateAndStart(host, throbber, bounds);
+}
+
+void ThrobberManager::CreateAndStart(views::Widget* host,
+ views::Throbber* throbber,
+ const gfx::Rect& relative_bounds) {
+ // Close the previously opened throbber (if any).
+ StopAndClose();
+
+ 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::StopAndClose() {
+ if (throbber_widget_) {
+ throbber_widget_->Close();
+ throbber_widget_ = NULL;
+ }
+}
+
views::Throbber* CreateDefaultSmoothedThrobber() {
views::SmoothedThrobber* throbber =
new views::SmoothedThrobber(kThrobberFrameMs);
@@ -138,4 +185,3 @@ gfx::Size WideButton::GetPreferredSize() {
} // namespace login
} // namespace chromeos
-

Powered by Google App Engine
This is Rietveld 408576698