diff options
author | dmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-23 19:05:41 +0000 |
---|---|---|
committer | dmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-23 19:05:41 +0000 |
commit | 09ea24c76c08e06912239194db90ca9e9618ef74 (patch) | |
tree | f2183570578aab5cfe1a9c8db99cfe531fc79f08 /chrome/browser/renderer_host | |
parent | 17168e2b91dda05e2980b4c8e48585d77f3c96d2 (diff) | |
download | chromium_src-09ea24c76c08e06912239194db90ca9e9618ef74.zip chromium_src-09ea24c76c08e06912239194db90ca9e9618ef74.tar.gz chromium_src-09ea24c76c08e06912239194db90ca9e9618ef74.tar.bz2 |
Add support for receiving text from system services on Mac.
BUG=20868
TEST=manual
Review: http://codereview.chromium.org/3158026
Review URL: http://codereview.chromium.org/3158026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57087 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host')
-rw-r--r-- | chrome/browser/renderer_host/render_widget_host_view_mac.mm | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.mm b/chrome/browser/renderer_host/render_widget_host_view_mac.mm index 4a634b2..8923467 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_mac.mm +++ b/chrome/browser/renderer_host/render_widget_host_view_mac.mm @@ -2273,12 +2273,24 @@ extern NSString *NSTextInputReplacementRangeAttributeName; - (id)validRequestorForSendType:(NSString*)sendType returnType:(NSString*)returnType { - if ([sendType isEqual:NSStringPboardType] && !returnType && - !renderWidgetHostView_->selected_text().empty()) { - return self; + id requestor = nil; + BOOL sendTypeIsString = [sendType isEqual:NSStringPboardType]; + BOOL returnTypeIsString = [returnType isEqual:NSStringPboardType]; + BOOL hasText = !renderWidgetHostView_->selected_text().empty(); + BOOL takesText = + renderWidgetHostView_->text_input_type_ != WebKit::WebTextInputTypeNone; + + if (sendTypeIsString && hasText && !returnType) { + requestor = self; + } else if (!sendType && returnTypeIsString && takesText) { + requestor = self; + } else if (sendTypeIsString && returnTypeIsString && hasText && takesText) { + requestor = self; + } else { + requestor = [super validRequestorForSendType:sendType + returnType:returnType]; } - - return [super validRequestorForSendType:sendType returnType:returnType]; + return requestor; } @end @@ -2290,11 +2302,9 @@ extern NSString *NSTextInputReplacementRangeAttributeName; - (BOOL)writeSelectionToPasteboard:(NSPasteboard*)pboard types:(NSArray*)types { - if (![types containsObject:NSStringPboardType] || - renderWidgetHostView_->selected_text().empty()) - return NO; - const std::string& str = renderWidgetHostView_->selected_text(); + if (![types containsObject:NSStringPboardType] || str.empty()) return NO; + scoped_nsobject<NSString> text([[NSString alloc] initWithUTF8String:str.c_str()]); NSArray* toDeclare = [NSArray arrayWithObject:NSStringPboardType]; @@ -2303,7 +2313,14 @@ extern NSString *NSTextInputReplacementRangeAttributeName; } - (BOOL)readSelectionFromPasteboard:(NSPasteboard*)pboard { - return NO; + NSString *string = [pboard stringForType:NSStringPboardType]; + if (!string) return NO; + + // If the user is currently using an IME, confirm the IME input, + // and then insert the text from the service, the same as TextEdit and Safari. + [self confirmComposition]; + [self insertText:string]; + return YES; } @end |