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

Side by Side Diff: chrome/browser/tab_contents/render_view_context_menu_mac.mm

Issue 6874030: Commit Instant if needed before handling a web page context menu. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/tab_contents/render_view_context_menu_mac.h" 5 #include "chrome/browser/tab_contents/render_view_context_menu_mac.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/memory/scoped_nsobject.h" 8 #include "base/memory/scoped_nsobject.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/sys_string_conversions.h" 10 #include "base/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"
12 #import "chrome/browser/ui/cocoa/menu_controller.h" 13 #import "chrome/browser/ui/cocoa/menu_controller.h"
13 #include "grit/generated_resources.h" 14 #include "grit/generated_resources.h"
14 15
15 // Obj-C bridge class that is the target of all items in the context menu. 16 // Obj-C bridge class that is the target of all items in the context menu.
16 // Relies on the tag being set to the command id. 17 // Relies on the tag being set to the command id.
17 18
18 RenderViewContextMenuMac::RenderViewContextMenuMac( 19 RenderViewContextMenuMac::RenderViewContextMenuMac(
19 TabContents* web_contents, 20 TabContents* web_contents,
20 const ContextMenuParams& params, 21 const ContextMenuParams& params,
21 NSView* parent_view) 22 NSView* parent_view)
(...skipping 30 matching lines...) Expand all
52 // Make sure events can be pumped while the menu is up. 53 // Make sure events can be pumped while the menu is up.
53 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); 54 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current());
54 55
55 // Show the menu. 56 // Show the menu.
56 [NSMenu popUpContextMenu:[menuController_ menu] 57 [NSMenu popUpContextMenu:[menuController_ menu]
57 withEvent:clickEvent 58 withEvent:clickEvent
58 forView:parent_view_]; 59 forView:parent_view_];
59 } 60 }
60 } 61 }
61 62
63 void RenderViewContextMenuMac::ExecuteCommand(int id) {
64 [[[parent_view_ window] windowController] commitInstant];
65 RenderViewContextMenu::ExecuteCommand(id);
66 }
67
62 bool RenderViewContextMenuMac::GetAcceleratorForCommandId( 68 bool RenderViewContextMenuMac::GetAcceleratorForCommandId(
63 int command_id, 69 int command_id,
64 ui::Accelerator* accelerator) { 70 ui::Accelerator* accelerator) {
65 return false; 71 return false;
66 } 72 }
67 73
68 void RenderViewContextMenuMac::InitPlatformMenu() { 74 void RenderViewContextMenuMac::InitPlatformMenu() {
69 bool has_selection = !params_.selection_text.empty(); 75 bool has_selection = !params_.selection_text.empty();
70 76
71 if (has_selection) { 77 if (has_selection) {
(...skipping 12 matching lines...) Expand all
84 NSString* text = base::SysUTF16ToNSString(params_.selection_text); 90 NSString* text = base::SysUTF16ToNSString(params_.selection_text);
85 NSPasteboard* pboard = [NSPasteboard pasteboardWithUniqueName]; 91 NSPasteboard* pboard = [NSPasteboard pasteboardWithUniqueName];
86 // 10.5 and earlier require declareTypes before setData. 92 // 10.5 and earlier require declareTypes before setData.
87 // See the documentation on [NSPasteboard declareTypes]. 93 // See the documentation on [NSPasteboard declareTypes].
88 NSArray* toDeclare = [NSArray arrayWithObject:NSStringPboardType]; 94 NSArray* toDeclare = [NSArray arrayWithObject:NSStringPboardType];
89 [pboard declareTypes:toDeclare owner:nil]; 95 [pboard declareTypes:toDeclare owner:nil];
90 BOOL ok = [pboard setString:text forType:NSStringPboardType]; 96 BOOL ok = [pboard setString:text forType:NSStringPboardType];
91 if (ok) 97 if (ok)
92 NSPerformService(@"Look Up in Dictionary", pboard); 98 NSPerformService(@"Look Up in Dictionary", pboard);
93 } 99 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/render_view_context_menu_mac.h ('k') | chrome/browser/ui/cocoa/browser_window_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698