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

Side by Side Diff: chrome/browser/ui/toolbar/media_router_contextual_menu.h

Issue 2721953002: [Media Router] Add "Hide in menu/Show in toolbar" option to Cast toolbar icon (Closed)
Patch Set: Address Jennifer's and Mike's comments Created 3 years, 9 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_UI_TOOLBAR_MEDIA_ROUTER_CONTEXTUAL_MENU_H_ 5 #ifndef CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_CONTEXTUAL_MENU_H_
6 #define CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_CONTEXTUAL_MENU_H_ 6 #define CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_CONTEXTUAL_MENU_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "ui/base/models/simple_menu_model.h" 10 #include "ui/base/models/simple_menu_model.h"
11 11
12 class Browser; 12 class Browser;
13 13
14 // The class for the contextual menu for the Media Router action. 14 // The class for the contextual menu for the Media Router action.
15 class MediaRouterContextualMenu : public ui::SimpleMenuModel::Delegate { 15 class MediaRouterContextualMenu : public ui::SimpleMenuModel::Delegate {
16 public: 16 public:
17 explicit MediaRouterContextualMenu(Browser* browser); 17 // Creates an instance for a Media Router Action shown in the toolbar.
18 static std::unique_ptr<MediaRouterContextualMenu> CreateForToolbar(
19 Browser* browser);
18 20
19 // Constructor for injecting values in tests. 21 // Creates an instance for a Media Router Action shown in the overflow menu.
20 MediaRouterContextualMenu(Browser* browser, bool shown_by_policy); 22 static std::unique_ptr<MediaRouterContextualMenu> CreateForOverflowMenu(
23 Browser* browser);
24
25 // Constructor called by the static Create* methods above and tests.
26 MediaRouterContextualMenu(Browser* browser,
27 bool is_action_in_toolbar,
28 bool shown_by_policy);
21 ~MediaRouterContextualMenu() override; 29 ~MediaRouterContextualMenu() override;
22 30
23 ui::MenuModel* menu_model() { return &menu_model_; } 31 ui::SimpleMenuModel* menu_model() { return &menu_model_; }
24 32
25 private: 33 private:
26 FRIEND_TEST_ALL_PREFIXES(MediaRouterContextualMenuUnitTest, 34 FRIEND_TEST_ALL_PREFIXES(MediaRouterContextualMenuUnitTest,
27 ToggleCloudServicesItem); 35 ToggleCloudServicesItem);
28 FRIEND_TEST_ALL_PREFIXES(MediaRouterContextualMenuUnitTest, 36 FRIEND_TEST_ALL_PREFIXES(MediaRouterContextualMenuUnitTest,
29 ToggleAlwaysShowIconItem); 37 ToggleAlwaysShowIconItem);
30 FRIEND_TEST_ALL_PREFIXES(MediaRouterContextualMenuUnitTest, 38 FRIEND_TEST_ALL_PREFIXES(MediaRouterContextualMenuUnitTest,
31 ActionShownByPolicy); 39 ActionShownByPolicy);
32 40
33 // Gets or sets the "Always show icon" option. 41 // Gets or sets the "Always show icon" option.
34 bool GetAlwaysShowActionPref() const; 42 bool GetAlwaysShowActionPref() const;
35 void SetAlwaysShowActionPref(bool always_show); 43 void SetAlwaysShowActionPref(bool always_show);
36 44
37 // ui::SimpleMenuModel::Delegate: 45 // ui::SimpleMenuModel::Delegate:
38 bool IsCommandIdChecked(int command_id) const override; 46 bool IsCommandIdChecked(int command_id) const override;
39 bool IsCommandIdEnabled(int command_id) const override; 47 bool IsCommandIdEnabled(int command_id) const override;
40 bool IsCommandIdVisible(int command_id) const override; 48 bool IsCommandIdVisible(int command_id) const override;
41 void ExecuteCommand(int command_id, int event_flags) override; 49 void ExecuteCommand(int command_id, int event_flags) override;
42 50
51 // Opens feedback page loaded from the media router extension.
43 void ReportIssue(); 52 void ReportIssue();
44 53
54 // Gets the ID corresponding to the text for the menu option to change the
55 // visibility of the action (e.g. "Hide in Chrome menu" / "Show in toolbar")
56 // depending on the location of the action.
57 int GetChangeVisibilityTextId();
58
45 Browser* const browser_; 59 Browser* const browser_;
46 ui::SimpleMenuModel menu_model_; 60 ui::SimpleMenuModel menu_model_;
47 61
62 // Whether the action icon is in the toolbar, as opposed to the overflow menu.
63 const bool is_action_in_toolbar_;
64
48 DISALLOW_COPY_AND_ASSIGN(MediaRouterContextualMenu); 65 DISALLOW_COPY_AND_ASSIGN(MediaRouterContextualMenu);
49 }; 66 };
50 67
51 #endif // CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_CONTEXTUAL_MENU_H_ 68 #endif // CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_CONTEXTUAL_MENU_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/toolbar/media_router_action.cc ('k') | chrome/browser/ui/toolbar/media_router_contextual_menu.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698