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

Side by Side Diff: content/browser/renderer_host/clipboard_message_filter_mac.mm

Issue 8437002: Move BrowserThread to content namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: A few updates. Created 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/browser/renderer_host/clipboard_message_filter.h" 5 #include "content/browser/renderer_host/clipboard_message_filter.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/sys_string_conversions.h" 9 #include "base/sys_string_conversions.h"
10 #import "content/browser/find_pasteboard.h" 10 #import "content/browser/find_pasteboard.h"
11 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
12 12
13 using content::BrowserThread;
14
13 // The number of utf16 code units that will be written to the find pasteboard, 15 // 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 16 // longer texts are silently ignored. This is to prevent that a compromised
15 // renderer can write unlimited amounts of data into the find pasteboard. 17 // renderer can write unlimited amounts of data into the find pasteboard.
16 static const size_t kMaxFindPboardStringLength = 4096; 18 static const size_t kMaxFindPboardStringLength = 4096;
17 19
18 class WriteFindPboardTask : public Task { 20 class WriteFindPboardTask : public Task {
19 public: 21 public:
20 explicit WriteFindPboardTask(NSString* text) 22 explicit WriteFindPboardTask(NSString* text)
21 : text_([text retain]) {} 23 : text_([text retain]) {}
22 24
23 void Run() { 25 void Run() {
24 [[FindPasteboard sharedInstance] setFindText:text_]; 26 [[FindPasteboard sharedInstance] setFindText:text_];
25 } 27 }
26 28
27 private: 29 private:
28 scoped_nsobject<NSString> text_; 30 scoped_nsobject<NSString> text_;
29 }; 31 };
30 32
31 // Called on the IO thread. 33 // Called on the IO thread.
32 void ClipboardMessageFilter::OnFindPboardWriteString(const string16& text) { 34 void ClipboardMessageFilter::OnFindPboardWriteString(const string16& text) {
33 if (text.length() <= kMaxFindPboardStringLength) { 35 if (text.length() <= kMaxFindPboardStringLength) {
34 NSString* nsText = base::SysUTF16ToNSString(text); 36 NSString* nsText = base::SysUTF16ToNSString(text);
35 if (nsText) { 37 if (nsText) {
36 // FindPasteboard must be used on the UI thread. 38 // FindPasteboard must be used on the UI thread.
37 BrowserThread::PostTask( 39 BrowserThread::PostTask(
38 BrowserThread::UI, FROM_HERE, new WriteFindPboardTask(nsText)); 40 BrowserThread::UI, FROM_HERE, new WriteFindPboardTask(nsText));
39 } 41 }
40 } 42 }
41 } 43 }
OLDNEW
« no previous file with comments | « content/browser/renderer_host/clipboard_message_filter.cc ('k') | content/browser/renderer_host/database_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698