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

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

Issue 42018: Initial pass at copy/paste. Menu items are always enabled. This matches Windo... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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
« no previous file with comments | « chrome/browser/tab_contents/web_contents_view_mac.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/web_contents_view_mac.h" 5 #include "chrome/browser/tab_contents/web_contents_view_mac.h"
6 6
7 #include "chrome/browser/browser.h" // TODO(beng): this dependency is awful. 7 #include "chrome/browser/browser.h" // TODO(beng): this dependency is awful.
8 #include "chrome/browser/cocoa/sad_tab_view.h" 8 #include "chrome/browser/cocoa/sad_tab_view.h"
9 #include "chrome/browser/renderer_host/render_widget_host.h" 9 #include "chrome/browser/renderer_host/render_widget_host.h"
10 #include "chrome/browser/renderer_host/render_widget_host_view_mac.h" 10 #include "chrome/browser/renderer_host/render_widget_host_view_mac.h"
11 #include "chrome/browser/tab_contents/web_contents.h" 11 #include "chrome/browser/tab_contents/web_contents.h"
12 12
13 #include "chrome/common/temp_scaffolding_stubs.h" 13 #include "chrome/common/temp_scaffolding_stubs.h"
14 14
15 @interface WebContentsViewCocoa (Private) 15 @interface WebContentsViewCocoa (Private)
16 - (id)initWithWebContentsViewMac:(WebContentsViewMac*)w;
16 - (void)processKeyboardEvent:(NSEvent*)event; 17 - (void)processKeyboardEvent:(NSEvent*)event;
17 @end 18 @end
18 19
19 // static 20 // static
20 WebContentsView* WebContentsView::Create(WebContents* web_contents) { 21 WebContentsView* WebContentsView::Create(WebContents* web_contents) {
21 return new WebContentsViewMac(web_contents); 22 return new WebContentsViewMac(web_contents);
22 } 23 }
23 24
24 WebContentsViewMac::WebContentsViewMac(WebContents* web_contents) 25 WebContentsViewMac::WebContentsViewMac(WebContents* web_contents)
25 : web_contents_(web_contents) { 26 : web_contents_(web_contents) {
26 registrar_.Add(this, NotificationType::WEB_CONTENTS_CONNECTED, 27 registrar_.Add(this, NotificationType::WEB_CONTENTS_CONNECTED,
27 Source<WebContents>(web_contents)); 28 Source<WebContents>(web_contents));
28 registrar_.Add(this, NotificationType::WEB_CONTENTS_DISCONNECTED, 29 registrar_.Add(this, NotificationType::WEB_CONTENTS_DISCONNECTED,
29 Source<WebContents>(web_contents)); 30 Source<WebContents>(web_contents));
30 } 31 }
31 32
32 WebContentsViewMac::~WebContentsViewMac() { 33 WebContentsViewMac::~WebContentsViewMac() {
33 } 34 }
34 35
35 WebContents* WebContentsViewMac::GetWebContents() { 36 WebContents* WebContentsViewMac::GetWebContents() {
36 return web_contents_; 37 return web_contents_;
37 } 38 }
38 39
39 void WebContentsViewMac::CreateView() { 40 void WebContentsViewMac::CreateView() {
40 WebContentsViewCocoa* view = 41 WebContentsViewCocoa* view =
41 [[WebContentsViewCocoa alloc] initWithFrame:NSZeroRect]; 42 [[WebContentsViewCocoa alloc] initWithWebContentsViewMac:this];
42 // Under GC, ObjC and CF retains/releases are no longer equivalent. So we 43 // Under GC, ObjC and CF retains/releases are no longer equivalent. So we
43 // change our ObjC retain to a CF retain se we can use a scoped_cftyperef. 44 // change our ObjC retain to a CF retain so we can use a scoped_cftyperef.
44 CFRetain(view); 45 CFRetain(view);
45 [view release]; 46 [view release];
46 cocoa_view_.reset(view); 47 cocoa_view_.reset(view);
47 } 48 }
48 49
49 RenderWidgetHostView* WebContentsViewMac::CreateViewForWidget( 50 RenderWidgetHostView* WebContentsViewMac::CreateViewForWidget(
50 RenderWidgetHost* render_widget_host) { 51 RenderWidgetHost* render_widget_host) {
51 DCHECK(!render_widget_host->view()); 52 DCHECK(!render_widget_host->view());
52 RenderWidgetHostViewMac* view = 53 RenderWidgetHostViewMac* view =
53 new RenderWidgetHostViewMac(render_widget_host); 54 new RenderWidgetHostViewMac(render_widget_host);
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 [view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; 239 [view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
239 break; 240 break;
240 } 241 }
241 default: 242 default:
242 NOTREACHED() << "Got a notification we didn't register for."; 243 NOTREACHED() << "Got a notification we didn't register for.";
243 } 244 }
244 } 245 }
245 246
246 @implementation WebContentsViewCocoa 247 @implementation WebContentsViewCocoa
247 248
249 - (id)initWithWebContentsViewMac:(WebContentsViewMac*)w {
250 self = [super initWithFrame:NSZeroRect];
251 if (self != nil) {
252 webContentsView_ = w;
253 }
254 return self;
255 }
256
248 - (void)processKeyboardEvent:(NSEvent*)event { 257 - (void)processKeyboardEvent:(NSEvent*)event {
249 if ([event type] == NSKeyDown) 258 if ([event type] == NSKeyDown)
250 [super keyDown:event]; 259 [super keyDown:event];
251 else if ([event type] == NSKeyUp) 260 else if ([event type] == NSKeyUp)
252 [super keyUp:event]; 261 [super keyUp:event];
253 } 262 }
254 263
264 // In the Windows version, we always have cut/copy/paste enabled. This is sub-
265 // optimal, but we do it too. TODO(avi): Plumb the "can*" methods up from
266 // WebCore.
267
268 - (void)cut:(id)sender {
269 webContentsView_->GetWebContents()->Cut();
270 }
271
272 - (void)copy:(id)sender {
273 webContentsView_->GetWebContents()->Copy();
274 }
275
276 - (void)paste:(id)sender {
277 webContentsView_->GetWebContents()->Paste();
278 }
279
255 // Tons of stuff goes here, where we grab events going on in Cocoaland and send 280 // Tons of stuff goes here, where we grab events going on in Cocoaland and send
256 // them into the C++ system. TODO(avi): all that jazz 281 // them into the C++ system. TODO(avi): all that jazz
257 282
258 @end 283 @end
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/web_contents_view_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698