summaryrefslogtreecommitdiffstats
path: root/chrome/browser/tab_contents
diff options
context:
space:
mode:
authoravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-11 14:53:13 +0000
committeravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-11 14:53:13 +0000
commit922244b319c4cb9c68b10cc3a206ae1bb1ebbfbd (patch)
treed7e17101086c5da7177db73883f7f0b515c2b395 /chrome/browser/tab_contents
parent4330ad19ce4e258ee8b3e36930c2265b1df029ab (diff)
downloadchromium_src-922244b319c4cb9c68b10cc3a206ae1bb1ebbfbd.zip
chromium_src-922244b319c4cb9c68b10cc3a206ae1bb1ebbfbd.tar.gz
chromium_src-922244b319c4cb9c68b10cc3a206ae1bb1ebbfbd.tar.bz2
Initial pass at copy/paste. Menu items are always enabled. This matches Windows; we'll do better soon.
Review URL: http://codereview.chromium.org/42018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11444 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents')
-rw-r--r--chrome/browser/tab_contents/web_contents_view_mac.h3
-rw-r--r--chrome/browser/tab_contents/web_contents_view_mac.mm29
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