diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-27 18:34:57 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-27 18:34:57 +0000 |
commit | efcebf36e26bbde3d2bdd774f65a9a15ba99c36a (patch) | |
tree | 3199448086a95953a3d2079b97c0779defc8f84f /ui | |
parent | 9cae4ee1c9b2c13ad9f87a160f76d78ebe45e1a9 (diff) | |
download | chromium_src-efcebf36e26bbde3d2bdd774f65a9a15ba99c36a.zip chromium_src-efcebf36e26bbde3d2bdd774f65a9a15ba99c36a.tar.gz chromium_src-efcebf36e26bbde3d2bdd774f65a9a15ba99c36a.tar.bz2 |
Fix printing PDFs through right click on Mac and Linux. Looks like they both give the menu closed notification before the notification about which item was clicked.
BUG=70987
Review URL: http://codereview.chromium.org/6336014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72840 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/base/models/simple_menu_model.cc | 14 | ||||
-rw-r--r-- | ui/base/models/simple_menu_model.h | 6 |
2 files changed, 19 insertions, 1 deletions
diff --git a/ui/base/models/simple_menu_model.cc b/ui/base/models/simple_menu_model.cc index ba7555b..6152766 100644 --- a/ui/base/models/simple_menu_model.cc +++ b/ui/base/models/simple_menu_model.cc @@ -4,6 +4,7 @@ #include "ui/base/models/simple_menu_model.h" +#include "base/message_loop.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/base/l10n/l10n_util.h" @@ -51,7 +52,9 @@ void SimpleMenuModel::Delegate::MenuClosed() { //////////////////////////////////////////////////////////////////////////////// // SimpleMenuModel, public: -SimpleMenuModel::SimpleMenuModel(Delegate* delegate) : delegate_(delegate) { +SimpleMenuModel::SimpleMenuModel(Delegate* delegate) + : delegate_(delegate), + ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { } SimpleMenuModel::~SimpleMenuModel() { @@ -288,6 +291,15 @@ MenuModel* SimpleMenuModel::GetSubmenuModelAt(int index) const { } void SimpleMenuModel::MenuClosed() { + // Due to how menus work on the different platforms, ActivatedAt will be + // called after this. It's more convenient for the delegate to be called + // afterwards though, so post a task. + MessageLoop::current()->PostTask( + FROM_HERE, + method_factory_.NewRunnableMethod(&SimpleMenuModel::OnMenuClosed)); +} + +void SimpleMenuModel::OnMenuClosed() { if (delegate_) delegate_->MenuClosed(); } diff --git a/ui/base/models/simple_menu_model.h b/ui/base/models/simple_menu_model.h index c321f07..32490ad 100644 --- a/ui/base/models/simple_menu_model.h +++ b/ui/base/models/simple_menu_model.h @@ -9,6 +9,7 @@ #include <vector> #include "base/string16.h" +#include "base/task.h" #include "ui/base/models/menu_model.h" namespace ui { @@ -138,10 +139,15 @@ class SimpleMenuModel : public MenuModel { void InsertItemAtIndex(const Item& item, int index); void ValidateItem(const Item& item); + // Notify the delegate that the menu is closed. + void OnMenuClosed(); + std::vector<Item> items_; Delegate* delegate_; + ScopedRunnableMethodFactory<SimpleMenuModel> method_factory_; + DISALLOW_COPY_AND_ASSIGN(SimpleMenuModel); }; |