OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ui/cocoa/tab_contents/render_view_context_menu_mac.h" | 5 #include "chrome/browser/ui/cocoa/tab_contents/render_view_context_menu_mac.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #import "base/mac/scoped_sending_event.h" | 8 #import "base/mac/scoped_sending_event.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
11 #include "chrome/app/chrome_command_ids.h" | 11 #include "chrome/app/chrome_command_ids.h" |
12 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | |
13 #include "content/public/browser/render_view_host.h" | 12 #include "content/public/browser/render_view_host.h" |
14 #include "content/public/browser/render_widget_host_view.h" | 13 #include "content/public/browser/render_widget_host_view.h" |
15 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
16 #import "ui/base/cocoa/menu_controller.h" | 15 #import "ui/base/cocoa/menu_controller.h" |
17 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
18 | 17 |
19 using content::WebContents; | 18 using content::WebContents; |
20 | 19 |
21 namespace { | 20 namespace { |
22 | 21 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 withEvent:clickEvent | 101 withEvent:clickEvent |
103 forView:parent_view_]; | 102 forView:parent_view_]; |
104 } | 103 } |
105 } | 104 } |
106 | 105 |
107 void RenderViewContextMenuMac::PlatformCancel() { | 106 void RenderViewContextMenuMac::PlatformCancel() { |
108 [menu_controller_ cancel]; | 107 [menu_controller_ cancel]; |
109 } | 108 } |
110 | 109 |
111 void RenderViewContextMenuMac::ExecuteCommand(int command_id, int event_flags) { | 110 void RenderViewContextMenuMac::ExecuteCommand(int command_id, int event_flags) { |
112 // Auxiliary windows that do not have address bars (Panels for example) | |
113 // may not have Instant support. | |
114 NSWindow* parent_window = [parent_view_ window]; | |
115 BrowserWindowController* controller = | |
116 [BrowserWindowController browserWindowControllerForWindow:parent_window]; | |
117 [controller commitInstant]; // It's ok if controller is nil. | |
118 | |
119 switch (command_id) { | 111 switch (command_id) { |
120 case IDC_CONTENT_CONTEXT_LOOK_UP_IN_DICTIONARY: | 112 case IDC_CONTENT_CONTEXT_LOOK_UP_IN_DICTIONARY: |
121 LookUpInDictionary(); | 113 LookUpInDictionary(); |
122 break; | 114 break; |
123 | 115 |
124 case IDC_CONTENT_CONTEXT_SPEECH_START_SPEAKING: | 116 case IDC_CONTENT_CONTEXT_SPEECH_START_SPEAKING: |
125 StartSpeaking(); | 117 StartSpeaking(); |
126 break; | 118 break; |
127 | 119 |
128 case IDC_CONTENT_CONTEXT_SPEECH_STOP_SPEAKING: | 120 case IDC_CONTENT_CONTEXT_SPEECH_STOP_SPEAKING: |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 command_id); | 270 command_id); |
279 if (!item) | 271 if (!item) |
280 return; | 272 return; |
281 | 273 |
282 // Update the returned NSMenuItem directly so we can update it immediately. | 274 // Update the returned NSMenuItem directly so we can update it immediately. |
283 [item setEnabled:enabled]; | 275 [item setEnabled:enabled]; |
284 [item setTitle:SysUTF16ToNSString(title)]; | 276 [item setTitle:SysUTF16ToNSString(title)]; |
285 [item setHidden:hidden]; | 277 [item setHidden:hidden]; |
286 [[item menu] itemChanged:item]; | 278 [[item menu] itemChanged:item]; |
287 } | 279 } |
OLD | NEW |