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

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

Issue 11262015: Remove unused / unnecessary stuff from Instant. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove SuggestedTextView entirely Created 8 years, 2 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 | Annotate | Revision Log
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/string_util.h" 9 #include "base/string_util.h"
10 #include "base/sys_string_conversions.h" 10 #include "base/sys_string_conversions.h"
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 suggest_text_length_ = 0; 517 suggest_text_length_ = 0;
518 SetWindowTextAndCaretPos(display_text, display_text.size(), false, false); 518 SetWindowTextAndCaretPos(display_text, display_text.size(), false, false);
519 model()->OnChanged(); 519 model()->OnChanged();
520 [field_ clearUndoChain]; 520 [field_ clearUndoChain];
521 } 521 }
522 522
523 void OmniboxViewMac::OnStartingIME() { 523 void OmniboxViewMac::OnStartingIME() {
524 // Reset the suggest text just before starting an IME composition session, 524 // Reset the suggest text just before starting an IME composition session,
525 // otherwise the IME composition may be interrupted when the suggest text 525 // otherwise the IME composition may be interrupted when the suggest text
526 // gets reset by the IME composition change. 526 // gets reset by the IME composition change.
527 SetInstantSuggestion(string16(), false); 527 SetInstantSuggestion(string16());
528 } 528 }
529 529
530 bool OmniboxViewMac::OnInlineAutocompleteTextMaybeChanged( 530 bool OmniboxViewMac::OnInlineAutocompleteTextMaybeChanged(
531 const string16& display_text, 531 const string16& display_text,
532 size_t user_text_length) { 532 size_t user_text_length) {
533 // TODO(shess): Make sure that this actually works. The round trip 533 // TODO(shess): Make sure that this actually works. The round trip
534 // to native form and back may mean that it's the same but not the 534 // to native form and back may mean that it's the same but not the
535 // same. 535 // same.
536 if (display_text == GetText()) 536 if (display_text == GetText())
537 return false; 537 return false;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 gfx::NativeView OmniboxViewMac::GetNativeView() const { 617 gfx::NativeView OmniboxViewMac::GetNativeView() const {
618 return field_; 618 return field_;
619 } 619 }
620 620
621 gfx::NativeView OmniboxViewMac::GetRelativeWindowForPopup() const { 621 gfx::NativeView OmniboxViewMac::GetRelativeWindowForPopup() const {
622 // Not used on mac. 622 // Not used on mac.
623 NOTREACHED(); 623 NOTREACHED();
624 return NULL; 624 return NULL;
625 } 625 }
626 626
627 void OmniboxViewMac::SetInstantSuggestion(const string16& suggest_text, 627 void OmniboxViewMac::SetInstantSuggestion(const string16& suggest_text) {
628 bool animate_to_complete) {
629 NSString* text = GetNonSuggestTextSubstring(); 628 NSString* text = GetNonSuggestTextSubstring();
630 bool needs_update = (suggest_text_length_ > 0); 629 bool needs_update = (suggest_text_length_ > 0);
631 630
632 // Append the new suggest text. 631 // Append the new suggest text.
633 suggest_text_length_ = suggest_text.length(); 632 suggest_text_length_ = suggest_text.length();
634 if (suggest_text_length_ > 0) { 633 if (suggest_text_length_ > 0) {
635 text = [text stringByAppendingString:base::SysUTF16ToNSString( 634 text = [text stringByAppendingString:base::SysUTF16ToNSString(
636 suggest_text)]; 635 suggest_text)];
637 needs_update = true; 636 needs_update = true;
638 } 637 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 bool OmniboxViewMac::OnDoCommandBySelector(SEL cmd) { 683 bool OmniboxViewMac::OnDoCommandBySelector(SEL cmd) {
685 // We should only arrive here when the field is focussed. 684 // We should only arrive here when the field is focussed.
686 DCHECK(IsFirstResponder()); 685 DCHECK(IsFirstResponder());
687 686
688 if (cmd != @selector(moveRight:) && 687 if (cmd != @selector(moveRight:) &&
689 cmd != @selector(insertTab:) && 688 cmd != @selector(insertTab:) &&
690 cmd != @selector(insertTabIgnoringFieldEditor:)) { 689 cmd != @selector(insertTabIgnoringFieldEditor:)) {
691 // Reset the suggest text for any change other than key right or tab. 690 // Reset the suggest text for any change other than key right or tab.
692 // TODO(rohitrao): This is here to prevent complications when editing text. 691 // TODO(rohitrao): This is here to prevent complications when editing text.
693 // See if this can be removed. 692 // See if this can be removed.
694 SetInstantSuggestion(string16(), false); 693 SetInstantSuggestion(string16());
695 } 694 }
696 695
697 if (cmd == @selector(deleteForward:)) 696 if (cmd == @selector(deleteForward:))
698 delete_was_pressed_ = true; 697 delete_was_pressed_ = true;
699 698
700 // Don't intercept up/down-arrow or backtab if the popup isn't open. 699 // Don't intercept up/down-arrow or backtab if the popup isn't open.
701 if (popup_view_->IsOpen()) { 700 if (popup_view_->IsOpen()) {
702 if (cmd == @selector(moveDown:)) { 701 if (cmd == @selector(moveDown:)) {
703 model()->OnUpOrDownKeyPressed(1); 702 model()->OnUpOrDownKeyPressed(1);
704 return true; 703 return true;
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 NSUInteger OmniboxViewMac::GetTextLength() const { 1006 NSUInteger OmniboxViewMac::GetTextLength() const {
1008 return ([field_ currentEditor] ? 1007 return ([field_ currentEditor] ?
1009 [[[field_ currentEditor] string] length] : 1008 [[[field_ currentEditor] string] length] :
1010 [[field_ stringValue] length]) - suggest_text_length_; 1009 [[field_ stringValue] length]) - suggest_text_length_;
1011 } 1010 }
1012 1011
1013 bool OmniboxViewMac::IsCaretAtEnd() const { 1012 bool OmniboxViewMac::IsCaretAtEnd() const {
1014 const NSRange selection = GetSelectedRange(); 1013 const NSRange selection = GetSelectedRange();
1015 return selection.length == 0 && selection.location == GetTextLength(); 1014 return selection.length == 0 && selection.location == GetTextLength();
1016 } 1015 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h ('k') | chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698