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

Side by Side Diff: chrome/browser/tab_contents/render_view_context_menu_win.h

Issue 122027: Remove the Menu object, converting all the remaining callers to use Menu2. I'... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_WIN_H_ 5 #ifndef CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_WIN_H_
6 #define CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_WIN_H_ 6 #define CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_WIN_H_
7 7
8 #include "base/scoped_ptr.h" 8 #include "base/scoped_ptr.h"
9 #include "base/scoped_vector.h"
9 #include "chrome/browser/tab_contents/render_view_context_menu.h" 10 #include "chrome/browser/tab_contents/render_view_context_menu.h"
10 #include "views/accelerator.h" 11 #include "views/accelerator.h"
11 #include "views/controls/menu/menu_win.h" 12 #include "views/controls/menu/simple_menu_model.h"
12 13
13 class RenderViewContextMenuWin : public RenderViewContextMenu, 14 class RenderViewContextMenuWin : public RenderViewContextMenu,
14 public views::Menu::Delegate { 15 public views::SimpleMenuModel::Delegate {
15 public: 16 public:
16 RenderViewContextMenuWin(TabContents* tab_contents, 17 RenderViewContextMenuWin(TabContents* tab_contents,
17 const ContextMenuParams& params, 18 const ContextMenuParams& params);
18 HWND window);
19 19
20 ~RenderViewContextMenuWin(); 20 ~RenderViewContextMenuWin();
21 21
22 void RunMenuAt(int x, int y); 22 void RunMenuAt(int x, int y);
23 23
24 // Menu::Delegate implementation --------------------------------------------- 24 // Overridden from SimpleMenuModel::Delegate:
25 virtual bool IsCommandEnabled(int id) const; 25 virtual bool IsCommandIdChecked(int command_id) const;
26 virtual bool IsItemChecked(int id) const; 26 virtual bool IsCommandIdEnabled(int command_id) const;
27 virtual void ExecuteCommand(int id); 27 virtual bool GetAcceleratorForCommandId(int command_id,
28 // TODO(port): move the logic in this function to RenderViewContextMenu. 28 views::Accelerator* accelerator);
29 virtual bool GetAcceleratorInfo(int id, views::Accelerator* accel); 29 virtual void ExecuteCommand(int command_id);
30 30
31 HMENU GetMenuHandle() const { 31 HMENU GetMenuHandle() const {
32 return (menu_.get() ? menu_->GetMenuHandle() : NULL); 32 return (menu_.get() ? menu_->GetNativeMenu() : NULL);
33 }
34
35 unsigned int GetTPMAlignFlags() const {
36 return (menu_.get() ? menu_->GetTPMAlignFlags() : 0);
37 } 33 }
38 34
39 protected: 35 protected:
40 // RenderViewContextMenu implementation -------------------------------------- 36 // RenderViewContextMenu implementation --------------------------------------
41 virtual void AppendMenuItem(int id); 37 virtual void AppendMenuItem(int id);
42 virtual void AppendMenuItem(int id, const std::wstring& label); 38 virtual void AppendMenuItem(int id, const std::wstring& label);
43 virtual void AppendRadioMenuItem(int id, const std::wstring& label); 39 virtual void AppendRadioMenuItem(int id, const std::wstring& label);
44 virtual void AppendCheckboxMenuItem(int id, const std::wstring& label); 40 virtual void AppendCheckboxMenuItem(int id, const std::wstring& label);
45 virtual void AppendSeparator(); 41 virtual void AppendSeparator();
46 virtual void StartSubMenu(int id, const std::wstring& label); 42 virtual void StartSubMenu(int id, const std::wstring& label);
47 virtual void FinishSubMenu(); 43 virtual void FinishSubMenu();
48 44
49 private: 45 private:
50 // Append the item to |sub_menu_| if it exists, or |menu_| otherwise. 46 // Gets the target model to append items to. This is either the main context
51 void AppendItem(int id, 47 // menu, or a submenu if we've descended into one.
52 const std::wstring& label, 48 views::SimpleMenuModel* GetTargetModel() const;
53 views::Menu::MenuItemType type);
54 49
55 scoped_ptr<views::MenuWin> menu_; 50 // The current radio group for radio menu items.
56 views::Menu* sub_menu_; 51 int current_radio_group_id_;
52
53 // The context menu itself and its contents.
54 scoped_ptr<views::SimpleMenuModel> menu_contents_;
55 scoped_ptr<views::Menu2> menu_;
56 // TODO(beng): This way of building submenus is kind of retarded, but it
57 // hasn't hurt us yet. It's just a bit awkward.
58 views::SimpleMenuModel* sub_menu_contents_;
59 // We own submenu models that we create, so we store them here.
60 ScopedVector<views::SimpleMenuModel> submenu_models_;
57 HWND owner_; 61 HWND owner_;
58 }; 62 };
59 63
60 #endif // CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_WIN_H_ 64 #endif // CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698