Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Unified Diff: chrome/browser/search_engines/template_url_service_test_util.cc

Issue 2639153002: Make extensions DSE persistent in browser prefs (Reland) (Closed)
Patch Set: Minor fix after review, round 7 Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..ea4971a9cd787006dc7731d8a688471cc8853946 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"
@@ -154,3 +155,28 @@ 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;
+ TemplateURL* result = model()->AddExtensionControlledTURL(
+ std::move(extension_turl), std::move(info));
+ if (wants_to_be_default && result) {
+ SetExtensionDefaultSearchInPrefs(profile()->GetTestingPrefService(),
+ result->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);
+}

Powered by Google App Engine
This is Rietveld 408576698