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/keyword_provider.h" | 5 #include "components/omnibox/browser/keyword_provider.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
14 #include "base/metrics/field_trial.h" | 14 #include "base/metrics/field_trial.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "components/metrics/proto/omnibox_event.pb.h" | 16 #include "components/metrics/proto/omnibox_event.pb.h" |
17 #include "components/omnibox/browser/autocomplete_match.h" | 17 #include "components/omnibox/browser/autocomplete_match.h" |
18 #include "components/omnibox/browser/autocomplete_scheme_classifier.h" | 18 #include "components/omnibox/browser/autocomplete_scheme_classifier.h" |
19 #include "components/omnibox/browser/mock_autocomplete_provider_client.h" | 19 #include "components/omnibox/browser/mock_autocomplete_provider_client.h" |
20 #include "components/omnibox/browser/omnibox_field_trial.h" | 20 #include "components/omnibox/browser/omnibox_field_trial.h" |
21 #include "components/search_engines/search_engines_switches.h" | 21 #include "components/search_engines/search_engines_switches.h" |
22 #include "components/search_engines/template_url.h" | 22 #include "components/search_engines/template_url.h" |
23 #include "components/search_engines/template_url_service.h" | 23 #include "components/search_engines/template_url_service.h" |
24 #include "components/variations/entropy_provider.h" | 24 #include "components/variations/entropy_provider.h" |
25 #include "components/variations/variations_associated_data.h" | 25 #include "components/variations/variations_associated_data.h" |
26 #include "testing/gmock/include/gmock/gmock.h" | 26 #include "testing/gmock/include/gmock/gmock.h" |
27 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
28 #include "url/gurl.h" | 28 #include "url/gurl.h" |
| 29 #include "url/url_constants.h" |
29 | 30 |
30 using base::ASCIIToUTF16; | 31 using base::ASCIIToUTF16; |
31 | 32 |
32 namespace { | 33 namespace { |
33 | 34 |
34 class TestingSchemeClassifier : public AutocompleteSchemeClassifier { | 35 class TestingSchemeClassifier : public AutocompleteSchemeClassifier { |
35 public: | 36 public: |
36 metrics::OmniboxInputType::Type GetInputTypeForScheme( | 37 metrics::OmniboxInputType::Type GetInputTypeForScheme( |
37 const std::string& scheme) const override { | 38 const std::string& scheme) const override { |
38 if (net::URLRequest::IsHandledProtocol(scheme)) | 39 if (scheme == url::kHttpScheme || scheme == url::kHttpsScheme || |
| 40 scheme == url::kWsScheme || scheme == url::kWssScheme) { |
39 return metrics::OmniboxInputType::URL; | 41 return metrics::OmniboxInputType::URL; |
| 42 } |
40 return metrics::OmniboxInputType::INVALID; | 43 return metrics::OmniboxInputType::INVALID; |
41 } | 44 } |
42 }; | 45 }; |
43 | 46 |
44 } // namespace | 47 } // namespace |
45 | 48 |
46 class KeywordProviderTest : public testing::Test { | 49 class KeywordProviderTest : public testing::Test { |
47 protected: | 50 protected: |
48 template<class ResultType> | 51 template<class ResultType> |
49 struct MatchType { | 52 struct MatchType { |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 | 539 |
537 TEST_F(KeywordProviderTest, DoesNotProvideMatchesOnFocus) { | 540 TEST_F(KeywordProviderTest, DoesNotProvideMatchesOnFocus) { |
538 SetUpClientAndKeywordProvider(); | 541 SetUpClientAndKeywordProvider(); |
539 AutocompleteInput input(ASCIIToUTF16("aaa"), base::string16::npos, | 542 AutocompleteInput input(ASCIIToUTF16("aaa"), base::string16::npos, |
540 std::string(), GURL(), | 543 std::string(), GURL(), |
541 metrics::OmniboxEventProto::INVALID_SPEC, true, false, | 544 metrics::OmniboxEventProto::INVALID_SPEC, true, false, |
542 true, true, true, TestingSchemeClassifier()); | 545 true, true, true, TestingSchemeClassifier()); |
543 kw_provider_->Start(input, false); | 546 kw_provider_->Start(input, false); |
544 ASSERT_TRUE(kw_provider_->matches().empty()); | 547 ASSERT_TRUE(kw_provider_->matches().empty()); |
545 } | 548 } |
OLD | NEW |