Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 namespace extensions { | 14 namespace extensions { |
| 15 class ComponentMigrationHelper; | 15 class ComponentMigrationHelper; |
| 16 } // namespace extensions | 16 } // namespace extensions |
| 17 | 17 |
| 18 // The class for the contextual menu for the Media Router action. | 18 // The class for the contextual menu for the Media Router action. |
| 19 class MediaRouterContextualMenu : public ui::SimpleMenuModel::Delegate { | 19 class MediaRouterContextualMenu : public ui::SimpleMenuModel::Delegate { |
| 20 public: | 20 public: |
| 21 explicit MediaRouterContextualMenu(Browser* browser); | 21 explicit MediaRouterContextualMenu(Browser* browser); |
| 22 | |
| 23 // Constructor for injecting values in tests. | |
| 24 MediaRouterContextualMenu(Browser* browser, bool shown_by_policy); | |
|
msw
2017/01/05 01:14:57
Can the test mark the preference as managed (polic
takumif
2017/01/06 22:06:57
That'd require moving the test to MediaRouterActio
msw
2017/01/06 23:01:23
Hmm, okay; this ctor flag seems fine to use a unit
| |
| 22 ~MediaRouterContextualMenu() override; | 25 ~MediaRouterContextualMenu() override; |
| 23 | 26 |
| 24 ui::MenuModel* menu_model() { return &menu_model_; } | 27 ui::MenuModel* menu_model() { return &menu_model_; } |
| 25 | 28 |
| 26 private: | 29 private: |
| 27 FRIEND_TEST_ALL_PREFIXES(MediaRouterContextualMenuUnitTest, | 30 FRIEND_TEST_ALL_PREFIXES(MediaRouterContextualMenuUnitTest, |
| 28 ToggleCloudServicesItem); | 31 ToggleCloudServicesItem); |
| 29 FRIEND_TEST_ALL_PREFIXES(MediaRouterContextualMenuUnitTest, | 32 FRIEND_TEST_ALL_PREFIXES(MediaRouterContextualMenuUnitTest, |
| 30 ToggleAlwaysShowIconItem); | 33 ToggleAlwaysShowIconItem); |
| 34 FRIEND_TEST_ALL_PREFIXES(MediaRouterContextualMenuUnitTest, | |
| 35 ActionShownByPolicy); | |
| 31 | 36 |
| 32 // Gets or sets the "Always show icon" option. | 37 // Gets or sets the "Always show icon" option. |
| 33 bool GetAlwaysShowActionPref() const; | 38 bool GetAlwaysShowActionPref() const; |
| 34 void SetAlwaysShowActionPref(bool always_show); | 39 void SetAlwaysShowActionPref(bool always_show); |
| 35 | 40 |
| 36 // ui::SimpleMenuModel::Delegate: | 41 // ui::SimpleMenuModel::Delegate: |
| 37 bool IsCommandIdChecked(int command_id) const override; | 42 bool IsCommandIdChecked(int command_id) const override; |
| 38 bool IsCommandIdEnabled(int command_id) const override; | 43 bool IsCommandIdEnabled(int command_id) const override; |
| 39 bool IsCommandIdVisible(int command_id) const override; | 44 bool IsCommandIdVisible(int command_id) const override; |
| 40 void ExecuteCommand(int command_id, int event_flags) override; | 45 void ExecuteCommand(int command_id, int event_flags) override; |
| 41 | 46 |
| 42 void ReportIssue(); | 47 void ReportIssue(); |
| 43 | 48 |
| 44 Browser* const browser_; | 49 Browser* const browser_; |
| 45 ui::SimpleMenuModel menu_model_; | 50 ui::SimpleMenuModel menu_model_; |
| 46 extensions::ComponentMigrationHelper* const component_migration_helper_; | 51 extensions::ComponentMigrationHelper* const component_migration_helper_; |
| 47 | 52 |
| 53 // Whether the media router action is shown by an administrator policy. | |
| 54 bool shown_by_policy_; | |
| 55 | |
| 48 DISALLOW_COPY_AND_ASSIGN(MediaRouterContextualMenu); | 56 DISALLOW_COPY_AND_ASSIGN(MediaRouterContextualMenu); |
| 49 }; | 57 }; |
| 50 | 58 |
| 51 #endif // CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_CONTEXTUAL_MENU_H_ | 59 #endif // CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_CONTEXTUAL_MENU_H_ |
| OLD | NEW |