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

Side by Side Diff: chrome/browser/renderer_host/resource_message_filter_mac.mm

Issue 342068: Third patch in getting rid of caching MessageLoop pointers and always using C... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/renderer_host/resource_message_filter.h" 5 #include "chrome/browser/renderer_host/resource_message_filter.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/sys_string_conversions.h" 10 #include "base/sys_string_conversions.h"
11 #include "chrome/browser/chrome_thread.h"
11 #import "chrome/browser/cocoa/find_pasteboard.h" 12 #import "chrome/browser/cocoa/find_pasteboard.h"
12 13
13 // The number of utf16 code units that will be written to the find pasteboard, 14 // The number of utf16 code units that will be written to the find pasteboard,
14 // longer texts are silently ignored. This is to prevent that a compromised 15 // longer texts are silently ignored. This is to prevent that a compromised
15 // renderer can write unlimited amounts of data into the find pasteboard. 16 // renderer can write unlimited amounts of data into the find pasteboard.
16 static const size_t kMaxFindPboardStringLength = 4096; 17 static const size_t kMaxFindPboardStringLength = 4096;
17 18
18 class WriteFindPboardTask : public Task { 19 class WriteFindPboardTask : public Task {
19 public: 20 public:
20 explicit WriteFindPboardTask(NSString* text) 21 explicit WriteFindPboardTask(NSString* text)
21 : text_([text retain]) {} 22 : text_([text retain]) {}
22 23
23 void Run() { 24 void Run() {
24 [[FindPasteboard sharedInstance] setFindText:text_]; 25 [[FindPasteboard sharedInstance] setFindText:text_];
25 } 26 }
26 27
27 private: 28 private:
28 scoped_nsobject<NSString> text_; 29 scoped_nsobject<NSString> text_;
29 }; 30 };
30 31
31 // Called on the IO thread. 32 // Called on the IO thread.
32 void ResourceMessageFilter::OnClipboardFindPboardWriteString( 33 void ResourceMessageFilter::OnClipboardFindPboardWriteString(
33 const string16& text) { 34 const string16& text) {
34 if (text.length() <= kMaxFindPboardStringLength) { 35 if (text.length() <= kMaxFindPboardStringLength) {
35 NSString* nsText = base::SysUTF16ToNSString(text); 36 NSString* nsText = base::SysUTF16ToNSString(text);
36 if (nsText) { 37 if (nsText) {
37 // FindPasteboard must be used on the UI thread. 38 // FindPasteboard must be used on the UI thread.
38 ui_loop()->PostTask(FROM_HERE, new WriteFindPboardTask(nsText)); 39 ChromeThread::PostTask(
40 ChromeThread::UI, FROM_HERE, new WriteFindPboardTask(nsText));
39 } 41 }
40 } 42 }
41 } 43 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698