OLD | NEW |
---|---|
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 Loading... | |
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 KeywordIsSelected(), false, | |
Peter Kasting
2011/05/10 22:47:49
This should be false
Matt Perry
2011/05/10 22:53:32
Done.
| |
415 &paste_and_go_match_, &paste_and_go_alternate_nav_url_); | 416 &paste_and_go_match_, &paste_and_go_alternate_nav_url_); |
416 return paste_and_go_match_.destination_url.is_valid(); | 417 return paste_and_go_match_.destination_url.is_valid(); |
417 } | 418 } |
418 | 419 |
419 void AutocompleteEditModel::PasteAndGo() { | 420 void AutocompleteEditModel::PasteAndGo() { |
420 // The final parameter to OpenURL, keyword, is not quite correct here: it's | 421 // 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 | 422 // possible to "paste and go" a string that contains a keyword. This is |
422 // enough of an edge case that we ignore this possibility. | 423 // enough of an edge case that we ignore this possibility. |
423 view_->RevertAll(); | 424 view_->RevertAll(); |
424 view_->OpenMatch(paste_and_go_match_, CURRENT_TAB, | 425 view_->OpenMatch(paste_and_go_match_, CURRENT_TAB, |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
927 *alternate_nav_url = result.alternate_nav_url(); | 928 *alternate_nav_url = result.alternate_nav_url(); |
928 } | 929 } |
929 | 930 |
930 void AutocompleteEditModel::GetInfoForCurrentText( | 931 void AutocompleteEditModel::GetInfoForCurrentText( |
931 AutocompleteMatch* match, | 932 AutocompleteMatch* match, |
932 GURL* alternate_nav_url) const { | 933 GURL* alternate_nav_url) const { |
933 if (popup_->IsOpen() || query_in_progress()) { | 934 if (popup_->IsOpen() || query_in_progress()) { |
934 InfoForCurrentSelection(match, alternate_nav_url); | 935 InfoForCurrentSelection(match, alternate_nav_url); |
935 } else { | 936 } else { |
936 profile_->GetAutocompleteClassifier()->Classify( | 937 profile_->GetAutocompleteClassifier()->Classify( |
937 UserTextFromDisplayText(view_->GetText()), GetDesiredTLD(), true, | 938 UserTextFromDisplayText(view_->GetText()), GetDesiredTLD(), |
938 match, alternate_nav_url); | 939 KeywordIsSelected(), true, match, alternate_nav_url); |
939 } | 940 } |
940 } | 941 } |
941 | 942 |
942 bool AutocompleteEditModel::GetURLForText(const string16& text, | 943 bool AutocompleteEditModel::GetURLForText(const string16& text, |
943 GURL* url) const { | 944 GURL* url) const { |
944 GURL parsed_url; | 945 GURL parsed_url; |
945 const AutocompleteInput::Type type = AutocompleteInput::Parse( | 946 const AutocompleteInput::Type type = AutocompleteInput::Parse( |
946 UserTextFromDisplayText(text), string16(), NULL, NULL, &parsed_url); | 947 UserTextFromDisplayText(text), string16(), NULL, NULL, &parsed_url); |
947 if (type != AutocompleteInput::URL) | 948 if (type != AutocompleteInput::URL) |
948 return false; | 949 return false; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1006 // static | 1007 // static |
1007 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { | 1008 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { |
1008 switch (c) { | 1009 switch (c) { |
1009 case 0x0020: // Space | 1010 case 0x0020: // Space |
1010 case 0x3000: // Ideographic Space | 1011 case 0x3000: // Ideographic Space |
1011 return true; | 1012 return true; |
1012 default: | 1013 default: |
1013 return false; | 1014 return false; |
1014 } | 1015 } |
1015 } | 1016 } |
OLD | NEW |