summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-03 20:58:01 +0000
committerfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-03 20:58:01 +0000
commita071e653c8e2b9b77c412600c3d35de814541527 (patch)
tree4f6edf175b8090a8140d511b72ae0879fbacfec2
parentd78f40f3543cd057d845625d1abce9cd79b0682c (diff)
downloadchromium_src-a071e653c8e2b9b77c412600c3d35de814541527.zip
chromium_src-a071e653c8e2b9b77c412600c3d35de814541527.tar.gz
chromium_src-a071e653c8e2b9b77c412600c3d35de814541527.tar.bz2
Fix 9867: Activating the previous/next buttons with the keyboard in the find bar should not change the focus.
Add param const Event& event to ButtonPressed, so that recipients can find out more about the event that generated the ButtonPress message. BUG=9687 TEST=Open www.google.com and open Find-in-page, search for 'e'. Press FindNext button with mouse and note that the focus should be on the textfield. Now press Tab twice to put focus on the FindNext button and press SpaceBar a few times. Note that the focus should stay on the FindNext button. Review URL: http://codereview.chromium.org/188016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25367 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/compact_navigation_bar.cc3
-rw-r--r--chrome/browser/chromeos/compact_navigation_bar.h2
-rw-r--r--chrome/browser/first_run_win.cc2
-rw-r--r--chrome/browser/gtk/browser_window_gtk.cc2
-rw-r--r--chrome/browser/views/about_ipc_dialog.cc3
-rw-r--r--chrome/browser/views/about_ipc_dialog.h2
-rw-r--r--chrome/browser/views/about_network_dialog.cc3
-rw-r--r--chrome/browser/views/about_network_dialog.h2
-rw-r--r--chrome/browser/views/blocked_popup_container_view_win.cc5
-rw-r--r--chrome/browser/views/bookmark_bar_view.cc5
-rw-r--r--chrome/browser/views/bookmark_bar_view.h4
-rw-r--r--chrome/browser/views/bookmark_bubble_view.cc31
-rw-r--r--chrome/browser/views/bookmark_bubble_view.h19
-rw-r--r--chrome/browser/views/bookmark_editor_view.cc3
-rw-r--r--chrome/browser/views/bookmark_editor_view.h2
-rw-r--r--chrome/browser/views/clear_browsing_data.cc3
-rw-r--r--chrome/browser/views/clear_browsing_data.h2
-rw-r--r--chrome/browser/views/constrained_window_win.cc5
-rw-r--r--chrome/browser/views/download_item_view.cc3
-rw-r--r--chrome/browser/views/download_item_view.h2
-rw-r--r--chrome/browser/views/download_shelf_view.cc3
-rw-r--r--chrome/browser/views/download_shelf_view.h2
-rw-r--r--chrome/browser/views/extensions/extension_pack_dialog.cc2
-rw-r--r--chrome/browser/views/find_bar_view.cc16
-rw-r--r--chrome/browser/views/find_bar_view.h2
-rw-r--r--chrome/browser/views/first_run_bubble.cc4
-rw-r--r--chrome/browser/views/first_run_customize_view.cc3
-rw-r--r--chrome/browser/views/first_run_customize_view.h2
-rw-r--r--chrome/browser/views/frame/opaque_browser_frame_view.cc3
-rw-r--r--chrome/browser/views/frame/opaque_browser_frame_view.h2
-rw-r--r--chrome/browser/views/go_button.cc2
-rw-r--r--chrome/browser/views/go_button.h2
-rw-r--r--chrome/browser/views/hung_renderer_view.cc5
-rw-r--r--chrome/browser/views/infobars/infobars.cc7
-rw-r--r--chrome/browser/views/infobars/infobars.h4
-rw-r--r--chrome/browser/views/keyword_editor_view.cc15
-rw-r--r--chrome/browser/views/keyword_editor_view.h2
-rw-r--r--chrome/browser/views/new_browser_window_widget.cc3
-rw-r--r--chrome/browser/views/new_browser_window_widget.h2
-rw-r--r--chrome/browser/views/options/advanced_contents_view.cc25
-rw-r--r--chrome/browser/views/options/advanced_page_view.cc3
-rw-r--r--chrome/browser/views/options/advanced_page_view.h2
-rw-r--r--chrome/browser/views/options/content_page_view.cc3
-rw-r--r--chrome/browser/views/options/content_page_view.h2
-rw-r--r--chrome/browser/views/options/cookies_view.cc3
-rw-r--r--chrome/browser/views/options/cookies_view.h2
-rw-r--r--chrome/browser/views/options/exceptions_page_view.cc3
-rw-r--r--chrome/browser/views/options/exceptions_page_view.h2
-rw-r--r--chrome/browser/views/options/fonts_page_view.cc3
-rw-r--r--chrome/browser/views/options/fonts_page_view.h2
-rw-r--r--chrome/browser/views/options/general_page_view.cc3
-rw-r--r--chrome/browser/views/options/general_page_view.h2
-rw-r--r--chrome/browser/views/options/languages_page_view.cc3
-rw-r--r--chrome/browser/views/options/languages_page_view.h2
-rw-r--r--chrome/browser/views/options/passwords_page_view.cc3
-rw-r--r--chrome/browser/views/options/passwords_page_view.h2
-rw-r--r--chrome/browser/views/page_info_window_view.cc5
-rw-r--r--chrome/browser/views/panel_controller.cc3
-rw-r--r--chrome/browser/views/panel_controller.h2
-rw-r--r--chrome/browser/views/tabs/tab.cc2
-rw-r--r--chrome/browser/views/tabs/tab.h2
-rw-r--r--chrome/browser/views/tabs/tab_2.cc2
-rw-r--r--chrome/browser/views/tabs/tab_2.h2
-rw-r--r--chrome/browser/views/tabs/tab_renderer.h3
-rw-r--r--chrome/browser/views/tabs/tab_strip.cc2
-rw-r--r--chrome/browser/views/tabs/tab_strip.h2
-rw-r--r--chrome/browser/views/task_manager_view.cc5
-rw-r--r--chrome/browser/views/toolbar_star_toggle.cc4
-rw-r--r--chrome/browser/views/toolbar_star_toggle.h2
-rw-r--r--chrome/browser/views/toolbar_view.cc3
-rw-r--r--chrome/browser/views/toolbar_view.h2
-rw-r--r--chrome/browser/views/uninstall_view.cc3
-rw-r--r--chrome/browser/views/uninstall_view.h2
-rw-r--r--views/controls/button/button.cc6
-rw-r--r--views/controls/button/button.h5
-rw-r--r--views/controls/button/custom_button.cc22
-rw-r--r--views/controls/button/native_button.cc29
-rw-r--r--views/controls/scrollbar/bitmap_scroll_bar.cc33
-rw-r--r--views/controls/scrollbar/bitmap_scroll_bar.h2
-rw-r--r--views/event.h10
-rw-r--r--views/view_unittest.cc2
-rw-r--r--views/window/custom_frame_view.cc2
-rw-r--r--views/window/custom_frame_view.h2
-rw-r--r--views/window/dialog_client_view.cc3
-rw-r--r--views/window/dialog_client_view.h2
85 files changed, 267 insertions, 146 deletions
diff --git a/chrome/browser/chromeos/compact_navigation_bar.cc b/chrome/browser/chromeos/compact_navigation_bar.cc
index add43dd9..415f763 100644
--- a/chrome/browser/chromeos/compact_navigation_bar.cc
+++ b/chrome/browser/chromeos/compact_navigation_bar.cc
@@ -153,7 +153,8 @@ void CompactNavigationBar::Paint(gfx::Canvas* canvas) {
height() - 5);
}
-void CompactNavigationBar::ButtonPressed(views::Button* sender) {
+void CompactNavigationBar::ButtonPressed(
+ views::Button* sender, const views::Event& event) {
TabContents* tab_contents = browser_->GetSelectedTabContents();
if (!tab_contents)
return;
diff --git a/chrome/browser/chromeos/compact_navigation_bar.h b/chrome/browser/chromeos/compact_navigation_bar.h
index f086f34..f423996 100644
--- a/chrome/browser/chromeos/compact_navigation_bar.h
+++ b/chrome/browser/chromeos/compact_navigation_bar.h
@@ -42,7 +42,7 @@ class CompactNavigationBar : public views::View,
private:
// views::ButtonListener implementation.
- virtual void ButtonPressed(views::Button* sender);
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
// AutocompleteController implementation.
virtual void OnAutocompleteAccept(const GURL& url,
diff --git a/chrome/browser/first_run_win.cc b/chrome/browser/first_run_win.cc
index 403f5ad..6ee44d6 100644
--- a/chrome/browser/first_run_win.cc
+++ b/chrome/browser/first_run_win.cc
@@ -798,7 +798,7 @@ class TryChromeDialog : public views::ButtonListener,
// Overridden from ButtonListener. We have two buttons and according to
// what the user clicked we set |result_| and we should always close and
// end the modal loop.
- virtual void ButtonPressed(views::Button* sender) {
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event) {
if (sender->tag() == BT_CLOSE_BUTTON) {
result_ = Upgrade::TD_NOT_NOW;
} else {
diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc
index 7a68ceb..1fea967 100644
--- a/chrome/browser/gtk/browser_window_gtk.cc
+++ b/chrome/browser/gtk/browser_window_gtk.cc
@@ -304,7 +304,7 @@ class MenuPopupCloser : public views::ButtonListener {
public:
MenuPopupCloser() {}
- virtual void ButtonPressed(views::Button* sender) {
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event) {
if (menu_popup) {
menu_popup->Close();
// Close takes care of deleting the popup.
diff --git a/chrome/browser/views/about_ipc_dialog.cc b/chrome/browser/views/about_ipc_dialog.cc
index 75be114..89325ca 100644
--- a/chrome/browser/views/about_ipc_dialog.cc
+++ b/chrome/browser/views/about_ipc_dialog.cc
@@ -431,7 +431,8 @@ bool AboutIPCDialog::CanResize() const {
return true;
}
-void AboutIPCDialog::ButtonPressed(views::Button* button) {
+void AboutIPCDialog::ButtonPressed(
+ views::Button* button, const views::Event& event) {
if (button == track_toggle_) {
if (tracking_) {
track_toggle_->SetText(kStartTrackingLabel);
diff --git a/chrome/browser/views/about_ipc_dialog.h b/chrome/browser/views/about_ipc_dialog.h
index 0ba6090..2f4eaf5 100644
--- a/chrome/browser/views/about_ipc_dialog.h
+++ b/chrome/browser/views/about_ipc_dialog.h
@@ -52,7 +52,7 @@ class AboutIPCDialog : public views::DialogDelegate,
virtual bool CanResize() const;
// views::ButtonListener.
- virtual void ButtonPressed(views::Button* button);
+ virtual void ButtonPressed(views::Button* button, const views::Event& event);
CListViewCtrl message_list_;
diff --git a/chrome/browser/views/about_network_dialog.cc b/chrome/browser/views/about_network_dialog.cc
index 51e5670..3d3a972 100644
--- a/chrome/browser/views/about_network_dialog.cc
+++ b/chrome/browser/views/about_network_dialog.cc
@@ -356,7 +356,8 @@ bool AboutNetworkDialog::CanResize() const {
return true;
}
-void AboutNetworkDialog::ButtonPressed(views::Button* button) {
+void AboutNetworkDialog::ButtonPressed(
+ views::Button* button, const views::Event& event) {
if (button == track_toggle_) {
if (tracking_) {
track_toggle_->SetText(kStartTrackingLabel);
diff --git a/chrome/browser/views/about_network_dialog.h b/chrome/browser/views/about_network_dialog.h
index 54dd254..cbfe0e4 100644
--- a/chrome/browser/views/about_network_dialog.h
+++ b/chrome/browser/views/about_network_dialog.h
@@ -48,7 +48,7 @@ class AboutNetworkDialog : public views::DialogDelegate,
virtual bool CanResize() const;
// views::ButtonListener.
- virtual void ButtonPressed(views::Button* button);
+ virtual void ButtonPressed(views::Button* button, const views::Event& event);
views::TextButton* track_toggle_;
views::TextButton* show_button_;
diff --git a/chrome/browser/views/blocked_popup_container_view_win.cc b/chrome/browser/views/blocked_popup_container_view_win.cc
index 058e5d2..85fba6b 100644
--- a/chrome/browser/views/blocked_popup_container_view_win.cc
+++ b/chrome/browser/views/blocked_popup_container_view_win.cc
@@ -94,7 +94,7 @@ class BlockedPopupContainerInternalView : public views::View,
virtual gfx::Size GetPreferredSize();
// Overridden from views::ButtonListener:
- virtual void ButtonPressed(views::Button* sender);
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
// Overridden from Menu::Delegate:
@@ -228,7 +228,8 @@ gfx::Size BlockedPopupContainerInternalView::GetPreferredSize() {
return preferred_size;
}
-void BlockedPopupContainerInternalView::ButtonPressed(views::Button* sender) {
+void BlockedPopupContainerInternalView::ButtonPressed(
+ views::Button* sender, const views::Event& event) {
if (sender == popup_count_label_) {
launch_menu_.reset(views::Menu::Create(this, views::Menu::TOPLEFT,
container_->GetNativeView()));
diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc
index 4bee007..6ff5c19 100644
--- a/chrome/browser/views/bookmark_bar_view.cc
+++ b/chrome/browser/views/bookmark_bar_view.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 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.
@@ -1115,7 +1115,8 @@ void BookmarkBarView::RunMenu(views::View* view,
anchor_point, false);
}
-void BookmarkBarView::ButtonPressed(views::Button* sender) {
+void BookmarkBarView::ButtonPressed(views::Button* sender,
+ const views::Event& event) {
#ifdef CHROME_PERSONALIZATION
// Show the login wizard if the user clicked the re-login button.
if (sender->tag() == kSyncErrorButtonTag) {
diff --git a/chrome/browser/views/bookmark_bar_view.h b/chrome/browser/views/bookmark_bar_view.h
index 4cb02f8..06b44f2 100644
--- a/chrome/browser/views/bookmark_bar_view.h
+++ b/chrome/browser/views/bookmark_bar_view.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 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.
@@ -327,7 +327,7 @@ class BookmarkBarView : public views::View,
// Invoked when a star entry corresponding to a URL on the bookmark bar is
// pressed. Forwards to the PageNavigator to open the URL.
- virtual void ButtonPressed(views::Button* sender);
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
// Invoked for this View, one of the buttons or the 'other' button. Shows the
// appropriate context menu.
diff --git a/chrome/browser/views/bookmark_bubble_view.cc b/chrome/browser/views/bookmark_bubble_view.cc
index 0ecf1b9..6a48deb 100644
--- a/chrome/browser/views/bookmark_bubble_view.cc
+++ b/chrome/browser/views/bookmark_bubble_view.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 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.
@@ -19,6 +19,7 @@
#include "chrome/common/notification_service.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
+#include "views/event.h"
#include "views/standard_layout.h"
#include "views/controls/button/native_button.h"
#include "views/controls/textfield/textfield.h"
@@ -195,10 +196,11 @@ bool BookmarkBubbleView::AcceleratorPressed(
const views::Accelerator& accelerator) {
if (accelerator.GetKeyCode() != base::VKEY_RETURN)
return false;
+
if (edit_button_->HasFocus())
- ButtonPressed(edit_button_);
+ HandleButtonPressed(edit_button_);
else
- ButtonPressed(close_button_);
+ HandleButtonPressed(close_button_);
return true;
}
@@ -318,15 +320,9 @@ std::wstring BookmarkBubbleView::GetTitle() {
return std::wstring();
}
-void BookmarkBubbleView::ButtonPressed(views::Button* sender) {
- if (sender == edit_button_) {
- UserMetrics::RecordAction(L"BookmarkBubble_Edit", profile_);
- ShowEditor();
- } else {
- DCHECK(sender == close_button_);
- Close();
- }
- // WARNING: we've most likely been deleted when CloseWindow returns.
+void BookmarkBubbleView::ButtonPressed(
+ views::Button* sender, const views::Event& event) {
+ HandleButtonPressed(sender);
}
void BookmarkBubbleView::LinkActivated(Link* source, int event_flags) {
@@ -379,6 +375,17 @@ void BookmarkBubbleView::Close() {
static_cast<InfoBubble*>(GetWidget())->Close();
}
+void BookmarkBubbleView::HandleButtonPressed(views::Button* sender) {
+ if (sender == edit_button_) {
+ UserMetrics::RecordAction(L"BookmarkBubble_Edit", profile_);
+ ShowEditor();
+ } else {
+ DCHECK(sender == close_button_);
+ Close();
+ }
+ // WARNING: we've most likely been deleted when CloseWindow returns.
+}
+
void BookmarkBubbleView::ShowEditor() {
const BookmarkNode* node =
profile_->GetBookmarkModel()->GetMostRecentlyAddedNodeForURL(url_);
diff --git a/chrome/browser/views/bookmark_bubble_view.h b/chrome/browser/views/bookmark_bubble_view.h
index 0c1d9e8..83bd517 100644
--- a/chrome/browser/views/bookmark_bubble_view.h
+++ b/chrome/browser/views/bookmark_bubble_view.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 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.
@@ -34,12 +34,12 @@ class BookmarkBubbleView : public views::View,
public views::Combobox::Listener,
public InfoBubbleDelegate {
public:
- static void Show(views::Window* window,
- const gfx::Rect& bounds,
- InfoBubbleDelegate* delegate,
- Profile* profile,
- const GURL& url,
- bool newly_bookmarked);
+ static void Show(views::Window* window,
+ const gfx::Rect& bounds,
+ InfoBubbleDelegate* delegate,
+ Profile* profile,
+ const GURL& url,
+ bool newly_bookmarked);
static bool IsShowing();
@@ -105,7 +105,7 @@ class BookmarkBubbleView : public views::View,
virtual void LinkActivated(views::Link* source, int event_flags);
// ButtonListener method, closes the bubble or opens the edit dialog.
- virtual void ButtonPressed(views::Button* sender);
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
// Combobox::Listener method. Changes the parent of the bookmark.
virtual void ItemChanged(views::Combobox* combobox,
@@ -122,6 +122,9 @@ class BookmarkBubbleView : public views::View,
// Closes the bubble.
void Close();
+ // Handle the message when the user presses a button.
+ void HandleButtonPressed(views::Button* sender);
+
// Shows the BookmarkEditor.
void ShowEditor();
diff --git a/chrome/browser/views/bookmark_editor_view.cc b/chrome/browser/views/bookmark_editor_view.cc
index e20dca6..bf47ec4 100644
--- a/chrome/browser/views/bookmark_editor_view.cc
+++ b/chrome/browser/views/bookmark_editor_view.cc
@@ -176,7 +176,8 @@ void BookmarkEditorView::ContentsChanged(Textfield* sender,
UserInputChanged();
}
-void BookmarkEditorView::ButtonPressed(Button* sender) {
+void BookmarkEditorView::ButtonPressed(
+ Button* sender, const views::Event& event) {
DCHECK(sender);
switch (sender->GetID()) {
case kNewGroupButtonID:
diff --git a/chrome/browser/views/bookmark_editor_view.h b/chrome/browser/views/bookmark_editor_view.h
index 0896b16..0b1ae90 100644
--- a/chrome/browser/views/bookmark_editor_view.h
+++ b/chrome/browser/views/bookmark_editor_view.h
@@ -90,7 +90,7 @@ class BookmarkEditorView : public BookmarkEditor,
}
// NativeButton.
- virtual void ButtonPressed(views::Button* sender);
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
// SimpleMenuModel::Delegate.
virtual bool IsCommandIdChecked(int command_id) const;
diff --git a/chrome/browser/views/clear_browsing_data.cc b/chrome/browser/views/clear_browsing_data.cc
index ba6417a..385095a 100644
--- a/chrome/browser/views/clear_browsing_data.cc
+++ b/chrome/browser/views/clear_browsing_data.cc
@@ -339,7 +339,8 @@ void ClearBrowsingDataView::ItemChanged(views::Combobox* sender,
////////////////////////////////////////////////////////////////////////////////
// ClearBrowsingDataView, views::ButtonListener implementation:
-void ClearBrowsingDataView::ButtonPressed(views::Button* sender) {
+void ClearBrowsingDataView::ButtonPressed(
+ views::Button* sender, const views::Event& event) {
if (sender == del_history_checkbox_)
profile_->GetPrefs()->SetBoolean(prefs::kDeleteBrowsingHistory,
del_history_checkbox_->checked() ? true : false);
diff --git a/chrome/browser/views/clear_browsing_data.h b/chrome/browser/views/clear_browsing_data.h
index f7b1743..2514af9c 100644
--- a/chrome/browser/views/clear_browsing_data.h
+++ b/chrome/browser/views/clear_browsing_data.h
@@ -73,7 +73,7 @@ class ClearBrowsingDataView : public views::View,
int new_index);
// Overridden from views::ButtonListener:
- virtual void ButtonPressed(views::Button* sender);
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
private:
// Adds a new check-box as a child to the view.
diff --git a/chrome/browser/views/constrained_window_win.cc b/chrome/browser/views/constrained_window_win.cc
index 8a68c1e..c94576e 100644
--- a/chrome/browser/views/constrained_window_win.cc
+++ b/chrome/browser/views/constrained_window_win.cc
@@ -181,7 +181,7 @@ class ConstrainedWindowFrameView
virtual void ThemeChanged();
// Overridden from views::ButtonListener:
- virtual void ButtonPressed(views::Button* sender);
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
private:
// Returns the thickness of the border that makes up the window frame edges.
@@ -399,7 +399,8 @@ void ConstrainedWindowFrameView::ThemeChanged() {
////////////////////////////////////////////////////////////////////////////////
// ConstrainedWindowFrameView, views::ButtonListener implementation:
-void ConstrainedWindowFrameView::ButtonPressed(views::Button* sender) {
+void ConstrainedWindowFrameView::ButtonPressed(
+ views::Button* sender, const views::Event& event) {
if (sender == close_button_)
container_->ExecuteSystemMenuCommand(SC_CLOSE);
}
diff --git a/chrome/browser/views/download_item_view.cc b/chrome/browser/views/download_item_view.cc
index ec4d514..c704b67 100644
--- a/chrome/browser/views/download_item_view.cc
+++ b/chrome/browser/views/download_item_view.cc
@@ -428,7 +428,8 @@ void DownloadItemView::Layout() {
}
}
-void DownloadItemView::ButtonPressed(views::Button* sender) {
+void DownloadItemView::ButtonPressed(
+ views::Button* sender, const views::Event& event) {
if (sender == discard_button_) {
UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download",
base::Time::Now() - creation_time_);
diff --git a/chrome/browser/views/download_item_view.h b/chrome/browser/views/download_item_view.h
index a97d6a0..229dab8 100644
--- a/chrome/browser/views/download_item_view.h
+++ b/chrome/browser/views/download_item_view.h
@@ -64,7 +64,7 @@ class DownloadItemView : public views::ButtonListener,
virtual bool OnMouseDragged(const views::MouseEvent& event);
// ButtonListener implementation.
- virtual void ButtonPressed(views::Button* sender);
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
// AnimationDelegate implementation.
virtual void AnimationProgressed(const Animation* animation);
diff --git a/chrome/browser/views/download_shelf_view.cc b/chrome/browser/views/download_shelf_view.cc
index 59a730ce..2141a17 100644
--- a/chrome/browser/views/download_shelf_view.cc
+++ b/chrome/browser/views/download_shelf_view.cc
@@ -307,7 +307,8 @@ void DownloadShelfView::LinkActivated(views::Link* source, int event_flags) {
browser_->ShowDownloadsTab();
}
-void DownloadShelfView::ButtonPressed(views::Button* button) {
+void DownloadShelfView::ButtonPressed(
+ views::Button* button, const views::Event& event) {
Close();
}
diff --git a/chrome/browser/views/download_shelf_view.h b/chrome/browser/views/download_shelf_view.h
index 148acff..2d24607 100644
--- a/chrome/browser/views/download_shelf_view.h
+++ b/chrome/browser/views/download_shelf_view.h
@@ -52,7 +52,7 @@ class DownloadShelfView : public DownloadShelf,
// Implementation of ButtonListener.
// Invoked when the user clicks the close button. Asks the browser to
// hide the download shelf.
- virtual void ButtonPressed(views::Button* button);
+ virtual void ButtonPressed(views::Button* button, const views::Event& event);
// Implementation of DownloadShelf.
virtual void AddDownload(BaseDownloadItemModel* download_model);
diff --git a/chrome/browser/views/extensions/extension_pack_dialog.cc b/chrome/browser/views/extensions/extension_pack_dialog.cc
index eab0e38..dcd8fc9 100644
--- a/chrome/browser/views/extensions/extension_pack_dialog.cc
+++ b/chrome/browser/views/extensions/extension_pack_dialog.cc
@@ -169,7 +169,7 @@ class PackDialogContent
}
// ButtonListener
- virtual void ButtonPressed(views::Button* sender) {
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event) {
file_dialog_ = SelectFileDialog::Create(this);
if (sender == extension_root_button_) {
diff --git a/chrome/browser/views/find_bar_view.cc b/chrome/browser/views/find_bar_view.cc
index da1acd1..857869c 100644
--- a/chrome/browser/views/find_bar_view.cc
+++ b/chrome/browser/views/find_bar_view.cc
@@ -406,7 +406,8 @@ gfx::Size FindBarView::GetPreferredSize() {
////////////////////////////////////////////////////////////////////////////////
// FindBarView, views::ButtonListener implementation:
-void FindBarView::ButtonPressed(views::Button* sender) {
+void FindBarView::ButtonPressed(
+ views::Button* sender, const views::Event& event) {
switch (sender->tag()) {
case FIND_PREVIOUS_TAG:
case FIND_NEXT_TAG:
@@ -416,11 +417,14 @@ void FindBarView::ButtonPressed(views::Button* sender) {
sender->tag() == FIND_NEXT_TAG,
false); // Not case sensitive.
}
- // Move the focus back to the text-field, we don't want the button
- // focused.
- // TODO(jcampan): http://crbug.com/9867 we should not change the focus
- // when teh button was pressed by pressing a key.
- find_text_->RequestFocus();
+ if (event.IsMouseEvent()) {
+ // If mouse event, we move the focus back to the text-field, so that the
+ // user doesn't have to click on the text field to change the search. We
+ // don't want to do this for keyboard clicks on the button, since the
+ // user is more likely to press FindNext again than change the search
+ // query.
+ find_text_->RequestFocus();
+ }
break;
case CLOSE_TAG:
container_->GetFindBarController()->EndFindSession();
diff --git a/chrome/browser/views/find_bar_view.h b/chrome/browser/views/find_bar_view.h
index 8e3a664..885e788 100644
--- a/chrome/browser/views/find_bar_view.h
+++ b/chrome/browser/views/find_bar_view.h
@@ -63,7 +63,7 @@ class FindBarView : public views::View,
virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child);
// Overridden from views::ButtonListener:
- virtual void ButtonPressed(views::Button* sender);
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
// Overridden from views::Textfield::Controller:
virtual void ContentsChanged(views::Textfield* sender,
diff --git a/chrome/browser/views/first_run_bubble.cc b/chrome/browser/views/first_run_bubble.cc
index b79c665..257a944 100644
--- a/chrome/browser/views/first_run_bubble.cc
+++ b/chrome/browser/views/first_run_bubble.cc
@@ -123,7 +123,7 @@ class FirstRunBubbleView : public FirstRunBubbleViewBase {
keep_button_->RequestFocus();
}
- virtual void ButtonPressed(views::Button* sender) {
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event) {
bubble_window_->Close();
if (change_button_ == sender) {
Browser* browser = BrowserList::GetLastActive();
@@ -257,7 +257,7 @@ class FirstRunOEMBubbleView : public FirstRunBubbleViewBase {
// No button in oem_bubble to request focus.
}
- virtual void ButtonPressed(views::Button* sender) {
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event) {
bubble_window_->Close();
}
diff --git a/chrome/browser/views/first_run_customize_view.cc b/chrome/browser/views/first_run_customize_view.cc
index 5ae339b..8ed49b3 100644
--- a/chrome/browser/views/first_run_customize_view.cc
+++ b/chrome/browser/views/first_run_customize_view.cc
@@ -156,7 +156,8 @@ void FirstRunCustomizeView::Layout() {
AdjustDialogWidth(quick_shortcut_cbox_);
}
-void FirstRunCustomizeView::ButtonPressed(views::Button* sender) {
+void FirstRunCustomizeView::ButtonPressed(
+ views::Button* sender, const views::Event& event) {
if (import_cbox_ == sender) {
// Disable the import combobox if the user unchecks the checkbox.
import_from_combo_->SetEnabled(import_cbox_->checked());
diff --git a/chrome/browser/views/first_run_customize_view.h b/chrome/browser/views/first_run_customize_view.h
index 1dcf1a0..cdc5e8e 100644
--- a/chrome/browser/views/first_run_customize_view.h
+++ b/chrome/browser/views/first_run_customize_view.h
@@ -53,7 +53,7 @@ class FirstRunCustomizeView : public FirstRunViewBase,
virtual bool Cancel();
// Overridden form views::ButtonListener.
- virtual void ButtonPressed(views::Button* sender);
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
// Overridden form ComboboxModel.
virtual int GetItemCount();
diff --git a/chrome/browser/views/frame/opaque_browser_frame_view.cc b/chrome/browser/views/frame/opaque_browser_frame_view.cc
index 13fb540..0bbdc7d 100644
--- a/chrome/browser/views/frame/opaque_browser_frame_view.cc
+++ b/chrome/browser/views/frame/opaque_browser_frame_view.cc
@@ -421,7 +421,8 @@ void OpaqueBrowserFrameView::SetAccessibleName(const std::wstring& name) {
///////////////////////////////////////////////////////////////////////////////
// OpaqueBrowserFrameView, views::ButtonListener implementation:
-void OpaqueBrowserFrameView::ButtonPressed(views::Button* sender) {
+void OpaqueBrowserFrameView::ButtonPressed(
+ views::Button* sender, const views::Event& event) {
views::Window* window = frame_->GetWindow();
if (sender == minimize_button_)
window->Minimize();
diff --git a/chrome/browser/views/frame/opaque_browser_frame_view.h b/chrome/browser/views/frame/opaque_browser_frame_view.h
index 3f71560..81d2b36 100644
--- a/chrome/browser/views/frame/opaque_browser_frame_view.h
+++ b/chrome/browser/views/frame/opaque_browser_frame_view.h
@@ -59,7 +59,7 @@ class OpaqueBrowserFrameView : public BrowserNonClientFrameView,
virtual void SetAccessibleName(const std::wstring& name);
// Overridden from views::ButtonListener:
- virtual void ButtonPressed(views::Button* sender);
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
// Overridden from TabIconView::TabIconViewModel:
virtual bool ShouldTabIconViewAnimate() const;
diff --git a/chrome/browser/views/go_button.cc b/chrome/browser/views/go_button.cc
index f3a040d..ca9c155 100644
--- a/chrome/browser/views/go_button.cc
+++ b/chrome/browser/views/go_button.cc
@@ -52,7 +52,7 @@ void GoButton::ChangeMode(Mode mode, bool force) {
////////////////////////////////////////////////////////////////////////////////
// GoButton, views::ButtonListener implementation:
-void GoButton::ButtonPressed(views::Button* button) {
+void GoButton::ButtonPressed(views::Button* button, const views::Event& event) {
if (visible_mode_ == MODE_STOP) {
browser_->Stop();
diff --git a/chrome/browser/views/go_button.h b/chrome/browser/views/go_button.h
index 1f1136b..f53117c 100644
--- a/chrome/browser/views/go_button.h
+++ b/chrome/browser/views/go_button.h
@@ -37,7 +37,7 @@ class GoButton : public views::ToggleImageButton,
void ChangeMode(Mode mode, bool force);
// Overridden from views::ButtonListener:
- virtual void ButtonPressed(views::Button* button);
+ virtual void ButtonPressed(views::Button* button, const views::Event& event);
// Overridden from views::View:
virtual void OnMouseExited(const views::MouseEvent& e);
diff --git a/chrome/browser/views/hung_renderer_view.cc b/chrome/browser/views/hung_renderer_view.cc
index 606a42c..560dbb3 100644
--- a/chrome/browser/views/hung_renderer_view.cc
+++ b/chrome/browser/views/hung_renderer_view.cc
@@ -139,7 +139,7 @@ class HungRendererDialogView : public views::View,
virtual views::View* GetContentsView();
// views::ButtonListener overrides:
- virtual void ButtonPressed(views::Button* sender);
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
protected:
// views::View overrides:
@@ -312,7 +312,8 @@ views::View* HungRendererDialogView::GetContentsView() {
///////////////////////////////////////////////////////////////////////////////
// HungRendererDialogView, views::ButtonListener implementation:
-void HungRendererDialogView::ButtonPressed(views::Button* sender) {
+void HungRendererDialogView::ButtonPressed(
+ views::Button* sender, const views::Event& event) {
if (sender == kill_button_) {
// Kill the process.
HANDLE process = contents_->process()->process().handle();
diff --git a/chrome/browser/views/infobars/infobars.cc b/chrome/browser/views/infobars/infobars.cc
index c404d0e..1bf1290 100644
--- a/chrome/browser/views/infobars/infobars.cc
+++ b/chrome/browser/views/infobars/infobars.cc
@@ -198,7 +198,7 @@ void InfoBar::RemoveInfoBar() const {
// InfoBar, views::ButtonListener implementation: ------------------
-void InfoBar::ButtonPressed(views::Button* sender) {
+void InfoBar::ButtonPressed(views::Button* sender, const views::Event& event) {
if (sender == close_button_) {
if (delegate_)
delegate_->InfoBarDismissed();
@@ -468,8 +468,9 @@ void ConfirmInfoBar::ViewHierarchyChanged(bool is_add,
// ConfirmInfoBar, views::ButtonListener implementation: ---------------
-void ConfirmInfoBar::ButtonPressed(views::Button* sender) {
- InfoBar::ButtonPressed(sender);
+void ConfirmInfoBar::ButtonPressed(
+ views::Button* sender, const views::Event& event) {
+ InfoBar::ButtonPressed(sender, event);
if (sender == ok_button_) {
if (GetDelegate()->Accept())
RemoveInfoBar();
diff --git a/chrome/browser/views/infobars/infobars.h b/chrome/browser/views/infobars/infobars.h
index b43d61d..d55baa4 100644
--- a/chrome/browser/views/infobars/infobars.h
+++ b/chrome/browser/views/infobars/infobars.h
@@ -75,7 +75,7 @@ class InfoBar : public views::View,
void RemoveInfoBar() const;
// Overridden from views::ButtonListener:
- virtual void ButtonPressed(views::Button* sender);
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
private:
// Overridden from AnimationDelegate:
@@ -177,7 +177,7 @@ class ConfirmInfoBar : public AlertInfoBar {
views::View* child);
// Overridden from views::ButtonListener:
- virtual void ButtonPressed(views::Button* sender);
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
// Overridden from InfoBar:
virtual int GetAvailableWidth() const;
diff --git a/chrome/browser/views/keyword_editor_view.cc b/chrome/browser/views/keyword_editor_view.cc
index ec68263..25e3dd1 100644
--- a/chrome/browser/views/keyword_editor_view.cc
+++ b/chrome/browser/views/keyword_editor_view.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 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.
@@ -215,11 +215,18 @@ void KeywordEditorView::OnSelectionChanged() {
}
void KeywordEditorView::OnDoubleClick() {
- if (edit_button_->IsEnabled())
- ButtonPressed(edit_button_);
+ if (edit_button_->IsEnabled()) {
+ DWORD pos = GetMessagePos();
+ POINT cursor_point = { GET_X_LPARAM(pos), GET_Y_LPARAM(pos) };
+ views::MouseEvent event(views::Event::ET_MOUSE_RELEASED,
+ cursor_point.x, cursor_point.y,
+ views::Event::EF_LEFT_BUTTON_DOWN);
+ ButtonPressed(edit_button_, event);
+ }
}
-void KeywordEditorView::ButtonPressed(views::Button* sender) {
+void KeywordEditorView::ButtonPressed(
+ views::Button* sender, const views::Event& event) {
if (sender == add_button_) {
browser::EditSearchEngine(GetWindow()->GetNativeWindow(), NULL, this,
profile_);
diff --git a/chrome/browser/views/keyword_editor_view.h b/chrome/browser/views/keyword_editor_view.h
index dd0cc89..361cc59 100644
--- a/chrome/browser/views/keyword_editor_view.h
+++ b/chrome/browser/views/keyword_editor_view.h
@@ -76,7 +76,7 @@ class KeywordEditorView : public views::View,
virtual void OnDoubleClick();
// Button::ButtonListener method.
- virtual void ButtonPressed(views::Button* sender);
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
// TemplateURLModelObserver notification.
virtual void OnTemplateURLModelChanged();
diff --git a/chrome/browser/views/new_browser_window_widget.cc b/chrome/browser/views/new_browser_window_widget.cc
index 74499c5..c8d3cf7 100644
--- a/chrome/browser/views/new_browser_window_widget.cc
+++ b/chrome/browser/views/new_browser_window_widget.cc
@@ -45,7 +45,8 @@ NewBrowserWindowWidget::~NewBrowserWindowWidget() {
widget_ = NULL;
}
-void NewBrowserWindowWidget::ButtonPressed(views::Button* sender) {
+void NewBrowserWindowWidget::ButtonPressed(
+ views::Button* sender, const views::Event& event) {
UserMetrics::RecordAction(L"TabOverview_PressedCreateNewBrowserButton",
profile_);
diff --git a/chrome/browser/views/new_browser_window_widget.h b/chrome/browser/views/new_browser_window_widget.h
index f19ce1c..5540009 100644
--- a/chrome/browser/views/new_browser_window_widget.h
+++ b/chrome/browser/views/new_browser_window_widget.h
@@ -22,7 +22,7 @@ class NewBrowserWindowWidget : public views::ButtonListener {
~NewBrowserWindowWidget();
// ButtonListener implementation.
- virtual void ButtonPressed(views::Button* sender);
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
private:
// The profile the browser is created with.
diff --git a/chrome/browser/views/options/advanced_contents_view.cc b/chrome/browser/views/options/advanced_contents_view.cc
index d398915..448e5a5 100644
--- a/chrome/browser/views/options/advanced_contents_view.cc
+++ b/chrome/browser/views/options/advanced_contents_view.cc
@@ -467,7 +467,7 @@ class PrivacySection : public AdvancedSection,
virtual ~PrivacySection() {}
// Overridden from views::ButtonListener:
- virtual void ButtonPressed(views::Button* sender);
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
// Overridden from views::Combobox::Listener:
virtual void ItemChanged(views::Combobox* sender,
@@ -529,7 +529,8 @@ PrivacySection::PrivacySection(Profile* profile)
l10n_util::GetString(IDS_OPTIONS_ADVANCED_SECTION_TITLE_PRIVACY)) {
}
-void PrivacySection::ButtonPressed(views::Button* sender) {
+void PrivacySection::ButtonPressed(
+ views::Button* sender, const views::Event& event) {
if (sender == enable_link_doctor_checkbox_) {
bool enabled = enable_link_doctor_checkbox_->checked();
UserMetricsRecordAction(enabled ?
@@ -758,7 +759,7 @@ class WebContentSection : public AdvancedSection,
virtual ~WebContentSection() {}
// Overridden from views::ButtonListener:
- virtual void ButtonPressed(views::Button* sender);
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
protected:
// OptionsPageView overrides:
@@ -783,7 +784,8 @@ WebContentSection::WebContentSection(Profile* profile)
l10n_util::GetString(IDS_OPTIONS_ADVANCED_SECTION_TITLE_CONTENT)) {
}
-void WebContentSection::ButtonPressed(views::Button* sender) {
+void WebContentSection::ButtonPressed(
+ views::Button* sender, const views::Event& event) {
if (sender == gears_settings_button_) {
UserMetricsRecordAction(L"Options_GearsSettings", NULL);
GearsSettingsPressed(GetAncestor(GetWidget()->GetNativeView(), GA_ROOT));
@@ -853,7 +855,7 @@ class SecuritySection : public AdvancedSection,
virtual ~SecuritySection() {}
// Overridden from views::ButtonListener:
- virtual void ButtonPressed(views::Button* sender);
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
protected:
// OptionsPageView overrides:
@@ -881,7 +883,8 @@ SecuritySection::SecuritySection(Profile* profile)
l10n_util::GetString(IDS_OPTIONS_ADVANCED_SECTION_TITLE_SECURITY)) {
}
-void SecuritySection::ButtonPressed(views::Button* sender) {
+void SecuritySection::ButtonPressed(
+ views::Button* sender, const views::Event& event) {
if (sender == enable_ssl2_checkbox_) {
bool enabled = enable_ssl2_checkbox_->checked();
if (enabled) {
@@ -1010,7 +1013,7 @@ class NetworkSection : public AdvancedSection,
virtual ~NetworkSection() {}
// Overridden from views::ButtonListener:
- virtual void ButtonPressed(views::Button* sender);
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
protected:
// OptionsPageView overrides:
@@ -1032,7 +1035,8 @@ NetworkSection::NetworkSection(Profile* profile)
l10n_util::GetString(IDS_OPTIONS_ADVANCED_SECTION_TITLE_NETWORK)) {
}
-void NetworkSection::ButtonPressed(views::Button* sender) {
+void NetworkSection::ButtonPressed(
+ views::Button* sender, const views::Event& event) {
if (sender == change_proxies_button_) {
UserMetricsRecordAction(L"Options_ChangeProxies", NULL);
base::Thread* thread = g_browser_process->file_thread();
@@ -1086,7 +1090,7 @@ class DownloadSection : public AdvancedSection,
}
// Overridden from views::ButtonListener.
- virtual void ButtonPressed(views::Button* sender);
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
// SelectFileDialog::Listener implementation.
virtual void FileSelected(const FilePath& path, int index, void* params);
@@ -1135,7 +1139,8 @@ DownloadSection::DownloadSection(Profile* profile)
l10n_util::GetString(IDS_OPTIONS_DOWNLOADLOCATION_GROUP_NAME)) {
}
-void DownloadSection::ButtonPressed(views::Button* sender) {
+void DownloadSection::ButtonPressed(
+ views::Button* sender, const views::Event& event) {
if (sender == download_browse_button_) {
const std::wstring dialog_title =
l10n_util::GetString(IDS_OPTIONS_DOWNLOADLOCATION_BROWSE_TITLE);
diff --git a/chrome/browser/views/options/advanced_page_view.cc b/chrome/browser/views/options/advanced_page_view.cc
index f5136342..b30ee35 100644
--- a/chrome/browser/views/options/advanced_page_view.cc
+++ b/chrome/browser/views/options/advanced_page_view.cc
@@ -102,7 +102,8 @@ void AdvancedPageView::ResetToDefaults() {
///////////////////////////////////////////////////////////////////////////////
// AdvancedPageView, views::ButtonListener implementation:
-void AdvancedPageView::ButtonPressed(views::Button* sender) {
+void AdvancedPageView::ButtonPressed(
+ views::Button* sender, const views::Event& event) {
if (sender == reset_to_default_button_) {
UserMetricsRecordAction(L"Options_ResetToDefaults", NULL);
ResetDefaultsConfirmBox::ShowConfirmBox(
diff --git a/chrome/browser/views/options/advanced_page_view.h b/chrome/browser/views/options/advanced_page_view.h
index 63f0ede..47c78b2 100644
--- a/chrome/browser/views/options/advanced_page_view.h
+++ b/chrome/browser/views/options/advanced_page_view.h
@@ -28,7 +28,7 @@ class AdvancedPageView : public OptionsPageView,
void ResetToDefaults();
// views::ButtonListener implementation:
- virtual void ButtonPressed(views::Button* sender);
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
protected:
// OptionsPageView implementation:
diff --git a/chrome/browser/views/options/content_page_view.cc b/chrome/browser/views/options/content_page_view.cc
index 81bfeef..4679338 100644
--- a/chrome/browser/views/options/content_page_view.cc
+++ b/chrome/browser/views/options/content_page_view.cc
@@ -85,7 +85,8 @@ ContentPageView::~ContentPageView() {
///////////////////////////////////////////////////////////////////////////////
// ContentPageView, views::ButtonListener implementation:
-void ContentPageView::ButtonPressed(views::Button* sender) {
+void ContentPageView::ButtonPressed(
+ views::Button* sender, const views::Event& event) {
if (sender == passwords_asktosave_radio_ ||
sender == passwords_neversave_radio_) {
bool enabled = passwords_asktosave_radio_->checked();
diff --git a/chrome/browser/views/options/content_page_view.h b/chrome/browser/views/options/content_page_view.h
index b6ad3b7..039f435 100644
--- a/chrome/browser/views/options/content_page_view.h
+++ b/chrome/browser/views/options/content_page_view.h
@@ -36,7 +36,7 @@ class ContentPageView : public OptionsPageView,
virtual ~ContentPageView();
// views::ButtonListener implementation:
- virtual void ButtonPressed(views::Button* sender);
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
#ifdef CHROME_PERSONALIZATION
// views::LinkController method.
diff --git a/chrome/browser/views/options/cookies_view.cc b/chrome/browser/views/options/cookies_view.cc
index fa0e711..b758483 100644
--- a/chrome/browser/views/options/cookies_view.cc
+++ b/chrome/browser/views/options/cookies_view.cc
@@ -358,7 +358,8 @@ void CookiesView::UpdateSearchResults() {
///////////////////////////////////////////////////////////////////////////////
// CookiesView, views::Buttonlistener implementation:
-void CookiesView::ButtonPressed(views::Button* sender) {
+void CookiesView::ButtonPressed(
+ views::Button* sender, const views::Event& event) {
if (sender == remove_button_) {
cookies_table_->RemoveSelectedCookies();
} else if (sender == remove_all_button_) {
diff --git a/chrome/browser/views/options/cookies_view.h b/chrome/browser/views/options/cookies_view.h
index 880d622..23e28ba 100644
--- a/chrome/browser/views/options/cookies_view.h
+++ b/chrome/browser/views/options/cookies_view.h
@@ -42,7 +42,7 @@ class CookiesView : public views::View,
void UpdateSearchResults();
// views::ButtonListener implementation.
- virtual void ButtonPressed(views::Button* sender);
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
// views::TableViewObserver implementation.
virtual void OnSelectionChanged();
diff --git a/chrome/browser/views/options/exceptions_page_view.cc b/chrome/browser/views/options/exceptions_page_view.cc
index a77ce01..5e9af5e 100644
--- a/chrome/browser/views/options/exceptions_page_view.cc
+++ b/chrome/browser/views/options/exceptions_page_view.cc
@@ -85,7 +85,8 @@ void ExceptionsPageView::OnSelectionChanged() {
remove_button_.SetEnabled(has_selection);
}
-void ExceptionsPageView::ButtonPressed(views::Button* sender) {
+void ExceptionsPageView::ButtonPressed(
+ views::Button* sender, const views::Event& event) {
// Close will result in our destruction.
if (sender == &remove_all_button_) {
table_model_.ForgetAndRemoveAllSignons();
diff --git a/chrome/browser/views/options/exceptions_page_view.h b/chrome/browser/views/options/exceptions_page_view.h
index 23182f8..b603a35 100644
--- a/chrome/browser/views/options/exceptions_page_view.h
+++ b/chrome/browser/views/options/exceptions_page_view.h
@@ -44,7 +44,7 @@ class ExceptionsPageView : public OptionsPageView,
virtual void OnSelectionChanged();
// views::ButtonListener implementation.
- virtual void ButtonPressed(views::Button* sender);
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
// PasswordsTableModelObserver implementation.
virtual void OnRowCountChanged(size_t rows);
diff --git a/chrome/browser/views/options/fonts_page_view.cc b/chrome/browser/views/options/fonts_page_view.cc
index 2affdb8..16836e6 100644
--- a/chrome/browser/views/options/fonts_page_view.cc
+++ b/chrome/browser/views/options/fonts_page_view.cc
@@ -229,7 +229,8 @@ FontsPageView::FontsPageView(Profile* profile)
FontsPageView::~FontsPageView() {
}
-void FontsPageView::ButtonPressed(views::Button* sender) {
+void FontsPageView::ButtonPressed(
+ views::Button* sender, const views::Event& event) {
HWND owning_hwnd = GetAncestor(GetWidget()->GetNativeView(), GA_ROOT);
std::wstring font_name;
int font_size = 0;
diff --git a/chrome/browser/views/options/fonts_page_view.h b/chrome/browser/views/options/fonts_page_view.h
index c92df20..d85d8ff 100644
--- a/chrome/browser/views/options/fonts_page_view.h
+++ b/chrome/browser/views/options/fonts_page_view.h
@@ -36,7 +36,7 @@ class FontsPageView : public OptionsPageView,
virtual ~FontsPageView();
// views::ButtonListener implementation:
- virtual void ButtonPressed(views::Button* sender);
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
// views::Combobox::Listener implementation:
virtual void ItemChanged(views::Combobox* combo_box,
diff --git a/chrome/browser/views/options/general_page_view.cc b/chrome/browser/views/options/general_page_view.cc
index e2ca0aa..cb87b72 100644
--- a/chrome/browser/views/options/general_page_view.cc
+++ b/chrome/browser/views/options/general_page_view.cc
@@ -427,7 +427,8 @@ GeneralPageView::~GeneralPageView() {
///////////////////////////////////////////////////////////////////////////////
// GeneralPageView, views::ButtonListener implementation:
-void GeneralPageView::ButtonPressed(views::Button* sender) {
+void GeneralPageView::ButtonPressed(
+ views::Button* sender, const views::Event& event) {
if (sender == startup_homepage_radio_ ||
sender == startup_last_session_radio_ ||
sender == startup_custom_radio_) {
diff --git a/chrome/browser/views/options/general_page_view.h b/chrome/browser/views/options/general_page_view.h
index 91b6d01..fea8b4d 100644
--- a/chrome/browser/views/options/general_page_view.h
+++ b/chrome/browser/views/options/general_page_view.h
@@ -44,7 +44,7 @@ class GeneralPageView : public OptionsPageView,
protected:
// views::ButtonListener implementation:
- virtual void ButtonPressed(views::Button* sender);
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
// views::Combobox::Listener implementation:
virtual void ItemChanged(views::Combobox* combobox,
diff --git a/chrome/browser/views/options/languages_page_view.cc b/chrome/browser/views/options/languages_page_view.cc
index ecb90d8..b1c2ee7 100644
--- a/chrome/browser/views/options/languages_page_view.cc
+++ b/chrome/browser/views/options/languages_page_view.cc
@@ -205,7 +205,8 @@ LanguagesPageView::~LanguagesPageView() {
language_order_table_->SetModel(NULL);
}
-void LanguagesPageView::ButtonPressed(views::Button* sender) {
+void LanguagesPageView::ButtonPressed(
+ views::Button* sender, const views::Event& event) {
if (sender == move_up_button_) {
OnMoveUpLanguage();
language_table_edited_ = true;
diff --git a/chrome/browser/views/options/languages_page_view.h b/chrome/browser/views/options/languages_page_view.h
index a16203b..4dad30c 100644
--- a/chrome/browser/views/options/languages_page_view.h
+++ b/chrome/browser/views/options/languages_page_view.h
@@ -36,7 +36,7 @@ class LanguagesPageView : public OptionsPageView,
virtual ~LanguagesPageView();
// views::ButtonListener implementation:
- virtual void ButtonPressed(views::Button* sender);
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
// Save Changes made to relevant pref members associated with this tab.
// This is public since it is called by FontsLanguageWindowView in its
diff --git a/chrome/browser/views/options/passwords_page_view.cc b/chrome/browser/views/options/passwords_page_view.cc
index bee94c3..40cf83c 100644
--- a/chrome/browser/views/options/passwords_page_view.cc
+++ b/chrome/browser/views/options/passwords_page_view.cc
@@ -211,7 +211,8 @@ void PasswordsPageView::OnSelectionChanged() {
}
}
-void PasswordsPageView::ButtonPressed(views::Button* sender) {
+void PasswordsPageView::ButtonPressed(
+ views::Button* sender, const views::Event& event) {
// Close will result in our destruction.
if (sender == &remove_all_button_) {
bool accepted = ConfirmMessageBoxDialog::Run(
diff --git a/chrome/browser/views/options/passwords_page_view.h b/chrome/browser/views/options/passwords_page_view.h
index 2766bce..d1c0346 100644
--- a/chrome/browser/views/options/passwords_page_view.h
+++ b/chrome/browser/views/options/passwords_page_view.h
@@ -153,7 +153,7 @@ class PasswordsPageView : public OptionsPageView,
virtual void OnSelectionChanged();
// views::ButtonListener implementation.
- virtual void ButtonPressed(views::Button* sender);
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
// PasswordsTableModelObserver implementation.
virtual void OnRowCountChanged(size_t rows);
diff --git a/chrome/browser/views/page_info_window_view.cc b/chrome/browser/views/page_info_window_view.cc
index 987552b6..9702e5b 100644
--- a/chrome/browser/views/page_info_window_view.cc
+++ b/chrome/browser/views/page_info_window_view.cc
@@ -72,7 +72,7 @@ class PageInfoWindowView : public views::View,
virtual void ShowCertDialog(int cert_id);
// views::ButtonListener method.
- virtual void ButtonPressed(views::Button* sender);
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
// views::DialogDelegate methods:
virtual int GetDialogButtons() const;
@@ -283,7 +283,8 @@ void PageInfoWindowView::ModelChanged() {
LayoutSections();
}
-void PageInfoWindowView::ButtonPressed(views::Button* sender) {
+void PageInfoWindowView::ButtonPressed(
+ views::Button* sender, const views::Event& event) {
// So far we only listen for the "Certificate info" button.
DCHECK(cert_id_ != 0);
ShowCertDialog(cert_id_);
diff --git a/chrome/browser/views/panel_controller.cc b/chrome/browser/views/panel_controller.cc
index 9d5dd69..0d722db 100644
--- a/chrome/browser/views/panel_controller.cc
+++ b/chrome/browser/views/panel_controller.cc
@@ -217,7 +217,8 @@ void PanelController::Close() {
title_window_->Close();
}
-void PanelController::ButtonPressed(views::Button* sender) {
+void PanelController::ButtonPressed(
+ views::Button* sender, const views::Event& event) {
if (sender == title_content_->close_button()) {
browser_window_->Close();
}
diff --git a/chrome/browser/views/panel_controller.h b/chrome/browser/views/panel_controller.h
index de7d613..bb5804f 100644
--- a/chrome/browser/views/panel_controller.h
+++ b/chrome/browser/views/panel_controller.h
@@ -36,7 +36,7 @@ class PanelController : public views::ButtonListener {
void UpdateTitleBar();
void Close();
// ButtonListener methods.
- virtual void ButtonPressed(views::Button* sender);
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
private:
class TitleContentView : public views::View {
diff --git a/chrome/browser/views/tabs/tab.cc b/chrome/browser/views/tabs/tab.cc
index 14d416c..95ea76a 100644
--- a/chrome/browser/views/tabs/tab.cc
+++ b/chrome/browser/views/tabs/tab.cc
@@ -221,7 +221,7 @@ void Tab::ShowContextMenu(views::View* source, int x, int y,
///////////////////////////////////////////////////////////////////////////////
// views::ButtonListener implementation:
-void Tab::ButtonPressed(views::Button* sender) {
+void Tab::ButtonPressed(views::Button* sender, const views::Event& event) {
if (sender == close_button())
delegate_->CloseTab(this);
}
diff --git a/chrome/browser/views/tabs/tab.h b/chrome/browser/views/tabs/tab.h
index ad918a2..a7a8d91 100644
--- a/chrome/browser/views/tabs/tab.h
+++ b/chrome/browser/views/tabs/tab.h
@@ -109,7 +109,7 @@ class Tab : public TabRenderer,
bool is_mouse_gesture);
// views::ButtonListener overrides:
- virtual void ButtonPressed(views::Button* sender);
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
// Creates a path that contains the clickable region of the tab's visual
// representation. Used by GetViewForPoint for hit-testing.
diff --git a/chrome/browser/views/tabs/tab_2.cc b/chrome/browser/views/tabs/tab_2.cc
index 14a8188..8065060 100644
--- a/chrome/browser/views/tabs/tab_2.cc
+++ b/chrome/browser/views/tabs/tab_2.cc
@@ -273,7 +273,7 @@ void Tab2::AddTabShapeToPath(gfx::Path* path) const {
///////////////////////////////////////////////////////////////////////////////
// Tab2, views::ButtonListener implementation:
-void Tab2::ButtonPressed(views::Button* sender) {
+void Tab2::ButtonPressed(views::Button* sender, const views::Event& event) {
if (sender == close_button_)
model_->CloseTab(this);
}
diff --git a/chrome/browser/views/tabs/tab_2.h b/chrome/browser/views/tabs/tab_2.h
index 4af97ec..079d39c 100644
--- a/chrome/browser/views/tabs/tab_2.h
+++ b/chrome/browser/views/tabs/tab_2.h
@@ -127,7 +127,7 @@ class Tab2 : public views::View,
};
// views::ButtonListener overrides:
- virtual void ButtonPressed(views::Button* sender);
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
// Overridden from views::View:
virtual void Layout();
diff --git a/chrome/browser/views/tabs/tab_renderer.h b/chrome/browser/views/tabs/tab_renderer.h
index 8b2cbb8..1f91dd3 100644
--- a/chrome/browser/views/tabs/tab_renderer.h
+++ b/chrome/browser/views/tabs/tab_renderer.h
@@ -94,7 +94,8 @@ class TabRenderer : public views::View,
std::wstring GetTitle() const;
// views::ButtonListener overrides:
- virtual void ButtonPressed(views::Button* sender) {}
+ virtual void ButtonPressed(views::Button* sender,
+ const views::Event& event) {}
private:
// Overridden from views::View:
diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc
index 9bfb84b..3ff6d45 100644
--- a/chrome/browser/views/tabs/tab_strip.cc
+++ b/chrome/browser/views/tabs/tab_strip.cc
@@ -970,7 +970,7 @@ bool TabStrip::HasAvailableDragActions() const {
///////////////////////////////////////////////////////////////////////////////
// TabStrip, views::BaseButton::ButtonListener implementation:
-void TabStrip::ButtonPressed(views::Button* sender) {
+void TabStrip::ButtonPressed(views::Button* sender, const views::Event& event) {
if (sender == newtab_button_) {
UserMetrics::RecordAction(L"NewTab_Button", model_->profile());
model_->delegate()->AddBlankTab(true);
diff --git a/chrome/browser/views/tabs/tab_strip.h b/chrome/browser/views/tabs/tab_strip.h
index 08ad39b..d598a2c 100644
--- a/chrome/browser/views/tabs/tab_strip.h
+++ b/chrome/browser/views/tabs/tab_strip.h
@@ -121,7 +121,7 @@ class TabStrip : public views::View,
virtual bool HasAvailableDragActions() const;
// views::ButtonListener implementation:
- virtual void ButtonPressed(views::Button* sender);
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
// MessageLoop::Observer implementation:
#if defined(OS_WIN)
diff --git a/chrome/browser/views/task_manager_view.cc b/chrome/browser/views/task_manager_view.cc
index 52a14bd..d449a92 100644
--- a/chrome/browser/views/task_manager_view.cc
+++ b/chrome/browser/views/task_manager_view.cc
@@ -184,7 +184,7 @@ class TaskManagerView : public views::View,
views::View* child);
// ButtonListener implementation.
- virtual void ButtonPressed(views::Button* sender);
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
// views::DialogDelegate
virtual bool CanResize() const;
@@ -425,7 +425,8 @@ void TaskManagerView::Show() {
}
// ButtonListener implementation.
-void TaskManagerView::ButtonPressed(views::Button* sender) {
+void TaskManagerView::ButtonPressed(
+ views::Button* sender, const views::Event& event) {
DCHECK(sender == kill_button_);
for (views::TableSelectionIterator iter = tab_table_->SelectionBegin();
iter != tab_table_->SelectionEnd(); ++iter) {
diff --git a/chrome/browser/views/toolbar_star_toggle.cc b/chrome/browser/views/toolbar_star_toggle.cc
index 8c89a5a..0d9a8ff 100644
--- a/chrome/browser/views/toolbar_star_toggle.cc
+++ b/chrome/browser/views/toolbar_star_toggle.cc
@@ -63,9 +63,9 @@ void ToolbarStarToggle::OnDragDone() {
ignore_click_ = false;
}
-void ToolbarStarToggle::NotifyClick(int mouse_event_flags) {
+void ToolbarStarToggle::NotifyClick(const views::Event& event) {
if (!ignore_click_ && !browser::IsBookmarkBubbleViewShowing())
- ToggleImageButton::NotifyClick(mouse_event_flags);
+ ToggleImageButton::NotifyClick(event);
}
SkBitmap ToolbarStarToggle::GetImageToPaint() {
diff --git a/chrome/browser/views/toolbar_star_toggle.h b/chrome/browser/views/toolbar_star_toggle.h
index 37c2db5..547fc19 100644
--- a/chrome/browser/views/toolbar_star_toggle.h
+++ b/chrome/browser/views/toolbar_star_toggle.h
@@ -34,7 +34,7 @@ class ToolbarStarToggle : public views::ToggleImageButton,
protected:
// Only invokes super if ignore_click_ is true and the bubble isn't showing.
- virtual void NotifyClick(int mouse_event_flags);
+ virtual void NotifyClick(const views::Event& event);
// Overridden to so that we appear pressed while the bubble is showing.
virtual SkBitmap GetImageToPaint();
diff --git a/chrome/browser/views/toolbar_view.cc b/chrome/browser/views/toolbar_view.cc
index 53ba16a..73d57a7 100644
--- a/chrome/browser/views/toolbar_view.cc
+++ b/chrome/browser/views/toolbar_view.cc
@@ -347,7 +347,8 @@ void ToolbarView::EnabledStateChangedForCommand(int id, bool enabled) {
////////////////////////////////////////////////////////////////////////////////
// ToolbarView, views::Button::ButtonListener implementation:
-void ToolbarView::ButtonPressed(views::Button* sender) {
+void ToolbarView::ButtonPressed(
+ views::Button* sender, const views::Event& event) {
int id = sender->tag();
switch (id) {
case IDC_BACK:
diff --git a/chrome/browser/views/toolbar_view.h b/chrome/browser/views/toolbar_view.h
index ad81be4..051b22d 100644
--- a/chrome/browser/views/toolbar_view.h
+++ b/chrome/browser/views/toolbar_view.h
@@ -126,7 +126,7 @@ class ToolbarView : public views::View,
virtual void EnabledStateChangedForCommand(int id, bool enabled);
// Overridden from views::BaseButton::ButtonListener:
- virtual void ButtonPressed(views::Button* sender);
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
// Overridden from AutocompletePopupPositioner:
virtual gfx::Rect GetPopupBounds() const;
diff --git a/chrome/browser/views/uninstall_view.cc b/chrome/browser/views/uninstall_view.cc
index cb31e23..4b29766 100644
--- a/chrome/browser/views/uninstall_view.cc
+++ b/chrome/browser/views/uninstall_view.cc
@@ -118,7 +118,8 @@ std::wstring UninstallView::GetDialogButtonLabel(
return label;
}
-void UninstallView::ButtonPressed(views::Button* sender) {
+void UninstallView::ButtonPressed(
+ views::Button* sender, const views::Event& event) {
if (change_default_browser_ == sender) {
// Disable the browsers combobox if the user unchecks the checkbox.
DCHECK(browsers_combo_);
diff --git a/chrome/browser/views/uninstall_view.h b/chrome/browser/views/uninstall_view.h
index b09cbc7..54e6790 100644
--- a/chrome/browser/views/uninstall_view.h
+++ b/chrome/browser/views/uninstall_view.h
@@ -32,7 +32,7 @@ class UninstallView : public views::View,
MessageBoxFlags::DialogButton button) const;
// Overridden form views::ButtonListener.
- virtual void ButtonPressed(views::Button* sender);
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
// Overridden from views::WindowDelegate:
virtual std::wstring GetWindowTitle() const;
diff --git a/views/controls/button/button.cc b/views/controls/button/button.cc
index cbb42bf..504a2f5 100644
--- a/views/controls/button/button.cc
+++ b/views/controls/button/button.cc
@@ -66,12 +66,12 @@ Button::Button(ButtonListener* listener)
mouse_event_flags_(0) {
}
-void Button::NotifyClick(int mouse_event_flags) {
- mouse_event_flags_ = mouse_event_flags;
+void Button::NotifyClick(const views::Event& event) {
+ mouse_event_flags_ = event.IsMouseEvent() ? event.GetFlags() : 0;
// We can be called when there is no listener, in cases like double clicks on
// menu buttons etc.
if (listener_)
- listener_->ButtonPressed(this);
+ listener_->ButtonPressed(this, event);
// NOTE: don't attempt to reset mouse_event_flags_ as the listener may have
// deleted us.
}
diff --git a/views/controls/button/button.h b/views/controls/button/button.h
index 514758f..9dd8b13 100644
--- a/views/controls/button/button.h
+++ b/views/controls/button/button.h
@@ -10,12 +10,13 @@
namespace views {
class Button;
+class Event;
// An interface implemented by an object to let it know that a button was
// pressed.
class ButtonListener {
public:
- virtual void ButtonPressed(Button* sender) = 0;
+ virtual void ButtonPressed(Button* sender, const views::Event& event) = 0;
};
// A View representing a button. Depending on the specific type, the button
@@ -46,7 +47,7 @@ class Button : public View {
explicit Button(ButtonListener* listener);
// Cause the button to notify the listener that a click occurred.
- virtual void NotifyClick(int mouse_event_flags);
+ virtual void NotifyClick(const views::Event& event);
// The button's listener. Notified when clicked.
ButtonListener* listener_;
diff --git a/views/controls/button/custom_button.cc b/views/controls/button/custom_button.cc
index 45482b8..69ac840 100644
--- a/views/controls/button/custom_button.cc
+++ b/views/controls/button/custom_button.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 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.
@@ -89,7 +89,19 @@ bool CustomButton::IsTriggerableEvent(const MouseEvent& e) {
bool CustomButton::AcceleratorPressed(const Accelerator& accelerator) {
if (enabled_) {
SetState(BS_NORMAL);
- NotifyClick(0);
+#if defined(OS_WIN)
+ KeyEvent key_event(Event::ET_KEY_RELEASED, accelerator.GetKeyCode(), 0, 0);
+#elif defined(OS_LINUX)
+ GdkEventKey gdk_key;
+ memset(&gdk_key, 0, sizeof(GdkEventKey));
+ gdk_key.type = GDK_KEY_RELEASE;
+ gdk_key.keyval = accelerator.GetKeyCode();
+ gdk_key.state = accelerator.IsAltDown() << 3 +
+ accelerator.IsCtrlDown() << 2 +
+ accelerator.IsShiftDown();
+ KeyEvent key_event(&gdk_key, false);
+#endif
+ NotifyClick(key_event);
return true;
}
return false;
@@ -128,7 +140,7 @@ void CustomButton::OnMouseReleased(const MouseEvent& e, bool canceled) {
} else {
SetState(BS_HOT);
if (IsTriggerableEvent(e)) {
- NotifyClick(e.GetFlags());
+ NotifyClick(e);
// We may be deleted at this point (by the listener's notification
// handler) so no more doing anything, just return.
return;
@@ -168,7 +180,7 @@ bool CustomButton::OnKeyPressed(const KeyEvent& e) {
return true;
} else if (e.GetCharacter() == base::VKEY_RETURN) {
SetState(BS_NORMAL);
- NotifyClick(0);
+ NotifyClick(e);
return true;
}
}
@@ -179,7 +191,7 @@ bool CustomButton::OnKeyReleased(const KeyEvent& e) {
if (state_ != BS_DISABLED) {
if (e.GetCharacter() == base::VKEY_SPACE) {
SetState(BS_NORMAL);
- NotifyClick(0);
+ NotifyClick(e);
return true;
}
}
diff --git a/views/controls/button/native_button.cc b/views/controls/button/native_button.cc
index 8a90aaa..f631bd8 100644
--- a/views/controls/button/native_button.cc
+++ b/views/controls/button/native_button.cc
@@ -4,8 +4,14 @@
#include "views/controls/button/native_button.h"
+#if defined(OS_WIN)
+#include <atlbase.h>
+#include <atlapp.h> // for GET_X/Y_LPARAM
+#endif
+
#if defined(OS_LINUX)
#include <gdk/gdkkeysyms.h>
+#include "views/screen.h"
#endif
#include "app/l10n_util.h"
@@ -95,7 +101,17 @@ void NativeButton::ButtonPressed() {
RequestFocus();
// TODO(beng): obtain mouse event flags for native buttons someday.
- NotifyClick(mouse_event_flags());
+#if defined(OS_WIN)
+ DWORD pos = GetMessagePos();
+ gfx::Point cursor_point(GET_X_LPARAM(pos), GET_Y_LPARAM(pos));
+#elif defined(OS_LINUX)
+ gfx::Point cursor_point = Screen::GetCursorScreenPoint();
+#endif
+
+ views::MouseEvent event(views::Event::ET_MOUSE_RELEASED,
+ cursor_point.x(), cursor_point.y(),
+ views::Event::EF_LEFT_BUTTON_DOWN);
+ NotifyClick(event);
}
////////////////////////////////////////////////////////////////////////////////
@@ -162,7 +178,16 @@ std::string NativeButton::GetClassName() const {
bool NativeButton::AcceleratorPressed(const Accelerator& accelerator) {
if (IsEnabled()) {
- NotifyClick(mouse_event_flags());
+#if defined(OS_WIN)
+ DWORD pos = GetMessagePos();
+ gfx::Point cursor_point(GET_X_LPARAM(pos), GET_Y_LPARAM(pos));
+#elif defined(OS_LINUX)
+ gfx::Point cursor_point = Screen::GetCursorScreenPoint();
+#endif
+ views::MouseEvent event(views::Event::ET_MOUSE_RELEASED,
+ cursor_point.x(), cursor_point.y(),
+ views::Event::EF_LEFT_BUTTON_DOWN);
+ NotifyClick(event);
return true;
}
return false;
diff --git a/views/controls/scrollbar/bitmap_scroll_bar.cc b/views/controls/scrollbar/bitmap_scroll_bar.cc
index 0736501..54f35ab 100644
--- a/views/controls/scrollbar/bitmap_scroll_bar.cc
+++ b/views/controls/scrollbar/bitmap_scroll_bar.cc
@@ -1,9 +1,16 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 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.
#include "views/controls/scrollbar/bitmap_scroll_bar.h"
+#if defined(OS_WIN)
+#include <atlbase.h>
+#include <atlapp.h> // for GET_X/Y_LPARAM
+#elif defined(OS_LINUX)
+#include "views/screen.h"
+#endif
+
#include "app/gfx/canvas.h"
#include "app/l10n_util.h"
#include "base/compiler_specific.h"
@@ -13,6 +20,7 @@
#include "views/controls/menu/menu.h"
#include "views/controls/scroll_view.h"
#include "views/widget/widget.h"
+#include "views/window/window.h"
#undef min
#undef max
@@ -46,7 +54,7 @@ class AutorepeatButton : public ImageButton {
protected:
virtual bool OnMousePressed(const MouseEvent& event) {
- Button::NotifyClick(event.GetFlags());
+ Button::NotifyClick(event);
repeater_.Start();
return true;
}
@@ -58,14 +66,23 @@ class AutorepeatButton : public ImageButton {
private:
void NotifyClick() {
- Button::NotifyClick(0);
+#if defined(OS_WIN)
+ DWORD pos = GetMessagePos();
+ gfx::Point cursor_point(GET_X_LPARAM(pos), GET_Y_LPARAM(pos));
+#elif defined(OS_LINUX)
+ gfx::Point cursor_point = Screen::GetCursorScreenPoint();
+#endif
+ views::MouseEvent event(views::Event::ET_MOUSE_RELEASED,
+ cursor_point.x(), cursor_point.y(),
+ views::Event::EF_LEFT_BUTTON_DOWN);
+ Button::NotifyClick(event);
}
// The repeat controller that we use to repeatedly click the button when the
// mouse button is down.
RepeatController repeater_;
- DISALLOW_EVIL_CONSTRUCTORS(AutorepeatButton);
+ DISALLOW_COPY_AND_ASSIGN(AutorepeatButton);
};
///////////////////////////////////////////////////////////////////////////////
@@ -246,10 +263,10 @@ class BitmapScrollBarThumb : public View {
// The current state of the thumb button.
CustomButton::ButtonState state_;
- DISALLOW_EVIL_CONSTRUCTORS(BitmapScrollBarThumb);
+ DISALLOW_COPY_AND_ASSIGN(BitmapScrollBarThumb);
};
-} // anonymous namespace
+} // anonymous namespace
///////////////////////////////////////////////////////////////////////////////
// BitmapScrollBar, public:
@@ -479,7 +496,7 @@ bool BitmapScrollBar::OnMouseWheel(const MouseWheelEvent& event) {
bool BitmapScrollBar::OnKeyPressed(const KeyEvent& event) {
ScrollAmount amount = SCROLL_NONE;
- switch(event.GetCharacter()) {
+ switch (event.GetCharacter()) {
case VK_UP:
if (!IsHorizontal())
amount = SCROLL_PREV_LINE;
@@ -629,7 +646,7 @@ void BitmapScrollBar::ExecuteCommand(int id) {
///////////////////////////////////////////////////////////////////////////////
// BitmapScrollBar, ButtonListener implementation:
-void BitmapScrollBar::ButtonPressed(Button* sender) {
+void BitmapScrollBar::ButtonPressed(Button* sender, const views::Event& event) {
if (sender == prev_button_) {
ScrollByAmount(SCROLL_PREV_LINE);
} else if (sender == next_button_) {
diff --git a/views/controls/scrollbar/bitmap_scroll_bar.h b/views/controls/scrollbar/bitmap_scroll_bar.h
index 904830e..1a3bc67 100644
--- a/views/controls/scrollbar/bitmap_scroll_bar.h
+++ b/views/controls/scrollbar/bitmap_scroll_bar.h
@@ -103,7 +103,7 @@ class BitmapScrollBar : public ScrollBar,
virtual bool OnKeyPressed(const KeyEvent& event);
// BaseButton::ButtonListener overrides:
- virtual void ButtonPressed(Button* sender);
+ virtual void ButtonPressed(Button* sender, const views::Event& event);
// ScrollBar overrides:
virtual void Update(int viewport_size,
diff --git a/views/event.h b/views/event.h
index ee9a838..882f558 100644
--- a/views/event.h
+++ b/views/event.h
@@ -87,6 +87,16 @@ class Event {
return (flags_ & EF_ALT_DOWN) != 0;
}
+ bool IsMouseEvent() const {
+ return type_ == ET_MOUSE_PRESSED ||
+ type_ == ET_MOUSE_DRAGGED ||
+ type_ == ET_MOUSE_RELEASED ||
+ type_ == ET_MOUSE_MOVED ||
+ type_ == ET_MOUSE_ENTERED ||
+ type_ == ET_MOUSE_EXITED ||
+ type_ == ET_MOUSEWHEEL;
+ }
+
#if defined(OS_WIN)
// Returns the EventFlags in terms of windows flags.
int GetWindowsFlags() const;
diff --git a/views/view_unittest.cc b/views/view_unittest.cc
index 9d2fa87..e02afd73a 100644
--- a/views/view_unittest.cc
+++ b/views/view_unittest.cc
@@ -1045,7 +1045,7 @@ class TestDialogView : public views::View,
}
// views::ButtonListener implementation.
- virtual void ButtonPressed(Button* sender) {
+ virtual void ButtonPressed(Button* sender, const views::Event& event) {
last_pressed_button_ = sender;
}
diff --git a/views/window/custom_frame_view.cc b/views/window/custom_frame_view.cc
index 3434485..d3fd085 100644
--- a/views/window/custom_frame_view.cc
+++ b/views/window/custom_frame_view.cc
@@ -236,7 +236,7 @@ gfx::Size CustomFrameView::GetPreferredSize() {
///////////////////////////////////////////////////////////////////////////////
// CustomFrameView, ButtonListener implementation:
-void CustomFrameView::ButtonPressed(Button* sender) {
+void CustomFrameView::ButtonPressed(Button* sender, const views::Event& event) {
if (sender == close_button_)
frame_->Close();
else if (sender == minimize_button_)
diff --git a/views/window/custom_frame_view.h b/views/window/custom_frame_view.h
index bee9e62..0ae0050 100644
--- a/views/window/custom_frame_view.h
+++ b/views/window/custom_frame_view.h
@@ -50,7 +50,7 @@ class CustomFrameView : public NonClientFrameView,
virtual gfx::Size GetPreferredSize();
// ButtonListener implementation:
- virtual void ButtonPressed(Button* sender);
+ virtual void ButtonPressed(Button* sender, const views::Event& event);
private:
// Returns the thickness of the border that makes up the window frame edges.
diff --git a/views/window/dialog_client_view.cc b/views/window/dialog_client_view.cc
index 9c40b7f..98482a0 100644
--- a/views/window/dialog_client_view.cc
+++ b/views/window/dialog_client_view.cc
@@ -367,7 +367,8 @@ bool DialogClientView::AcceleratorPressed(const Accelerator& accelerator) {
////////////////////////////////////////////////////////////////////////////////
// DialogClientView, ButtonListener implementation:
-void DialogClientView::ButtonPressed(Button* sender) {
+void DialogClientView::ButtonPressed(
+ Button* sender, const views::Event& event) {
// We NULL check the delegate here since the buttons can receive WM_COMMAND
// messages even after they (and the window containing us) are destroyed.
if (!GetDialogDelegate())
diff --git a/views/window/dialog_client_view.h b/views/window/dialog_client_view.h
index 5d1fa33..1c3d19f 100644
--- a/views/window/dialog_client_view.h
+++ b/views/window/dialog_client_view.h
@@ -69,7 +69,7 @@ class DialogClientView : public ClientView,
virtual bool AcceleratorPressed(const Accelerator& accelerator);
// ButtonListener implementation:
- virtual void ButtonPressed(Button* sender);
+ virtual void ButtonPressed(Button* sender, const views::Event& event);
private:
// Paint the size box in the bottom right corner of the window if it is