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

Unified Diff: trunk/src/chrome/browser/autocomplete/shortcuts_provider.cc

Issue 106573003: Revert 242029 "Omnibox: Bug Fixes for Shortcuts Inlining" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years 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: trunk/src/chrome/browser/autocomplete/shortcuts_provider.cc
===================================================================
--- trunk/src/chrome/browser/autocomplete/shortcuts_provider.cc (revision 242105)
+++ trunk/src/chrome/browser/autocomplete/shortcuts_provider.cc (working copy)
@@ -21,7 +21,6 @@
#include "chrome/browser/autocomplete/autocomplete_input.h"
#include "chrome/browser/autocomplete/autocomplete_provider_listener.h"
#include "chrome/browser/autocomplete/autocomplete_result.h"
-#include "chrome/browser/autocomplete/history_provider.h"
#include "chrome/browser/autocomplete/url_prefix.h"
#include "chrome/browser/history/history_notifications.h"
#include "chrome/browser/history/history_service.h"
@@ -29,7 +28,6 @@
#include "chrome/browser/history/shortcuts_backend_factory.h"
#include "chrome/browser/omnibox/omnibox_field_trial.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/common/net/url_fixer_upper.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "url/url_parse.h"
@@ -53,8 +51,7 @@
: AutocompleteProvider(listener, profile,
AutocompleteProvider::TYPE_SHORTCUTS),
languages_(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)),
- initialized_(false),
- www_prefix_(ASCIIToUTF16("www."), 1) {
+ initialized_(false) {
scoped_refptr<history::ShortcutsBackend> backend =
ShortcutsBackendFactory::GetForProfile(profile_);
if (backend.get()) {
@@ -137,11 +134,6 @@
base::string16 term_string(base::i18n::ToLower(input.text()));
DCHECK(!term_string.empty());
- base::string16 fixed_up_term_string(term_string);
- AutocompleteInput fixed_up_input(input);
- if (HistoryProvider::FixupUserInput(&fixed_up_input))
- fixed_up_term_string = fixed_up_input.text();
-
int max_relevance;
if (!OmniboxFieldTrial::ShortcutsScoringMaxRelevance(
input.current_page_classification(), &max_relevance))
@@ -155,7 +147,7 @@
int relevance = CalculateScore(term_string, it->second, max_relevance);
if (relevance) {
matches_.push_back(ShortcutToACMatch(
- it->second, relevance, term_string, fixed_up_term_string,
+ it->second, relevance, term_string,
input.prevent_inline_autocomplete()));
}
}
@@ -191,8 +183,7 @@
const history::ShortcutsBackend::Shortcut& shortcut,
int relevance,
const base::string16& term_string,
- const base::string16& fixed_up_term_string,
- const bool prevent_inline_autocomplete) {
+ bool prevent_inline_autocomplete) {
DCHECK(!term_string.empty());
AutocompleteMatch match(shortcut.match_core.ToMatch());
match.provider = this;
@@ -220,21 +211,21 @@
}
} else {
const URLPrefix* best_prefix =
- BestURLPrefixWithWWWCase(match.fill_into_edit, term_string);
- const base::string16* matching_string = &term_string;
- // If we failed to find a best_prefix initially, try again using a
- // fixed-up version of the user input. This is especially useful to
- // get about: URLs to inline against chrome:// shortcuts. (about:
- // URLs are fixed up to the chrome:// scheme.)
- if ((best_prefix == NULL) && !fixed_up_term_string.empty() &&
- (fixed_up_term_string != term_string)) {
- best_prefix = BestURLPrefixWithWWWCase(
- match.fill_into_edit, fixed_up_term_string);
- matching_string = &fixed_up_term_string;
+ URLPrefix::BestURLPrefix(match.fill_into_edit, term_string);
+ URLPrefix www_prefix(ASCIIToUTF16("www."), 1);
+ if ((best_prefix == NULL) ||
+ (best_prefix->num_components < www_prefix.num_components)) {
+ // Sometimes |fill_into_edit| can start with "www." without having a
+ // protocol at the beginning. Because "www." is not on the default
+ // prefix list, we test for it explicitly here and use that match if
+ // the default list didn't have a match or the default list's match
+ // was shorter than it could've been.
+ if (URLPrefix::PrefixMatch(www_prefix, match.fill_into_edit, term_string))
+ best_prefix = &www_prefix;
}
if (best_prefix != NULL) {
match.inline_autocompletion = match.fill_into_edit.substr(
- best_prefix->prefix.length() + matching_string->length());
+ best_prefix->prefix.length() + term_string.length());
match.allowed_to_be_default_match =
!prevent_inline_autocomplete || match.inline_autocompletion.empty();
}
@@ -408,15 +399,3 @@
return static_cast<int>((base_score / exp(decay_exponent / decay_divisor)) +
0.5);
}
-
-const URLPrefix* ShortcutsProvider::BestURLPrefixWithWWWCase(
- const base::string16& text,
- const base::string16& prefix_suffix) const {
- const URLPrefix* best_prefix = URLPrefix::BestURLPrefix(text, prefix_suffix);
- if ((best_prefix == NULL) ||
- (best_prefix->num_components < www_prefix_.num_components)) {
- if (URLPrefix::PrefixMatch(www_prefix_, text, prefix_suffix))
- best_prefix = &www_prefix_;
- }
- return best_prefix;
-}

Powered by Google App Engine
This is Rietveld 408576698