summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-04 21:38:07 +0000
committerfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-04 21:38:07 +0000
commit8af4c1991ec7ff8d8e6bcd87d882ba0c99e4f916 (patch)
treec17049add98efa0cd11dd1ee0289af7ee848d2a1
parenta0c6c257e5715e1e035f831c77ecb02ba209a86c (diff)
downloadchromium_src-8af4c1991ec7ff8d8e6bcd87d882ba0c99e4f916.zip
chromium_src-8af4c1991ec7ff8d8e6bcd87d882ba0c99e4f916.tar.gz
chromium_src-8af4c1991ec7ff8d8e6bcd87d882ba0c99e4f916.tar.bz2
Adding drag-drop support in and out of the Browser Action overflow menu.
BUG=26990 TEST=Drag icons into and out of (and within) both the Browser Action container and its overflow menu. Review URL: http://codereview.chromium.org/570014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38135 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/views/bookmark_bar_view.cc10
-rw-r--r--chrome/browser/views/browser_actions_container.cc74
-rw-r--r--chrome/browser/views/browser_actions_container.h44
-rw-r--r--chrome/browser/views/extensions/browser_action_overflow_menu_controller.cc118
-rw-r--r--chrome/browser/views/extensions/browser_action_overflow_menu_controller.h50
-rw-r--r--views/view.cc5
-rw-r--r--views/view.h10
-rw-r--r--views/view_gtk.cc6
-rw-r--r--views/view_win.cc10
9 files changed, 294 insertions, 33 deletions
diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc
index 4ca2148..fce6a7f 100644
--- a/chrome/browser/views/bookmark_bar_view.cc
+++ b/chrome/browser/views/bookmark_bar_view.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -1388,13 +1388,7 @@ void BookmarkBarView::StartShowFolderDropMenuTimer(const BookmarkNode* node) {
}
DCHECK(!show_folder_drop_menu_task_);
show_folder_drop_menu_task_ = new ShowFolderDropMenuTask(this, node);
-#if defined(OS_WIN)
- static DWORD delay = 0;
- if (!delay && !SystemParametersInfo(SPI_GETMENUSHOWDELAY, 0, &delay, 0))
- delay = kShowFolderDropMenuDelay;
-#else
- int delay = kShowFolderDropMenuDelay;
-#endif
+ int delay = View::GetMenuShowDelay();
MessageLoop::current()->PostDelayedTask(FROM_HERE,
show_folder_drop_menu_task_, delay);
}
diff --git a/chrome/browser/views/browser_actions_container.cc b/chrome/browser/views/browser_actions_container.cc
index 6382b82..a81181c 100644
--- a/chrome/browser/views/browser_actions_container.cc
+++ b/chrome/browser/views/browser_actions_container.cc
@@ -21,7 +21,6 @@
#include "chrome/browser/view_ids.h"
#include "chrome/browser/views/detachable_toolbar_view.h"
#include "chrome/browser/views/extensions/browser_action_drag_data.h"
-#include "chrome/browser/views/extensions/browser_action_overflow_menu_controller.h"
#include "chrome/browser/views/extensions/extension_popup.h"
#include "chrome/common/notification_source.h"
#include "chrome/common/notification_type.h"
@@ -302,11 +301,13 @@ BrowserActionsContainer::BrowserActionsContainer(
model_(NULL),
resize_gripper_(NULL),
chevron_(NULL),
+ overflow_menu_(NULL),
suppress_chevron_(false),
resize_amount_(0),
animation_target_size_(0),
drop_indicator_position_(-1),
- ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)),
+ ALLOW_THIS_IN_INITIALIZER_LIST(show_menu_task_factory_(this)) {
SetID(VIEW_ID_BROWSER_ACTION_TOOLBAR);
ExtensionsService* extension_service = profile_->GetExtensionsService();
@@ -348,6 +349,7 @@ BrowserActionsContainer::BrowserActionsContainer(
BrowserActionsContainer::~BrowserActionsContainer() {
if (model_)
model_->RemoveObserver(this);
+ StopShowFolderDropMenuTimer();
CloseOverflowMenu();
HidePopup();
DeleteBrowserActionViews();
@@ -385,10 +387,37 @@ void BrowserActionsContainer::RefreshBrowserActionViews() {
void BrowserActionsContainer::CloseOverflowMenu() {
// Close the overflow menu if open (and the context menu off of that).
- if (overflow_menu_.get())
+ if (overflow_menu_)
overflow_menu_->CancelMenu();
}
+void BrowserActionsContainer::StopShowFolderDropMenuTimer() {
+ show_menu_task_factory_.RevokeAll();
+}
+
+void BrowserActionsContainer::StartShowFolderDropMenuTimer() {
+ int delay = View::GetMenuShowDelay();
+ MessageLoop::current()->PostDelayedTask(FROM_HERE,
+ show_menu_task_factory_.NewRunnableMethod(
+ &BrowserActionsContainer::ShowDropFolder),
+ delay);
+}
+
+void BrowserActionsContainer::ShowDropFolder() {
+ DCHECK(!overflow_menu_);
+ overflow_menu_ = new BrowserActionOverflowMenuController(
+ this, chevron_, browser_action_views_, VisibleBrowserActions());
+ overflow_menu_->set_observer(this);
+ overflow_menu_->RunMenu(GetWindow()->GetNativeWindow(), true);
+}
+
+void BrowserActionsContainer::SetDropIndicator(int x_pos) {
+ if (drop_indicator_position_ != x_pos) {
+ drop_indicator_position_ = x_pos;
+ SchedulePaint();
+ }
+}
+
void BrowserActionsContainer::CreateBrowserActionViews() {
DCHECK(browser_action_views_.empty());
for (ExtensionList::iterator iter = model_->begin();
@@ -636,6 +665,17 @@ void BrowserActionsContainer::OnDragEntered(
int BrowserActionsContainer::OnDragUpdated(
const views::DropTargetEvent& event) {
+ // First check if we are above the chevron (overflow) menu.
+ if (GetViewForPoint(event.location()) == chevron_) {
+ SetDropIndicator(-1);
+
+ if (show_menu_task_factory_.empty() && !overflow_menu_)
+ StartShowFolderDropMenuTimer();
+ return DragDropTypes::DRAG_MOVE;
+ } else {
+ StopShowFolderDropMenuTimer();
+ }
+
// Modifying the x value before clamping affects how far you have to drag to
// get the drop indicator to shift to another position. Modifying after
// clamping affects where the drop indicator is drawn.
@@ -658,15 +698,14 @@ int BrowserActionsContainer::OnDragUpdated(
// Clamping gives us a value where the next button will be drawn, but we want
// to subtract the padding (and then some) to make it appear in-between the
// buttons.
- drop_indicator_position_ = x - kBrowserActionButtonPadding -
+ SetDropIndicator(x - kBrowserActionButtonPadding -
(UILayoutIsRightToLeft() ? kDropIndicatorOffsetRtl :
- kDropIndicatorOffsetLtr);
-
- SchedulePaint();
+ kDropIndicatorOffsetLtr));
return DragDropTypes::DRAG_MOVE;
}
void BrowserActionsContainer::OnDragExited() {
+ StopShowFolderDropMenuTimer();
drop_indicator_position_ = -1;
SchedulePaint();
}
@@ -712,6 +751,14 @@ int BrowserActionsContainer::OnPerformDrop(
return DragDropTypes::DRAG_MOVE;
}
+void BrowserActionsContainer::MoveBrowserAction(
+ const std::string& extension_id, size_t new_index) {
+ ExtensionsService* service = profile_->GetExtensionsService();
+ Extension* extension = service->GetExtensionById(extension_id, false);
+ model_->MoveBrowserAction(extension, new_index);
+ SchedulePaint();
+}
+
void BrowserActionsContainer::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
@@ -773,9 +820,10 @@ void BrowserActionsContainer::BubbleLostFocus(BrowserBubble* bubble,
void BrowserActionsContainer::RunMenu(View* source, const gfx::Point& pt) {
if (source == chevron_) {
- overflow_menu_.reset(new BrowserActionOverflowMenuController(
- this, chevron_, browser_action_views_, VisibleBrowserActions()));
- overflow_menu_->RunMenu(GetWindow()->GetNativeWindow());
+ overflow_menu_ = new BrowserActionOverflowMenuController(
+ this, chevron_, browser_action_views_, VisibleBrowserActions());
+ overflow_menu_->set_observer(this);
+ overflow_menu_->RunMenu(GetWindow()->GetNativeWindow(), false);
}
}
@@ -1008,3 +1056,9 @@ void BrowserActionsContainer::AnimationEnded(const Animation* animation) {
profile_->GetPrefs()->SetInteger(prefs::kBrowserActionContainerWidth,
container_size_.width());
}
+
+void BrowserActionsContainer::NotifyMenuDeleted(
+ BrowserActionOverflowMenuController* controller) {
+ DCHECK(controller == overflow_menu_);
+ overflow_menu_ = NULL;
+}
diff --git a/chrome/browser/views/browser_actions_container.h b/chrome/browser/views/browser_actions_container.h
index b087622..600c1eb 100644
--- a/chrome/browser/views/browser_actions_container.h
+++ b/chrome/browser/views/browser_actions_container.h
@@ -5,12 +5,15 @@
#ifndef CHROME_BROWSER_VIEWS_BROWSER_ACTIONS_CONTAINER_H_
#define CHROME_BROWSER_VIEWS_BROWSER_ACTIONS_CONTAINER_H_
+#include <set>
+#include <string>
#include <vector>
#include "base/task.h"
#include "chrome/browser/extensions/extension_toolbar_model.h"
#include "chrome/browser/extensions/image_loading_tracker.h"
#include "chrome/browser/views/browser_bubble.h"
+#include "chrome/browser/views/extensions/browser_action_overflow_menu_controller.h"
#include "chrome/browser/views/extensions/extension_action_context_menu.h"
#include "chrome/common/notification_observer.h"
#include "chrome/common/notification_registrar.h"
@@ -226,7 +229,9 @@ class BrowserActionsContainer
public views::DragController,
public views::ResizeGripper::ResizeGripperDelegate,
public AnimationDelegate,
- public ExtensionToolbarModel::Observer {
+ public ExtensionToolbarModel::Observer,
+ public BrowserActionOverflowMenuController::Observer {
+ friend class ShowFolderMenuTask;
public:
BrowserActionsContainer(Browser* browser, views::View* owner_view);
virtual ~BrowserActionsContainer();
@@ -242,6 +247,9 @@ class BrowserActionsContainer
// Returns the chevron, if any.
const views::View* chevron() const { return chevron_; }
+ // Returns the profile this container is associated with.
+ Profile* profile() const { return profile_; }
+
// Returns the current tab's ID, or -1 if there is no current tab.
int GetCurrentTabId() const;
@@ -265,6 +273,9 @@ class BrowserActionsContainer
// Called when a browser action becomes visible/hidden.
void OnBrowserActionVisibilityChanged();
+ // Returns how many browser actions are visible.
+ size_t VisibleBrowserActions() const;
+
// Called when the user clicks on the browser action icon.
void OnBrowserActionExecuted(BrowserActionButton* button);
@@ -318,6 +329,13 @@ class BrowserActionsContainer
virtual void AnimationProgressed(const Animation* animation);
virtual void AnimationEnded(const Animation* animation);
+ // Overridden from BrowserActionOverflowMenuController::Observer:
+ virtual void NotifyMenuDeleted(
+ BrowserActionOverflowMenuController* controller);
+
+ // Moves a browser action with |id| to |new_index|.
+ void MoveBrowserAction(const std::string& extension_id, size_t new_index);
+
// Hide the current popup.
void HidePopup();
@@ -337,6 +355,19 @@ class BrowserActionsContainer
// Closes the overflow menu if open.
void CloseOverflowMenu();
+ // Cancels the timer for showing the drop down menu.
+ void StopShowFolderDropMenuTimer();
+
+ // Show the drop down folder after a slight delay.
+ void StartShowFolderDropMenuTimer();
+
+ // Show the overflow menu.
+ void ShowDropFolder();
+
+ // Sets the drop indicator position (and schedules paint if the position has
+ // changed).
+ void SetDropIndicator(int x_pos);
+
// Takes a width in pixels, calculates how many icons fit within that space
// (up to the maximum number of icons in our vector) and shaves off the
// excess pixels. |allow_shrink_to_minimum| specifies whether this function
@@ -359,9 +390,6 @@ class BrowserActionsContainer
// all the padding that we normally show if there are icons.
int ContainerMinSize() const;
- // Returns how many browser actions are visible.
- size_t VisibleBrowserActions() const;
-
// The vector of browser actions (icons/image buttons for each action).
std::vector<BrowserActionView*> browser_action_views_;
@@ -394,8 +422,9 @@ class BrowserActionsContainer
// The chevron for accessing the overflow items.
views::MenuButton* chevron_;
- // The menu to show for the overflow button (chevron).
- scoped_ptr<BrowserActionOverflowMenuController> overflow_menu_;
+ // The menu to show for the overflow button (chevron). This class manages its
+ // own lifetime so that it can stay alive during drag and drop operations.
+ BrowserActionOverflowMenuController* overflow_menu_;
// The animation that happens when the container snaps to place.
scoped_ptr<SlideAnimation> resize_animation_;
@@ -417,6 +446,9 @@ class BrowserActionsContainer
ScopedRunnableMethodFactory<BrowserActionsContainer> task_factory_;
+ // Handles delayed showing of the overflow menu when hovering.
+ ScopedRunnableMethodFactory<BrowserActionsContainer> show_menu_task_factory_;
+
DISALLOW_COPY_AND_ASSIGN(BrowserActionsContainer);
};
diff --git a/chrome/browser/views/extensions/browser_action_overflow_menu_controller.cc b/chrome/browser/views/extensions/browser_action_overflow_menu_controller.cc
index 6cb56d8..b97cd2a 100644
--- a/chrome/browser/views/extensions/browser_action_overflow_menu_controller.cc
+++ b/chrome/browser/views/extensions/browser_action_overflow_menu_controller.cc
@@ -8,6 +8,7 @@
#include "chrome/browser/browser_list.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/views/browser_actions_container.h"
+#include "chrome/browser/views/extensions/browser_action_drag_data.h"
#include "chrome/common/extensions/extension.h"
#include "views/controls/menu/menu_item_view.h"
@@ -17,9 +18,11 @@ BrowserActionOverflowMenuController::BrowserActionOverflowMenuController(
const std::vector<BrowserActionView*>& views,
int start_index)
: owner_(owner),
+ observer_(NULL),
menu_button_(menu_button),
views_(&views),
- start_index_(start_index) {
+ start_index_(start_index),
+ for_drop_(false) {
menu_.reset(new views::MenuItemView(this));
menu_->set_has_icons(true);
@@ -42,9 +45,14 @@ BrowserActionOverflowMenuController::BrowserActionOverflowMenuController(
}
BrowserActionOverflowMenuController::~BrowserActionOverflowMenuController() {
+ if (observer_)
+ observer_->NotifyMenuDeleted(this);
}
-bool BrowserActionOverflowMenuController::RunMenu(gfx::NativeWindow window) {
+bool BrowserActionOverflowMenuController::RunMenu(gfx::NativeWindow window,
+ bool for_drop) {
+ for_drop_ = for_drop;
+
gfx::Rect bounds = menu_button_->GetBounds(
views::View::IGNORE_MIRRORING_TRANSFORMATION);
gfx::Point screen_loc;
@@ -55,7 +63,12 @@ bool BrowserActionOverflowMenuController::RunMenu(gfx::NativeWindow window) {
views::MenuItemView::AnchorPosition anchor =
menu_button_->UILayoutIsRightToLeft() ? views::MenuItemView::TOPRIGHT :
views::MenuItemView::TOPLEFT;
- menu_->RunMenuAt(window, menu_button_, bounds, anchor, false);
+ if (for_drop) {
+ menu_->RunMenuForDropAt(window, bounds, anchor);
+ } else {
+ menu_->RunMenuAt(window, menu_button_, bounds, anchor, false);
+ delete this;
+ }
return true;
}
@@ -84,3 +97,102 @@ bool BrowserActionOverflowMenuController::ShowContextMenu(
return true;
}
+
+void BrowserActionOverflowMenuController::DropMenuClosed(
+ views::MenuItemView* menu) {
+ delete this;
+}
+
+bool BrowserActionOverflowMenuController::GetDropFormats(
+ views::MenuItemView* menu,
+ int* formats,
+ std::set<OSExchangeData::CustomFormat>* custom_formats) {
+ custom_formats->insert(BrowserActionDragData::GetBrowserActionCustomFormat());
+ return true;
+}
+
+bool BrowserActionOverflowMenuController::AreDropTypesRequired(
+ views::MenuItemView* menu) {
+ return true;
+}
+
+bool BrowserActionOverflowMenuController::CanDrop(
+ views::MenuItemView* menu, const OSExchangeData& data) {
+ BrowserActionDragData drop_data;
+ if (!drop_data.Read(data))
+ return false;
+ return drop_data.IsFromProfile(owner_->profile());
+}
+
+int BrowserActionOverflowMenuController::GetDropOperation(
+ views::MenuItemView* item,
+ const views::DropTargetEvent& event,
+ DropPosition* position) {
+ // Don't allow dropping from the BrowserActionContainer into slot 0 of the
+ // overflow menu since once the move has taken place the item you are dragging
+ // falls right out of the menu again once the user releases the button
+ // (because we don't shrink the BrowserActionContainer when you do this).
+ if ((item->GetCommand() == 0) && (*position == DROP_BEFORE)) {
+ BrowserActionDragData drop_data;
+ if (!drop_data.Read(event.GetData()))
+ return DragDropTypes::DRAG_NONE;
+
+ if (drop_data.index() < owner_->VisibleBrowserActions())
+ return DragDropTypes::DRAG_NONE;
+ }
+
+ return DragDropTypes::DRAG_MOVE;
+}
+
+int BrowserActionOverflowMenuController::OnPerformDrop(
+ views::MenuItemView* menu,
+ DropPosition position,
+ const views::DropTargetEvent& event) {
+ BrowserActionDragData drop_data;
+ if (!drop_data.Read(event.GetData()))
+ return DragDropTypes::DRAG_NONE;
+
+ size_t drop_index;
+ ViewForId(menu->GetCommand(), &drop_index);
+
+ // When not dragging within the overflow menu (dragging an icon into the menu)
+ // subtract one to get the right index.
+ if (position == DROP_BEFORE &&
+ drop_data.index() < owner_->VisibleBrowserActions())
+ --drop_index;
+
+ owner_->MoveBrowserAction(drop_data.id(), drop_index);
+
+ if (for_drop_)
+ delete this;
+ return DragDropTypes::DRAG_MOVE;
+}
+
+bool BrowserActionOverflowMenuController::CanDrag(views::MenuItemView* menu) {
+ return true;
+}
+
+void BrowserActionOverflowMenuController::WriteDragData(
+ views::MenuItemView* sender, OSExchangeData* data) {
+ size_t drag_index;
+ BrowserActionView* view = ViewForId(sender->GetCommand(), &drag_index);
+ std::string id = view->button()->extension()->id();
+
+ BrowserActionDragData drag_data(id, drag_index);
+ drag_data.Write(owner_->profile(), data);
+}
+
+int BrowserActionOverflowMenuController::GetDragOperations(
+ views::MenuItemView* sender) {
+ return DragDropTypes::DRAG_MOVE;
+}
+
+BrowserActionView* BrowserActionOverflowMenuController::ViewForId(
+ int id, size_t* index) {
+ // The index of the view being dragged (GetCommand gives a 0-based index into
+ // the overflow menu).
+ size_t view_index = owner_->VisibleBrowserActions() + id;
+ if (index)
+ *index = view_index;
+ return owner_->GetBrowserActionViewAt(view_index);
+}
diff --git a/chrome/browser/views/extensions/browser_action_overflow_menu_controller.h b/chrome/browser/views/extensions/browser_action_overflow_menu_controller.h
index 02950a4..d23449c 100644
--- a/chrome/browser/views/extensions/browser_action_overflow_menu_controller.h
+++ b/chrome/browser/views/extensions/browser_action_overflow_menu_controller.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_VIEWS_EXTENSIONS_BROWSER_ACTION_OVERFLOW_MENU_CONTROLLER_H_
#define CHROME_BROWSER_VIEWS_EXTENSIONS_BROWSER_ACTION_OVERFLOW_MENU_CONTROLLER_H_
+#include <set>
#include <vector>
#include "views/controls/menu/menu_delegate.h"
@@ -13,17 +14,27 @@ class BrowserActionsContainer;
class BrowserActionView;
class ExtensionActionContextMenu;
+// This class handles the overflow menu for browser actions (showing the menu,
+// drag and drop, etc). This class manages its own lifetime.
class BrowserActionOverflowMenuController : public views::MenuDelegate {
public:
+ // The observer is notified prior to the menu being deleted.
+ class Observer {
+ public:
+ virtual void NotifyMenuDeleted(
+ BrowserActionOverflowMenuController* controller) = 0;
+ };
+
BrowserActionOverflowMenuController(
BrowserActionsContainer* owner,
views::MenuButton* menu_button,
const std::vector<BrowserActionView*>& views,
int start_index);
- virtual ~BrowserActionOverflowMenuController();
+
+ void set_observer(Observer* observer) { observer_ = observer; }
// Shows the overflow menu.
- bool RunMenu(gfx::NativeWindow window);
+ bool RunMenu(gfx::NativeWindow window, bool for_drop);
// Closes the overflow menu (and its context menu if open as well).
void CancelMenu();
@@ -35,11 +46,43 @@ class BrowserActionOverflowMenuController : public views::MenuDelegate {
int x,
int y,
bool is_mouse_gesture);
+ virtual void DropMenuClosed(views::MenuItemView* menu);
+ // These drag functions offer support for dragging icons into the overflow
+ // menu.
+ virtual bool GetDropFormats(
+ views::MenuItemView* menu,
+ int* formats,
+ std::set<OSExchangeData::CustomFormat>* custom_formats);
+ virtual bool AreDropTypesRequired(views::MenuItemView* menu);
+ virtual bool CanDrop(views::MenuItemView* menu, const OSExchangeData& data);
+ virtual int GetDropOperation(views::MenuItemView* item,
+ const views::DropTargetEvent& event,
+ DropPosition* position);
+ virtual int OnPerformDrop(views::MenuItemView* menu,
+ DropPosition position,
+ const views::DropTargetEvent& event);
+ // These three drag functions offer support for dragging icons out of the
+ // overflow menu.
+ virtual bool CanDrag(views::MenuItemView* menu);
+ virtual void WriteDragData(views::MenuItemView* sender, OSExchangeData* data);
+ virtual int GetDragOperations(views::MenuItemView* sender);
+
private:
+ // This class manages its own lifetime.
+ virtual ~BrowserActionOverflowMenuController();
+
+ // Converts a menu item |id| into a BrowserActionView by adding the |id| value
+ // to the number of visible views (according to the container owner). If
+ // |index| is specified, it will point to the absolute index of the view.
+ BrowserActionView* ViewForId(int id, size_t* index);
+
// A pointer to the browser action container that owns the overflow menu.
BrowserActionsContainer* owner_;
+ // The observer, may be null.
+ Observer* observer_;
+
// A pointer to the overflow menu button that we are showing the menu for.
views::MenuButton* menu_button_;
@@ -57,6 +100,9 @@ class BrowserActionOverflowMenuController : public views::MenuDelegate {
// picking browser actions to draw.
int start_index_;
+ // Whether this controller is being used for drop.
+ bool for_drop_;
+
DISALLOW_COPY_AND_ASSIGN(BrowserActionOverflowMenuController);
};
diff --git a/views/view.cc b/views/view.cc
index 9c5ab42..b8db44c 100644
--- a/views/view.cc
+++ b/views/view.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -41,6 +41,9 @@ ViewsDelegate* ViewsDelegate::views_delegate = NULL;
// static
char View::kViewClassName[] = "views/View";
+// static
+const int View::kShowFolderDropMenuDelay = 400;
+
/////////////////////////////////////////////////////////////////////////////
//
// View - constructors, destructors, initialization
diff --git a/views/view.h b/views/view.h
index a9865d2..5ae8be5 100644
--- a/views/view.h
+++ b/views/view.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -143,6 +143,10 @@ class View : public AcceleratorTarget {
// Returns the amount of time between double clicks, in milliseconds.
static int GetDoubleClickTimeMS();
+ // Returns the amount of time to wait from hovering over a menu button until
+ // showing the menu.
+ static int GetMenuShowDelay();
+
// Sizing functions
// Get the bounds of the View, relative to the parent. Essentially, this
@@ -1281,6 +1285,10 @@ class View : public AcceleratorTarget {
// right-to-left locales for this View.
bool flip_canvas_on_paint_for_rtl_ui_;
+ // The default value for how long to wait (in ms) before showing a menu
+ // button on hover. This value is used if the OS doesn't supply one.
+ static const int kShowFolderDropMenuDelay;
+
DISALLOW_COPY_AND_ASSIGN(View);
};
diff --git a/views/view_gtk.cc b/views/view_gtk.cc
index 0e53b38..7621d0f 100644
--- a/views/view_gtk.cc
+++ b/views/view_gtk.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -16,6 +16,10 @@ int View::GetDoubleClickTimeMS() {
return display ? display->double_click_time : 500;
}
+int View::GetMenuShowDelay() {
+ return kShowFolderDropMenuDelay;
+}
+
ViewAccessibilityWrapper* View::GetViewAccessibilityWrapper() {
NOTIMPLEMENTED();
return NULL;
diff --git a/views/view_win.cc b/views/view_win.cc
index e5f1c4f..a92cf68 100644
--- a/views/view_win.cc
+++ b/views/view_win.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -20,6 +20,14 @@ int View::GetDoubleClickTimeMS() {
return ::GetDoubleClickTime();
}
+// static
+int View::GetMenuShowDelay() {
+ static DWORD delay = 0;
+ if (!delay && !SystemParametersInfo(SPI_GETMENUSHOWDELAY, 0, &delay, 0))
+ delay = View::kShowFolderDropMenuDelay;
+ return delay;
+}
+
ViewAccessibilityWrapper* View::GetViewAccessibilityWrapper() {
if (accessibility_.get() == NULL) {
accessibility_.reset(new ViewAccessibilityWrapper(this));