summaryrefslogtreecommitdiffstats
path: root/chrome/browser/renderer_host
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-23 22:43:00 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-23 22:43:00 +0000
commit6a4f5af29737b966d1cb9e0ab149d7cd0055e5fd (patch)
treef97c014a06b7ce43c372d9dc1946bfad9878f026 /chrome/browser/renderer_host
parent80d5f425f45ccd05330a0d326229e7b5d684a06f (diff)
downloadchromium_src-6a4f5af29737b966d1cb9e0ab149d7cd0055e5fd.zip
chromium_src-6a4f5af29737b966d1cb9e0ab149d7cd0055e5fd.tar.gz
chromium_src-6a4f5af29737b966d1cb9e0ab149d7cd0055e5fd.tar.bz2
Let cmd-f/cmd-g use the findboard.
In a nutshell, this means that the find bars honor the global find pasteboard, which is like a clipboard, but for searches. See the TEST section below for consequences, and also see the bug for more information. BUG=14562 TEST= * Select some text, hit cmd-e, cmd-g. This should search for the marked text and open the find bar if it's not open. * Open TextEdit, hit cmd-f. Enter some text, hit enter. Switch back to Chrome with an open find bar. The find bar should now contain the text you entered in TextEdit * Enter different text into chrome's find bar, switch back to TextEdit. Its find window should now contain the new text. * Search for something in one tab, switch to another tab. It should contain the same text in the findbar as the first one. * Open the findbar, select some text, hit cmd-e. The find bar should be updated with the selected text and this text should be highlighted in the web page. Find bars in other tabs should be updated with that text as well. Review URL: http://codereview.chromium.org/206035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27015 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host')
-rw-r--r--chrome/browser/renderer_host/resource_message_filter_mac.mm21
1 files changed, 17 insertions, 4 deletions
diff --git a/chrome/browser/renderer_host/resource_message_filter_mac.mm b/chrome/browser/renderer_host/resource_message_filter_mac.mm
index b63c5bf..f7687c9 100644
--- a/chrome/browser/renderer_host/resource_message_filter_mac.mm
+++ b/chrome/browser/renderer_host/resource_message_filter_mac.mm
@@ -6,23 +6,36 @@
#import <Cocoa/Cocoa.h>
+#include "base/message_loop.h"
#include "base/sys_string_conversions.h"
+#import "chrome/browser/cocoa/find_pasteboard.h"
// The number of utf16 code units that will be written to the find pasteboard,
// longer texts are silently ignored. This is to prevent that a compromised
// renderer can write unlimited amounts of data into the find pasteboard.
static const size_t kMaxFindPboardStringLength = 4096;
+class WriteFindPboardTask : public Task {
+ public:
+ explicit WriteFindPboardTask(NSString* text)
+ : text_([text retain]) {}
+
+ void Run() {
+ [[FindPasteboard sharedInstance] setFindText:text_];
+ }
+
+ private:
+ scoped_nsobject<NSString> text_;
+};
+
// Called on the IO thread.
void ResourceMessageFilter::OnClipboardFindPboardWriteString(
const string16& text) {
if (text.length() <= kMaxFindPboardStringLength) {
NSString* nsText = base::SysUTF16ToNSString(text);
if (nsText) {
- NSPasteboard* findPboard = [NSPasteboard pasteboardWithName:NSFindPboard];
- [findPboard declareTypes:[NSArray arrayWithObject:NSStringPboardType]
- owner:nil];
- [findPboard setString:nsText forType:NSStringPboardType];
+ // FindPasteboard must be used on the UI thread.
+ ui_loop()->PostTask(FROM_HERE, new WriteFindPboardTask(nsText));
}
}
}