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/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 } else { | 515 } else { |
516 NOTREACHED(); | 516 NOTREACHED(); |
517 color = BaseTextColor(); | 517 color = BaseTextColor(); |
518 } | 518 } |
519 [as addAttribute:NSForegroundColorAttributeName value:color | 519 [as addAttribute:NSForegroundColorAttributeName value:color |
520 range:ComponentToNSRange(scheme)]; | 520 range:ComponentToNSRange(scheme)]; |
521 } | 521 } |
522 } | 522 } |
523 | 523 |
524 void OmniboxViewMac::OnTemporaryTextMaybeChanged(const string16& display_text, | 524 void OmniboxViewMac::OnTemporaryTextMaybeChanged(const string16& display_text, |
525 bool save_original_selection) { | 525 bool save_original_selection, |
| 526 bool notify_text_changed) { |
526 if (save_original_selection) | 527 if (save_original_selection) |
527 saved_temporary_selection_ = GetSelectedRange(); | 528 saved_temporary_selection_ = GetSelectedRange(); |
528 | 529 |
529 suggest_text_length_ = 0; | 530 suggest_text_length_ = 0; |
530 SetWindowTextAndCaretPos(display_text, display_text.size(), false, false); | 531 SetWindowTextAndCaretPos(display_text, display_text.size(), false, false); |
531 model()->OnChanged(); | 532 if (notify_text_changed) |
| 533 model()->OnChanged(); |
532 [field_ clearUndoChain]; | 534 [field_ clearUndoChain]; |
533 } | 535 } |
534 | 536 |
535 void OmniboxViewMac::OnStartingIME() { | 537 void OmniboxViewMac::OnStartingIME() { |
536 // Reset the suggest text just before starting an IME composition session, | 538 // Reset the suggest text just before starting an IME composition session, |
537 // otherwise the IME composition may be interrupted when the suggest text | 539 // otherwise the IME composition may be interrupted when the suggest text |
538 // gets reset by the IME composition change. | 540 // gets reset by the IME composition change. |
539 SetInstantSuggestion(string16()); | 541 SetInstantSuggestion(string16()); |
540 } | 542 } |
541 | 543 |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 NSUInteger OmniboxViewMac::GetTextLength() const { | 1040 NSUInteger OmniboxViewMac::GetTextLength() const { |
1039 return ([field_ currentEditor] ? | 1041 return ([field_ currentEditor] ? |
1040 [[[field_ currentEditor] string] length] : | 1042 [[[field_ currentEditor] string] length] : |
1041 [[field_ stringValue] length]) - suggest_text_length_; | 1043 [[field_ stringValue] length]) - suggest_text_length_; |
1042 } | 1044 } |
1043 | 1045 |
1044 bool OmniboxViewMac::IsCaretAtEnd() const { | 1046 bool OmniboxViewMac::IsCaretAtEnd() const { |
1045 const NSRange selection = GetSelectedRange(); | 1047 const NSRange selection = GetSelectedRange(); |
1046 return selection.length == 0 && selection.location == GetTextLength(); | 1048 return selection.length == 0 && selection.location == GetTextLength(); |
1047 } | 1049 } |
OLD | NEW |