OLD | NEW |
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/browser/autocomplete/history_provider.h" |
13 #include "chrome/common/net/url_fixer_upper.h" | 13 #include "chrome/common/net/url_fixer_upper.h" |
14 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
15 #include "components/metrics/proto/omnibox_input_type.pb.h" | |
16 | 15 |
17 namespace { | 16 namespace { |
18 | 17 |
19 #if !defined(OS_ANDROID) | 18 #if !defined(OS_ANDROID) |
20 // This list should be kept in sync with chrome/common/url_constants.h. | 19 // This list should be kept in sync with chrome/common/url_constants.h. |
21 // Only include useful sub-pages, confirmation alerts are not useful. | 20 // Only include useful sub-pages, confirmation alerts are not useful. |
22 const char* const kChromeSettingsSubPages[] = { | 21 const char* const kChromeSettingsSubPages[] = { |
23 chrome::kAutofillSubPage, | 22 chrome::kAutofillSubPage, |
24 chrome::kClearBrowserDataSubPage, | 23 chrome::kClearBrowserDataSubPage, |
25 chrome::kContentSettingsSubPage, | 24 chrome::kContentSettingsSubPage, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 for (size_t i = 0; i < arraysize(kChromeSettingsSubPages); i++) { | 57 for (size_t i = 0; i < arraysize(kChromeSettingsSubPages); i++) { |
59 builtins_.push_back( | 58 builtins_.push_back( |
60 settings + base::ASCIIToUTF16(kChromeSettingsSubPages[i])); | 59 settings + base::ASCIIToUTF16(kChromeSettingsSubPages[i])); |
61 } | 60 } |
62 #endif | 61 #endif |
63 } | 62 } |
64 | 63 |
65 void BuiltinProvider::Start(const AutocompleteInput& input, | 64 void BuiltinProvider::Start(const AutocompleteInput& input, |
66 bool minimal_changes) { | 65 bool minimal_changes) { |
67 matches_.clear(); | 66 matches_.clear(); |
68 if ((input.type() == metrics::OmniboxInputType::INVALID) || | 67 if ((input.type() == AutocompleteInput::INVALID) || |
69 (input.type() == metrics::OmniboxInputType::FORCED_QUERY) || | 68 (input.type() == AutocompleteInput::FORCED_QUERY) || |
70 (input.type() == metrics::OmniboxInputType::QUERY)) | 69 (input.type() == AutocompleteInput::QUERY)) |
71 return; | 70 return; |
72 | 71 |
73 const size_t kAboutSchemeLength = strlen(content::kAboutScheme); | 72 const size_t kAboutSchemeLength = strlen(content::kAboutScheme); |
74 const base::string16 kAbout = base::ASCIIToUTF16(content::kAboutScheme) + | 73 const base::string16 kAbout = base::ASCIIToUTF16(content::kAboutScheme) + |
75 base::ASCIIToUTF16(url::kStandardSchemeSeparator); | 74 base::ASCIIToUTF16(url::kStandardSchemeSeparator); |
76 const base::string16 kChrome = base::ASCIIToUTF16(content::kChromeUIScheme) + | 75 const base::string16 kChrome = base::ASCIIToUTF16(content::kChromeUIScheme) + |
77 base::ASCIIToUTF16(url::kStandardSchemeSeparator); | 76 base::ASCIIToUTF16(url::kStandardSchemeSeparator); |
78 | 77 |
79 const int kUrl = ACMatchClassification::URL; | 78 const int kUrl = ACMatchClassification::URL; |
80 const int kMatch = kUrl | ACMatchClassification::MATCH; | 79 const int kMatch = kUrl | ACMatchClassification::MATCH; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 const ACMatchClassifications& styles) { | 160 const ACMatchClassifications& styles) { |
162 AutocompleteMatch match(this, kRelevance, false, | 161 AutocompleteMatch match(this, kRelevance, false, |
163 AutocompleteMatchType::NAVSUGGEST); | 162 AutocompleteMatchType::NAVSUGGEST); |
164 match.fill_into_edit = match_string; | 163 match.fill_into_edit = match_string; |
165 match.inline_autocompletion = inline_completion; | 164 match.inline_autocompletion = inline_completion; |
166 match.destination_url = GURL(match_string); | 165 match.destination_url = GURL(match_string); |
167 match.contents = match_string; | 166 match.contents = match_string; |
168 match.contents_class = styles; | 167 match.contents_class = styles; |
169 matches_.push_back(match); | 168 matches_.push_back(match); |
170 } | 169 } |
OLD | NEW |