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

Unified Diff: chrome/browser/ui/omnibox/omnibox_edit_model.cc

Issue 10704074: "Paste and go" state was being calculated wrong on views (at least). Fix by making this calculatio… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/omnibox/omnibox_edit_model.cc
===================================================================
--- chrome/browser/ui/omnibox/omnibox_edit_model.cc (revision 144499)
+++ chrome/browser/ui/omnibox/omnibox_edit_model.cc (working copy)
@@ -449,18 +449,27 @@
if (!view_->GetCommandUpdater()->IsCommandEnabled(IDC_OPEN_CURRENT_URL))
return false;
- AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text,
- string16(), false, false, &paste_and_go_match_,
- &paste_and_go_alternate_nav_url_);
- return paste_and_go_match_.destination_url.is_valid();
+ AutocompleteMatch match;
+ ClassifyStringForPasteAndGo(text, &match, NULL);
+ return match.destination_url.is_valid();
}
-void OmniboxEditModel::PasteAndGo() {
+void OmniboxEditModel::PasteAndGo(const string16& text) {
+ DCHECK(CanPasteAndGo(text));
view_->RevertAll();
- view_->OpenMatch(paste_and_go_match_, CURRENT_TAB,
- paste_and_go_alternate_nav_url_, OmniboxPopupModel::kNoMatch);
+ AutocompleteMatch match;
+ GURL alternate_nav_url;
+ ClassifyStringForPasteAndGo(text, &match, &alternate_nav_url);
+ view_->OpenMatch(match, CURRENT_TAB, alternate_nav_url,
+ OmniboxPopupModel::kNoMatch);
}
+bool OmniboxEditModel::IsPasteAndSearch(const string16& text) const {
+ AutocompleteMatch match;
+ ClassifyStringForPasteAndGo(text, &match, NULL);
+ return (match.transition != content::PAGE_TRANSITION_TYPED);
+}
+
void OmniboxEditModel::AcceptInput(WindowOpenDisposition disposition,
bool for_drop) {
// Get the URL and transition type for the selected entry.
@@ -1157,3 +1166,12 @@
return metrics::OmniboxEventProto_PageClassification_HOMEPAGE;
return metrics::OmniboxEventProto_PageClassification_OTHER;
}
+
+void OmniboxEditModel::ClassifyStringForPasteAndGo(
+ const string16& text,
+ AutocompleteMatch* match,
+ GURL* alternate_nav_url) const {
+ DCHECK(match);
+ AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text,
+ string16(), false, false, match, alternate_nav_url);
+}
« no previous file with comments | « chrome/browser/ui/omnibox/omnibox_edit_model.h ('k') | chrome/browser/ui/views/omnibox/omnibox_view_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698