diff options
author | flackr@chromium.org <flackr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-20 17:34:18 +0000 |
---|---|---|
committer | flackr@chromium.org <flackr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-20 17:34:18 +0000 |
commit | 97648ffce8ea8d9a3d2408e9c6d633a575ddfd76 (patch) | |
tree | 2928f95e4eb38d7989d22f51e1c104270be35f24 /ash/launcher | |
parent | 5426114610074f80dab6c33a25accab67f4223a4 (diff) | |
download | chromium_src-97648ffce8ea8d9a3d2408e9c6d633a575ddfd76.zip chromium_src-97648ffce8ea8d9a3d2408e9c6d633a575ddfd76.tar.gz chromium_src-97648ffce8ea8d9a3d2408e9c6d633a575ddfd76.tar.bz2 |
Revert 152221 - chromeos: Sync animation.
This was causing Linux ChromiumOS (dbg) browser_tests to fail with timeouts on several tests, identified with a local bisect.
- Pulse app list button while LauncherModel has STATUS_LOADING;
- Remove LauncherItemStatus::STATUS_IS_PENDING etc since it is no longer needed;
- ChromeLauncherController sets LauncherModel::STATUS_LOADING on starting and
watch for sync finish and pending extension install. It sets
LauncherModel::STATUS_NORMAL when sync is finished and there is no pending
extension install from sync, or when a maximum 60 seconds timeout since
turning on loading status;
BUG=129236
TEST=Verify sync animation after OOBE.
Review URL: https://chromiumcodereview.appspot.com/10829268
TBR=xiyuan@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10827420
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152352 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/launcher')
-rw-r--r-- | ash/launcher/app_list_button.cc | 98 | ||||
-rw-r--r-- | ash/launcher/app_list_button.h | 5 | ||||
-rw-r--r-- | ash/launcher/launcher_button.cc | 107 | ||||
-rw-r--r-- | ash/launcher/launcher_button.h | 12 | ||||
-rw-r--r-- | ash/launcher/launcher_model.cc | 12 | ||||
-rw-r--r-- | ash/launcher/launcher_model.h | 10 | ||||
-rw-r--r-- | ash/launcher/launcher_model_observer.h | 5 | ||||
-rw-r--r-- | ash/launcher/launcher_model_unittest.cc | 5 | ||||
-rw-r--r-- | ash/launcher/launcher_types.h | 5 | ||||
-rw-r--r-- | ash/launcher/launcher_view.cc | 53 | ||||
-rw-r--r-- | ash/launcher/launcher_view.h | 1 | ||||
-rw-r--r-- | ash/launcher/launcher_view_unittest.cc | 6 |
12 files changed, 178 insertions, 141 deletions
diff --git a/ash/launcher/app_list_button.cc b/ash/launcher/app_list_button.cc index d38fe22..14e80e5 100644 --- a/ash/launcher/app_list_button.cc +++ b/ash/launcher/app_list_button.cc @@ -4,113 +4,35 @@ #include "ash/launcher/app_list_button.h" -#include <vector> - #include "ash/launcher/launcher_button_host.h" -#include "ash/launcher/launcher_types.h" -#include "grit/ash_strings.h" -#include "grit/ui_resources.h" #include "ui/base/accessibility/accessible_view_state.h" -#include "ui/base/l10n/l10n_util.h" +#include "ui/base/animation/animation_delegate.h" +#include "ui/base/animation/throb_animation.h" #include "ui/base/resource/resource_bundle.h" #include "ui/compositor/layer.h" #include "ui/compositor/layer_animation_element.h" +#include "ui/compositor/layer_animation_observer.h" #include "ui/compositor/layer_animation_sequence.h" #include "ui/compositor/scoped_layer_animation_settings.h" +#include "ui/gfx/canvas.h" +#include "ui/gfx/image/image.h" +#include "ui/gfx/shadow_value.h" +#include "ui/gfx/skbitmap_operations.h" #include "ui/gfx/transform_util.h" +#include "ui/views/controls/image_view.h" namespace ash { -namespace internal { - -namespace { -const int kAnimationDurationInMs = 600; -const float kAnimationOpacity[] = { 0.4f, 0.8f, 0.4f }; -const float kAnimationScale[] = { 0.8f, 1.0f, 0.8f }; - -} // namespace +namespace internal { AppListButton::AppListButton(views::ButtonListener* listener, LauncherButtonHost* host) : views::ImageButton(listener), - host_(host) { - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - SetImage( - views::CustomButton::BS_NORMAL, - rb.GetImageNamed(IDR_AURA_LAUNCHER_ICON_APPLIST).ToImageSkia()); - SetImage( - views::CustomButton::BS_HOT, - rb.GetImageNamed(IDR_AURA_LAUNCHER_ICON_APPLIST_HOT). - ToImageSkia()); - SetImage( - views::CustomButton::BS_PUSHED, - rb.GetImageNamed(IDR_AURA_LAUNCHER_ICON_APPLIST_PUSHED). - ToImageSkia()); - SetAccessibleName(l10n_util::GetStringUTF16(IDS_AURA_APP_LIST_TITLE)); - SetSize(gfx::Size(kLauncherPreferredSize, kLauncherPreferredSize)); -} + host_(host) {} AppListButton::~AppListButton() { } -void AppListButton::StartLoadingAnimation() { - // The two animation set should have the same size. - DCHECK_EQ(arraysize(kAnimationOpacity), arraysize(kAnimationScale)); - - layer()->GetAnimator()->StopAnimating(); - - scoped_ptr<ui::LayerAnimationSequence> opacity_sequence( - new ui::LayerAnimationSequence()); - scoped_ptr<ui::LayerAnimationSequence> transform_sequence( - new ui::LayerAnimationSequence()); - - // The animations loop infinitely. - opacity_sequence->set_is_cyclic(true); - transform_sequence->set_is_cyclic(true); - - for (size_t i = 0; i < arraysize(kAnimationOpacity); ++i) { - opacity_sequence->AddElement( - ui::LayerAnimationElement::CreateOpacityElement( - kAnimationOpacity[i], - base::TimeDelta::FromMilliseconds(kAnimationDurationInMs))); - transform_sequence->AddElement( - ui::LayerAnimationElement::CreateTransformElement( - ui::GetScaleTransform(GetLocalBounds().CenterPoint(), - kAnimationScale[i]), - base::TimeDelta::FromMilliseconds(kAnimationDurationInMs))); - } - - ui::LayerAnimationElement::AnimatableProperties opacity_properties; - opacity_properties.insert(ui::LayerAnimationElement::OPACITY); - opacity_sequence->AddElement( - ui::LayerAnimationElement::CreatePauseElement( - opacity_properties, - base::TimeDelta::FromMilliseconds(kAnimationDurationInMs))); - - ui::LayerAnimationElement::AnimatableProperties transform_properties; - transform_properties.insert(ui::LayerAnimationElement::TRANSFORM); - transform_sequence->AddElement( - ui::LayerAnimationElement::CreatePauseElement( - transform_properties, - base::TimeDelta::FromMilliseconds(kAnimationDurationInMs))); - - std::vector<ui::LayerAnimationSequence*> animations; - // LayerAnimator::ScheduleTogether takes ownership of the sequences. - animations.push_back(opacity_sequence.release()); - animations.push_back(transform_sequence.release()); - layer()->GetAnimator()->ScheduleTogether(animations); -} - -void AppListButton::StopLoadingAnimation() { - layer()->GetAnimator()->StopAnimating(); - - ui::ScopedLayerAnimationSettings settings(layer()->GetAnimator()); - settings.SetTransitionDuration( - base::TimeDelta::FromMilliseconds(kAnimationDurationInMs)); - layer()->SetOpacity(1.0f); - layer()->SetTransform(ui::Transform()); -} - bool AppListButton::OnMousePressed(const ui::MouseEvent& event) { ImageButton::OnMousePressed(event); host_->PointerPressedOnButton(this, LauncherButtonHost::MOUSE, event); diff --git a/ash/launcher/app_list_button.h b/ash/launcher/app_list_button.h index 4d25254..ee18557 100644 --- a/ash/launcher/app_list_button.h +++ b/ash/launcher/app_list_button.h @@ -19,9 +19,6 @@ class AppListButton : public views::ImageButton { LauncherButtonHost* host); virtual ~AppListButton(); - void StartLoadingAnimation(); - void StopLoadingAnimation(); - protected: // View overrides: virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; @@ -42,4 +39,4 @@ class AppListButton : public views::ImageButton { } // namespace internal } // namespace ash -#endif // ASH_LAUNCHER_APP_LIST_BUTTON_H_ +#endif // ASH_LAUNCHER_LAUNCHER_BUTTON_H_ diff --git a/ash/launcher/launcher_button.cc b/ash/launcher/launcher_button.cc index c0d0685..b550d56d 100644 --- a/ash/launcher/launcher_button.cc +++ b/ash/launcher/launcher_button.cc @@ -5,6 +5,7 @@ #include "ash/launcher/launcher_button.h" #include <algorithm> +#include <vector> #include "ash/launcher/launcher_button_host.h" #include "grit/ui_resources.h" @@ -15,10 +16,14 @@ #include "ui/base/events.h" #include "ui/base/resource/resource_bundle.h" #include "ui/compositor/layer.h" +#include "ui/compositor/layer_animation_element.h" +#include "ui/compositor/layer_animation_observer.h" +#include "ui/compositor/layer_animation_sequence.h" #include "ui/compositor/scoped_layer_animation_settings.h" #include "ui/gfx/canvas.h" #include "ui/gfx/image/image.h" #include "ui/gfx/image/image_skia_operations.h" +#include "ui/gfx/transform_util.h" #include "ui/views/controls/image_view.h" namespace { @@ -95,6 +100,102 @@ class LauncherButton::BarView : public views::ImageView, }; //////////////////////////////////////////////////////////////////////////////// +// LauncherButton::IconPulseAnimation + +// IconPulseAnimation plays a pulse animation in a loop for given |icon_view|. +// It iterates through all animations, wait for one duration then starts again. +class LauncherButton::IconPulseAnimation { + public: + explicit IconPulseAnimation(IconView* icon_view) + : icon_view_(icon_view) { + SchedulePulseAnimations(); + } + virtual ~IconPulseAnimation() { + // Restore icon_view_ on destruction. + ScheduleRestoreAnimation(); + } + + private: + // Animation duration in millisecond. + static const int kAnimationDurationInMs; + + // Number of animations to run and animation parameters. + static const float kAnimationOpacity[]; + static const float kAnimationScale[]; + + // Schedules pulse animations. + void SchedulePulseAnimations(); + + // Schedule an animation to restore the view to normal state. + void ScheduleRestoreAnimation(); + + IconView* icon_view_; // Owned by views hierarchy of LauncherButton. + + DISALLOW_COPY_AND_ASSIGN(IconPulseAnimation); +}; + +// static +const int LauncherButton::IconPulseAnimation::kAnimationDurationInMs = 600; +const float LauncherButton::IconPulseAnimation::kAnimationOpacity[] = + { 0.4f, 0.8f }; +const float LauncherButton::IconPulseAnimation::kAnimationScale[] = + { 0.8f, 1.0f }; + +void LauncherButton::IconPulseAnimation::SchedulePulseAnimations() { + // The two animation set should have the same size. + DCHECK(arraysize(kAnimationOpacity) == arraysize(kAnimationScale)); + + scoped_ptr<ui::LayerAnimationSequence> opacity_sequence( + new ui::LayerAnimationSequence()); + scoped_ptr<ui::LayerAnimationSequence> transform_sequence( + new ui::LayerAnimationSequence()); + + // The animations loop infinitely. + opacity_sequence->set_is_cyclic(true); + transform_sequence->set_is_cyclic(true); + + for (size_t i = 0; i < arraysize(kAnimationOpacity); ++i) { + opacity_sequence->AddElement( + ui::LayerAnimationElement::CreateOpacityElement( + kAnimationOpacity[i], + base::TimeDelta::FromMilliseconds(kAnimationDurationInMs))); + transform_sequence->AddElement( + ui::LayerAnimationElement::CreateTransformElement( + ui::GetScaleTransform(icon_view_->GetLocalBounds().CenterPoint(), + kAnimationScale[i]), + base::TimeDelta::FromMilliseconds(kAnimationDurationInMs))); + } + + ui::LayerAnimationElement::AnimatableProperties opacity_properties; + opacity_properties.insert(ui::LayerAnimationElement::OPACITY); + opacity_sequence->AddElement( + ui::LayerAnimationElement::CreatePauseElement( + opacity_properties, + base::TimeDelta::FromMilliseconds(kAnimationDurationInMs))); + + ui::LayerAnimationElement::AnimatableProperties transform_properties; + transform_properties.insert(ui::LayerAnimationElement::TRANSFORM); + transform_sequence->AddElement( + ui::LayerAnimationElement::CreatePauseElement( + transform_properties, + base::TimeDelta::FromMilliseconds(kAnimationDurationInMs))); + + std::vector<ui::LayerAnimationSequence*> animations; + // LayerAnimator::ScheduleTogether takes ownership of the sequences. + animations.push_back(opacity_sequence.release()); + animations.push_back(transform_sequence.release()); + icon_view_->layer()->GetAnimator()->ScheduleTogether(animations); +} + +// Schedule an animation to restore the view to normal state. +void LauncherButton::IconPulseAnimation::ScheduleRestoreAnimation() { + ui::Layer* layer = icon_view_->layer(); + ui::ScopedLayerAnimationSettings settings(layer->GetAnimator()); + layer->SetOpacity(1.0f); + layer->SetTransform(ui::Transform()); +} + +//////////////////////////////////////////////////////////////////////////////// // LauncherButton::IconView LauncherButton::IconView::IconView() : icon_size_(kIconSize) { @@ -192,6 +293,8 @@ void LauncherButton::AddState(State state) { } if (state & STATE_ATTENTION) bar_->ShowAttention(true); + if (state & STATE_PENDING) + icon_pulse_animation_.reset(new IconPulseAnimation(icon_view_)); } } @@ -211,6 +314,8 @@ void LauncherButton::ClearState(State state) { } if (state & STATE_ATTENTION) bar_->ShowAttention(false); + if (state & STATE_PENDING) + icon_pulse_animation_.reset(); } } @@ -356,7 +461,7 @@ bool LauncherButton::IsShelfHorizontal() const { } void LauncherButton::UpdateState() { - if (state_ == STATE_NORMAL) { + if (state_ == STATE_NORMAL || state_ & STATE_PENDING) { bar_->SetVisible(false); } else { int bar_id; diff --git a/ash/launcher/launcher_button.h b/ash/launcher/launcher_button.h index eb4a735..161f13e 100644 --- a/ash/launcher/launcher_button.h +++ b/ash/launcher/launcher_button.h @@ -5,6 +5,7 @@ #ifndef ASH_LAUNCHER_LAUNCHER_BUTTON_H_ #define ASH_LAUNCHER_LAUNCHER_BUTTON_H_ +#include "base/memory/scoped_ptr.h" #include "ui/gfx/shadow_value.h" #include "ui/views/controls/button/custom_button.h" #include "ui/views/controls/image_view.h" @@ -31,7 +32,11 @@ class LauncherButton : public views::CustomButton { STATE_ACTIVE = 1 << 2, // Underlying LauncherItem needs user's attention. STATE_ATTENTION = 1 << 3, - STATE_FOCUSED = 1 << 4, + // Underlying LauncherItem has pending operations. + // e.g. A TYPE_APP_SHORTCUT item whose corresponding app is being + // installed. + STATE_PENDING = 1 << 4, + STATE_FOCUSED = 1 << 5, }; virtual ~LauncherButton(); @@ -102,6 +107,7 @@ class LauncherButton : public views::CustomButton { private: class BarView; + class IconPulseAnimation; // Returns true if the shelf is horizontal. If this returns false the shelf is // vertical. @@ -119,6 +125,10 @@ class LauncherButton : public views::CustomButton { // together. int state_; + // Runs a pulse animation for |icon_view_|. It is created when button state + // has a STATE_PENDING bit and destroyed when that bit is clear. + scoped_ptr<IconPulseAnimation> icon_pulse_animation_; + gfx::ShadowValues icon_shadows_; DISALLOW_COPY_AND_ASSIGN(LauncherButton); diff --git a/ash/launcher/launcher_model.cc b/ash/launcher/launcher_model.cc index 2945a5d..d9aa8ad 100644 --- a/ash/launcher/launcher_model.cc +++ b/ash/launcher/launcher_model.cc @@ -7,6 +7,7 @@ #include <algorithm> #include "ash/launcher/launcher_model_observer.h" +#include "ui/aura/window.h" namespace ash { @@ -36,7 +37,7 @@ bool CompareByWeight(const LauncherItem& a, const LauncherItem& b) { } // namespace -LauncherModel::LauncherModel() : next_id_(1), status_(STATUS_NORMAL) { +LauncherModel::LauncherModel() : next_id_(1) { LauncherItem app_list; app_list.type = TYPE_APP_LIST; app_list.is_incognito = false; @@ -117,15 +118,6 @@ LauncherItems::const_iterator LauncherModel::ItemByID(int id) const { return items_.end(); } -void LauncherModel::SetStatus(Status status) { - if (status_ == status) - return; - - status_ = status; - FOR_EACH_OBSERVER(LauncherModelObserver, observers_, - LauncherStatusChanged()); -} - void LauncherModel::AddObserver(LauncherModelObserver* observer) { observers_.AddObserver(observer); } diff --git a/ash/launcher/launcher_model.h b/ash/launcher/launcher_model.h index a733a1b..d4cd05e 100644 --- a/ash/launcher/launcher_model.h +++ b/ash/launcher/launcher_model.h @@ -22,12 +22,6 @@ class LauncherModelObserver; // Model used by LauncherView. class ASH_EXPORT LauncherModel { public: - enum Status { - STATUS_NORMAL, - // A status that indicates apps are syncing/loading. - STATUS_LOADING, - }; - LauncherModel(); ~LauncherModel(); @@ -62,9 +56,6 @@ class ASH_EXPORT LauncherModel { const LauncherItems& items() const { return items_; } int item_count() const { return static_cast<int>(items_.size()); } - void SetStatus(Status status); - Status status() const { return status_; } - void AddObserver(LauncherModelObserver* observer); void RemoveObserver(LauncherModelObserver* observer); @@ -77,7 +68,6 @@ class ASH_EXPORT LauncherModel { // ID assigned to the next item. LauncherID next_id_; LauncherItems items_; - Status status_; ObserverList<LauncherModelObserver> observers_; DISALLOW_COPY_AND_ASSIGN(LauncherModel); diff --git a/ash/launcher/launcher_model_observer.h b/ash/launcher/launcher_model_observer.h index 16067c0..5d73d1c 100644 --- a/ash/launcher/launcher_model_observer.h +++ b/ash/launcher/launcher_model_observer.h @@ -25,13 +25,10 @@ class ASH_EXPORT LauncherModelObserver { // of the arguments. virtual void LauncherItemMoved(int start_index, int target_index) = 0; - // Invoked when the state of an item changes. |old_item| is the item + // Invoked when the the state of an item changes. |old_item| is the item // before the change. virtual void LauncherItemChanged(int index, const LauncherItem& old_item) = 0; - // Invoked when launcher status is changed. - virtual void LauncherStatusChanged() = 0; - protected: virtual ~LauncherModelObserver() {} }; diff --git a/ash/launcher/launcher_model_unittest.cc b/ash/launcher/launcher_model_unittest.cc index 9a4fbcd..cc449eba 100644 --- a/ash/launcher/launcher_model_unittest.cc +++ b/ash/launcher/launcher_model_unittest.cc @@ -4,9 +4,6 @@ #include "ash/launcher/launcher_model.h" -#include <set> -#include <string> - #include "ash/launcher/launcher_model_observer.h" #include "base/stringprintf.h" #include "testing/gtest/include/gtest/gtest.h" @@ -51,8 +48,6 @@ class TestLauncherModelObserver : public LauncherModelObserver { virtual void LauncherItemMoved(int start_index, int target_index) OVERRIDE { moved_count_++; } - virtual void LauncherStatusChanged() OVERRIDE { - } private: void AddToResult(const std::string& format, int count, std::string* result) { diff --git a/ash/launcher/launcher_types.h b/ash/launcher/launcher_types.h index 24110f4..a6a6dc0 100644 --- a/ash/launcher/launcher_types.h +++ b/ash/launcher/launcher_types.h @@ -56,6 +56,11 @@ enum LauncherItemStatus { STATUS_ACTIVE, // A LauncherItem that needs user's attention. STATUS_ATTENTION, + // A LauncherItem that has pending operations. + // e.g. A TYEE_APP_SHORTCUT item whose application is + // being installed/upgraded. + // Note STATUS_PENDING is a macro in WinNT.h on Windows. + STATUS_IS_PENDING, }; struct ASH_EXPORT LauncherItem { diff --git a/ash/launcher/launcher_view.cc b/ash/launcher/launcher_view.cc index 9a72042..20fa176 100644 --- a/ash/launcher/launcher_view.cc +++ b/ash/launcher/launcher_view.cc @@ -18,20 +18,27 @@ #include "ash/shell.h" #include "ash/shell_delegate.h" #include "base/auto_reset.h" -#include "base/memory/scoped_ptr.h" +#include "base/utf_string_conversions.h" #include "grit/ash_strings.h" #include "grit/ui_resources.h" +#include "ui/aura/window.h" +#include "ui/base/animation/animation.h" +#include "ui/base/animation/throb_animation.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/models/simple_menu_model.h" #include "ui/base/resource/resource_bundle.h" #include "ui/compositor/layer.h" +#include "ui/gfx/image/image.h" #include "ui/views/animation/bounds_animator.h" #include "ui/views/border.h" +#include "ui/views/controls/button/image_button.h" #include "ui/views/controls/menu/menu_model_adapter.h" #include "ui/views/controls/menu/menu_runner.h" #include "ui/views/focus/focus_search.h" #include "ui/views/view_model.h" #include "ui/views/view_model_utils.h" +#include "ui/views/widget/root_view.h" +#include "ui/views/widget/widget.h" using ui::Animation; using views::View; @@ -40,13 +47,13 @@ namespace ash { namespace internal { // Default amount content is inset on the left edge. -const int kDefaultLeadingInset = 8; +static const int kDefaultLeadingInset = 8; // Minimum distance before drag starts. -const int kMinimumDragDistance = 8; +static const int kMinimumDragDistance = 8; // Size between the buttons. -const int kButtonSpacing = 4; +static const int kButtonSpacing = 4; namespace { @@ -170,21 +177,31 @@ void ReflectItemStatus(const ash::LauncherItem& item, button->ClearState(LauncherButton::STATE_ACTIVE); button->ClearState(LauncherButton::STATE_RUNNING); button->ClearState(LauncherButton::STATE_ATTENTION); + button->ClearState(LauncherButton::STATE_PENDING); break; case STATUS_RUNNING: button->ClearState(LauncherButton::STATE_ACTIVE); button->AddState(LauncherButton::STATE_RUNNING); button->ClearState(LauncherButton::STATE_ATTENTION); + button->ClearState(LauncherButton::STATE_PENDING); break; case STATUS_ACTIVE: button->AddState(LauncherButton::STATE_ACTIVE); button->ClearState(LauncherButton::STATE_RUNNING); button->ClearState(LauncherButton::STATE_ATTENTION); + button->ClearState(LauncherButton::STATE_PENDING); break; case STATUS_ATTENTION: button->ClearState(LauncherButton::STATE_ACTIVE); button->ClearState(LauncherButton::STATE_RUNNING); button->AddState(LauncherButton::STATE_ATTENTION); + button->ClearState(LauncherButton::STATE_PENDING); + break; + case STATUS_IS_PENDING: + button->ClearState(LauncherButton::STATE_ACTIVE); + button->ClearState(LauncherButton::STATE_RUNNING); + button->ClearState(LauncherButton::STATE_ATTENTION); + button->AddState(LauncherButton::STATE_PENDING); break; } } @@ -287,7 +304,6 @@ void LauncherView::Init() { AddChildView(child); } UpdateFirstButtonPadding(); - LauncherStatusChanged(); overflow_button_ = new OverflowButton(this); overflow_button_->set_context_menu_controller(this); @@ -506,7 +522,21 @@ views::View* LauncherView::CreateViewForItem(const LauncherItem& item) { case TYPE_APP_LIST: { // TODO(dave): turn this into a LauncherButton too. + ResourceBundle& rb = ResourceBundle::GetSharedInstance(); AppListButton* button = new AppListButton(this, this); + button->SetImage( + views::CustomButton::BS_NORMAL, + rb.GetImageNamed(IDR_AURA_LAUNCHER_ICON_APPLIST).ToImageSkia()); + button->SetImage( + views::CustomButton::BS_HOT, + rb.GetImageNamed(IDR_AURA_LAUNCHER_ICON_APPLIST_HOT). + ToImageSkia()); + button->SetImage( + views::CustomButton::BS_PUSHED, + rb.GetImageNamed(IDR_AURA_LAUNCHER_ICON_APPLIST_PUSHED). + ToImageSkia()); + button->SetAccessibleName( + l10n_util::GetStringUTF16(IDS_AURA_APP_LIST_TITLE)); view = button; break; } @@ -857,15 +887,6 @@ void LauncherView::LauncherItemMoved(int start_index, int target_index) { AnimateToIdealBounds(); } -void LauncherView::LauncherStatusChanged() { - AppListButton* app_list_button = - static_cast<AppListButton*>(GetAppListButtonView()); - if (model_->status() == LauncherModel::STATUS_LOADING) - app_list_button->StartLoadingAnimation(); - else - app_list_button->StopLoadingAnimation(); -} - void LauncherView::PointerPressedOnButton(views::View* view, Pointer pointer, const ui::LocatedEvent& event) { @@ -958,9 +979,7 @@ string16 LauncherView::GetAccessibleName(const views::View* view) { return delegate_->GetTitle(model_->items()[view_index]); case TYPE_APP_LIST: - return model_->status() == LauncherModel::STATUS_LOADING ? - l10n_util::GetStringUTF16(IDS_AURA_APP_LIST_SYNCING_TITLE) : - l10n_util::GetStringUTF16(IDS_AURA_APP_LIST_TITLE); + return l10n_util::GetStringUTF16(IDS_AURA_APP_LIST_TITLE); case TYPE_BROWSER_SHORTCUT: return l10n_util::GetStringUTF16(IDS_AURA_NEW_TAB); diff --git a/ash/launcher/launcher_view.h b/ash/launcher/launcher_view.h index ca3f632..bfac558 100644 --- a/ash/launcher/launcher_view.h +++ b/ash/launcher/launcher_view.h @@ -182,7 +182,6 @@ class ASH_EXPORT LauncherView : public views::View, virtual void LauncherItemChanged(int model_index, const ash::LauncherItem& old_item) OVERRIDE; virtual void LauncherItemMoved(int start_index, int target_index) OVERRIDE; - virtual void LauncherStatusChanged() OVERRIDE; // Overridden from LauncherButtonHost: virtual void PointerPressedOnButton( diff --git a/ash/launcher/launcher_view_unittest.cc b/ash/launcher/launcher_view_unittest.cc index 5a43c33..d2585bd 100644 --- a/ash/launcher/launcher_view_unittest.cc +++ b/ash/launcher/launcher_view_unittest.cc @@ -536,6 +536,9 @@ TEST_F(LauncherViewTest, LauncherItemStatus) { item.status = ash::STATUS_ATTENTION; model_->Set(index, item); ASSERT_EQ(internal::LauncherButton::STATE_ATTENTION, button->state()); + item.status = ash::STATUS_IS_PENDING; + model_->Set(index, item); + ASSERT_EQ(internal::LauncherButton::STATE_PENDING, button->state()); } // Confirm that item status changes are reflected in the buttons @@ -556,6 +559,9 @@ TEST_F(LauncherViewTest, LauncherItemStatusPlatformApp) { item.status = ash::STATUS_ATTENTION; model_->Set(index, item); ASSERT_EQ(internal::LauncherButton::STATE_ATTENTION, button->state()); + item.status = ash::STATUS_IS_PENDING; + model_->Set(index, item); + ASSERT_EQ(internal::LauncherButton::STATE_PENDING, button->state()); } TEST_F(LauncherViewTest, LauncherTooltipTest) { |