cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / ash / system / tray / throbber_view.cc
blob6ec1f8dc94323c1e652a0b96570439f4418c9f0a
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ash/system/tray/throbber_view.h"
7 #include "ash/system/tray/tray_constants.h"
8 #include "grit/ash_resources.h"
9 #include "ui/base/resource/resource_bundle.h"
10 #include "ui/compositor/layer.h"
11 #include "ui/compositor/scoped_layer_animation_settings.h"
13 namespace ash {
14 namespace {
16 // Duration for showing/hiding animation in milliseconds.
17 const int kThrobberAnimationDurationMs = 200;
19 } // namespace
21 SystemTrayThrobber::SystemTrayThrobber() : views::SmoothedThrobber() {
24 SystemTrayThrobber::~SystemTrayThrobber() {
27 void SystemTrayThrobber::SetTooltipText(const base::string16& tooltip_text) {
28 tooltip_text_ = tooltip_text;
31 bool SystemTrayThrobber::GetTooltipText(const gfx::Point& p,
32 base::string16* tooltip) const {
33 if (tooltip_text_.empty())
34 return false;
36 *tooltip = tooltip_text_;
37 return true;
40 ThrobberView::ThrobberView() {
41 throbber_ = new SystemTrayThrobber();
42 throbber_->set_stop_delay_ms(kThrobberAnimationDurationMs);
43 AddChildView(throbber_);
45 SetPaintToLayer(true);
46 layer()->SetFillsBoundsOpaquely(false);
47 layer()->SetOpacity(0.0);
50 ThrobberView::~ThrobberView() {
53 gfx::Size ThrobberView::GetPreferredSize() const {
54 return gfx::Size(ash::kTrayPopupItemHeight, ash::kTrayPopupItemHeight);
57 void ThrobberView::Layout() {
58 View* child = child_at(0);
59 gfx::Size ps = child->GetPreferredSize();
60 child->SetBounds((width() - ps.width()) / 2,
61 (height() - ps.height()) / 2,
62 ps.width(), ps.height());
63 SizeToPreferredSize();
66 bool ThrobberView::GetTooltipText(const gfx::Point& p,
67 base::string16* tooltip) const {
68 if (tooltip_text_.empty())
69 return false;
71 *tooltip = tooltip_text_;
72 return true;
75 void ThrobberView::Start() {
76 ScheduleAnimation(true);
77 throbber_->Start();
80 void ThrobberView::Stop() {
81 ScheduleAnimation(false);
82 throbber_->Stop();
85 void ThrobberView::SetTooltipText(const base::string16& tooltip_text) {
86 tooltip_text_ = tooltip_text;
87 throbber_->SetTooltipText(tooltip_text);
90 void ThrobberView::ScheduleAnimation(bool start_throbber) {
91 // Stop any previous animation.
92 layer()->GetAnimator()->StopAnimating();
94 ui::ScopedLayerAnimationSettings animation(layer()->GetAnimator());
95 animation.SetTransitionDuration(
96 base::TimeDelta::FromMilliseconds(kThrobberAnimationDurationMs));
98 layer()->SetOpacity(start_throbber ? 1.0 : 0.0);
101 } // namespace ash