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 "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" | 5 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" |
6 | 6 |
7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
8 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" | 8 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" |
9 #include "chrome/browser/external_protocol/external_protocol_handler.h" | 9 #include "chrome/browser/external_protocol/external_protocol_handler.h" |
10 #include "chrome/browser/profiles/profile_io_data.h" | 10 #include "chrome/browser/profiles/profile_io_data.h" |
11 #include "content/public/common/url_constants.h" | 11 #include "content/public/common/url_constants.h" |
12 #include "net/base/net_util.h" | 12 #include "net/base/net_util.h" |
13 #include "url/url_util.h" | 13 #include "url/url_util.h" |
14 | 14 |
15 ChromeAutocompleteSchemeClassifier::ChromeAutocompleteSchemeClassifier( | 15 ChromeAutocompleteSchemeClassifier::ChromeAutocompleteSchemeClassifier( |
16 Profile* profile) | 16 Profile* profile) |
17 : profile_(profile) { | 17 : profile_(profile) { |
18 } | 18 } |
19 | 19 |
20 ChromeAutocompleteSchemeClassifier::~ChromeAutocompleteSchemeClassifier() { | 20 ChromeAutocompleteSchemeClassifier::~ChromeAutocompleteSchemeClassifier() { |
21 } | 21 } |
22 | 22 |
23 metrics::OmniboxInputType::Type | 23 metrics::OmniboxInputType::Type |
24 ChromeAutocompleteSchemeClassifier::GetInputTypeForScheme( | 24 ChromeAutocompleteSchemeClassifier::GetInputTypeForScheme( |
25 const std::string& scheme) const { | 25 const std::string& scheme) const { |
26 if (base::IsStringASCII(scheme) && | 26 if (base::IsStringASCII(scheme) && |
27 (ProfileIOData::IsHandledProtocol(scheme) || | 27 (ProfileIOData::IsHandledProtocol(scheme) || |
28 LowerCaseEqualsASCII(scheme, content::kViewSourceScheme) || | 28 base::LowerCaseEqualsASCII(scheme, content::kViewSourceScheme) || |
29 LowerCaseEqualsASCII(scheme, url::kJavaScriptScheme) || | 29 base::LowerCaseEqualsASCII(scheme, url::kJavaScriptScheme) || |
30 LowerCaseEqualsASCII(scheme, url::kDataScheme))) { | 30 base::LowerCaseEqualsASCII(scheme, url::kDataScheme))) { |
31 return metrics::OmniboxInputType::URL; | 31 return metrics::OmniboxInputType::URL; |
32 } | 32 } |
33 | 33 |
34 // Also check for schemes registered via registerProtocolHandler(), which | 34 // Also check for schemes registered via registerProtocolHandler(), which |
35 // can be handled by web pages/apps. | 35 // can be handled by web pages/apps. |
36 ProtocolHandlerRegistry* registry = profile_ ? | 36 ProtocolHandlerRegistry* registry = profile_ ? |
37 ProtocolHandlerRegistryFactory::GetForBrowserContext(profile_) : NULL; | 37 ProtocolHandlerRegistryFactory::GetForBrowserContext(profile_) : NULL; |
38 if (registry && registry->IsHandledProtocol(scheme)) | 38 if (registry && registry->IsHandledProtocol(scheme)) |
39 return metrics::OmniboxInputType::URL; | 39 return metrics::OmniboxInputType::URL; |
40 | 40 |
(...skipping 12 matching lines...) Expand all Loading... |
53 | 53 |
54 case ExternalProtocolHandler::BLOCK: | 54 case ExternalProtocolHandler::BLOCK: |
55 // If we don't want the user to open the URL, don't let it be navigated | 55 // If we don't want the user to open the URL, don't let it be navigated |
56 // to at all. | 56 // to at all. |
57 return metrics::OmniboxInputType::QUERY; | 57 return metrics::OmniboxInputType::QUERY; |
58 | 58 |
59 default: | 59 default: |
60 return metrics::OmniboxInputType::INVALID; | 60 return metrics::OmniboxInputType::INVALID; |
61 } | 61 } |
62 } | 62 } |
OLD | NEW |