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/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
768 } | 768 } |
769 | 769 |
770 void OmniboxViewMac::OnMouseDown(NSInteger button_number) { | 770 void OmniboxViewMac::OnMouseDown(NSInteger button_number) { |
771 // Restore caret visibility whenever the user clicks in the the omnibox. This | 771 // Restore caret visibility whenever the user clicks in the the omnibox. This |
772 // is not always covered by OnSetFocus() because when clicking while the | 772 // is not always covered by OnSetFocus() because when clicking while the |
773 // omnibox has invisible focus does not trigger a new OnSetFocus() call. | 773 // omnibox has invisible focus does not trigger a new OnSetFocus() call. |
774 if (button_number == 0 || button_number == 1) | 774 if (button_number == 0 || button_number == 1) |
775 model()->SetCaretVisibility(true); | 775 model()->SetCaretVisibility(true); |
776 } | 776 } |
777 | 777 |
| 778 bool OmniboxViewMac::ShouldSelectAllOnMouseDown() { |
| 779 return !controller()->GetToolbarModel()->WouldPerformSearchTermReplacement( |
| 780 false); |
| 781 } |
| 782 |
778 bool OmniboxViewMac::CanCopy() { | 783 bool OmniboxViewMac::CanCopy() { |
779 const NSRange selection = GetSelectedRange(); | 784 const NSRange selection = GetSelectedRange(); |
780 return selection.length > 0; | 785 return selection.length > 0; |
781 } | 786 } |
782 | 787 |
783 void OmniboxViewMac::CopyToPasteboard(NSPasteboard* pb) { | 788 void OmniboxViewMac::CopyToPasteboard(NSPasteboard* pb) { |
784 DCHECK(CanCopy()); | 789 DCHECK(CanCopy()); |
785 | 790 |
786 const NSRange selection = GetSelectedRange(); | 791 const NSRange selection = GetSelectedRange(); |
787 string16 text = base::SysNSStringToUTF16( | 792 string16 text = base::SysNSStringToUTF16( |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 | 941 |
937 NSUInteger OmniboxViewMac::GetTextLength() const { | 942 NSUInteger OmniboxViewMac::GetTextLength() const { |
938 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : | 943 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : |
939 [[field_ stringValue] length]; | 944 [[field_ stringValue] length]; |
940 } | 945 } |
941 | 946 |
942 bool OmniboxViewMac::IsCaretAtEnd() const { | 947 bool OmniboxViewMac::IsCaretAtEnd() const { |
943 const NSRange selection = GetSelectedRange(); | 948 const NSRange selection = GetSelectedRange(); |
944 return NSMaxRange(selection) == GetTextLength(); | 949 return NSMaxRange(selection) == GetTextLength(); |
945 } | 950 } |
OLD | NEW |