| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/omnibox/browser/autocomplete_provider.h" | 5 #include "components/omnibox/browser/autocomplete_provider.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "components/omnibox/browser/autocomplete_input.h" | 9 #include "components/omnibox/browser/autocomplete_input.h" |
| 10 #include "components/omnibox/browser/autocomplete_match.h" | 10 #include "components/omnibox/browser/autocomplete_match.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 case TYPE_KEYWORD: | 33 case TYPE_KEYWORD: |
| 34 return "Keyword"; | 34 return "Keyword"; |
| 35 case TYPE_SEARCH: | 35 case TYPE_SEARCH: |
| 36 return "Search"; | 36 return "Search"; |
| 37 case TYPE_SHORTCUTS: | 37 case TYPE_SHORTCUTS: |
| 38 return "Shortcuts"; | 38 return "Shortcuts"; |
| 39 case TYPE_ZERO_SUGGEST: | 39 case TYPE_ZERO_SUGGEST: |
| 40 return "ZeroSuggest"; | 40 return "ZeroSuggest"; |
| 41 case TYPE_CLIPBOARD_URL: | 41 case TYPE_CLIPBOARD_URL: |
| 42 return "ClipboardURL"; | 42 return "ClipboardURL"; |
| 43 case TYPE_PHYSICAL_WEB: |
| 44 return "PhysicalWeb"; |
| 43 default: | 45 default: |
| 44 NOTREACHED() << "Unhandled AutocompleteProvider::Type " << type; | 46 NOTREACHED() << "Unhandled AutocompleteProvider::Type " << type; |
| 45 return "Unknown"; | 47 return "Unknown"; |
| 46 } | 48 } |
| 47 } | 49 } |
| 48 | 50 |
| 49 void AutocompleteProvider::Stop(bool clear_cached_results, | 51 void AutocompleteProvider::Stop(bool clear_cached_results, |
| 50 bool due_to_user_inactivity) { | 52 bool due_to_user_inactivity) { |
| 51 done_ = true; | 53 done_ = true; |
| 52 } | 54 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 69 case TYPE_KEYWORD: | 71 case TYPE_KEYWORD: |
| 70 return metrics::OmniboxEventProto::KEYWORD; | 72 return metrics::OmniboxEventProto::KEYWORD; |
| 71 case TYPE_SEARCH: | 73 case TYPE_SEARCH: |
| 72 return metrics::OmniboxEventProto::SEARCH; | 74 return metrics::OmniboxEventProto::SEARCH; |
| 73 case TYPE_SHORTCUTS: | 75 case TYPE_SHORTCUTS: |
| 74 return metrics::OmniboxEventProto::SHORTCUTS; | 76 return metrics::OmniboxEventProto::SHORTCUTS; |
| 75 case TYPE_ZERO_SUGGEST: | 77 case TYPE_ZERO_SUGGEST: |
| 76 return metrics::OmniboxEventProto::ZERO_SUGGEST; | 78 return metrics::OmniboxEventProto::ZERO_SUGGEST; |
| 77 case TYPE_CLIPBOARD_URL: | 79 case TYPE_CLIPBOARD_URL: |
| 78 return metrics::OmniboxEventProto::CLIPBOARD_URL; | 80 return metrics::OmniboxEventProto::CLIPBOARD_URL; |
| 81 case TYPE_PHYSICAL_WEB: |
| 82 return metrics::OmniboxEventProto::PHYSICAL_WEB; |
| 79 default: | 83 default: |
| 80 NOTREACHED() << "Unhandled AutocompleteProvider::Type " << type_; | 84 NOTREACHED() << "Unhandled AutocompleteProvider::Type " << type_; |
| 81 return metrics::OmniboxEventProto::UNKNOWN_PROVIDER; | 85 return metrics::OmniboxEventProto::UNKNOWN_PROVIDER; |
| 82 } | 86 } |
| 83 } | 87 } |
| 84 | 88 |
| 85 void AutocompleteProvider::DeleteMatch(const AutocompleteMatch& match) { | 89 void AutocompleteProvider::DeleteMatch(const AutocompleteMatch& match) { |
| 86 DLOG(WARNING) << "The AutocompleteProvider '" << GetName() | 90 DLOG(WARNING) << "The AutocompleteProvider '" << GetName() |
| 87 << "' has not implemented DeleteMatch."; | 91 << "' has not implemented DeleteMatch."; |
| 88 } | 92 } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 DCHECK_NE(base::string16::npos, scheme_pos); | 184 DCHECK_NE(base::string16::npos, scheme_pos); |
| 181 | 185 |
| 182 // Erase scheme plus up to two slashes. | 186 // Erase scheme plus up to two slashes. |
| 183 size_t prefix_end = scheme_pos + strlen(url::kHttpScheme) + 1; | 187 size_t prefix_end = scheme_pos + strlen(url::kHttpScheme) + 1; |
| 184 const size_t after_slashes = std::min(url->length(), prefix_end + 2); | 188 const size_t after_slashes = std::min(url->length(), prefix_end + 2); |
| 185 while ((prefix_end < after_slashes) && ((*url)[prefix_end] == '/')) | 189 while ((prefix_end < after_slashes) && ((*url)[prefix_end] == '/')) |
| 186 ++prefix_end; | 190 ++prefix_end; |
| 187 url->erase(scheme_pos, prefix_end - scheme_pos); | 191 url->erase(scheme_pos, prefix_end - scheme_pos); |
| 188 return (scheme_pos == 0) ? prefix_end : 0; | 192 return (scheme_pos == 0) ? prefix_end : 0; |
| 189 } | 193 } |
| OLD | NEW |