summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrhashimoto@chromium.org <rhashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-09 18:29:18 +0000
committerrhashimoto@chromium.org <rhashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-09 18:29:18 +0000
commit06a45ebb1b65edfb84f96450ff34e4bac9fd550f (patch)
treea38a060ec241ca49c12d7cb2117c9b8681aca64d
parent9f35ab470bc34a1cbe04132f6fa38393d01a7ebc (diff)
downloadchromium_src-06a45ebb1b65edfb84f96450ff34e4bac9fd550f.zip
chromium_src-06a45ebb1b65edfb84f96450ff34e4bac9fd550f.tar.gz
chromium_src-06a45ebb1b65edfb84f96450ff34e4bac9fd550f.tar.bz2
Convert PageActionImageView context menu to MenuItemView.
BUG=chromium-os:13887 TEST=none Review URL: http://codereview.chromium.org/7104087 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88555 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/views/location_bar/page_action_image_view.cc25
-rw-r--r--chrome/browser/ui/views/location_bar/page_action_image_view.h7
2 files changed, 14 insertions, 18 deletions
diff --git a/chrome/browser/ui/views/location_bar/page_action_image_view.cc b/chrome/browser/ui/views/location_bar/page_action_image_view.cc
index 5b7c16a..5a43196 100644
--- a/chrome/browser/ui/views/location_bar/page_action_image_view.cc
+++ b/chrome/browser/ui/views/location_bar/page_action_image_view.cc
@@ -15,7 +15,8 @@
#include "chrome/common/extensions/extension_action.h"
#include "chrome/common/extensions/extension_resource.h"
#include "ui/base/accessibility/accessible_view_state.h"
-#include "views/controls/menu/menu_2.h"
+#include "views/controls/menu/menu_item_view.h"
+#include "views/controls/menu/menu_model_adapter.h"
PageActionImageView::PageActionImageView(LocationBarView* owner,
Profile* profile,
@@ -123,12 +124,7 @@ void PageActionImageView::OnMouseReleased(const views::MouseEvent& event) {
} else if (event.IsMiddleMouseButton()) {
button = 2;
} else if (event.IsRightMouseButton()) {
- // Get the top left point of this button in screen coordinates.
- gfx::Point menu_origin;
- ConvertPointToScreen(this, &menu_origin);
- // Make the menu appear below the button.
- menu_origin.Offset(0, height());
- ShowContextMenu(menu_origin, true);
+ ShowContextMenu(gfx::Point(), true);
return;
}
@@ -153,10 +149,17 @@ void PageActionImageView::ShowContextMenu(const gfx::Point& p,
Browser* browser = BrowserView::GetBrowserViewForNativeWindow(
platform_util::GetTopLevel(GetWidget()->GetNativeView()))->browser();
- context_menu_contents_ =
- new ExtensionContextMenuModel(extension, browser, this);
- context_menu_menu_.reset(new views::Menu2(context_menu_contents_.get()));
- context_menu_menu_->RunContextMenuAt(p);
+
+ scoped_refptr<ExtensionContextMenuModel> context_menu_model(
+ new ExtensionContextMenuModel(extension, browser, this));
+ views::MenuModelAdapter menu_model_adapter(context_menu_model.get());
+ views::MenuItemView menu(&menu_model_adapter);
+ menu_model_adapter.BuildMenu(&menu);
+
+ gfx::Point screen_loc;
+ views::View::ConvertPointToScreen(this, &screen_loc);
+ menu.RunMenuAt(GetWidget()->GetNativeWindow(), NULL,
+ gfx::Rect(screen_loc ,size()), views::MenuItemView::TOPLEFT, true);
}
void PageActionImageView::OnImageLoaded(
diff --git a/chrome/browser/ui/views/location_bar/page_action_image_view.h b/chrome/browser/ui/views/location_bar/page_action_image_view.h
index 90f50e1..a594f11 100644
--- a/chrome/browser/ui/views/location_bar/page_action_image_view.h
+++ b/chrome/browser/ui/views/location_bar/page_action_image_view.h
@@ -16,9 +16,6 @@
#include "views/controls/image_view.h"
class LocationBarView;
-namespace views {
-class Menu2;
-};
// PageActionImageView is used by the LocationBarView to display the icon for a
// given PageAction and notify the extension when the icon is clicked.
@@ -85,10 +82,6 @@ class PageActionImageView : public views::ImageView,
typedef std::map<std::string, SkBitmap> PageActionMap;
PageActionMap page_action_icons_;
- // The context menu for this page action.
- scoped_refptr<ExtensionContextMenuModel> context_menu_contents_;
- scoped_ptr<views::Menu2> context_menu_menu_;
-
// The object that is waiting for the image loading to complete
// asynchronously.
ImageLoadingTracker tracker_;