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

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

Issue 9382037: Move ContextMenuParams struct from webkit/glue to content/public/common. The reasons are: (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix mac Created 8 years, 10 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_OBSERVER_H_ 5 #ifndef CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_OBSERVER_H_
6 #define CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_OBSERVER_H_ 6 #define CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_OBSERVER_H_
7 #pragma once 7 #pragma once
8 8
9 namespace content {
9 struct ContextMenuParams; 10 struct ContextMenuParams;
11 }
10 12
11 // The interface used for implementing context-menu items. The following 13 // The interface used for implementing context-menu items. The following
12 // instruction describe how to implement a context-menu item with this 14 // instruction describe how to implement a context-menu item with this
13 // interface. 15 // interface.
14 // 16 //
15 // 1. Add command IDs for the context-menu items to 'chrome_command_ids.h'. 17 // 1. Add command IDs for the context-menu items to 'chrome_command_ids.h'.
16 // 18 //
17 // #define IDC_MY_COMMAND 99999 19 // #define IDC_MY_COMMAND 99999
18 // 20 //
19 // 2. Add strings for the context-menu items to 'generated_sources.grd'. 21 // 2. Add strings for the context-menu items to 'generated_sources.grd'.
20 // 22 //
21 // <message name="IDS_MY_COMMAND" desc="..."> 23 // <message name="IDS_MY_COMMAND" desc="...">
22 // My command 24 // My command
23 // </message> 25 // </message>
24 // 26 //
25 // 3. Create a class that implements this interface. (It is a good idea to use 27 // 3. Create a class that implements this interface. (It is a good idea to use
26 // the RenderViewContextMenuDelegate interface to avoid accessing the 28 // the RenderViewContextMenuDelegate interface to avoid accessing the
27 // RenderViewContextMenu class directly.) 29 // RenderViewContextMenu class directly.)
28 // 30 //
29 // class MyMenuObserver : public RenderViewContextMenuObserver { 31 // class MyMenuObserver : public RenderViewContextMenuObserver {
30 // public: 32 // public:
31 // MyMenuObserver(RenderViewContextMenuDelegate* d); 33 // MyMenuObserver(RenderViewContextMenuDelegate* d);
32 // ~MyMenuObserver(); 34 // ~MyMenuObserver();
33 // 35 //
34 // virtual void InitMenu(const ContextMenuParams& params) OVERRIDE; 36 // virtual void InitMenu(const content::ContextMenuParams& params) OVERRIDE;
35 // virtual bool IsCommandIdSupported(int command_id) OVERRIDE; 37 // virtual bool IsCommandIdSupported(int command_id) OVERRIDE;
36 // virtual bool IsCommandIdEnabled(int command_id) OVERRIDE; 38 // virtual bool IsCommandIdEnabled(int command_id) OVERRIDE;
37 // virtual void ExecuteCommand(int command_id) OVERRIDE; 39 // virtual void ExecuteCommand(int command_id) OVERRIDE;
38 // 40 //
39 // private: 41 // private:
40 // RenderViewContextMenuDelgate* delegate_; 42 // RenderViewContextMenuDelgate* delegate_;
41 // } 43 // }
42 // 44 //
43 // void MyMenuObserver::InitMenu(const ContextMenuParams& params) { 45 // void MyMenuObserver::InitMenu(const content::ContextMenuParams& params) {
44 // delegate_->AddMenuItem(IDC_MY_COMMAND,...); 46 // delegate_->AddMenuItem(IDC_MY_COMMAND,...);
45 // } 47 // }
46 // 48 //
47 // bool MyMenuObserver::IsCommandIdSupported(int command_id) { 49 // bool MyMenuObserver::IsCommandIdSupported(int command_id) {
48 // return command_id == IDC_MY_COMMAND; 50 // return command_id == IDC_MY_COMMAND;
49 // } 51 // }
50 // 52 //
51 // bool MyMenuObserver::IsCommandIdEnabled(int command_id) { 53 // bool MyMenuObserver::IsCommandIdEnabled(int command_id) {
52 // DCHECK(command_id == IDC_MY_COMMAND); 54 // DCHECK(command_id == IDC_MY_COMMAND);
53 // return true; 55 // return true;
(...skipping 22 matching lines...) Expand all
76 // } 78 // }
77 // 79 //
78 // 80 //
79 class RenderViewContextMenuObserver { 81 class RenderViewContextMenuObserver {
80 public: 82 public:
81 virtual ~RenderViewContextMenuObserver() {} 83 virtual ~RenderViewContextMenuObserver() {}
82 84
83 // Called when the RenderViewContextMenu class initializes a context menu. We 85 // Called when the RenderViewContextMenu class initializes a context menu. We
84 // usually call RenderViewContextMenuDelegate::AddMenuItem() to add menu items 86 // usually call RenderViewContextMenuDelegate::AddMenuItem() to add menu items
85 // in this function. 87 // in this function.
86 virtual void InitMenu(const ContextMenuParams& params); 88 virtual void InitMenu(const content::ContextMenuParams& params);
87 89
88 // Called when the RenderViewContextMenu class asks whether an observer 90 // Called when the RenderViewContextMenu class asks whether an observer
89 // listens for the specified command ID. If this function returns true, the 91 // listens for the specified command ID. If this function returns true, the
90 // RenderViewContextMenu class calls IsCommandIdEnabled() or ExecuteCommand(). 92 // RenderViewContextMenu class calls IsCommandIdEnabled() or ExecuteCommand().
91 virtual bool IsCommandIdSupported(int command_id); 93 virtual bool IsCommandIdSupported(int command_id);
92 94
93 // Called when the RenderViewContextMenu class sets the initial status of the 95 // Called when the RenderViewContextMenu class sets the initial status of the
94 // specified context-menu item. If we need to enable or disable a context-menu 96 // specified context-menu item. If we need to enable or disable a context-menu
95 // item while showing, use RenderViewContextMenuDelegate::UpdateMenuItem(). 97 // item while showing, use RenderViewContextMenuDelegate::UpdateMenuItem().
96 virtual bool IsCommandIdChecked(int command_id); 98 virtual bool IsCommandIdChecked(int command_id);
97 virtual bool IsCommandIdEnabled(int command_id); 99 virtual bool IsCommandIdEnabled(int command_id);
98 100
99 // Called when a user selects the specified context-menu item. 101 // Called when a user selects the specified context-menu item.
100 virtual void ExecuteCommand(int command_id); 102 virtual void ExecuteCommand(int command_id);
101 }; 103 };
102 104
103 #endif // CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_OBSERVER_H_ 105 #endif // CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698