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

Side by Side Diff: chrome/browser/renderer_context_menu/mock_render_view_context_menu.h

Issue 1647723002: [win/cros/lin] Add back the spellcheck menu. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 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
OLDNEW
(Empty)
1 // Copyright 2016 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_RENDERER_CONTEXT_MENU_MOCK_RENDER_VIEW_CONTEXT_MENU_H_
6 #define CHROME_BROWSER_RENDERER_CONTEXT_MENU_MOCK_RENDER_VIEW_CONTEXT_MENU_H_
7
8 #include <cstddef>
9 #include <vector>
10
11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/strings/string16.h"
14 #include "components/renderer_context_menu/render_view_context_menu_proxy.h"
15 #include "ui/base/models/simple_menu_model.h"
16
17 class PrefService;
18 class Profile;
19 class RenderViewContextMenuObserver;
20 class TestingProfile;
21
22 // A mock context menu used in tests. This class overrides virtual methods
23 // derived from the RenderViewContextMenuProxy class to monitor calls from the
24 // SpellingMenuObserver class.
25 class MockRenderViewContextMenu : public ui::SimpleMenuModel::Delegate,
26 public RenderViewContextMenuProxy {
27 public:
28 // A menu item used in this test.
29 struct MockMenuItem {
30 MockMenuItem();
31 ~MockMenuItem();
32
33 int command_id;
34 bool enabled;
35 bool checked;
36 bool hidden;
37 base::string16 title;
38 };
39
40 explicit MockRenderViewContextMenu(bool incognito);
41 ~MockRenderViewContextMenu() override;
42
43 // SimpleMenuModel::Delegate implementation.
44 bool IsCommandIdChecked(int command_id) const override;
45 bool IsCommandIdEnabled(int command_id) const override;
46 void ExecuteCommand(int command_id, int event_flags) override;
47 void MenuWillShow(ui::SimpleMenuModel* source) override;
48 void MenuClosed(ui::SimpleMenuModel* source) override;
49 bool GetAcceleratorForCommandId(int command_id,
50 ui::Accelerator* accelerator) override;
51
52 // RenderViewContextMenuProxy implementation.
53 void AddMenuItem(int command_id, const base::string16& title) override;
54 void AddCheckItem(int command_id, const base::string16& title) override;
55 void AddSeparator() override;
56 void AddSubMenu(int command_id,
57 const base::string16& label,
58 ui::MenuModel* model) override;
59 void UpdateMenuItem(int command_id,
60 bool enabled,
61 bool hidden,
62 const base::string16& title) override;
63 content::RenderViewHost* GetRenderViewHost() const override;
64 content::BrowserContext* GetBrowserContext() const override;
65 content::WebContents* GetWebContents() const override;
66
67 // Attaches a RenderViewContextMenuObserver to be tested.
68 void SetObserver(RenderViewContextMenuObserver* observer);
69
70 // Returns the number of items added by the test.
71 size_t GetMenuSize() const;
72
73 // Returns the item at |index|.
74 bool GetMenuItem(size_t index, MockMenuItem* item) const;
75
76 // Returns the writable profile used in this test.
77 PrefService* GetPrefs();
78
79 private:
80 // An observer used for initializing the status of menu items added in this
81 // test. This is owned by our owner and the owner is responsible for its
82 // lifetime.
83 RenderViewContextMenuObserver* observer_;
84
85 // A dummy profile used in this test. Call GetPrefs() when a test needs to
86 // change this profile and use PrefService methods.
87 scoped_ptr<TestingProfile> original_profile_;
88
89 // Either |original_profile_| or its incognito profile.
90 Profile* profile_;
91
92 // A list of menu items added by the SpellingMenuObserver class.
93 std::vector<MockMenuItem> items_;
94
95 DISALLOW_COPY_AND_ASSIGN(MockRenderViewContextMenu);
96 };
97
98 #endif // CHROME_BROWSER_RENDERER_CONTEXT_MENU_MOCK_RENDER_VIEW_CONTEXT_MENU_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698