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

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

Issue 17593006: mac: Update clients of scoped_nsobject.h. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: iwyu, scoped_nsprotocol Created 7 years, 5 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 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/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
12 #include "base/mac/scoped_nsobject.h"
12 #include "base/strings/sys_string_conversions.h" 13 #include "base/strings/sys_string_conversions.h"
13 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
14 #import "ui/base/cocoa/find_pasteboard.h" 15 #import "ui/base/cocoa/find_pasteboard.h"
15 16
16 namespace content { 17 namespace content {
17 namespace { 18 namespace {
18 19
19 // The number of utf16 code units that will be written to the find pasteboard, 20 // The number of utf16 code units that will be written to the find pasteboard,
20 // longer texts are silently ignored. This is to prevent that a compromised 21 // longer texts are silently ignored. This is to prevent that a compromised
21 // renderer can write unlimited amounts of data into the find pasteboard. 22 // renderer can write unlimited amounts of data into the find pasteboard.
22 static const size_t kMaxFindPboardStringLength = 4096; 23 static const size_t kMaxFindPboardStringLength = 4096;
23 24
24 class WriteFindPboardWrapper { 25 class WriteFindPboardWrapper {
25 public: 26 public:
26 explicit WriteFindPboardWrapper(NSString* text) 27 explicit WriteFindPboardWrapper(NSString* text)
27 : text_([text retain]) {} 28 : text_([text retain]) {}
28 29
29 void Run() { 30 void Run() {
30 [[FindPasteboard sharedInstance] setFindText:text_]; 31 [[FindPasteboard sharedInstance] setFindText:text_];
31 } 32 }
32 33
33 private: 34 private:
34 scoped_nsobject<NSString> text_; 35 base::scoped_nsobject<NSString> text_;
35 36
36 DISALLOW_COPY_AND_ASSIGN(WriteFindPboardWrapper); 37 DISALLOW_COPY_AND_ASSIGN(WriteFindPboardWrapper);
37 }; 38 };
38 39
39 } // namespace 40 } // namespace
40 41
41 // Called on the IO thread. 42 // Called on the IO thread.
42 void ClipboardMessageFilter::OnFindPboardWriteString(const string16& text) { 43 void ClipboardMessageFilter::OnFindPboardWriteString(const string16& text) {
43 if (text.length() <= kMaxFindPboardStringLength) { 44 if (text.length() <= kMaxFindPboardStringLength) {
44 NSString* nsText = base::SysUTF16ToNSString(text); 45 NSString* nsText = base::SysUTF16ToNSString(text);
45 if (nsText) { 46 if (nsText) {
46 // FindPasteboard must be used on the UI thread. 47 // FindPasteboard must be used on the UI thread.
47 BrowserThread::PostTask( 48 BrowserThread::PostTask(
48 BrowserThread::UI, FROM_HERE, base::Bind( 49 BrowserThread::UI, FROM_HERE, base::Bind(
49 &WriteFindPboardWrapper::Run, 50 &WriteFindPboardWrapper::Run,
50 base::Owned(new WriteFindPboardWrapper(nsText)))); 51 base::Owned(new WriteFindPboardWrapper(nsText))));
51 } 52 }
52 } 53 }
53 } 54 }
54 55
55 } // namespace content 56 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698