diff options
Diffstat (limited to 'chrome/browser/tab_contents')
-rw-r--r-- | chrome/browser/tab_contents/web_contents_view_mac.h | 3 | ||||
-rw-r--r-- | chrome/browser/tab_contents/web_contents_view_mac.mm | 29 |
2 files changed, 30 insertions, 2 deletions
diff --git a/chrome/browser/tab_contents/web_contents_view_mac.h b/chrome/browser/tab_contents/web_contents_view_mac.h index 497725c..9f562c0 100644 --- a/chrome/browser/tab_contents/web_contents_view_mac.h +++ b/chrome/browser/tab_contents/web_contents_view_mac.h @@ -15,8 +15,11 @@ class FindBarMac; @class SadTabView; +class WebContentsViewMac; @interface WebContentsViewCocoa : BaseView { + @private + WebContentsViewMac* webContentsView_; // WEAK; owns us } @end diff --git a/chrome/browser/tab_contents/web_contents_view_mac.mm b/chrome/browser/tab_contents/web_contents_view_mac.mm index 19c2d64..deb452c 100644 --- a/chrome/browser/tab_contents/web_contents_view_mac.mm +++ b/chrome/browser/tab_contents/web_contents_view_mac.mm @@ -13,6 +13,7 @@ #include "chrome/common/temp_scaffolding_stubs.h" @interface WebContentsViewCocoa (Private) +- (id)initWithWebContentsViewMac:(WebContentsViewMac*)w; - (void)processKeyboardEvent:(NSEvent*)event; @end @@ -38,9 +39,9 @@ WebContents* WebContentsViewMac::GetWebContents() { void WebContentsViewMac::CreateView() { WebContentsViewCocoa* view = - [[WebContentsViewCocoa alloc] initWithFrame:NSZeroRect]; + [[WebContentsViewCocoa alloc] initWithWebContentsViewMac:this]; // Under GC, ObjC and CF retains/releases are no longer equivalent. So we - // change our ObjC retain to a CF retain se we can use a scoped_cftyperef. + // change our ObjC retain to a CF retain so we can use a scoped_cftyperef. CFRetain(view); [view release]; cocoa_view_.reset(view); @@ -245,6 +246,14 @@ void WebContentsViewMac::Observe(NotificationType type, @implementation WebContentsViewCocoa +- (id)initWithWebContentsViewMac:(WebContentsViewMac*)w { + self = [super initWithFrame:NSZeroRect]; + if (self != nil) { + webContentsView_ = w; + } + return self; +} + - (void)processKeyboardEvent:(NSEvent*)event { if ([event type] == NSKeyDown) [super keyDown:event]; @@ -252,6 +261,22 @@ void WebContentsViewMac::Observe(NotificationType type, [super keyUp:event]; } +// In the Windows version, we always have cut/copy/paste enabled. This is sub- +// optimal, but we do it too. TODO(avi): Plumb the "can*" methods up from +// WebCore. + +- (void)cut:(id)sender { + webContentsView_->GetWebContents()->Cut(); +} + +- (void)copy:(id)sender { + webContentsView_->GetWebContents()->Copy(); +} + +- (void)paste:(id)sender { + webContentsView_->GetWebContents()->Paste(); +} + // Tons of stuff goes here, where we grab events going on in Cocoaland and send // them into the C++ system. TODO(avi): all that jazz |