render_view_context_menu_views.h revision 116680a4aac90f2aa7413d9095a592090648e557
1// Copyright 2014 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_UI_VIEWS_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_VIEWS_H_
6#define CHROME_BROWSER_UI_VIEWS_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_VIEWS_H_
7
8#include "base/memory/scoped_ptr.h"
9#include "base/memory/scoped_vector.h"
10#include "base/strings/string16.h"
11#include "chrome/browser/renderer_context_menu/render_view_context_menu.h"
12#include "ui/base/ui_base_types.h"
13
14namespace gfx {
15class Point;
16}
17
18namespace views {
19class MenuItemView;
20class MenuModelAdapter;
21class MenuRunner;
22class Widget;
23}
24
25class RenderViewContextMenuViews : public RenderViewContextMenu {
26 public:
27  virtual ~RenderViewContextMenuViews();
28
29  // Factory function to create an instance.
30  static RenderViewContextMenuViews* Create(
31      content::RenderFrameHost* render_frame_host,
32      const content::ContextMenuParams& params);
33
34  void RunMenuAt(views::Widget* parent,
35                 const gfx::Point& point,
36                 ui::MenuSourceType type);
37
38  // RenderViewContextMenuDelegate implementation.
39  virtual void UpdateMenuItem(int command_id,
40                              bool enabled,
41                              bool hidden,
42                              const base::string16& title) OVERRIDE;
43
44  virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE;
45
46 protected:
47  RenderViewContextMenuViews(content::RenderFrameHost* render_frame_host,
48                             const content::ContextMenuParams& params);
49
50  // RenderViewContextMenu implementation.
51  virtual void PlatformInit() OVERRIDE;
52  virtual void PlatformCancel() OVERRIDE;
53  virtual bool GetAcceleratorForCommandId(
54      int command_id,
55      ui::Accelerator* accelerator) OVERRIDE;
56
57 private:
58  virtual void AppendPlatformEditableItems() OVERRIDE;
59  virtual bool IsCommandIdChecked(int command_id) const OVERRIDE;
60  virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE;
61
62  // Model for the BiDi input submenu.
63  ui::SimpleMenuModel bidi_submenu_model_;
64
65  scoped_ptr<views::MenuModelAdapter> menu_adapter_;
66  scoped_ptr<views::MenuRunner> menu_runner_;
67
68  // Weak. Owned by menu_runner_;
69  views::MenuItemView* menu_view_;
70
71  DISALLOW_COPY_AND_ASSIGN(RenderViewContextMenuViews);
72};
73
74#endif  // CHROME_BROWSER_UI_VIEWS_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_VIEWS_H_
75