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

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

Issue 7331017: Multi-Profiles: Add icon chooser to profiles menu (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Multi-Profiles: Add icon chooser to profiles menu Created 9 years, 5 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
Index: chrome/browser/ui/views/avatar_menu_button.cc
===================================================================
--- chrome/browser/ui/views/avatar_menu_button.cc (revision 91956)
+++ chrome/browser/ui/views/avatar_menu_button.cc (working copy)
@@ -4,22 +4,20 @@
#include "chrome/browser/ui/views/avatar_menu_button.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/profile_menu_model.h"
+#include "chrome/browser/ui/views/avatar_menu.h"
#include "ui/gfx/canvas_skia.h"
-#include "views/controls/menu/menu_model_adapter.h"
#include "views/widget/widget.h"
-// Menu should display below the image on the frame. This
-// offset size depends on whether the frame is in glass or opaque mode.
-const int kMenuDisplayOffset = 5;
-
static inline int Round(double x) {
return static_cast<int>(x + 0.5);
}
-AvatarMenuButton::AvatarMenuButton(const std::wstring& text,
- ui::MenuModel* menu_model)
- : MenuButton(NULL, text, this, false),
- menu_model_(menu_model) {
+AvatarMenuButton::AvatarMenuButton(Browser* browser, bool has_menu)
+ : MenuButton(NULL, std::wstring(), this, false),
+ browser_(browser),
+ has_menu_(has_menu) {
// In RTL mode, the avatar icon should be looking the opposite direction.
EnableCanvasFlippingForRTLUI(true);
}
@@ -53,18 +51,20 @@
dst_x, dst_y, dst_width, dst_height, false);
}
+bool AvatarMenuButton::HitTest(const gfx::Point& point) const {
+ if (!has_menu_)
+ return false;
+ return views::MenuButton::HitTest(point);
+}
+
// views::ViewMenuDelegate implementation
void AvatarMenuButton::RunMenu(views::View* source, const gfx::Point& pt) {
- if (!menu_model_.get())
+ if (!has_menu_)
return;
- views::MenuModelAdapter menu_model_adapter(menu_model_.get());
- views::MenuItemView menu(&menu_model_adapter);
- menu_model_adapter.BuildMenu(&menu);
-
- gfx::Point menu_point(pt.x(), pt.y() + kMenuDisplayOffset);
- menu.RunMenuAt(source->GetWidget()->GetNativeWindow(), NULL,
- gfx::Rect(pt, gfx::Size(0, 0)),
- views::MenuItemView::TOPRIGHT,
- true);
+ menu_model_.reset(new ProfileMenuModel(browser_));
+ // The avatar menu will automatically delete itself when done.
+ AvatarMenu* avatar_menu =
+ new AvatarMenu(menu_model_.get(), browser_->profile());
+ avatar_menu->RunMenu(this);
}
« no previous file with comments | « chrome/browser/ui/views/avatar_menu_button.h ('k') | chrome/browser/ui/views/frame/glass_browser_frame_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698