Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6249)

Unified Diff: chrome/browser/ui/views/location_bar/page_action_image_view.cc

Issue 7104087: Convert PageActionImageView context menu to MenuItemView. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove computation of context menu location. Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/location_bar/page_action_image_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/location_bar/page_action_image_view.cc
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 5b7c16afc27f5c71c72a036ba9496291969b65be..5a431969a03bc1a923b929fd03b6174af7c90c4e 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(
« no previous file with comments | « chrome/browser/ui/views/location_bar/page_action_image_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698