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

Side by Side Diff: chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm

Issue 1857843002: mac: Fix copying from the Omnibox. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/omnibox/omnibox_view_mac_browsertest.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/omnibox/omnibox_view_mac_browsertest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698