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/autocomplete_provider.h" | 5 #include "components/omnibox/autocomplete_provider.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 Profile* profile, | 50 Profile* profile, |
51 const base::string16 match_keyword) | 51 const base::string16 match_keyword) |
52 : AutocompleteProvider(AutocompleteProvider::TYPE_SEARCH), | 52 : AutocompleteProvider(AutocompleteProvider::TYPE_SEARCH), |
53 listener_(NULL), | 53 listener_(NULL), |
54 profile_(profile), | 54 profile_(profile), |
55 relevance_(relevance), | 55 relevance_(relevance), |
56 prefix_(prefix), | 56 prefix_(prefix), |
57 match_keyword_(match_keyword) { | 57 match_keyword_(match_keyword) { |
58 } | 58 } |
59 | 59 |
60 virtual void Start(const AutocompleteInput& input, | 60 void Start(const AutocompleteInput& input, bool minimal_changes) override; |
61 bool minimal_changes) override; | |
62 | 61 |
63 void set_listener(AutocompleteProviderListener* listener) { | 62 void set_listener(AutocompleteProviderListener* listener) { |
64 listener_ = listener; | 63 listener_ = listener; |
65 } | 64 } |
66 | 65 |
67 private: | 66 private: |
68 virtual ~TestProvider() {} | 67 ~TestProvider() override {} |
69 | 68 |
70 void Run(); | 69 void Run(); |
71 | 70 |
72 void AddResults(int start_at, int num); | 71 void AddResults(int start_at, int num); |
73 void AddResultsWithSearchTermsArgs( | 72 void AddResultsWithSearchTermsArgs( |
74 int start_at, | 73 int start_at, |
75 int num, | 74 int num, |
76 AutocompleteMatch::Type type, | 75 AutocompleteMatch::Type type, |
77 const TemplateURLRef::SearchTermsArgs& search_terms_args); | 76 const TemplateURLRef::SearchTermsArgs& search_terms_args); |
78 | 77 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 // Returns match.destination_url as it would be set by | 207 // Returns match.destination_url as it would be set by |
209 // AutocompleteController::UpdateMatchDestinationURL(). | 208 // AutocompleteController::UpdateMatchDestinationURL(). |
210 GURL GetDestinationURL(AutocompleteMatch match, | 209 GURL GetDestinationURL(AutocompleteMatch match, |
211 base::TimeDelta query_formulation_time) const; | 210 base::TimeDelta query_formulation_time) const; |
212 | 211 |
213 AutocompleteResult result_; | 212 AutocompleteResult result_; |
214 scoped_ptr<AutocompleteController> controller_; | 213 scoped_ptr<AutocompleteController> controller_; |
215 | 214 |
216 private: | 215 private: |
217 // content::NotificationObserver: | 216 // content::NotificationObserver: |
218 virtual void Observe(int type, | 217 void Observe(int type, |
219 const content::NotificationSource& source, | 218 const content::NotificationSource& source, |
220 const content::NotificationDetails& details) override; | 219 const content::NotificationDetails& details) override; |
221 | 220 |
222 base::MessageLoopForUI message_loop_; | 221 base::MessageLoopForUI message_loop_; |
223 content::NotificationRegistrar registrar_; | 222 content::NotificationRegistrar registrar_; |
224 TestingProfile profile_; | 223 TestingProfile profile_; |
225 }; | 224 }; |
226 | 225 |
227 void AutocompleteProviderTest::RegisterTemplateURL( | 226 void AutocompleteProviderTest::RegisterTemplateURL( |
228 const base::string16 keyword, | 227 const base::string16 keyword, |
229 const std::string& template_url) { | 228 const std::string& template_url) { |
230 if (TemplateURLServiceFactory::GetForProfile(&profile_) == NULL) { | 229 if (TemplateURLServiceFactory::GetForProfile(&profile_) == NULL) { |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
728 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); | 727 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); |
729 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j0j4&", url.path()); | 728 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j0j4&", url.path()); |
730 | 729 |
731 // Test page classification and field trial triggered set. | 730 // Test page classification and field trial triggered set. |
732 controller_->search_provider_->field_trial_triggered_in_session_ = true; | 731 controller_->search_provider_->field_trial_triggered_in_session_ = true; |
733 EXPECT_TRUE( | 732 EXPECT_TRUE( |
734 controller_->search_provider_->field_trial_triggered_in_session()); | 733 controller_->search_provider_->field_trial_triggered_in_session()); |
735 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); | 734 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); |
736 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j1j4&", url.path()); | 735 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j1j4&", url.path()); |
737 } | 736 } |
OLD | NEW |