OLD | NEW |
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 #include <QuartzCore/QuartzCore.h> | 7 #include <QuartzCore/QuartzCore.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/debug/crash_logging.h" | 12 #include "base/debug/crash_logging.h" |
13 #include "base/debug/trace_event.h" | 13 #include "base/debug/trace_event.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/mac/mac_util.h" | 15 #include "base/mac/mac_util.h" |
16 #include "base/mac/scoped_cftyperef.h" | 16 #include "base/mac/scoped_cftyperef.h" |
| 17 #import "base/mac/scoped_nsobject.h" |
17 #include "base/mac/sdk_forward_declarations.h" | 18 #include "base/mac/sdk_forward_declarations.h" |
18 #import "base/memory/scoped_nsobject.h" | |
19 #include "base/message_loop.h" | 19 #include "base/message_loop.h" |
20 #include "base/metrics/histogram.h" | 20 #include "base/metrics/histogram.h" |
21 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
22 #include "base/strings/stringprintf.h" | 22 #include "base/strings/stringprintf.h" |
23 #include "base/strings/sys_string_conversions.h" | 23 #include "base/strings/sys_string_conversions.h" |
24 #include "base/strings/utf_string_conversions.h" | 24 #include "base/strings/utf_string_conversions.h" |
25 #include "base/sys_info.h" | 25 #include "base/sys_info.h" |
26 #import "content/browser/accessibility/browser_accessibility_cocoa.h" | 26 #import "content/browser/accessibility/browser_accessibility_cocoa.h" |
27 #include "content/browser/accessibility/browser_accessibility_manager_mac.h" | 27 #include "content/browser/accessibility/browser_accessibility_manager_mac.h" |
28 #include "content/browser/renderer_host/backing_store_mac.h" | 28 #include "content/browser/renderer_host/backing_store_mac.h" |
(...skipping 2108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2137 if ([theEvent type] != NSKeyDown) { | 2137 if ([theEvent type] != NSKeyDown) { |
2138 widgetHost->ForwardKeyboardEvent(event); | 2138 widgetHost->ForwardKeyboardEvent(event); |
2139 | 2139 |
2140 // Possibly autohide the cursor. | 2140 // Possibly autohide the cursor. |
2141 if ([RenderWidgetHostViewCocoa shouldAutohideCursorForEvent:theEvent]) | 2141 if ([RenderWidgetHostViewCocoa shouldAutohideCursorForEvent:theEvent]) |
2142 [NSCursor setHiddenUntilMouseMoves:YES]; | 2142 [NSCursor setHiddenUntilMouseMoves:YES]; |
2143 | 2143 |
2144 return; | 2144 return; |
2145 } | 2145 } |
2146 | 2146 |
2147 scoped_nsobject<RenderWidgetHostViewCocoa> keepSelfAlive([self retain]); | 2147 base::scoped_nsobject<RenderWidgetHostViewCocoa> keepSelfAlive([self retain]); |
2148 | 2148 |
2149 // Records the current marked text state, so that we can know if the marked | 2149 // Records the current marked text state, so that we can know if the marked |
2150 // text was deleted or not after handling the key down event. | 2150 // text was deleted or not after handling the key down event. |
2151 BOOL oldHasMarkedText = hasMarkedText_; | 2151 BOOL oldHasMarkedText = hasMarkedText_; |
2152 | 2152 |
2153 // This method should not be called recursively. | 2153 // This method should not be called recursively. |
2154 DCHECK(!handlingKeyDown_); | 2154 DCHECK(!handlingKeyDown_); |
2155 | 2155 |
2156 // Tells insertText: and doCommandBySelector: that we are handling a key | 2156 // Tells insertText: and doCommandBySelector: that we are handling a key |
2157 // down event. | 2157 // down event. |
(...skipping 1534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3692 // | 3692 // |
3693 // Supporting application services | 3693 // Supporting application services |
3694 // | 3694 // |
3695 @implementation RenderWidgetHostViewCocoa(NSServicesRequests) | 3695 @implementation RenderWidgetHostViewCocoa(NSServicesRequests) |
3696 | 3696 |
3697 - (BOOL)writeSelectionToPasteboard:(NSPasteboard*)pboard | 3697 - (BOOL)writeSelectionToPasteboard:(NSPasteboard*)pboard |
3698 types:(NSArray*)types { | 3698 types:(NSArray*)types { |
3699 const std::string& str = renderWidgetHostView_->selected_text(); | 3699 const std::string& str = renderWidgetHostView_->selected_text(); |
3700 if (![types containsObject:NSStringPboardType] || str.empty()) return NO; | 3700 if (![types containsObject:NSStringPboardType] || str.empty()) return NO; |
3701 | 3701 |
3702 scoped_nsobject<NSString> text([[NSString alloc] | 3702 base::scoped_nsobject<NSString> text( |
3703 initWithUTF8String:str.c_str()]); | 3703 [[NSString alloc] initWithUTF8String:str.c_str()]); |
3704 NSArray* toDeclare = [NSArray arrayWithObject:NSStringPboardType]; | 3704 NSArray* toDeclare = [NSArray arrayWithObject:NSStringPboardType]; |
3705 [pboard declareTypes:toDeclare owner:nil]; | 3705 [pboard declareTypes:toDeclare owner:nil]; |
3706 return [pboard setString:text forType:NSStringPboardType]; | 3706 return [pboard setString:text forType:NSStringPboardType]; |
3707 } | 3707 } |
3708 | 3708 |
3709 - (BOOL)readSelectionFromPasteboard:(NSPasteboard*)pboard { | 3709 - (BOOL)readSelectionFromPasteboard:(NSPasteboard*)pboard { |
3710 NSString *string = [pboard stringForType:NSStringPboardType]; | 3710 NSString *string = [pboard stringForType:NSStringPboardType]; |
3711 if (!string) return NO; | 3711 if (!string) return NO; |
3712 | 3712 |
3713 // If the user is currently using an IME, confirm the IME input, | 3713 // If the user is currently using an IME, confirm the IME input, |
3714 // and then insert the text from the service, the same as TextEdit and Safari. | 3714 // and then insert the text from the service, the same as TextEdit and Safari. |
3715 [self confirmComposition]; | 3715 [self confirmComposition]; |
3716 [self insertText:string]; | 3716 [self insertText:string]; |
3717 return YES; | 3717 return YES; |
3718 } | 3718 } |
3719 | 3719 |
3720 - (BOOL)isOpaque { | 3720 - (BOOL)isOpaque { |
3721 if (renderWidgetHostView_->use_core_animation_) | 3721 if (renderWidgetHostView_->use_core_animation_) |
3722 return YES; | 3722 return YES; |
3723 return [super isOpaque]; | 3723 return [super isOpaque]; |
3724 } | 3724 } |
3725 | 3725 |
3726 @end | 3726 @end |
OLD | NEW |