diff options
author | jennb@chromium.org <jennb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-14 00:29:59 +0000 |
---|---|---|
committer | jennb@chromium.org <jennb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-14 00:29:59 +0000 |
commit | ad996343442c413edf82011c3e6b0e81b0af70ee (patch) | |
tree | e55d0b4778a0e658a6f8c6e90b1d67ba65db2378 | |
parent | 2b62c8e97d4810ab3a2346c84c79682a6eb630fa (diff) | |
download | chromium_src-ad996343442c413edf82011c3e6b0e81b0af70ee.zip chromium_src-ad996343442c413edf82011c3e6b0e81b0af70ee.tar.gz chromium_src-ad996343442c413edf82011c3e6b0e81b0af70ee.tar.bz2 |
Implement chrome.windows.update(drawAttention=false).
Modified BrowserWindow FlashFrame to take a param to turn flashing on/off.
Prior, drawAttention=false was ignored.
BUG=104807
TEST=Manually tested with extension that uses new API.
Review URL: http://codereview.chromium.org/9112036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117738 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/chromeos/frame/panel_browser_view.cc | 6 | ||||
-rw-r--r-- | chrome/browser/chromeos/frame/panel_browser_view.h | 4 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_tabs_module.cc | 3 | ||||
-rw-r--r-- | chrome/browser/ui/browser_window.h | 3 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/browser_window_cocoa.h | 3 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/browser_window_cocoa.mm | 12 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/browser_window_gtk.cc | 4 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/browser_window_gtk.h | 4 | ||||
-rw-r--r-- | chrome/browser/ui/panels/panel.cc | 7 | ||||
-rw-r--r-- | chrome/browser/ui/panels/panel.h | 2 | ||||
-rw-r--r-- | chrome/browser/ui/panels/panel_browsertest.cc | 10 | ||||
-rw-r--r-- | chrome/browser/ui/panels/panel_overflow_browsertest.cc | 8 | ||||
-rw-r--r-- | chrome/browser/ui/views/frame/browser_view.cc | 14 | ||||
-rw-r--r-- | chrome/browser/ui/views/frame/browser_view.h | 2 | ||||
-rw-r--r-- | chrome/common/extensions/api/windows.json | 2 | ||||
-rw-r--r-- | chrome/common/extensions/docs/windows.html | 2 | ||||
-rw-r--r-- | chrome/test/base/test_browser_window.h | 4 |
17 files changed, 52 insertions, 38 deletions
diff --git a/chrome/browser/chromeos/frame/panel_browser_view.cc b/chrome/browser/chromeos/frame/panel_browser_view.cc index 25f1a28..3ef3bd2 100644 --- a/chrome/browser/chromeos/frame/panel_browser_view.cc +++ b/chrome/browser/chromeos/frame/panel_browser_view.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. @@ -88,9 +88,9 @@ void PanelBrowserView::Close() { panel_controller_->Close(); } -void PanelBrowserView::FlashFrame() { +void PanelBrowserView::FlashFrame(bool flash) { if (panel_controller_.get()) - panel_controller_->SetUrgent(true); + panel_controller_->SetUrgent(flash); } void PanelBrowserView::UpdateTitleBar() { diff --git a/chrome/browser/chromeos/frame/panel_browser_view.h b/chrome/browser/chromeos/frame/panel_browser_view.h index d11a26e..467c7ff 100644 --- a/chrome/browser/chromeos/frame/panel_browser_view.h +++ b/chrome/browser/chromeos/frame/panel_browser_view.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,7 +31,7 @@ class PanelBrowserView : public ::BrowserView, virtual void ShowInactive() OVERRIDE; virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; virtual void Close() OVERRIDE; - virtual void FlashFrame() OVERRIDE; + virtual void FlashFrame(bool flash) OVERRIDE; virtual void UpdateTitleBar() OVERRIDE; virtual bool IsPanel() const OVERRIDE; virtual WindowOpenDisposition GetDispositionForPopupBounds( diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc index 0566cc8..cb3cfef 100644 --- a/chrome/browser/extensions/extension_tabs_module.cc +++ b/chrome/browser/extensions/extension_tabs_module.cc @@ -683,8 +683,7 @@ bool UpdateWindowFunction::RunImpl() { if (update_props->HasKey(keys::kDrawAttentionKey)) { EXTENSION_FUNCTION_VALIDATE(update_props->GetBoolean( keys::kDrawAttentionKey, &draw_attention)); - if (draw_attention) - browser->window()->FlashFrame(); + browser->window()->FlashFrame(draw_attention); } result_.reset(ExtensionTabUtil::CreateWindowValue(browser, false)); diff --git a/chrome/browser/ui/browser_window.h b/chrome/browser/ui/browser_window.h index 6577157..0580f7f 100644 --- a/chrome/browser/ui/browser_window.h +++ b/chrome/browser/ui/browser_window.h @@ -86,7 +86,8 @@ class BrowserWindow { virtual bool IsActive() const = 0; // Flashes the taskbar item associated with this frame. - virtual void FlashFrame() = 0; + // Set |flash| to true to initiate flashing, false to stop flashing. + virtual void FlashFrame(bool flash) = 0; // Return a platform dependent identifier for this frame. On Windows, this // returns an HWND. diff --git a/chrome/browser/ui/cocoa/browser_window_cocoa.h b/chrome/browser/ui/cocoa/browser_window_cocoa.h index 05a5106..af7cd11 100644 --- a/chrome/browser/ui/cocoa/browser_window_cocoa.h +++ b/chrome/browser/ui/cocoa/browser_window_cocoa.h @@ -40,7 +40,7 @@ class BrowserWindowCocoa : public BrowserWindow, virtual void Activate() OVERRIDE; virtual void Deactivate() OVERRIDE; virtual bool IsActive() const OVERRIDE; - virtual void FlashFrame() OVERRIDE; + virtual void FlashFrame(bool flash) OVERRIDE; virtual gfx::NativeWindow GetNativeHandle() OVERRIDE; virtual BrowserWindowTesting* GetBrowserWindowTesting() OVERRIDE; virtual StatusBubble* GetStatusBubble() OVERRIDE; @@ -157,6 +157,7 @@ class BrowserWindowCocoa : public BrowserWindow, base::WeakPtrFactory<Browser> confirm_close_factory_; scoped_nsobject<NSString> pending_window_title_; ui::WindowShowState initial_show_state_; + NSInteger attention_request_id_; // identifier from requestUserAttention }; #endif // CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_COCOA_H_ diff --git a/chrome/browser/ui/cocoa/browser_window_cocoa.mm b/chrome/browser/ui/cocoa/browser_window_cocoa.mm index c23cf56..63d7a5d 100644 --- a/chrome/browser/ui/cocoa/browser_window_cocoa.mm +++ b/chrome/browser/ui/cocoa/browser_window_cocoa.mm @@ -76,7 +76,8 @@ BrowserWindowCocoa::BrowserWindowCocoa(Browser* browser, BrowserWindowController* controller) : browser_(browser), controller_(controller), - confirm_close_factory_(browser) { + confirm_close_factory_(browser), + attention_request_id_(0) { pref_change_registrar_.Init(browser_->profile()->GetPrefs()); pref_change_registrar_.Add(prefs::kShowBookmarkBar, this); @@ -178,8 +179,13 @@ void BrowserWindowCocoa::Deactivate() { NOTIMPLEMENTED(); } -void BrowserWindowCocoa::FlashFrame() { - [NSApp requestUserAttention:NSInformationalRequest]; +void BrowserWindowCocoa::FlashFrame(bool flash) { + if (flash) { + attention_request_id_ = [NSApp requestUserAttention:NSInformationalRequest]; + } else { + [NSApp cancelUserAttentionRequest:attention_request_id_]; + attention_request_id_ = 0; + } } bool BrowserWindowCocoa::IsActive() const { diff --git a/chrome/browser/ui/gtk/browser_window_gtk.cc b/chrome/browser/ui/gtk/browser_window_gtk.cc index be90cfe..2f636e8 100644 --- a/chrome/browser/ui/gtk/browser_window_gtk.cc +++ b/chrome/browser/ui/gtk/browser_window_gtk.cc @@ -768,9 +768,9 @@ bool BrowserWindowGtk::IsActive() const { return is_active_; } -void BrowserWindowGtk::FlashFrame() { +void BrowserWindowGtk::FlashFrame(bool flash) { // May not be respected by all window managers. - gtk_window_set_urgency_hint(window_, TRUE); + gtk_window_set_urgency_hint(window_, flash); } gfx::NativeWindow BrowserWindowGtk::GetNativeHandle() { diff --git a/chrome/browser/ui/gtk/browser_window_gtk.h b/chrome/browser/ui/gtk/browser_window_gtk.h index 767d33b..fcba466 100644 --- a/chrome/browser/ui/gtk/browser_window_gtk.h +++ b/chrome/browser/ui/gtk/browser_window_gtk.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. @@ -77,7 +77,7 @@ class BrowserWindowGtk : public BrowserWindow, virtual void Activate() OVERRIDE; virtual void Deactivate() OVERRIDE; virtual bool IsActive() const OVERRIDE; - virtual void FlashFrame() OVERRIDE; + virtual void FlashFrame(bool flash) OVERRIDE; virtual gfx::NativeWindow GetNativeHandle() OVERRIDE; virtual BrowserWindowTesting* GetBrowserWindowTesting() OVERRIDE; virtual StatusBubble* GetStatusBubble() OVERRIDE; diff --git a/chrome/browser/ui/panels/panel.cc b/chrome/browser/ui/panels/panel.cc index eacf7b2..ed3cca0 100644 --- a/chrome/browser/ui/panels/panel.cc +++ b/chrome/browser/ui/panels/panel.cc @@ -201,8 +201,11 @@ bool Panel::IsActive() const { return native_panel_->IsPanelActive(); } -void Panel::FlashFrame() { - native_panel_->DrawAttention(); +void Panel::FlashFrame(bool flash) { + if (flash) + native_panel_->DrawAttention(); + else + NOTIMPLEMENTED(); // TODO(jennb) - will be in next patch. manager()->OnPanelAttentionStateChanged(this); } diff --git a/chrome/browser/ui/panels/panel.h b/chrome/browser/ui/panels/panel.h index aefb8fd..6a78d4d 100644 --- a/chrome/browser/ui/panels/panel.h +++ b/chrome/browser/ui/panels/panel.h @@ -85,7 +85,7 @@ class Panel : public BrowserWindow, virtual void Activate() OVERRIDE; virtual void Deactivate() OVERRIDE; virtual bool IsActive() const OVERRIDE; - virtual void FlashFrame() OVERRIDE; + virtual void FlashFrame(bool flash) OVERRIDE; virtual gfx::NativeWindow GetNativeHandle() OVERRIDE; virtual BrowserWindowTesting* GetBrowserWindowTesting() OVERRIDE; virtual StatusBubble* GetStatusBubble() OVERRIDE; diff --git a/chrome/browser/ui/panels/panel_browsertest.cc b/chrome/browser/ui/panels/panel_browsertest.cc index 826c73a..17afe21 100644 --- a/chrome/browser/ui/panels/panel_browsertest.cc +++ b/chrome/browser/ui/panels/panel_browsertest.cc @@ -1137,7 +1137,7 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DrawAttentionBasic) { EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); EXPECT_FALSE(panel->IsActive()); EXPECT_FALSE(panel->IsDrawingAttention()); - panel->FlashFrame(); + panel->FlashFrame(true); EXPECT_TRUE(panel->IsDrawingAttention()); MessageLoop::current()->RunAllPending(); EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention()); @@ -1161,7 +1161,7 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DrawAttentionWhileMinimized) { panel->SetExpansionState(Panel::MINIMIZED); WaitForPanelActiveState(panel, SHOW_AS_INACTIVE); EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); - panel->FlashFrame(); + panel->FlashFrame(true); EXPECT_TRUE(panel->IsDrawingAttention()); EXPECT_EQ(Panel::TITLE_ONLY, panel->expansion_state()); MessageLoop::current()->RunAllPending(); @@ -1200,7 +1200,7 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DrawAttentionWhenActive) { EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); EXPECT_TRUE(panel->IsActive()); EXPECT_FALSE(panel->IsDrawingAttention()); - panel->FlashFrame(); + panel->FlashFrame(true); EXPECT_FALSE(panel->IsDrawingAttention()); MessageLoop::current()->RunAllPending(); EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); @@ -1218,7 +1218,7 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DrawAttentionResetOnActivate) { panel->Deactivate(); WaitForPanelActiveState(panel, SHOW_AS_INACTIVE); - panel->FlashFrame(); + panel->FlashFrame(true); EXPECT_TRUE(panel->IsDrawingAttention()); MessageLoop::current()->RunAllPending(); EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention()); @@ -1246,7 +1246,7 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MAYBE_DrawAttentionResetOnClick) { scoped_ptr<NativePanelTesting> native_panel_testing( NativePanelTesting::Create(panel->native_panel())); - panel->FlashFrame(); + panel->FlashFrame(true); EXPECT_TRUE(panel->IsDrawingAttention()); MessageLoop::current()->RunAllPending(); EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention()); diff --git a/chrome/browser/ui/panels/panel_overflow_browsertest.cc b/chrome/browser/ui/panels/panel_overflow_browsertest.cc index 5060910..920dab1 100644 --- a/chrome/browser/ui/panels/panel_overflow_browsertest.cc +++ b/chrome/browser/ui/panels/panel_overflow_browsertest.cc @@ -1501,7 +1501,7 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_DrawOverflowAttention) { // normal: P0, P1, P2, P3 // overflow: P4, *P5, P6, (P7, P8, P9, P10, P11) EXPECT_FALSE(panels[5]->IsDrawingAttention()); - panels[5]->FlashFrame(); + panels[5]->FlashFrame(true); EXPECT_TRUE(panels[5]->IsDrawingAttention()); EXPECT_FALSE(overflow_indicator->IsDrawingAttention()); @@ -1519,7 +1519,7 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_DrawOverflowAttention) { // normal: P0, P1, P2, P5 // overflow: P3, P4, P6, (P7, *P8, P9, P10, P11) EXPECT_FALSE(panels[8]->IsDrawingAttention()); - panels[8]->FlashFrame(); + panels[8]->FlashFrame(true); EXPECT_TRUE(panels[8]->IsDrawingAttention()); EXPECT_TRUE(overflow_indicator->IsDrawingAttention()); @@ -1528,7 +1528,7 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_DrawOverflowAttention) { // normal: P0, P1, P2, P5 // overflow: P3, P4, P6, (P7, *P8, P9, *P10, P11) EXPECT_FALSE(panels[10]->IsDrawingAttention()); - panels[10]->FlashFrame(); + panels[10]->FlashFrame(true); EXPECT_TRUE(panels[10]->IsDrawingAttention()); EXPECT_TRUE(overflow_indicator->IsDrawingAttention()); @@ -1556,7 +1556,7 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_DrawOverflowAttention) { // overflow: P8, P5, *P3, (P4, P6, P7, P9, P11) EXPECT_TRUE(IsPanelVisible(panels[3])); EXPECT_FALSE(panels[3]->IsDrawingAttention()); - panels[3]->FlashFrame(); + panels[3]->FlashFrame(true); EXPECT_TRUE(panels[3]->IsDrawingAttention()); EXPECT_FALSE(overflow_indicator->IsDrawingAttention()); diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc index 73dbda0..0a8a7b0 100644 --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc @@ -516,7 +516,7 @@ bool BrowserView::ActivateAppModalDialog() const { if (AppModalDialogQueue::GetInstance()->HasActiveDialog()) { Browser* active_browser = BrowserList::GetLastActive(); if (active_browser && (browser_ != active_browser)) { - active_browser->window()->FlashFrame(); + active_browser->window()->FlashFrame(true); active_browser->window()->Activate(); } AppModalDialogQueue::GetInstance()->ActivateModalDialog(); @@ -646,14 +646,18 @@ bool BrowserView::IsActive() const { return frame_->IsActive(); } -void BrowserView::FlashFrame() { +void BrowserView::FlashFrame(bool flash) { #if defined(OS_WIN) && !defined(USE_AURA) FLASHWINFO fwi; fwi.cbSize = sizeof(fwi); fwi.hwnd = frame_->GetNativeWindow(); - fwi.dwFlags = FLASHW_ALL; - fwi.uCount = 4; - fwi.dwTimeout = 0; + if (flash) { + fwi.dwFlags = FLASHW_ALL; + fwi.uCount = 4; + fwi.dwTimeout = 0; + } else { + fwi.dwFlags = FLASHW_STOP; + } FlashWindowEx(&fwi); #else // Doesn't matter for chrome os. diff --git a/chrome/browser/ui/views/frame/browser_view.h b/chrome/browser/ui/views/frame/browser_view.h index 8d5fefb..552ac86 100644 --- a/chrome/browser/ui/views/frame/browser_view.h +++ b/chrome/browser/ui/views/frame/browser_view.h @@ -232,7 +232,7 @@ class BrowserView : public BrowserWindow, virtual void Activate() OVERRIDE; virtual void Deactivate() OVERRIDE; virtual bool IsActive() const OVERRIDE; - virtual void FlashFrame() OVERRIDE; + virtual void FlashFrame(bool flash) OVERRIDE; virtual gfx::NativeWindow GetNativeHandle() OVERRIDE; virtual BrowserWindowTesting* GetBrowserWindowTesting() OVERRIDE; virtual StatusBubble* GetStatusBubble() OVERRIDE; diff --git a/chrome/common/extensions/api/windows.json b/chrome/common/extensions/api/windows.json index 1e37ddb..4c7b7ac 100644 --- a/chrome/common/extensions/api/windows.json +++ b/chrome/common/extensions/api/windows.json @@ -203,7 +203,7 @@ "width": {"type": "integer", "minimum": 0, "optional": true, "description": "The width to resize the window to in pixels. This value is ignored for panels."}, "height": {"type": "integer", "minimum": 0, "optional": true, "description": "The height to resize the window to in pixels. This value is ignored for panels."}, "focused": {"type": "boolean", "optional": true, "description": "If true, brings the window to the front. If false, brings the next window in the z-order to the front."}, - "drawAttention": {"type": "boolean", "optional": true, "description": "If true, causes the window to be displayed in a manner that draws the user's attention to the window, without changing the focused window. The effect lasts until the user changes focus to the window. This option has no effect if set to false or if the window already has focus."}, + "drawAttention": {"type": "boolean", "optional": true, "description": "If true, causes the window to be displayed in a manner that draws the user's attention to the window, without changing the focused window. The effect lasts until the user changes focus to the window. This option has no effect if the window already has focus. Set to false to cancel a previous draw attention request."}, "state": { "type": "string", "optional": true, diff --git a/chrome/common/extensions/docs/windows.html b/chrome/common/extensions/docs/windows.html index 889364a..3b3fe3f 100644 --- a/chrome/common/extensions/docs/windows.html +++ b/chrome/common/extensions/docs/windows.html @@ -3650,7 +3650,7 @@ For other examples and for help in viewing the source code, see <dd class="todo" style="display: none; "> Undocumented. </dd> - <dd>If true, causes the window to be displayed in a manner that draws the user's attention to the window, without changing the focused window. The effect lasts until the user changes focus to the window. This option has no effect if set to false or if the window already has focus.</dd> + <dd>If true, causes the window to be displayed in a manner that draws the user's attention to the window, without changing the focused window. The effect lasts until the user changes focus to the window. This option has no effect if the window already has focus. Set to false to cancel a previous draw attention request.</dd> <dd style="display: none; "> This parameter was added in version <b><span></span></b>. diff --git a/chrome/test/base/test_browser_window.h b/chrome/test/base/test_browser_window.h index 9952804..b3b5b51 100644 --- a/chrome/test/base/test_browser_window.h +++ b/chrome/test/base/test_browser_window.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. @@ -28,7 +28,7 @@ class TestBrowserWindow : public BrowserWindow { virtual void Activate() OVERRIDE {} virtual void Deactivate() OVERRIDE {} virtual bool IsActive() const OVERRIDE; - virtual void FlashFrame() OVERRIDE {} + virtual void FlashFrame(bool flash) OVERRIDE {} virtual gfx::NativeWindow GetNativeHandle() OVERRIDE; virtual BrowserWindowTesting* GetBrowserWindowTesting() OVERRIDE; virtual StatusBubble* GetStatusBubble() OVERRIDE; |