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

Side by Side Diff: chrome/browser/autocomplete/autocomplete_edit.cc

Issue 6995032: Fix a browser crash involving omnibox extension keywords. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: latest Created 9 years, 7 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/autocomplete/autocomplete_edit.h" 5 #include "chrome/browser/autocomplete/autocomplete_edit.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 instant->DestroyPreviewContents(); 404 instant->DestroyPreviewContents();
405 } 405 }
406 406
407 autocomplete_controller_->Stop(true); 407 autocomplete_controller_->Stop(true);
408 } 408 }
409 409
410 bool AutocompleteEditModel::CanPasteAndGo(const string16& text) const { 410 bool AutocompleteEditModel::CanPasteAndGo(const string16& text) const {
411 if (!view_->GetCommandUpdater()->IsCommandEnabled(IDC_OPEN_CURRENT_URL)) 411 if (!view_->GetCommandUpdater()->IsCommandEnabled(IDC_OPEN_CURRENT_URL))
412 return false; 412 return false;
413 413
414 profile_->GetAutocompleteClassifier()->Classify(text, string16(), false, 414 profile_->GetAutocompleteClassifier()->Classify(text, string16(),
415 &paste_and_go_match_, &paste_and_go_alternate_nav_url_); 415 false, false, &paste_and_go_match_, &paste_and_go_alternate_nav_url_);
416 return paste_and_go_match_.destination_url.is_valid(); 416 return paste_and_go_match_.destination_url.is_valid();
417 } 417 }
418 418
419 void AutocompleteEditModel::PasteAndGo() { 419 void AutocompleteEditModel::PasteAndGo() {
420 // The final parameter to OpenURL, keyword, is not quite correct here: it's 420 // The final parameter to OpenURL, keyword, is not quite correct here: it's
421 // possible to "paste and go" a string that contains a keyword. This is 421 // possible to "paste and go" a string that contains a keyword. This is
422 // enough of an edge case that we ignore this possibility. 422 // enough of an edge case that we ignore this possibility.
423 view_->RevertAll(); 423 view_->RevertAll();
424 view_->OpenMatch(paste_and_go_match_, CURRENT_TAB, 424 view_->OpenMatch(paste_and_go_match_, CURRENT_TAB,
425 paste_and_go_alternate_nav_url_, AutocompletePopupModel::kNoMatch, 425 paste_and_go_alternate_nav_url_, AutocompletePopupModel::kNoMatch,
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 *alternate_nav_url = result.alternate_nav_url(); 927 *alternate_nav_url = result.alternate_nav_url();
928 } 928 }
929 929
930 void AutocompleteEditModel::GetInfoForCurrentText( 930 void AutocompleteEditModel::GetInfoForCurrentText(
931 AutocompleteMatch* match, 931 AutocompleteMatch* match,
932 GURL* alternate_nav_url) const { 932 GURL* alternate_nav_url) const {
933 if (popup_->IsOpen() || query_in_progress()) { 933 if (popup_->IsOpen() || query_in_progress()) {
934 InfoForCurrentSelection(match, alternate_nav_url); 934 InfoForCurrentSelection(match, alternate_nav_url);
935 } else { 935 } else {
936 profile_->GetAutocompleteClassifier()->Classify( 936 profile_->GetAutocompleteClassifier()->Classify(
937 UserTextFromDisplayText(view_->GetText()), GetDesiredTLD(), true, 937 UserTextFromDisplayText(view_->GetText()), GetDesiredTLD(),
938 match, alternate_nav_url); 938 KeywordIsSelected(), true, match, alternate_nav_url);
939 } 939 }
940 } 940 }
941 941
942 bool AutocompleteEditModel::GetURLForText(const string16& text, 942 bool AutocompleteEditModel::GetURLForText(const string16& text,
943 GURL* url) const { 943 GURL* url) const {
944 GURL parsed_url; 944 GURL parsed_url;
945 const AutocompleteInput::Type type = AutocompleteInput::Parse( 945 const AutocompleteInput::Type type = AutocompleteInput::Parse(
946 UserTextFromDisplayText(text), string16(), NULL, NULL, &parsed_url); 946 UserTextFromDisplayText(text), string16(), NULL, NULL, &parsed_url);
947 if (type != AutocompleteInput::URL) 947 if (type != AutocompleteInput::URL)
948 return false; 948 return false;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 // static 1006 // static
1007 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { 1007 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) {
1008 switch (c) { 1008 switch (c) {
1009 case 0x0020: // Space 1009 case 0x0020: // Space
1010 case 0x3000: // Ideographic Space 1010 case 0x3000: // Ideographic Space
1011 return true; 1011 return true;
1012 default: 1012 default:
1013 return false; 1013 return false;
1014 } 1014 }
1015 } 1015 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_classifier.cc ('k') | chrome/browser/autocomplete/search_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698