| 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 "components/omnibox/browser/autocomplete_classifier.h" | 5 #include "components/omnibox/browser/autocomplete_classifier.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/feature_list.h" |
| 10 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 11 #include "components/metrics/proto/omnibox_event.pb.h" | 12 #include "components/metrics/proto/omnibox_event.pb.h" |
| 12 #include "components/omnibox/browser/autocomplete_controller.h" | 13 #include "components/omnibox/browser/autocomplete_controller.h" |
| 13 #include "components/omnibox/browser/autocomplete_input.h" | 14 #include "components/omnibox/browser/autocomplete_input.h" |
| 14 #include "components/omnibox/browser/autocomplete_match.h" | 15 #include "components/omnibox/browser/autocomplete_match.h" |
| 15 #include "components/omnibox/browser/autocomplete_provider.h" | 16 #include "components/omnibox/browser/autocomplete_provider.h" |
| 17 #include "components/omnibox/browser/omnibox_field_trial.h" |
| 16 #include "url/gurl.h" | 18 #include "url/gurl.h" |
| 17 | 19 |
| 18 // static | 20 // static |
| 19 const int AutocompleteClassifier::kDefaultOmniboxProviders = | 21 int AutocompleteClassifier::DefaultOmniboxProviders() { |
| 22 return |
| 20 #if defined(OS_ANDROID) || defined(OS_IOS) | 23 #if defined(OS_ANDROID) || defined(OS_IOS) |
| 21 // The Physical Web currently is only implemented on mobile devices. | 24 // The Physical Web currently is only implemented on mobile devices. |
| 22 AutocompleteProvider::TYPE_PHYSICAL_WEB | | 25 AutocompleteProvider::TYPE_PHYSICAL_WEB | |
| 23 #else | 26 #else |
| 24 // Custom search engines cannot be used on mobile. | 27 // Custom search engines cannot be used on mobile. |
| 25 AutocompleteProvider::TYPE_KEYWORD | | 28 AutocompleteProvider::TYPE_KEYWORD | |
| 26 #endif | 29 #endif |
| 27 #if !defined(OS_IOS) | 30 #if !defined(OS_IOS) |
| 28 // "Builtin", "Shortcuts" and "Zero Suggest" are not supported on iOS. | 31 // "Builtin", "Shortcuts" and "Zero Suggest" are not supported on iOS. |
| 29 AutocompleteProvider::TYPE_BUILTIN | | 32 AutocompleteProvider::TYPE_BUILTIN | |
| 30 AutocompleteProvider::TYPE_SHORTCUTS | | 33 AutocompleteProvider::TYPE_SHORTCUTS | |
| 31 AutocompleteProvider::TYPE_ZERO_SUGGEST | | 34 AutocompleteProvider::TYPE_ZERO_SUGGEST | |
| 32 #else | |
| 33 // "URL from clipboard" can only be used on iOS. | |
| 34 AutocompleteProvider::TYPE_CLIPBOARD_URL | | |
| 35 #endif | 35 #endif |
| 36 AutocompleteProvider::TYPE_BOOKMARK | | 36 (base::FeatureList::IsEnabled(omnibox::kEnableClipboardProvider) |
| 37 AutocompleteProvider::TYPE_HISTORY_QUICK | | 37 ? AutocompleteProvider::TYPE_CLIPBOARD_URL |
| 38 AutocompleteProvider::TYPE_HISTORY_URL | | 38 : 0) | |
| 39 AutocompleteProvider::TYPE_SEARCH; | 39 AutocompleteProvider::TYPE_BOOKMARK | |
| 40 AutocompleteProvider::TYPE_HISTORY_QUICK | |
| 41 AutocompleteProvider::TYPE_HISTORY_URL | |
| 42 AutocompleteProvider::TYPE_SEARCH; |
| 43 } |
| 40 | 44 |
| 41 AutocompleteClassifier::AutocompleteClassifier( | 45 AutocompleteClassifier::AutocompleteClassifier( |
| 42 std::unique_ptr<AutocompleteController> controller, | 46 std::unique_ptr<AutocompleteController> controller, |
| 43 std::unique_ptr<AutocompleteSchemeClassifier> scheme_classifier) | 47 std::unique_ptr<AutocompleteSchemeClassifier> scheme_classifier) |
| 44 : controller_(std::move(controller)), | 48 : controller_(std::move(controller)), |
| 45 scheme_classifier_(std::move(scheme_classifier)), | 49 scheme_classifier_(std::move(scheme_classifier)), |
| 46 inside_classify_(false) {} | 50 inside_classify_(false) {} |
| 47 | 51 |
| 48 AutocompleteClassifier::~AutocompleteClassifier() { | 52 AutocompleteClassifier::~AutocompleteClassifier() { |
| 49 // We should only reach here after Shutdown() has been called. | 53 // We should only reach here after Shutdown() has been called. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 73 if (alternate_nav_url) | 77 if (alternate_nav_url) |
| 74 *alternate_nav_url = GURL(); | 78 *alternate_nav_url = GURL(); |
| 75 return; | 79 return; |
| 76 } | 80 } |
| 77 | 81 |
| 78 DCHECK(result.default_match() != result.end()); | 82 DCHECK(result.default_match() != result.end()); |
| 79 *match = *result.default_match(); | 83 *match = *result.default_match(); |
| 80 if (alternate_nav_url) | 84 if (alternate_nav_url) |
| 81 *alternate_nav_url = result.alternate_nav_url(); | 85 *alternate_nav_url = result.alternate_nav_url(); |
| 82 } | 86 } |
| OLD | NEW |