summaryrefslogtreecommitdiffstats
path: root/chrome/browser/page_menu_model.h
blob: b3fc8ed3cbe08b148af393a1a3b6c619e2061bc1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Copyright (c) 2009 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_PAGE_MENU_MODEL_H_
#define CHROME_BROWSER_PAGE_MENU_MODEL_H_

#include "app/menus/simple_menu_model.h"
#include "base/scoped_ptr.h"

class Browser;

// A menu model that builds the contents of an encoding menu.
class EncodingMenuModel : public menus::SimpleMenuModel,
                          public menus::SimpleMenuModel::Delegate {
 public:
  explicit EncodingMenuModel(Browser* browser);
  virtual ~EncodingMenuModel() {}

  // Overridden from menus::SimpleMenuModel::Delegate:
  virtual bool IsCommandIdChecked(int command_id) const;
  virtual bool IsCommandIdEnabled(int command_id) const;
  virtual bool GetAcceleratorForCommandId(int command_id,
                                          menus::Accelerator* accelerator);
  virtual void ExecuteCommand(int command_id);

 private:
  void Build();

  Browser* browser_;  // weak

  DISALLOW_COPY_AND_ASSIGN(EncodingMenuModel);
};

// A menu model that builds the contents of the zoom menu.
class ZoomMenuModel : public menus::SimpleMenuModel {
 public:
  explicit ZoomMenuModel(menus::SimpleMenuModel::Delegate* delegate);
  virtual ~ZoomMenuModel() {}

 private:
  void Build();

  DISALLOW_COPY_AND_ASSIGN(ZoomMenuModel);
};

// A menu model that builds the contents of the dev tools menu.
class DevToolsMenuModel : public menus::SimpleMenuModel {
 public:
  explicit DevToolsMenuModel(menus::SimpleMenuModel::Delegate* delegate);
  virtual ~DevToolsMenuModel() {}

 private:
  void Build();

  DISALLOW_COPY_AND_ASSIGN(DevToolsMenuModel);
};

// A menu model that builds the contents of the page menu and all of its
// submenus.
class PageMenuModel : public menus::SimpleMenuModel {
 public:
  explicit PageMenuModel(menus::SimpleMenuModel::Delegate* delegate,
                         Browser* browser);
  virtual ~PageMenuModel() { }

 private:
  void Build();

  // The top-level model.
  scoped_ptr<menus::SimpleMenuModel> model_;
  // Models for submenus referenced by model_. SimpleMenuModel only uses weak
  // references so these must be kept for the lifetime of the top-level model.
  scoped_ptr<ZoomMenuModel> zoom_menu_model_;
  scoped_ptr<EncodingMenuModel> encoding_menu_model_;
  scoped_ptr<DevToolsMenuModel> devtools_menu_model_;
  Browser* browser_;  // weak

  DISALLOW_COPY_AND_ASSIGN(PageMenuModel);
};

#endif  // CHROME_BROWSER_PAGE_MENU_MODEL_H_