summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ash/launcher/launcher_button.cc9
-rw-r--r--chrome/browser/ui/views/ash/launcher/browser_launcher_item_controller.cc31
-rw-r--r--chrome/browser/ui/views/ash/launcher/browser_launcher_item_controller.h13
-rw-r--r--chrome/browser/ui/views/ash/launcher/browser_launcher_item_controller_unittest.cc27
-rw-r--r--ui/aura/client/aura_constants.cc1
-rw-r--r--ui/aura/client/aura_constants.h4
-rw-r--r--ui/base/animation/throb_animation.cc8
-rw-r--r--ui/base/animation/throb_animation.h3
-rw-r--r--ui/views/widget/native_widget_aura.cc2
9 files changed, 86 insertions, 12 deletions
diff --git a/ash/launcher/launcher_button.cc b/ash/launcher/launcher_button.cc
index c0fafbb..c6758eb 100644
--- a/ash/launcher/launcher_button.cc
+++ b/ash/launcher/launcher_button.cc
@@ -73,10 +73,13 @@ class LauncherButton::BarView : public views::ImageView,
}
void ShowAttention(bool show) {
- if (show)
+ if (show) {
+ // It's less disruptive if we don't start the pulsing at 0.
+ animation_.Reset(0.375);
animation_.StartThrobbing(-1);
- else
- animation_.Reset();
+ } else {
+ animation_.Reset(0.0);
+ }
}
private:
diff --git a/chrome/browser/ui/views/ash/launcher/browser_launcher_item_controller.cc b/chrome/browser/ui/views/ash/launcher/browser_launcher_item_controller.cc
index f227d2c..3563c3c 100644
--- a/chrome/browser/ui/views/ash/launcher/browser_launcher_item_controller.cc
+++ b/chrome/browser/ui/views/ash/launcher/browser_launcher_item_controller.cc
@@ -20,6 +20,7 @@
#include "chrome/browser/web_applications/web_app.h"
#include "content/public/browser/web_contents.h"
#include "grit/ui_resources.h"
+#include "ui/aura/client/aura_constants.h"
#include "ui/aura/window.h"
#include "ui/base/resource/resource_bundle.h"
@@ -37,10 +38,12 @@ BrowserLauncherItemController::BrowserLauncherItemController(
is_incognito_(tab_model->profile()->GetOriginalProfile() !=
tab_model->profile() && !Profile::IsGuestSession()),
item_id_(-1) {
+ window_->AddObserver(this);
}
BrowserLauncherItemController::~BrowserLauncherItemController() {
tab_model_->RemoveObserver(this);
+ window_->RemoveObserver(this);
if (item_id_ != -1)
launcher_controller_->LauncherItemClosed(item_id_);
}
@@ -95,10 +98,7 @@ BrowserLauncherItemController* BrowserLauncherItemController::Create(
}
void BrowserLauncherItemController::BrowserActivationStateChanged() {
- launcher_controller_->SetItemStatus(
- item_id_,
- ash::wm::IsActiveWindow(window_) ?
- ash::STATUS_ACTIVE : ash::STATUS_RUNNING);
+ UpdateItemStatus();
}
void BrowserLauncherItemController::ActiveTabChanged(
@@ -138,6 +138,29 @@ void BrowserLauncherItemController::FaviconUpdated() {
UpdateLauncher(tab_model_->GetActiveTabContents());
}
+void BrowserLauncherItemController::OnWindowPropertyChanged(
+ aura::Window* window,
+ const void* key,
+ intptr_t old) {
+ if (key == aura::client::kDrawAttentionKey)
+ UpdateItemStatus();
+}
+
+void BrowserLauncherItemController::UpdateItemStatus() {
+ ash::LauncherItemStatus status;
+ if (ash::wm::IsActiveWindow(window_)) {
+ // Clear attention state if active.
+ if (window_->GetProperty(aura::client::kDrawAttentionKey))
+ window_->SetProperty(aura::client::kDrawAttentionKey, false);
+ status = ash::STATUS_ACTIVE;
+ } else if (window_->GetProperty(aura::client::kDrawAttentionKey)) {
+ status = ash::STATUS_ATTENTION;
+ } else {
+ status = ash::STATUS_RUNNING;
+ }
+ launcher_controller_->SetItemStatus(item_id_, status);
+}
+
void BrowserLauncherItemController::UpdateLauncher(TabContentsWrapper* tab) {
if (type_ == TYPE_APP_PANEL)
return; // Maintained entirely by ChromeLauncherController.
diff --git a/chrome/browser/ui/views/ash/launcher/browser_launcher_item_controller.h b/chrome/browser/ui/views/ash/launcher/browser_launcher_item_controller.h
index 58334e6..e8f8bd4 100644
--- a/chrome/browser/ui/views/ash/launcher/browser_launcher_item_controller.h
+++ b/chrome/browser/ui/views/ash/launcher/browser_launcher_item_controller.h
@@ -15,6 +15,7 @@
#include "base/string16.h"
#include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
#include "chrome/browser/ui/views/ash/launcher/launcher_favicon_loader.h"
+#include "ui/aura/window_observer.h"
class Browser;
class ChromeLauncherController;
@@ -32,7 +33,8 @@ class Window;
// BrowserLauncherItemController is responsible for keeping the launcher
// representation of a window up to date as the active tab changes.
class BrowserLauncherItemController : public TabStripModelObserver,
- public LauncherFaviconLoader::Delegate {
+ public LauncherFaviconLoader::Delegate,
+ public aura::WindowObserver {
public:
// This API is to be used as part of testing only.
class TestApi {
@@ -96,6 +98,11 @@ class BrowserLauncherItemController : public TabStripModelObserver,
// LauncherFaviconLoader::Delegate overrides:
virtual void FaviconUpdated() OVERRIDE;
+ // aura::WindowObserver overrides:
+ virtual void OnWindowPropertyChanged(aura::Window* window,
+ const void* key,
+ intptr_t old) OVERRIDE;
+
private:
FRIEND_TEST_ALL_PREFIXES(BrowserLauncherItemControllerTest, PanelItem);
@@ -106,6 +113,10 @@ class BrowserLauncherItemController : public TabStripModelObserver,
UPDATE_TAB_INSERTED,
};
+ // Updates the launcher item status base on the activation and attention
+ // state of the window.
+ void UpdateItemStatus();
+
// Updates the launcher from |tab|.
void UpdateLauncher(TabContentsWrapper* tab);
diff --git a/chrome/browser/ui/views/ash/launcher/browser_launcher_item_controller_unittest.cc b/chrome/browser/ui/views/ash/launcher/browser_launcher_item_controller_unittest.cc
index bf05745..86b75c0 100644
--- a/chrome/browser/ui/views/ash/launcher/browser_launcher_item_controller_unittest.cc
+++ b/chrome/browser/ui/views/ash/launcher/browser_launcher_item_controller_unittest.cc
@@ -18,6 +18,7 @@
#include "content/test/test_browser_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkBitmap.h"
+#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/activation_delegate.h"
#include "ui/aura/root_window.h"
#include "ui/aura/test/test_activation_client.h"
@@ -362,3 +363,29 @@ TEST_F(BrowserLauncherItemControllerTest, SwitchDirectlyToApp) {
EXPECT_EQ(ash::STATUS_ACTIVE, launcher_model_->items()[index2].status);
EXPECT_EQ(&state2.window, activation_client_->GetActiveWindow());
}
+
+// Test attention states of windows.
+TEST_F(BrowserLauncherItemControllerTest, FlashWindow) {
+ // App panel first
+ State app_state(this, "1", BrowserLauncherItemController::TYPE_APP_PANEL);
+ EXPECT_EQ(ash::STATUS_ACTIVE, app_state.GetUpdaterItem().status);
+
+ // Active windows don't show attention.
+ app_state.window.SetProperty(aura::client::kDrawAttentionKey, true);
+ EXPECT_EQ(ash::STATUS_ACTIVE, app_state.GetUpdaterItem().status);
+
+ // Then browser window
+ State browser_state(
+ this, std::string(), BrowserLauncherItemController::TYPE_TABBED);
+ // First browser is active.
+ EXPECT_EQ(ash::STATUS_ACTIVE, browser_state.GetUpdaterItem().status);
+ EXPECT_EQ(ash::STATUS_RUNNING, app_state.GetUpdaterItem().status);
+
+ // App window should go to attention state.
+ app_state.window.SetProperty(aura::client::kDrawAttentionKey, true);
+ EXPECT_EQ(ash::STATUS_ATTENTION, app_state.GetUpdaterItem().status);
+
+ // Activating app window should clear attention state.
+ activation_client_->ActivateWindow(&app_state.window);
+ EXPECT_EQ(ash::STATUS_ACTIVE, app_state.GetUpdaterItem().status);
+}
diff --git a/ui/aura/client/aura_constants.cc b/ui/aura/client/aura_constants.cc
index f74d2ea..96c38ee 100644
--- a/ui/aura/client/aura_constants.cc
+++ b/ui/aura/client/aura_constants.cc
@@ -20,6 +20,7 @@ namespace client {
DEFINE_WINDOW_PROPERTY_KEY(bool, kAlwaysOnTopKey, false);
DEFINE_WINDOW_PROPERTY_KEY(bool, kAnimationsDisabledKey, false);
+DEFINE_WINDOW_PROPERTY_KEY(bool, kDrawAttentionKey, false);
DEFINE_WINDOW_PROPERTY_KEY(ui::ModalType, kModalKey, ui::MODAL_TYPE_NONE);
// gfx::Rect object for RestoreBoundsKey property is owned by the window
// and will be freed automatically.
diff --git a/ui/aura/client/aura_constants.h b/ui/aura/client/aura_constants.h
index 92fa298..5ded101 100644
--- a/ui/aura/client/aura_constants.h
+++ b/ui/aura/client/aura_constants.h
@@ -26,6 +26,10 @@ AURA_EXPORT extern const WindowProperty<bool>* const kAlwaysOnTopKey;
// of value is an int.
AURA_EXPORT extern const WindowProperty<bool>* const kAnimationsDisabledKey;
+// A property key to indicate that a window should show that it deserves
+// attention.
+AURA_EXPORT extern const aura::WindowProperty<bool>* const kDrawAttentionKey;
+
// A property key to store the window modality.
AURA_EXPORT extern const WindowProperty<ui::ModalType>* const kModalKey;
diff --git a/ui/base/animation/throb_animation.cc b/ui/base/animation/throb_animation.cc
index 95e9a65..72392a0 100644
--- a/ui/base/animation/throb_animation.cc
+++ b/ui/base/animation/throb_animation.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -35,8 +35,12 @@ void ThrobAnimation::StartThrobbing(int cycles_til_stop) {
}
void ThrobAnimation::Reset() {
+ Reset(0);
+}
+
+void ThrobAnimation::Reset(double value) {
ResetForSlide();
- SlideAnimation::Reset();
+ SlideAnimation::Reset(value);
}
void ThrobAnimation::Show() {
diff --git a/ui/base/animation/throb_animation.h b/ui/base/animation/throb_animation.h
index 46aae2f..08b2840 100644
--- a/ui/base/animation/throb_animation.h
+++ b/ui/base/animation/throb_animation.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -31,6 +31,7 @@ class UI_EXPORT ThrobAnimation : public SlideAnimation {
// Overridden to reset to the slide duration.
virtual void Reset() OVERRIDE;
+ virtual void Reset(double value) OVERRIDE;
virtual void Show() OVERRIDE;
virtual void Hide() OVERRIDE;
diff --git a/ui/views/widget/native_widget_aura.cc b/ui/views/widget/native_widget_aura.cc
index 5fb9e7de..51b00ac 100644
--- a/ui/views/widget/native_widget_aura.cc
+++ b/ui/views/widget/native_widget_aura.cc
@@ -618,7 +618,7 @@ void NativeWidgetAura::SetUseDragFrame(bool use_drag_frame) {
}
void NativeWidgetAura::FlashFrame(bool flash) {
- NOTIMPLEMENTED();
+ window_->SetProperty(aura::client::kDrawAttentionKey, flash);
}
bool NativeWidgetAura::IsAccessibleWidget() const {