| 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
|
| -
|
|
|