| 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 "chrome/browser/search_engines/template_url_service_test_util.h" | 5 #include "chrome/browser/search_engines/template_url_service_test_util.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop_proxy.h" | 7 #include "base/message_loop/message_loop_proxy.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "chrome/browser/history/history_service_factory.h" | 9 #include "chrome/browser/history/history_service_factory.h" |
| 10 #include "chrome/browser/search_engines/chrome_template_url_service_client.h" | 10 #include "chrome/browser/search_engines/chrome_template_url_service_client.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 search_terms_data_ = NULL; | 107 search_terms_data_ = NULL; |
| 108 } | 108 } |
| 109 | 109 |
| 110 void TemplateURLServiceTestUtil::ResetModel(bool verify_load) { | 110 void TemplateURLServiceTestUtil::ResetModel(bool verify_load) { |
| 111 if (model_) | 111 if (model_) |
| 112 ClearModel(); | 112 ClearModel(); |
| 113 search_terms_data_ = new TestingSearchTermsData("http://www.google.com/"); | 113 search_terms_data_ = new TestingSearchTermsData("http://www.google.com/"); |
| 114 model_.reset(new TemplateURLService( | 114 model_.reset(new TemplateURLService( |
| 115 profile()->GetPrefs(), scoped_ptr<SearchTermsData>(search_terms_data_), | 115 profile()->GetPrefs(), scoped_ptr<SearchTermsData>(search_terms_data_), |
| 116 web_data_service_.get(), | 116 web_data_service_.get(), |
| 117 scoped_ptr<TemplateURLServiceClient>( | 117 scoped_ptr<TemplateURLServiceClient>(new TestingTemplateURLServiceClient( |
| 118 new TestingTemplateURLServiceClient( | 118 HistoryServiceFactory::GetForProfileIfExists( |
| 119 HistoryServiceFactory::GetForProfileIfExists( | 119 profile(), ServiceAccessType::EXPLICIT_ACCESS), |
| 120 profile(), Profile::EXPLICIT_ACCESS), | 120 &search_term_)), |
| 121 &search_term_)), | |
| 122 NULL, NULL, base::Closure())); | 121 NULL, NULL, base::Closure())); |
| 123 model()->AddObserver(this); | 122 model()->AddObserver(this); |
| 124 changed_count_ = 0; | 123 changed_count_ = 0; |
| 125 if (verify_load) | 124 if (verify_load) |
| 126 VerifyLoad(); | 125 VerifyLoad(); |
| 127 } | 126 } |
| 128 | 127 |
| 129 base::string16 TemplateURLServiceTestUtil::GetAndClearSearchTerm() { | 128 base::string16 TemplateURLServiceTestUtil::GetAndClearSearchTerm() { |
| 130 base::string16 search_term; | 129 base::string16 search_term; |
| 131 search_term.swap(search_term_); | 130 search_term.swap(search_term_); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 151 DefaultSearchPrefTestUtil::SetManagedPref( | 150 DefaultSearchPrefTestUtil::SetManagedPref( |
| 152 profile()->GetTestingPrefService(), | 151 profile()->GetTestingPrefService(), |
| 153 enabled, name, keyword, search_url, suggest_url, icon_url, encodings, | 152 enabled, name, keyword, search_url, suggest_url, icon_url, encodings, |
| 154 alternate_url, search_terms_replacement_key); | 153 alternate_url, search_terms_replacement_key); |
| 155 } | 154 } |
| 156 | 155 |
| 157 void TemplateURLServiceTestUtil::RemoveManagedDefaultSearchPreferences() { | 156 void TemplateURLServiceTestUtil::RemoveManagedDefaultSearchPreferences() { |
| 158 DefaultSearchPrefTestUtil::RemoveManagedPref( | 157 DefaultSearchPrefTestUtil::RemoveManagedPref( |
| 159 profile()->GetTestingPrefService()); | 158 profile()->GetTestingPrefService()); |
| 160 } | 159 } |
| OLD | NEW |