| 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 #import "chrome/browser/ui/cocoa/browser_window_command_handler.h" | 5 #import "chrome/browser/ui/cocoa/browser_window_command_handler.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #import "base/mac/foundation_util.h" | 8 #import "base/mac/foundation_util.h" |
| 9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
| 10 #import "chrome/browser/app_controller_mac.h" | 10 #import "chrome/browser/app_controller_mac.h" |
| 11 #include "chrome/browser/media/router/media_router_feature.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" | 13 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" |
| 13 #include "chrome/browser/ui/browser_commands.h" | 14 #include "chrome/browser/ui/browser_commands.h" |
| 14 #include "chrome/browser/ui/browser_finder.h" | 15 #include "chrome/browser/ui/browser_finder.h" |
| 15 #include "chrome/browser/ui/browser_window.h" | 16 #include "chrome/browser/ui/browser_window.h" |
| 16 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h" | 17 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h" |
| 17 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
| 18 #include "chrome/grit/generated_resources.h" | 19 #include "chrome/grit/generated_resources.h" |
| 19 #include "content/public/browser/user_metrics.h" | 20 #include "content/public/browser/user_metrics.h" |
| 20 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 [menuItem setHidden:shouldHide]; | 156 [menuItem setHidden:shouldHide]; |
| 156 break; | 157 break; |
| 157 } | 158 } |
| 158 case IDC_SHOW_AS_TAB: { | 159 case IDC_SHOW_AS_TAB: { |
| 159 // Hide this menu option if the window is tabbed or is the devtools | 160 // Hide this menu option if the window is tabbed or is the devtools |
| 160 // window. | 161 // window. |
| 161 NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item); | 162 NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item); |
| 162 [menuItem setHidden:browser->is_type_tabbed() || browser->is_devtools()]; | 163 [menuItem setHidden:browser->is_type_tabbed() || browser->is_devtools()]; |
| 163 break; | 164 break; |
| 164 } | 165 } |
| 166 case IDC_ROUTE_MEDIA: { |
| 167 // Hide this menu option if Media Router is disabled. |
| 168 NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item); |
| 169 [menuItem |
| 170 setHidden:!media_router::MediaRouterEnabled(browser->profile())]; |
| 171 break; |
| 172 } |
| 165 default: | 173 default: |
| 166 break; | 174 break; |
| 167 } | 175 } |
| 168 | 176 |
| 169 // If the item is toggleable, find its toggle state and | 177 // If the item is toggleable, find its toggle state and |
| 170 // try to update it. This is a little awkward, but the alternative is | 178 // try to update it. This is a little awkward, but the alternative is |
| 171 // to check after a commandDispatch, which seems worse. | 179 // to check after a commandDispatch, which seems worse. |
| 172 UpdateToggleStateWithTag(tag, item, window); | 180 UpdateToggleStateWithTag(tag, item, window); |
| 173 | 181 |
| 174 return enable; | 182 return enable; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 203 // the background" in this case. | 211 // the background" in this case. |
| 204 modifierFlags &= ~NSCommandKeyMask; | 212 modifierFlags &= ~NSCommandKeyMask; |
| 205 } | 213 } |
| 206 chrome::ExecuteCommandWithDisposition( | 214 chrome::ExecuteCommandWithDisposition( |
| 207 FindBrowserForSender(sender, window), command, | 215 FindBrowserForSender(sender, window), command, |
| 208 ui::WindowOpenDispositionFromNSEventWithFlags([NSApp currentEvent], | 216 ui::WindowOpenDispositionFromNSEventWithFlags([NSApp currentEvent], |
| 209 modifierFlags)); | 217 modifierFlags)); |
| 210 } | 218 } |
| 211 | 219 |
| 212 @end | 220 @end |
| OLD | NEW |