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 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 DCHECK_LE(user_text_length, display_text.size()); | 507 DCHECK_LE(user_text_length, display_text.size()); |
508 const NSRange range = | 508 const NSRange range = |
509 NSMakeRange(user_text_length, display_text.size() - user_text_length); | 509 NSMakeRange(user_text_length, display_text.size() - user_text_length); |
510 SetTextAndSelectedRange(display_text, range); | 510 SetTextAndSelectedRange(display_text, range); |
511 model()->OnChanged(); | 511 model()->OnChanged(); |
512 [field_ clearUndoChain]; | 512 [field_ clearUndoChain]; |
513 | 513 |
514 return true; | 514 return true; |
515 } | 515 } |
516 | 516 |
| 517 void OmniboxViewMac::OnInlineAutocompleteTextCleared() { |
| 518 } |
| 519 |
517 void OmniboxViewMac::OnRevertTemporaryText() { | 520 void OmniboxViewMac::OnRevertTemporaryText() { |
518 SetSelectedRange(saved_temporary_selection_); | 521 SetSelectedRange(saved_temporary_selection_); |
519 // We got here because the user hit the Escape key. We explicitly don't call | 522 // We got here because the user hit the Escape key. We explicitly don't call |
520 // TextChanged(), since OmniboxPopupModel::ResetToDefaultMatch() has already | 523 // TextChanged(), since OmniboxPopupModel::ResetToDefaultMatch() has already |
521 // been called by now, and it would've called TextChanged() if it was | 524 // been called by now, and it would've called TextChanged() if it was |
522 // warranted. | 525 // warranted. |
523 } | 526 } |
524 | 527 |
525 bool OmniboxViewMac::IsFirstResponder() const { | 528 bool OmniboxViewMac::IsFirstResponder() const { |
526 return [field_ currentEditor] != nil ? true : false; | 529 return [field_ currentEditor] != nil ? true : false; |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 | 943 |
941 NSUInteger OmniboxViewMac::GetTextLength() const { | 944 NSUInteger OmniboxViewMac::GetTextLength() const { |
942 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : | 945 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : |
943 [[field_ stringValue] length]; | 946 [[field_ stringValue] length]; |
944 } | 947 } |
945 | 948 |
946 bool OmniboxViewMac::IsCaretAtEnd() const { | 949 bool OmniboxViewMac::IsCaretAtEnd() const { |
947 const NSRange selection = GetSelectedRange(); | 950 const NSRange selection = GetSelectedRange(); |
948 return NSMaxRange(selection) == GetTextLength(); | 951 return NSMaxRange(selection) == GetTextLength(); |
949 } | 952 } |
OLD | NEW |