| 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 "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/browser_about_handler.h" | 9 #include "chrome/browser/browser_about_handler.h" |
| 10 #include "chrome/browser/net/url_fixer_upper.h" | 10 #include "chrome/browser/net/url_fixer_upper.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 std::vector<std::string> builtins(ChromePaths()); | 39 std::vector<std::string> builtins(ChromePaths()); |
| 40 for (std::vector<std::string>::iterator i(builtins.begin()); | 40 for (std::vector<std::string>::iterator i(builtins.begin()); |
| 41 i != builtins.end(); ++i) | 41 i != builtins.end(); ++i) |
| 42 builtins_.push_back(ASCIIToUTF16(*i)); | 42 builtins_.push_back(ASCIIToUTF16(*i)); |
| 43 string16 settings(ASCIIToUTF16(chrome::kChromeUISettingsHost) + | 43 string16 settings(ASCIIToUTF16(chrome::kChromeUISettingsHost) + |
| 44 ASCIIToUTF16("/")); | 44 ASCIIToUTF16("/")); |
| 45 for (size_t i = 0; i < arraysize(kChromeSettingsSubPages); i++) | 45 for (size_t i = 0; i < arraysize(kChromeSettingsSubPages); i++) |
| 46 builtins_.push_back(settings + ASCIIToUTF16(kChromeSettingsSubPages[i])); | 46 builtins_.push_back(settings + ASCIIToUTF16(kChromeSettingsSubPages[i])); |
| 47 } | 47 } |
| 48 | 48 |
| 49 BuiltinProvider::~BuiltinProvider() {} | |
| 50 | |
| 51 void BuiltinProvider::Start(const AutocompleteInput& input, | 49 void BuiltinProvider::Start(const AutocompleteInput& input, |
| 52 bool minimal_changes) { | 50 bool minimal_changes) { |
| 53 matches_.clear(); | 51 matches_.clear(); |
| 54 if ((input.type() == AutocompleteInput::INVALID) || | 52 if ((input.type() == AutocompleteInput::INVALID) || |
| 55 (input.type() == AutocompleteInput::FORCED_QUERY) || | 53 (input.type() == AutocompleteInput::FORCED_QUERY) || |
| 56 (input.type() == AutocompleteInput::QUERY) || | 54 (input.type() == AutocompleteInput::QUERY) || |
| 57 (input.matches_requested() == AutocompleteInput::BEST_MATCH)) | 55 (input.matches_requested() == AutocompleteInput::BEST_MATCH)) |
| 58 return; | 56 return; |
| 59 | 57 |
| 60 const string16 kAbout = ASCIIToUTF16(chrome::kAboutScheme) + | 58 const string16 kAbout = ASCIIToUTF16(chrome::kAboutScheme) + |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 AddMatch(match_string, styles); | 99 AddMatch(match_string, styles); |
| 102 } | 100 } |
| 103 } | 101 } |
| 104 } | 102 } |
| 105 } | 103 } |
| 106 | 104 |
| 107 for (size_t i = 0; i < matches_.size(); ++i) | 105 for (size_t i = 0; i < matches_.size(); ++i) |
| 108 matches_[i].relevance = kRelevance + matches_.size() - (i + 1); | 106 matches_[i].relevance = kRelevance + matches_.size() - (i + 1); |
| 109 } | 107 } |
| 110 | 108 |
| 109 BuiltinProvider::~BuiltinProvider() {} |
| 110 |
| 111 void BuiltinProvider::AddMatch(const string16& match_string, | 111 void BuiltinProvider::AddMatch(const string16& match_string, |
| 112 const ACMatchClassifications& styles) { | 112 const ACMatchClassifications& styles) { |
| 113 AutocompleteMatch match(this, kRelevance, false, | 113 AutocompleteMatch match(this, kRelevance, false, |
| 114 AutocompleteMatch::NAVSUGGEST); | 114 AutocompleteMatch::NAVSUGGEST); |
| 115 match.fill_into_edit = match_string; | 115 match.fill_into_edit = match_string; |
| 116 match.destination_url = GURL(match_string); | 116 match.destination_url = GURL(match_string); |
| 117 match.contents = match_string; | 117 match.contents = match_string; |
| 118 match.contents_class = styles; | 118 match.contents_class = styles; |
| 119 matches_.push_back(match); | 119 matches_.push_back(match); |
| 120 } | 120 } |
| OLD | NEW |