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/autocomplete_provider.h" | 5 #include "chrome/browser/autocomplete/autocomplete_provider.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/autocomplete/autocomplete_match.h" | 10 #include "chrome/browser/autocomplete/autocomplete_match.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 type_(type) { | 31 type_(type) { |
32 } | 32 } |
33 | 33 |
34 // static | 34 // static |
35 const char* AutocompleteProvider::TypeToString(Type type) { | 35 const char* AutocompleteProvider::TypeToString(Type type) { |
36 switch (type) { | 36 switch (type) { |
37 case TYPE_BOOKMARK: | 37 case TYPE_BOOKMARK: |
38 return "Bookmark"; | 38 return "Bookmark"; |
39 case TYPE_BUILTIN: | 39 case TYPE_BUILTIN: |
40 return "Builtin"; | 40 return "Builtin"; |
41 case TYPE_CONTACT: | |
42 return "Contact"; | |
43 case TYPE_EXTENSION_APP: | 41 case TYPE_EXTENSION_APP: |
44 return "ExtensionApp"; | 42 return "ExtensionApp"; |
45 case TYPE_HISTORY_QUICK: | 43 case TYPE_HISTORY_QUICK: |
46 return "HistoryQuick"; | 44 return "HistoryQuick"; |
47 case TYPE_HISTORY_URL: | 45 case TYPE_HISTORY_URL: |
48 return "HistoryURL"; | 46 return "HistoryURL"; |
49 case TYPE_KEYWORD: | 47 case TYPE_KEYWORD: |
50 return "Keyword"; | 48 return "Keyword"; |
51 case TYPE_SEARCH: | 49 case TYPE_SEARCH: |
52 return "Search"; | 50 return "Search"; |
(...skipping 15 matching lines...) Expand all Loading... |
68 return TypeToString(type_); | 66 return TypeToString(type_); |
69 } | 67 } |
70 | 68 |
71 metrics::OmniboxEventProto_ProviderType AutocompleteProvider:: | 69 metrics::OmniboxEventProto_ProviderType AutocompleteProvider:: |
72 AsOmniboxEventProviderType() const { | 70 AsOmniboxEventProviderType() const { |
73 switch (type_) { | 71 switch (type_) { |
74 case TYPE_BOOKMARK: | 72 case TYPE_BOOKMARK: |
75 return metrics::OmniboxEventProto::BOOKMARK; | 73 return metrics::OmniboxEventProto::BOOKMARK; |
76 case TYPE_BUILTIN: | 74 case TYPE_BUILTIN: |
77 return metrics::OmniboxEventProto::BUILTIN; | 75 return metrics::OmniboxEventProto::BUILTIN; |
78 case TYPE_CONTACT: | |
79 return metrics::OmniboxEventProto::CONTACT; | |
80 case TYPE_EXTENSION_APP: | 76 case TYPE_EXTENSION_APP: |
81 return metrics::OmniboxEventProto::EXTENSION_APPS; | 77 return metrics::OmniboxEventProto::EXTENSION_APPS; |
82 case TYPE_HISTORY_QUICK: | 78 case TYPE_HISTORY_QUICK: |
83 return metrics::OmniboxEventProto::HISTORY_QUICK; | 79 return metrics::OmniboxEventProto::HISTORY_QUICK; |
84 case TYPE_HISTORY_URL: | 80 case TYPE_HISTORY_URL: |
85 return metrics::OmniboxEventProto::HISTORY_URL; | 81 return metrics::OmniboxEventProto::HISTORY_URL; |
86 case TYPE_KEYWORD: | 82 case TYPE_KEYWORD: |
87 return metrics::OmniboxEventProto::KEYWORD; | 83 return metrics::OmniboxEventProto::KEYWORD; |
88 case TYPE_SEARCH: | 84 case TYPE_SEARCH: |
89 return metrics::OmniboxEventProto::SEARCH; | 85 return metrics::OmniboxEventProto::SEARCH; |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 | 215 |
220 // Erase scheme plus up to two slashes. | 216 // Erase scheme plus up to two slashes. |
221 size_t prefix_end = scheme_pos + strlen(content::kHttpScheme) + 1; | 217 size_t prefix_end = scheme_pos + strlen(content::kHttpScheme) + 1; |
222 const size_t after_slashes = std::min(url->length(), prefix_end + 2); | 218 const size_t after_slashes = std::min(url->length(), prefix_end + 2); |
223 while ((prefix_end < after_slashes) && ((*url)[prefix_end] == '/')) | 219 while ((prefix_end < after_slashes) && ((*url)[prefix_end] == '/')) |
224 ++prefix_end; | 220 ++prefix_end; |
225 url->erase(scheme_pos, prefix_end - scheme_pos); | 221 url->erase(scheme_pos, prefix_end - scheme_pos); |
226 return (scheme_pos == 0) ? prefix_end : 0; | 222 return (scheme_pos == 0) ? prefix_end : 0; |
227 } | 223 } |
228 | 224 |
OLD | NEW |