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..500b83d433e28fe9f154d684b731bcd79d505aaf 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,49 @@ class BackgroundPainter : public views::Painter { |
} // namespace |
+ThrobberHost::ThrobberHost(views::View* host_view) |
+ : host_view_(host_view), throbber_widget_(NULL) { |
whywhat
2010/12/13 16:10:55
Add two spaces in front of : and put the second me
altimofeev
2010/12/14 11:15:21
Done.
|
+} |
+ |
+ThrobberHost::~ThrobberHost() { |
+ StopThrobber(); |
+} |
+ |
+void ThrobberHost::StartThrobber() { |
+ StopThrobber(); |
+ views::Widget* widget = host_view_->GetWidget(); |
+ if (widget) { |
+ views::Throbber* throbber = CreateDefaultSmoothedThrobber(); |
+ 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 ThrobberHost::StopThrobber() { |
+ if (throbber_widget_) { |
+ throbber_widget_->Close(); |
+ throbber_widget_ = NULL; |
+ } |
+} |
+ |
+gfx::Rect ThrobberHost::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::Throbber* CreateDefaultSmoothedThrobber() { |
views::SmoothedThrobber* throbber = |
new views::SmoothedThrobber(kThrobberFrameMs); |
@@ -94,7 +138,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 +181,3 @@ gfx::Size WideButton::GetPreferredSize() { |
} // namespace login |
} // namespace chromeos |
- |