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

Unified Diff: chrome/browser/renderer_host/render_widget_host_view_mac.mm

Issue 3158026: Add support for receiving text from system services on Mac.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/app_controller_mac.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/renderer_host/render_widget_host_view_mac.mm
===================================================================
--- chrome/browser/renderer_host/render_widget_host_view_mac.mm (revision 57022)
+++ chrome/browser/renderer_host/render_widget_host_view_mac.mm (working copy)
@@ -2259,12 +2259,24 @@
- (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
@@ -2276,11 +2288,9 @@
- (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;
- const std::string& str = renderWidgetHostView_->selected_text();
scoped_nsobject<NSString> text([[NSString alloc]
initWithUTF8String:str.c_str()]);
NSArray* toDeclare = [NSArray arrayWithObject:NSStringPboardType];
@@ -2289,7 +2299,14 @@
}
- (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
« no previous file with comments | « chrome/browser/app_controller_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698