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

Unified Diff: chrome/browser/ui/toolbar/media_router_contextual_menu.cc

Issue 1582143002: [Media Router] Add enable cloud services menu item to contextual menu. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes per sky@'s comments. Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/toolbar/media_router_contextual_menu.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/toolbar/media_router_contextual_menu.cc
diff --git a/chrome/browser/ui/toolbar/media_router_contextual_menu.cc b/chrome/browser/ui/toolbar/media_router_contextual_menu.cc
index 4d649f04bdd2eed08ee4b1e67686368dc255d020..0c73980dddd7a6f37d5603a8e7f75777b8d6112e 100644
--- a/chrome/browser/ui/toolbar/media_router_contextual_menu.cc
+++ b/chrome/browser/ui/toolbar/media_router_contextual_menu.cc
@@ -16,12 +16,21 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/menu_model_delegate.h"
+#if defined(GOOGLE_CHROME_BUILD)
+#include "base/prefs/pref_service.h"
+#include "chrome/common/pref_names.h"
+#endif // defined(GOOGLE_CHROME_BUILD)
+
MediaRouterContextualMenu::MediaRouterContextualMenu(Browser* browser)
: browser_(browser),
menu_model_(this) {
menu_model_.AddItemWithStringId(IDC_MEDIA_ROUTER_ABOUT,
IDS_MEDIA_ROUTER_ABOUT);
menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
+#if defined(GOOGLE_CHROME_BUILD)
+ menu_model_.AddCheckItemWithStringId(IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE,
+ IDS_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE);
+#endif // defined(GOOGLE_CHROME_BUILD)
menu_model_.AddItemWithStringId(IDC_MEDIA_ROUTER_LEARN_MORE,
IDS_MEDIA_ROUTER_LEARN_MORE);
menu_model_.AddItemWithStringId(IDC_MEDIA_ROUTER_HELP,
@@ -35,6 +44,12 @@ MediaRouterContextualMenu::~MediaRouterContextualMenu() {
}
bool MediaRouterContextualMenu::IsCommandIdChecked(int command_id) const {
+#if defined(GOOGLE_CHROME_BUILD)
+ if (command_id == IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE) {
+ return browser_->profile()->GetPrefs()->GetBoolean(
+ prefs::kMediaRouterEnableCloudServices);
+ }
+#endif // defined(GOOGLE_CHROME_BUILD)
return false;
}
@@ -42,6 +57,15 @@ bool MediaRouterContextualMenu::IsCommandIdEnabled(int command_id) const {
return true;
}
+bool MediaRouterContextualMenu::IsCommandIdVisible(int command_id) const {
+#if defined(GOOGLE_CHROME_BUILD)
+ // Cloud services preference is not set or used if sync is disabled.
+ if (command_id == IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE)
+ return browser_->profile()->IsSyncAllowed();
imcheng 2016/01/26 18:35:45 should we surface this command to users if they ha
apacible 2016/01/26 19:27:34 Yes, we (+pm, design) decided to surface the comma
+#endif // defined(GOOGLE_CHROME_BUILD)
+ return true;
imcheng 2016/01/26 18:35:45 should this return false for the cloud services to
apacible 2016/01/26 19:27:34 The cloud services toggle will not appear in Chrom
+}
+
bool MediaRouterContextualMenu::GetAcceleratorForCommandId(
int command_id,
ui::Accelerator* accelerator) {
@@ -55,6 +79,11 @@ base::string16 MediaRouterContextualMenu::GetLabelForCommandId(
case IDC_MEDIA_ROUTER_ABOUT:
string_id = IDS_MEDIA_ROUTER_ABOUT;
break;
+#if defined(GOOGLE_CHROME_BUILD)
+ case IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE:
+ string_id = IDS_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE;
+ break;
+#endif // defined(GOOGLE_CHROME_BUILD)
case IDC_MEDIA_ROUTER_HELP:
string_id = IDS_MEDIA_ROUTER_HELP;
break;
@@ -85,6 +114,19 @@ void MediaRouterContextualMenu::ExecuteCommand(int command_id,
case IDC_MEDIA_ROUTER_ABOUT:
chrome::ShowSingletonTab(browser_, GURL(kAboutPageUrl));
break;
+#if defined(GOOGLE_CHROME_BUILD)
+ case IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE:
+ browser_->profile()->GetPrefs()->SetBoolean(
imcheng 2016/01/26 18:35:45 would it be possible to extract browser_->profile(
apacible 2016/01/26 19:27:34 Done.
+ prefs::kMediaRouterEnableCloudServices,
+ !browser_->profile()->GetPrefs()->GetBoolean(
+ prefs::kMediaRouterEnableCloudServices));
+
+ // If this has been set before, this is a no-op.
+ browser_->profile()->GetPrefs()->SetBoolean(
+ prefs::kMediaRouterCloudServicesPrefSet,
+ true);
+ break;
+#endif // defined(GOOGLE_CHROME_BUILD)
case IDC_MEDIA_ROUTER_HELP:
chrome::ShowSingletonTab(browser_, GURL(kCastHelpCenterPageUrl));
base::RecordAction(base::UserMetricsAction(
« no previous file with comments | « chrome/browser/ui/toolbar/media_router_contextual_menu.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698