Index: chrome/browser/search_engines/template_url_service_test_util.cc |
diff --git a/chrome/browser/search_engines/template_url_service_test_util.cc b/chrome/browser/search_engines/template_url_service_test_util.cc |
index 74b8b613f65c8122d546ef857a553a69aa90aeee..168fc10a22fb0f06ca438cec6c9b34eb859dcdf8 100644 |
--- a/chrome/browser/search_engines/template_url_service_test_util.cc |
+++ b/chrome/browser/search_engines/template_url_service_test_util.cc |
@@ -12,6 +12,7 @@ |
#include "chrome/test/base/testing_profile.h" |
#include "components/search_engines/keyword_table.h" |
#include "components/search_engines/keyword_web_data_service.h" |
+#include "components/search_engines/search_engines_test_util.h" |
#include "components/search_engines/template_url_data_util.h" |
#include "components/search_engines/template_url_service.h" |
#include "components/search_engines/testing_search_terms_data.h" |
@@ -127,6 +128,7 @@ void TemplateURLServiceTestUtil::ResetModel(bool verify_load) { |
if (model_) |
ClearModel(); |
search_terms_data_ = new TestingSearchTermsData("http://www.google.com/"); |
+ |
Peter Kasting
2017/01/06 01:44:57
Nit: Not sure why this blank line here
Alexander Yashkin
2017/01/07 12:55:59
Removed.
|
model_.reset(new TemplateURLService( |
profile()->GetPrefs(), |
std::unique_ptr<SearchTermsData>(search_terms_data_), |
@@ -154,3 +156,29 @@ void TemplateURLServiceTestUtil::SetGoogleBaseURL(const GURL& base_url) { |
search_terms_data_->set_google_base_url(base_url.spec()); |
model_->GoogleBaseURLChanged(); |
} |
+ |
+TemplateURL* TemplateURLServiceTestUtil::AddExtensionControlledTURL( |
+ std::unique_ptr<TemplateURL> extension_turl, |
+ std::unique_ptr<TemplateURL::AssociatedExtensionInfo> info) { |
+ bool wants_to_be_default = info->wants_to_be_default_engine; |
+ TemplateURLData extension_data = extension_turl->data(); |
Peter Kasting
2017/01/06 01:44:57
Nit: Why copy this off instead of using result->da
Alexander Yashkin
2017/01/07 12:55:59
Thanks, fixed.
|
+ TemplateURL* result = model()->AddExtensionControlledTURL( |
+ std::move(extension_turl), std::move(info)); |
+ if (wants_to_be_default) { |
Peter Kasting
2017/01/06 01:44:57
Should this check |result| too? Seems like yes, u
Alexander Yashkin
2017/01/07 12:55:59
Added check.
|
+ SetExtensionDefaultSearchInPrefs(profile()->GetTestingPrefService(), |
+ extension_data); |
+ } |
+ return result; |
+} |
+ |
+void TemplateURLServiceTestUtil::RemoveExtensionControlledTURL( |
+ const std::string& extension_id) { |
+ TemplateURL* turl = model()->FindTemplateURLForExtension( |
+ extension_id, TemplateURL::NORMAL_CONTROLLED_BY_EXTENSION); |
+ ASSERT_TRUE(turl); |
+ ASSERT_TRUE(turl->GetExtensionInfoForTesting()); |
+ if (turl->GetExtensionInfoForTesting()->wants_to_be_default_engine) |
+ RemoveExtensionDefaultSearchFromPrefs(profile()->GetTestingPrefService()); |
+ model()->RemoveExtensionControlledTURL( |
+ extension_id, TemplateURL::NORMAL_CONTROLLED_BY_EXTENSION); |
+} |