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

Side by Side Diff: chrome/browser/chromeos/login/helper.cc

Issue 5964004: Use WINDOW instead of BUBBLE for the throbber widget. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/browser/chromeos/login
Patch Set: merged Created 9 years, 12 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/login/helper.h" 5 #include "chrome/browser/chromeos/login/helper.h"
6 6
7 #include "app/resource_bundle.h" 7 #include "app/resource_bundle.h"
8 #include "chrome/browser/google/google_util.h" 8 #include "chrome/browser/google/google_util.h"
9 #include "gfx/canvas_skia.h" 9 #include "gfx/canvas_skia.h"
10 #include "googleurl/src/gurl.h" 10 #include "googleurl/src/gurl.h"
11 #include "grit/theme_resources.h" 11 #include "grit/theme_resources.h"
12 #include "third_party/skia/include/effects/SkGradientShader.h" 12 #include "third_party/skia/include/effects/SkGradientShader.h"
13 #include "views/controls/button/menu_button.h" 13 #include "views/controls/button/menu_button.h"
14 #include "views/controls/button/native_button.h" 14 #include "views/controls/button/native_button.h"
15 #include "views/controls/label.h" 15 #include "views/controls/label.h"
16 #include "views/controls/textfield/textfield.h" 16 #include "views/controls/textfield/textfield.h"
17 #include "views/controls/throbber.h" 17 #include "views/controls/throbber.h"
18 #include "views/painter.h" 18 #include "views/painter.h"
19 #include "views/screen.h" 19 #include "views/screen.h"
20 #include "views/widget/widget.h" 20 #include "views/widget/widget.h"
21 #include "views/widget/widget_gtk.h"
21 22
22 namespace chromeos { 23 namespace chromeos {
23 24
24 namespace { 25 namespace {
25 26
26 // Time in ms per throbber frame. 27 // Time in ms per throbber frame.
27 const int kThrobberFrameMs = 60; 28 const int kThrobberFrameMs = 60;
28 29
29 // Time in ms before smoothed throbber is shown. 30 // Time in ms before smoothed throbber is shown.
30 const int kThrobberStartDelayMs = 500; 31 const int kThrobberStartDelayMs = 500;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 : host_view_(this), 73 : host_view_(this),
73 throbber_widget_(NULL) { 74 throbber_widget_(NULL) {
74 } 75 }
75 76
76 ThrobberHostView::~ThrobberHostView() { 77 ThrobberHostView::~ThrobberHostView() {
77 StopThrobber(); 78 StopThrobber();
78 } 79 }
79 80
80 void ThrobberHostView::StartThrobber() { 81 void ThrobberHostView::StartThrobber() {
81 StopThrobber(); 82 StopThrobber();
82 views::Widget* widget = host_view_->GetWidget();
83 if (widget) {
84 views::SmoothedThrobber* throbber = CreateDefaultSmoothedThrobber();
85 throbber->set_stop_delay_ms(0);
86 gfx::Rect throbber_bounds = CalculateThrobberBounds(throbber);
87 83
88 throbber_widget_ = 84 views::Widget* host_widget = host_view_->GetWidget();
89 views::Widget::CreatePopupWidget(views::Widget::Transparent, 85 if (!host_widget) {
90 views::Widget::NotAcceptEvents, 86 LOG(WARNING) << "Failed to start the throbber: no Widget";
91 views::Widget::DeleteOnDestroy, 87 return;
92 views::Widget::DontMirrorOriginInRTL);
93 throbber_bounds.Offset(host_view_->GetScreenBounds().origin());
94 throbber_widget_->InitWithWidget(widget, throbber_bounds);
95 throbber_widget_->SetContentsView(throbber);
96 throbber_widget_->Show();
97 throbber->Start();
98 } 88 }
89
90 GtkWidget* host_gtk_window = host_widget->GetNativeView();
91 while (host_gtk_window && !GTK_IS_WINDOW(host_gtk_window))
92 host_gtk_window = gtk_widget_get_parent(host_gtk_window);
93 if (!host_gtk_window) {
94 LOG(WARNING) << "Failed to start the throbber: no GtkWindow";
95 return;
96 }
97
98 views::SmoothedThrobber* throbber = CreateDefaultSmoothedThrobber();
99 throbber->set_stop_delay_ms(0);
100 gfx::Rect throbber_bounds = CalculateThrobberBounds(throbber);
101
102 views::WidgetGtk* widget_gtk =
103 new views::WidgetGtk(views::WidgetGtk::TYPE_WINDOW);
104 widget_gtk->make_transient_to_parent();
105 widget_gtk->MakeTransparent();
106 throbber_widget_ = widget_gtk;
107
108 throbber_bounds.Offset(host_view_->GetScreenBounds().origin());
109 throbber_widget_->Init(host_gtk_window, throbber_bounds);
110 throbber_widget_->SetContentsView(throbber);
111 throbber_widget_->Show();
112 // WM can ignore bounds before widget is shown.
113 throbber_widget_->SetBounds(throbber_bounds);
114 throbber->Start();
99 } 115 }
100 116
101 void ThrobberHostView::StopThrobber() { 117 void ThrobberHostView::StopThrobber() {
102 if (throbber_widget_) { 118 if (throbber_widget_) {
103 throbber_widget_->Close(); 119 throbber_widget_->Close();
104 throbber_widget_ = NULL; 120 throbber_widget_ = NULL;
105 } 121 }
106 } 122 }
107 123
108 gfx::Rect ThrobberHostView::CalculateThrobberBounds(views::Throbber* throbber) { 124 gfx::Rect ThrobberHostView::CalculateThrobberBounds(views::Throbber* throbber) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 gfx::Size preferred_size = NativeButton::GetPreferredSize(); 189 gfx::Size preferred_size = NativeButton::GetPreferredSize();
174 // Set minimal width. 190 // Set minimal width.
175 if (preferred_size.width() < kButtonMinWidth) 191 if (preferred_size.width() < kButtonMinWidth)
176 preferred_size.set_width(kButtonMinWidth); 192 preferred_size.set_width(kButtonMinWidth);
177 return preferred_size; 193 return preferred_size;
178 } 194 }
179 195
180 } // namespace login 196 } // namespace login
181 197
182 } // namespace chromeos 198 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698