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

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: nits 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
« no previous file with comments | « chrome/browser/chromeos/login/helper.h ('k') | chrome/browser/chromeos/login/login_screen.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..188a3ceae6dece2c00feb075e13409ac891042e6 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,7 +68,52 @@ class BackgroundPainter : public views::Painter {
} // namespace
-views::Throbber* CreateDefaultSmoothedThrobber() {
+ThrobberHostView::ThrobberHostView()
+ : host_view_(this),
+ throbber_widget_(NULL) {
+}
+
+ThrobberHostView::~ThrobberHostView() {
+ StopThrobber();
+}
+
+void ThrobberHostView::StartThrobber() {
+ StopThrobber();
+ views::Widget* widget = host_view_->GetWidget();
+ if (widget) {
+ views::SmoothedThrobber* throbber = CreateDefaultSmoothedThrobber();
+ throbber->set_stop_delay_ms(0);
+ gfx::Rect throbber_bounds = CalculateThrobberBounds(throbber);
+
+ throbber_widget_ =
+ views::Widget::CreatePopupWidget(views::Widget::Transparent,
+ views::Widget::NotAcceptEvents,
+ views::Widget::DeleteOnDestroy,
+ views::Widget::DontMirrorOriginInRTL);
+ throbber_bounds.Offset(host_view_->GetScreenBounds().origin());
+ throbber_widget_->InitWithWidget(widget, throbber_bounds);
+ throbber_widget_->SetContentsView(throbber);
+ throbber_widget_->Show();
+ throbber->Start();
+ }
+}
+
+void ThrobberHostView::StopThrobber() {
+ if (throbber_widget_) {
+ throbber_widget_->Close();
+ throbber_widget_ = NULL;
+ }
+}
+
+gfx::Rect ThrobberHostView::CalculateThrobberBounds(views::Throbber* throbber) {
+ gfx::Rect bounds(throbber->GetPreferredSize());
+ bounds.set_x(
+ host_view_->width() - login::kThrobberRightMargin - bounds.width());
+ bounds.set_y((host_view_->height() - bounds.height()) / 2);
+ return bounds;
+}
+
+views::SmoothedThrobber* CreateDefaultSmoothedThrobber() {
views::SmoothedThrobber* throbber =
new views::SmoothedThrobber(kThrobberFrameMs);
throbber->SetFrames(
@@ -94,7 +140,6 @@ gfx::Rect CalculateScreenBounds(const gfx::Size& size) {
int vertical_diff = bounds.height() - size.height();
bounds.Inset(horizontal_diff / 2, vertical_diff / 2);
}
-
return bounds;
}
@@ -138,4 +183,3 @@ gfx::Size WideButton::GetPreferredSize() {
} // namespace login
} // namespace chromeos
-
« no previous file with comments | « chrome/browser/chromeos/login/helper.h ('k') | chrome/browser/chromeos/login/login_screen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698