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

Unified Diff: chrome/browser/ui/views/avatar_menu.h

Issue 7331017: Multi-Profiles: Add icon chooser to profiles menu (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove debug code 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.h
diff --git a/chrome/browser/ui/views/avatar_menu.h b/chrome/browser/ui/views/avatar_menu.h
new file mode 100644
index 0000000000000000000000000000000000000000..c29ba957d4826316089138792aa7e7cde4eaf208
--- /dev/null
+++ b/chrome/browser/ui/views/avatar_menu.h
@@ -0,0 +1,65 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_VIEWS_AVATAR_MENU_H_
+#define CHROME_BROWSER_UI_VIEWS_AVATAR_MENU_H_
+#pragma once
+
+#include <map>
+#include <utility>
+
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "ui/base/models/menu_model.h"
+#include "views/controls/menu/menu_delegate.h"
+
+class Browser;
+
+class AvatarMenu : public base::RefCounted<AvatarMenu>,
+ public views::MenuDelegate {
+ public:
+ explicit AvatarMenu(Browser* browser);
sky 2011/07/08 21:01:44 It seems like we only need Profile for this class.
sail 2011/07/08 21:53:57 Done.
+
+ void Init(ui::MenuModel* model);
+
+ // Shows the menu relative to the specified view.
+ void RunMenu(views::MenuButton* host);
+
+ virtual bool IsItemChecked(int id) const OVERRIDE;
sky 2011/07/08 21:01:44 Code for building a MenuItemView exists in MenuMod
sail 2011/07/08 21:53:57 Done.
+ virtual bool IsCommandEnabled(int id) const OVERRIDE;
+ virtual void ExecuteCommand(int id, int mouse_event_flags) OVERRIDE;
+ virtual bool GetAccelerator(int id, views::Accelerator* accelerator) OVERRIDE;
+
+ private:
+ // Populates |parent| with all the child menus in |model|. Recursively invokes
+ // |PopulateMenu| for any submenu.
+ void PopulateMenu(views::MenuItemView* parent,
+ ui::MenuModel* model,
+ int* next_id);
+
+ // Adds a new menu to |parent| to represent the MenuModel/index pair passed
+ // in.
+ views::MenuItemView* AppendMenuItem(views::MenuItemView* parent,
+ ui::MenuModel* model,
+ int index,
+ ui::MenuModel::ItemType menu_type,
+ int* next_id);
+
+ typedef std::pair<ui::MenuModel*,int> Entry;
+ typedef std::map<int,Entry> IDToEntry;
+
+ // Maps from the ID as understood by MenuItemView to the model/index pair the
+ // item came from.
+ IDToEntry id_to_entry_;
+
+ // The views menu.
+ scoped_ptr<views::MenuItemView> root_;
+
+ // Browser the menu is being shown for.
+ Browser* browser_;
+
+ DISALLOW_COPY_AND_ASSIGN(AvatarMenu);
+};
+
+#endif // CHROME_BROWSER_UI_VIEWS_AVATAR_MENU_H_

Powered by Google App Engine
This is Rietveld 408576698