[email protected] | a817ed39 | 2014-06-27 05:03:00 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
avi | f57136c1 | 2015-12-25 23:27:45 | [diff] [blame] | 5 | #include <stddef.h> |
| 6 | |
| 7 | #include "base/macros.h" |
[email protected] | a817ed39 | 2014-06-27 05:03:00 | [diff] [blame] | 8 | #include "components/metrics/proto/omnibox_input_type.pb.h" |
blundell | 2102f7c | 2015-07-09 10:00:53 | [diff] [blame] | 9 | #include "components/omnibox/browser/test_scheme_classifier.h" |
[email protected] | a817ed39 | 2014-06-27 05:03:00 | [diff] [blame] | 10 | #include "net/url_request/url_request.h" |
| 11 | #include "url/url_constants.h" |
| 12 | |
| 13 | TestSchemeClassifier::TestSchemeClassifier() {} |
| 14 | |
| 15 | TestSchemeClassifier::~TestSchemeClassifier() {} |
| 16 | |
| 17 | metrics::OmniboxInputType::Type TestSchemeClassifier::GetInputTypeForScheme( |
| 18 | const std::string& scheme) const { |
| 19 | // This doesn't check the preference but check some chrome-ish schemes. |
| 20 | const char* kKnownURLSchemes[] = { |
| 21 | url::kFileScheme, url::kAboutScheme, url::kFtpScheme, url::kBlobScheme, |
| 22 | url::kFileSystemScheme, "view-source", "javascript", "chrome", "chrome-ui", |
| 23 | }; |
| 24 | for (size_t i = 0; i < arraysize(kKnownURLSchemes); ++i) { |
| 25 | if (scheme == kKnownURLSchemes[i]) |
| 26 | return metrics::OmniboxInputType::URL; |
| 27 | } |
| 28 | if (net::URLRequest::IsHandledProtocol(scheme)) |
| 29 | return metrics::OmniboxInputType::URL; |
| 30 | |
| 31 | return metrics::OmniboxInputType::INVALID; |
| 32 | } |