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