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

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

Issue 1852433004: Fix NSPasteboard leaks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile error. Created 4 years, 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/render_widget_host_view_mac.h" 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h"
6 6
7 #import <objc/runtime.h> 7 #import <objc/runtime.h>
8 #include <OpenGL/gl.h> 8 #include <OpenGL/gl.h>
9 #include <QuartzCore/QuartzCore.h> 9 #include <QuartzCore/QuartzCore.h>
10 #include <stdint.h> 10 #include <stdint.h>
11 11
12 #include <limits> 12 #include <limits>
13 #include <utility> 13 #include <utility>
14 14
15 #include "base/bind.h" 15 #include "base/bind.h"
16 #include "base/callback_helpers.h" 16 #include "base/callback_helpers.h"
17 #include "base/command_line.h" 17 #include "base/command_line.h"
18 #include "base/debug/crash_logging.h" 18 #include "base/debug/crash_logging.h"
19 #include "base/logging.h" 19 #include "base/logging.h"
20 #include "base/mac/mac_util.h" 20 #include "base/mac/mac_util.h"
21 #include "base/mac/scoped_cftyperef.h" 21 #include "base/mac/scoped_cftyperef.h"
22 #import "base/mac/scoped_nsobject.h" 22 #import "base/mac/scoped_nsobject.h"
23 #include "base/mac/sdk_forward_declarations.h" 23 #include "base/mac/sdk_forward_declarations.h"
24 #include "base/memory/ref_counted.h"
24 #include "base/message_loop/message_loop.h" 25 #include "base/message_loop/message_loop.h"
25 #include "base/metrics/histogram.h" 26 #include "base/metrics/histogram.h"
26 #include "base/numerics/safe_conversions.h" 27 #include "base/numerics/safe_conversions.h"
27 #include "base/strings/string_util.h" 28 #include "base/strings/string_util.h"
28 #include "base/strings/stringprintf.h" 29 #include "base/strings/stringprintf.h"
29 #include "base/strings/sys_string_conversions.h" 30 #include "base/strings/sys_string_conversions.h"
30 #include "base/strings/utf_string_conversions.h" 31 #include "base/strings/utf_string_conversions.h"
31 #include "base/sys_info.h" 32 #include "base/sys_info.h"
32 #include "base/trace_event/trace_event.h" 33 #include "base/trace_event/trace_event.h"
33 #import "content/browser/accessibility/browser_accessibility_cocoa.h" 34 #import "content/browser/accessibility/browser_accessibility_cocoa.h"
(...skipping 29 matching lines...) Expand all
63 #include "content/public/browser/native_web_keyboard_event.h" 64 #include "content/public/browser/native_web_keyboard_event.h"
64 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" 65 #include "content/public/browser/render_widget_host_view_frame_subscriber.h"
65 #import "content/public/browser/render_widget_host_view_mac_delegate.h" 66 #import "content/public/browser/render_widget_host_view_mac_delegate.h"
66 #include "content/public/browser/web_contents.h" 67 #include "content/public/browser/web_contents.h"
67 #include "gpu/ipc/common/gpu_messages.h" 68 #include "gpu/ipc/common/gpu_messages.h"
68 #include "skia/ext/platform_canvas.h" 69 #include "skia/ext/platform_canvas.h"
69 #include "skia/ext/skia_utils_mac.h" 70 #include "skia/ext/skia_utils_mac.h"
70 #include "third_party/WebKit/public/platform/WebScreenInfo.h" 71 #include "third_party/WebKit/public/platform/WebScreenInfo.h"
71 #include "third_party/WebKit/public/web/WebInputEvent.h" 72 #include "third_party/WebKit/public/web/WebInputEvent.h"
72 #import "third_party/mozilla/ComplexTextInputPanel.h" 73 #import "third_party/mozilla/ComplexTextInputPanel.h"
74 #import "ui/base/clipboard/clipboard_util_mac.h"
73 #include "ui/base/cocoa/animation_utils.h" 75 #include "ui/base/cocoa/animation_utils.h"
74 #include "ui/base/cocoa/cocoa_base_utils.h" 76 #include "ui/base/cocoa/cocoa_base_utils.h"
75 #import "ui/base/cocoa/fullscreen_window_manager.h" 77 #import "ui/base/cocoa/fullscreen_window_manager.h"
76 #import "ui/base/cocoa/underlay_opengl_hosting_window.h" 78 #import "ui/base/cocoa/underlay_opengl_hosting_window.h"
77 #include "ui/base/layout.h" 79 #include "ui/base/layout.h"
78 #include "ui/compositor/compositor.h" 80 #include "ui/compositor/compositor.h"
79 #include "ui/compositor/layer.h" 81 #include "ui/compositor/layer.h"
80 #include "ui/events/keycodes/keyboard_codes.h" 82 #include "ui/events/keycodes/keyboard_codes.h"
81 #include "ui/gfx/color_profile.h" 83 #include "ui/gfx/color_profile.h"
82 #include "ui/gfx/display.h" 84 #include "ui/gfx/display.h"
(...skipping 2335 matching lines...) Expand 10 before | Expand all | Expand 10 after
2418 targetView:(NSView*) view { 2420 targetView:(NSView*) view {
2419 if ([string length] == 0) { 2421 if ([string length] == 0) {
2420 // The PDF plugin does not support getting the attributed string at point. 2422 // The PDF plugin does not support getting the attributed string at point.
2421 // Until it does, use NSPerformService(), which opens Dictionary.app. 2423 // Until it does, use NSPerformService(), which opens Dictionary.app.
2422 // TODO(shuchen): Support GetStringAtPoint() & GetStringFromRange() for PDF. 2424 // TODO(shuchen): Support GetStringAtPoint() & GetStringFromRange() for PDF.
2423 // See crbug.com/152438. 2425 // See crbug.com/152438.
2424 NSString* text = base::SysUTF8ToNSString( 2426 NSString* text = base::SysUTF8ToNSString(
2425 renderWidgetHostView_->selected_text()); 2427 renderWidgetHostView_->selected_text());
2426 if ([text length] == 0) 2428 if ([text length] == 0)
2427 return; 2429 return;
2428 NSPasteboard* pasteboard = [NSPasteboard pasteboardWithUniqueName]; 2430 scoped_refptr<ui::UniquePasteboard> pasteboard = new ui::UniquePasteboard;
2429 NSArray* types = [NSArray arrayWithObject:NSStringPboardType]; 2431 NSArray* types = [NSArray arrayWithObject:NSStringPboardType];
2430 [pasteboard declareTypes:types owner:nil]; 2432 [pasteboard->get() declareTypes:types owner:nil];
2431 if ([pasteboard setString:text forType:NSStringPboardType]) 2433 if ([pasteboard->get() setString:text forType:NSStringPboardType])
2432 NSPerformService(@"Look Up in Dictionary", pasteboard); 2434 NSPerformService(@"Look Up in Dictionary", pasteboard->get());
2433 return; 2435 return;
2434 } 2436 }
2435 dispatch_async(dispatch_get_main_queue(), ^{ 2437 dispatch_async(dispatch_get_main_queue(), ^{
2436 [view showDefinitionForAttributedString:string 2438 [view showDefinitionForAttributedString:string
2437 atPoint:baselinePoint]; 2439 atPoint:baselinePoint];
2438 }); 2440 });
2439 } 2441 }
2440 2442
2441 - (void)showLookUpDictionaryOverlayFromRange:(NSRange)range 2443 - (void)showLookUpDictionaryOverlayFromRange:(NSRange)range
2442 targetView:(NSView*)targetView { 2444 targetView:(NSView*)targetView {
(...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after
3491 3493
3492 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding 3494 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding
3493 // regions that are not draggable. (See ControlRegionView in 3495 // regions that are not draggable. (See ControlRegionView in
3494 // native_app_window_cocoa.mm). This requires the render host view to be 3496 // native_app_window_cocoa.mm). This requires the render host view to be
3495 // draggable by default. 3497 // draggable by default.
3496 - (BOOL)mouseDownCanMoveWindow { 3498 - (BOOL)mouseDownCanMoveWindow {
3497 return YES; 3499 return YES;
3498 } 3500 }
3499 3501
3500 @end 3502 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/find_pasteboard_unittest.mm ('k') | content/browser/web_contents/web_drag_dest_mac_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698