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

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

Issue 191293009: Cleanup: Move kAboutScheme constant into content namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 } 56 }
57 57
58 void BuiltinProvider::Start(const AutocompleteInput& input, 58 void BuiltinProvider::Start(const AutocompleteInput& input,
59 bool minimal_changes) { 59 bool minimal_changes) {
60 matches_.clear(); 60 matches_.clear();
61 if ((input.type() == AutocompleteInput::INVALID) || 61 if ((input.type() == AutocompleteInput::INVALID) ||
62 (input.type() == AutocompleteInput::FORCED_QUERY) || 62 (input.type() == AutocompleteInput::FORCED_QUERY) ||
63 (input.type() == AutocompleteInput::QUERY)) 63 (input.type() == AutocompleteInput::QUERY))
64 return; 64 return;
65 65
66 const base::string16 kAbout = base::ASCIIToUTF16(chrome::kAboutScheme) + 66 const base::string16 kAbout = base::ASCIIToUTF16(content::kAboutScheme) +
67 base::ASCIIToUTF16(content::kStandardSchemeSeparator); 67 base::ASCIIToUTF16(content::kStandardSchemeSeparator);
68 const base::string16 kChrome = base::ASCIIToUTF16(content::kChromeUIScheme) + 68 const base::string16 kChrome = base::ASCIIToUTF16(content::kChromeUIScheme) +
69 base::ASCIIToUTF16(content::kStandardSchemeSeparator); 69 base::ASCIIToUTF16(content::kStandardSchemeSeparator);
70 70
71 const int kUrl = ACMatchClassification::URL; 71 const int kUrl = ACMatchClassification::URL;
72 const int kMatch = kUrl | ACMatchClassification::MATCH; 72 const int kMatch = kUrl | ACMatchClassification::MATCH;
73 73
74 base::string16 text = input.text(); 74 base::string16 text = input.text();
75 bool starting_chrome = StartsWith(kChrome, text, false); 75 bool starting_chrome = StartsWith(kChrome, text, false);
76 if (starting_chrome || StartsWith(kAbout, text, false)) { 76 if (starting_chrome || StartsWith(kAbout, text, false)) {
77 ACMatchClassifications styles; 77 ACMatchClassifications styles;
78 // Highlight the input portion matching "chrome://"; or if the user has 78 // Highlight the input portion matching "chrome://"; or if the user has
79 // input "about:" (with optional slashes), highlight the whole "chrome://". 79 // input "about:" (with optional slashes), highlight the whole "chrome://".
80 const size_t kAboutSchemeLength = strlen(chrome::kAboutScheme); 80 const size_t kAboutSchemeLength = strlen(content::kAboutScheme);
81 bool highlight = starting_chrome || text.length() > kAboutSchemeLength; 81 bool highlight = starting_chrome || text.length() > kAboutSchemeLength;
82 styles.push_back(ACMatchClassification(0, highlight ? kMatch : kUrl)); 82 styles.push_back(ACMatchClassification(0, highlight ? kMatch : kUrl));
83 size_t offset = starting_chrome ? text.length() : kChrome.length(); 83 size_t offset = starting_chrome ? text.length() : kChrome.length();
84 if (highlight) 84 if (highlight)
85 styles.push_back(ACMatchClassification(offset, kUrl)); 85 styles.push_back(ACMatchClassification(offset, kUrl));
86 // Include some common builtin chrome URLs as the user types the scheme. 86 // Include some common builtin chrome URLs as the user types the scheme.
87 AddMatch(base::ASCIIToUTF16(chrome::kChromeUIChromeURLsURL), 87 AddMatch(base::ASCIIToUTF16(chrome::kChromeUIChromeURLsURL),
88 base::string16(), styles); 88 base::string16(), styles);
89 AddMatch(base::ASCIIToUTF16(chrome::kChromeUISettingsURL), 89 AddMatch(base::ASCIIToUTF16(chrome::kChromeUISettingsURL),
90 base::string16(), styles); 90 base::string16(), styles);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 const ACMatchClassifications& styles) { 135 const ACMatchClassifications& styles) {
136 AutocompleteMatch match(this, kRelevance, false, 136 AutocompleteMatch match(this, kRelevance, false,
137 AutocompleteMatchType::NAVSUGGEST); 137 AutocompleteMatchType::NAVSUGGEST);
138 match.fill_into_edit = match_string; 138 match.fill_into_edit = match_string;
139 match.inline_autocompletion = inline_completion; 139 match.inline_autocompletion = inline_completion;
140 match.destination_url = GURL(match_string); 140 match.destination_url = GURL(match_string);
141 match.contents = match_string; 141 match.contents = match_string;
142 match.contents_class = styles; 142 match.contents_class = styles;
143 matches_.push_back(match); 143 matches_.push_back(match);
144 } 144 }
OLDNEW
« no previous file with comments | « android_webview/renderer/aw_content_renderer_client.cc ('k') | chrome/browser/autocomplete/builtin_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698