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

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

Issue 229733004: Omnibox: Make Bookmarks Set Inline_Autocompletion (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: massive new patch, new change description Created 6 years, 8 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/autocomplete/builtin_provider.h" 5 #include "chrome/browser/autocomplete/builtin_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "chrome/browser/autocomplete/autocomplete_input.h" 11 #include "chrome/browser/autocomplete/autocomplete_input.h"
12 #include "chrome/browser/autocomplete/history_provider.h"
12 #include "chrome/common/net/url_fixer_upper.h" 13 #include "chrome/common/net/url_fixer_upper.h"
13 #include "chrome/common/url_constants.h" 14 #include "chrome/common/url_constants.h"
14 15
15 namespace { 16 namespace {
16 17
17 // This list should be kept in sync with chrome/common/url_constants.h. 18 // This list should be kept in sync with chrome/common/url_constants.h.
18 // Only include useful sub-pages, confirmation alerts are not useful. 19 // Only include useful sub-pages, confirmation alerts are not useful.
19 const char* const kChromeSettingsSubPages[] = { 20 const char* const kChromeSettingsSubPages[] = {
20 chrome::kAutofillSubPage, 21 chrome::kAutofillSubPage,
21 chrome::kClearBrowserDataSubPage, 22 chrome::kClearBrowserDataSubPage,
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 if (match_string.length() > match_length) 113 if (match_string.length() > match_length)
113 styles.push_back(ACMatchClassification(match_length, kUrl)); 114 styles.push_back(ACMatchClassification(match_length, kUrl));
114 AddMatch(match_string, match_string.substr(match_length), styles); 115 AddMatch(match_string, match_string.substr(match_length), styles);
115 } 116 }
116 } 117 }
117 } 118 }
118 } 119 }
119 120
120 for (size_t i = 0; i < matches_.size(); ++i) 121 for (size_t i = 0; i < matches_.size(); ++i)
121 matches_[i].relevance = kRelevance + matches_.size() - (i + 1); 122 matches_[i].relevance = kRelevance + matches_.size() - (i + 1);
122 if (!input.prevent_inline_autocomplete() && (matches_.size() == 1)) { 123 if (!HistoryProvider::PreventInlineAutocomplete(input) &&
124 (matches_.size() == 1)) {
123 // If there's only one possible completion of the user's input and 125 // If there's only one possible completion of the user's input and
124 // allowing completions is okay, give the match a high enough score to 126 // allowing completions is okay, give the match a high enough score to
125 // allow it to beat url-what-you-typed and be inlined. 127 // allow it to beat url-what-you-typed and be inlined.
126 matches_[0].relevance = 1250; 128 matches_[0].relevance = 1250;
127 matches_[0].allowed_to_be_default_match = true; 129 matches_[0].allowed_to_be_default_match = true;
128 } 130 }
129 } 131 }
130 132
131 BuiltinProvider::~BuiltinProvider() {} 133 BuiltinProvider::~BuiltinProvider() {}
132 134
133 void BuiltinProvider::AddMatch(const base::string16& match_string, 135 void BuiltinProvider::AddMatch(const base::string16& match_string,
134 const base::string16& inline_completion, 136 const base::string16& inline_completion,
135 const ACMatchClassifications& styles) { 137 const ACMatchClassifications& styles) {
136 AutocompleteMatch match(this, kRelevance, false, 138 AutocompleteMatch match(this, kRelevance, false,
137 AutocompleteMatchType::NAVSUGGEST); 139 AutocompleteMatchType::NAVSUGGEST);
138 match.fill_into_edit = match_string; 140 match.fill_into_edit = match_string;
139 match.inline_autocompletion = inline_completion; 141 match.inline_autocompletion = inline_completion;
140 match.destination_url = GURL(match_string); 142 match.destination_url = GURL(match_string);
141 match.contents = match_string; 143 match.contents = match_string;
142 match.contents_class = styles; 144 match.contents_class = styles;
143 matches_.push_back(match); 145 matches_.push_back(match);
144 } 146 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698