| 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/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 880 [editor didChangeText]; | 880 [editor didChangeText]; |
| 881 } | 881 } |
| 882 } | 882 } |
| 883 | 883 |
| 884 // TODO(dominich): Move to OmniboxView base class? Currently this is defined on | 884 // TODO(dominich): Move to OmniboxView base class? Currently this is defined on |
| 885 // the AutocompleteTextFieldObserver but the logic is shared between all | 885 // the AutocompleteTextFieldObserver but the logic is shared between all |
| 886 // platforms. Some refactor might be necessary to simplify this. Or at least | 886 // platforms. Some refactor might be necessary to simplify this. Or at least |
| 887 // this method could call the OmniboxView version. | 887 // this method could call the OmniboxView version. |
| 888 bool OmniboxViewMac::ShouldEnableCopyURL() { | 888 bool OmniboxViewMac::ShouldEnableCopyURL() { |
| 889 return !model()->user_input_in_progress() && | 889 return !model()->user_input_in_progress() && |
| 890 toolbar_model()->WouldReplaceSearchURLWithSearchTerms(); | 890 toolbar_model()->GetSearchTermsType() != ToolbarModel::NO_SEARCH_TERMS; |
| 891 } | 891 } |
| 892 | 892 |
| 893 bool OmniboxViewMac::CanPasteAndGo() { | 893 bool OmniboxViewMac::CanPasteAndGo() { |
| 894 return model()->CanPasteAndGo(GetClipboardText()); | 894 return model()->CanPasteAndGo(GetClipboardText()); |
| 895 } | 895 } |
| 896 | 896 |
| 897 int OmniboxViewMac::GetPasteActionStringId() { | 897 int OmniboxViewMac::GetPasteActionStringId() { |
| 898 string16 text(GetClipboardText()); | 898 string16 text(GetClipboardText()); |
| 899 DCHECK(model()->CanPasteAndGo(text)); | 899 DCHECK(model()->CanPasteAndGo(text)); |
| 900 return model()->IsPasteAndSearch(text) ? | 900 return model()->IsPasteAndSearch(text) ? |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 973 | 973 |
| 974 NSUInteger OmniboxViewMac::GetTextLength() const { | 974 NSUInteger OmniboxViewMac::GetTextLength() const { |
| 975 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : | 975 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : |
| 976 [[field_ stringValue] length]; | 976 [[field_ stringValue] length]; |
| 977 } | 977 } |
| 978 | 978 |
| 979 bool OmniboxViewMac::IsCaretAtEnd() const { | 979 bool OmniboxViewMac::IsCaretAtEnd() const { |
| 980 const NSRange selection = GetSelectedRange(); | 980 const NSRange selection = GetSelectedRange(); |
| 981 return NSMaxRange(selection) == GetTextLength(); | 981 return NSMaxRange(selection) == GetTextLength(); |
| 982 } | 982 } |
| OLD | NEW |