Chromium Code Reviews| 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_ |