| 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 "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" | 5 #include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" |
| 6 | 6 |
| 7 #include <Carbon/Carbon.h> // kVK_Return | 7 #include <Carbon/Carbon.h> // kVK_Return |
| 8 | 8 |
| 9 #include "base/mac/foundation_util.h" | 9 #include "base/mac/foundation_util.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 950 NSString* nstext = base::SysUTF16ToNSString(text); | 950 NSString* nstext = base::SysUTF16ToNSString(text); |
| 951 if (write_url) { | 951 if (write_url) { |
| 952 return ui::ClipboardUtil::PasteboardItemFromUrl( | 952 return ui::ClipboardUtil::PasteboardItemFromUrl( |
| 953 base::SysUTF8ToNSString(url.spec()), nstext); | 953 base::SysUTF8ToNSString(url.spec()), nstext); |
| 954 } else { | 954 } else { |
| 955 return ui::ClipboardUtil::PasteboardItemFromString(nstext); | 955 return ui::ClipboardUtil::PasteboardItemFromString(nstext); |
| 956 } | 956 } |
| 957 } | 957 } |
| 958 | 958 |
| 959 void OmniboxViewMac::CopyToPasteboard(NSPasteboard* pboard) { | 959 void OmniboxViewMac::CopyToPasteboard(NSPasteboard* pboard) { |
| 960 [pboard clearContents]; |
| 960 base::scoped_nsobject<NSPasteboardItem> item(CreatePasteboardItem()); | 961 base::scoped_nsobject<NSPasteboardItem> item(CreatePasteboardItem()); |
| 961 [pboard writeObjects:@[ item.get() ]]; | 962 [pboard writeObjects:@[ item.get() ]]; |
| 962 } | 963 } |
| 963 | 964 |
| 964 void OmniboxViewMac::ShowURL() { | 965 void OmniboxViewMac::ShowURL() { |
| 965 DCHECK(ShouldEnableShowURL()); | 966 DCHECK(ShouldEnableShowURL()); |
| 966 OmniboxView::ShowURL(); | 967 OmniboxView::ShowURL(); |
| 967 } | 968 } |
| 968 | 969 |
| 969 void OmniboxViewMac::OnPaste() { | 970 void OmniboxViewMac::OnPaste() { |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1106 | 1107 |
| 1107 NSUInteger OmniboxViewMac::GetTextLength() const { | 1108 NSUInteger OmniboxViewMac::GetTextLength() const { |
| 1108 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : | 1109 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : |
| 1109 [[field_ stringValue] length]; | 1110 [[field_ stringValue] length]; |
| 1110 } | 1111 } |
| 1111 | 1112 |
| 1112 bool OmniboxViewMac::IsCaretAtEnd() const { | 1113 bool OmniboxViewMac::IsCaretAtEnd() const { |
| 1113 const NSRange selection = GetSelectedRange(); | 1114 const NSRange selection = GetSelectedRange(); |
| 1114 return NSMaxRange(selection) == GetTextLength(); | 1115 return NSMaxRange(selection) == GetTextLength(); |
| 1115 } | 1116 } |
| OLD | NEW |