| 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 #include "base/logging.h" | 5 #include "base/logging.h" |
| 6 #include "base/metrics/user_metrics.h" | 6 #include "base/metrics/user_metrics.h" |
| 7 #include "chrome/app/chrome_command_ids.h" | 7 #include "chrome/app/chrome_command_ids.h" |
| 8 #include "chrome/browser/extensions/component_migration_helper.h" | 8 #include "chrome/browser/extensions/component_migration_helper.h" |
| 9 #include "chrome/browser/media/router/media_router_factory.h" | 9 #include "chrome/browser/media/router/media_router_factory.h" |
| 10 #include "chrome/browser/media/router/mojo/media_router_mojo_impl.h" | 10 #include "chrome/browser/media/router/mojo/media_router_mojo_impl.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/singleton_tabs.h" | 13 #include "chrome/browser/ui/singleton_tabs.h" |
| 14 #include "chrome/browser/ui/toolbar/component_toolbar_actions_factory.h" | 14 #include "chrome/browser/ui/toolbar/component_toolbar_actions_factory.h" |
| 15 #include "chrome/browser/ui/toolbar/media_router_contextual_menu.h" | 15 #include "chrome/browser/ui/toolbar/media_router_contextual_menu.h" |
| 16 #include "chrome/browser/ui/toolbar/toolbar_actions_model.h" | 16 #include "chrome/browser/ui/toolbar/toolbar_actions_model.h" |
| 17 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
| 18 #include "chrome/grit/chromium_strings.h" | 18 #include "chrome/grit/chromium_strings.h" |
| 19 #include "chrome/grit/generated_resources.h" | 19 #include "chrome/grit/generated_resources.h" |
| 20 #include "extensions/common/constants.h" | 20 #include "extensions/common/constants.h" |
| 21 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
| 22 #include "ui/base/models/menu_model_delegate.h" | 22 #include "ui/base/models/menu_model_delegate.h" |
| 23 | 23 |
| 24 #if defined(GOOGLE_CHROME_BUILD) | 24 #if defined(GOOGLE_CHROME_BUILD) |
| 25 #include "chrome/browser/signin/signin_manager_factory.h" | 25 #include "chrome/browser/signin/signin_manager_factory.h" |
| 26 #include "chrome/browser/sync/profile_sync_service_factory.h" | |
| 27 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
| 28 #include "components/browser_sync/browser/profile_sync_service.h" | |
| 29 #include "components/prefs/pref_service.h" | 27 #include "components/prefs/pref_service.h" |
| 30 #include "components/signin/core/browser/signin_manager.h" | 28 #include "components/signin/core/browser/signin_manager.h" |
| 31 #endif // defined(GOOGLE_CHROME_BUILD) | 29 #endif // defined(GOOGLE_CHROME_BUILD) |
| 32 | 30 |
| 33 MediaRouterContextualMenu::MediaRouterContextualMenu(Browser* browser) | 31 MediaRouterContextualMenu::MediaRouterContextualMenu(Browser* browser) |
| 34 : browser_(browser), | 32 : browser_(browser), |
| 35 menu_model_(this) { | 33 menu_model_(this) { |
| 36 menu_model_.AddItemWithStringId(IDC_MEDIA_ROUTER_ABOUT, | 34 menu_model_.AddItemWithStringId(IDC_MEDIA_ROUTER_ABOUT, |
| 37 IDS_MEDIA_ROUTER_ABOUT); | 35 IDS_MEDIA_ROUTER_ABOUT); |
| 38 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); | 36 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 69 } | 67 } |
| 70 | 68 |
| 71 bool MediaRouterContextualMenu::IsCommandIdEnabled(int command_id) const { | 69 bool MediaRouterContextualMenu::IsCommandIdEnabled(int command_id) const { |
| 72 return true; | 70 return true; |
| 73 } | 71 } |
| 74 | 72 |
| 75 bool MediaRouterContextualMenu::IsCommandIdVisible(int command_id) const { | 73 bool MediaRouterContextualMenu::IsCommandIdVisible(int command_id) const { |
| 76 #if defined(GOOGLE_CHROME_BUILD) | 74 #if defined(GOOGLE_CHROME_BUILD) |
| 77 if (command_id == IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE) { | 75 if (command_id == IDC_MEDIA_ROUTER_CLOUD_SERVICES_TOGGLE) { |
| 78 // Cloud services preference is not set or used if the user is not signed | 76 // Cloud services preference is not set or used if the user is not signed |
| 79 // in or has disabled sync. | 77 // in. |
| 80 if (browser_->profile()->IsSyncAllowed()) { | 78 SigninManagerBase* signin_manager = |
| 81 SigninManagerBase* signin_manager = | 79 SigninManagerFactory::GetForProfile(browser_->profile()); |
| 82 SigninManagerFactory::GetForProfile(browser_->profile()); | 80 return signin_manager && signin_manager->IsAuthenticated(); |
| 83 return signin_manager && signin_manager->IsAuthenticated() && | |
| 84 ProfileSyncServiceFactory::GetForProfile( | |
| 85 browser_->profile())->IsSyncActive(); | |
| 86 } | |
| 87 return false; | |
| 88 } | 81 } |
| 89 #endif // defined(GOOGLE_CHROME_BUILD) | 82 #endif // defined(GOOGLE_CHROME_BUILD) |
| 90 return true; | 83 return true; |
| 91 } | 84 } |
| 92 | 85 |
| 93 bool MediaRouterContextualMenu::GetAcceleratorForCommandId( | 86 bool MediaRouterContextualMenu::GetAcceleratorForCommandId( |
| 94 int command_id, | 87 int command_id, |
| 95 ui::Accelerator* accelerator) { | 88 ui::Accelerator* accelerator) { |
| 96 return false; | 89 return false; |
| 97 } | 90 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 std::string(url::kStandardSchemeSeparator) + | 154 std::string(url::kStandardSchemeSeparator) + |
| 162 media_router->media_route_provider_extension_id() + | 155 media_router->media_route_provider_extension_id() + |
| 163 "/feedback.html"); | 156 "/feedback.html"); |
| 164 chrome::ShowSingletonTab(browser_, GURL(feedback_url)); | 157 chrome::ShowSingletonTab(browser_, GURL(feedback_url)); |
| 165 } | 158 } |
| 166 | 159 |
| 167 void MediaRouterContextualMenu::RemoveMediaRouterComponentAction() { | 160 void MediaRouterContextualMenu::RemoveMediaRouterComponentAction() { |
| 168 ToolbarActionsModel::Get(browser_->profile())->component_migration_helper() | 161 ToolbarActionsModel::Get(browser_->profile())->component_migration_helper() |
| 169 ->OnActionRemoved(ComponentToolbarActionsFactory::kMediaRouterActionId); | 162 ->OnActionRemoved(ComponentToolbarActionsFactory::kMediaRouterActionId); |
| 170 } | 163 } |
| OLD | NEW |