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

Unified Diff: chrome/browser/ui/views/browser_actions_container.cc

Issue 7057058: Convert BrowserActionsContainer context menu from Menu2 to MenuItemView. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix anchor position for RTL and non-RTL. 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/browser_actions_container.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/browser_actions_container.cc
diff --git a/chrome/browser/ui/views/browser_actions_container.cc b/chrome/browser/ui/views/browser_actions_container.cc
index ebec34e192426c13b7b424c7f8ae04ec582eebb6..c2c020161f423cb7d04ec6d54a98cc387ebb45ee 100644
--- a/chrome/browser/ui/views/browser_actions_container.cc
+++ b/chrome/browser/ui/views/browser_actions_container.cc
@@ -42,7 +42,8 @@
#include "ui/gfx/canvas_skia.h"
#include "views/controls/button/menu_button.h"
#include "views/controls/button/text_button.h"
-#include "views/controls/menu/menu_2.h"
+#include "views/controls/menu/menu_item_view.h"
+#include "views/controls/menu/menu_model_adapter.h"
#include "views/drag_utils.h"
#include "views/metrics.h"
#include "views/window/window.h"
@@ -80,7 +81,7 @@ BrowserActionButton::BrowserActionButton(const Extension* extension,
void BrowserActionButton::Destroy() {
if (showing_context_menu_) {
- context_menu_menu_->CancelMenu();
+ context_menu_menu_->Cancel();
MessageLoop::current()->DeleteSoon(FROM_HERE, this);
} else {
delete this;
@@ -219,6 +220,10 @@ bool BrowserActionButton::OnMousePressed(const views::MouseEvent& event) {
gfx::Point point = gfx::Point(0, 0);
ConvertPointToScreen(this, &point);
+ // Align with button left edge for RTL, right edge otherwise.
Peter Kasting 2011/06/08 20:29:43 This seems backwards. We want to align to the lef
rhashimoto 2011/06/09 00:26:23 It looks like we indeed align to the left edge on
+ if (!base::i18n::IsRTL())
+ point.Offset(width(), 0);
+
// Make the menu appear below the button.
point.Offset(0, height());
@@ -259,11 +264,15 @@ void BrowserActionButton::ShowContextMenu(const gfx::Point& p,
// Reconstructs the menu every time because the menu's contents are dynamic.
context_menu_contents_ =
new ExtensionContextMenuModel(extension(), panel_->browser(), panel_);
- context_menu_menu_.reset(new views::Menu2(context_menu_contents_.get()));
- context_menu_menu_->RunContextMenuAt(p);
+ views::MenuModelAdapter menu_model_adapter(context_menu_contents_.get());
+ context_menu_menu_.reset(new views::MenuItemView(&menu_model_adapter));
+ menu_model_adapter.BuildMenu(context_menu_menu_.get());
+ context_menu_menu_->RunMenuAt(GetWindow()->GetNativeWindow(), NULL,
+ gfx::Rect(p, gfx::Size()), views::MenuItemView::TOPRIGHT, true);
Peter Kasting 2011/06/08 20:29:43 Nit: I mentioned this in the last code review and
rhashimoto 2011/06/09 00:26:23 I believe the API allows the specification of a Re
Peter Kasting 2011/06/09 00:39:09 This makes callers who use just a point construct
rhashimoto 2011/06/09 01:15:27 I can add convenience API to pass a Point, but I t
Peter Kasting 2011/06/09 17:43:57 This worries me. The old APIs took a point. That
rhashimoto 2011/06/09 18:19:00 I filed crosbug.com/85585.
SetButtonNotPushed();
showing_context_menu_ = false;
+ context_menu_menu_.reset(NULL);
Peter Kasting 2011/06/08 20:29:43 Do we really need to use a scoped_ptr if we're res
rhashimoto 2011/06/09 00:26:23 Done.
}
void BrowserActionButton::SetButtonPushed() {
« no previous file with comments | « chrome/browser/ui/views/browser_actions_container.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698