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

Unified Diff: chrome/browser/protector/default_search_provider_change_browsertest.cc

Issue 9982018: Move most TemplateURL data members to a new struct, TemplateURLData. This allows us to eliminate t… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 8 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/protector/default_search_provider_change_browsertest.cc
===================================================================
--- chrome/browser/protector/default_search_provider_change_browsertest.cc (revision 130759)
+++ chrome/browser/protector/default_search_provider_change_browsertest.cc (working copy)
@@ -40,6 +40,20 @@
const string16 example_net = ASCIIToUTF16("Example.net");
const std::string http_example_net = "http://example.net/%s";
+// Convenience function.
+TemplateURL* MakeTemplateURL(const string16& short_name,
+ const string16& keyword,
+ const std::string& url) {
+ TemplateURLData data;
+ data.short_name = short_name;
+ if (keyword.empty())
+ data.SetAutogenerateKeyword(true);
+ else
+ data.SetKeyword(keyword);
+ data.SetURL(url);
+ return new TemplateURL(data);
+}
+
};
class DefaultSearchProviderChangeTest : public InProcessBrowserTest {
@@ -61,19 +75,6 @@
EXPECT_CALL(*mock_protector_service_, Shutdown());
}
- TemplateURL* MakeTemplateURL(const string16& short_name,
- const string16& keyword,
- const std::string& search_url) {
- TemplateURL* url = new TemplateURL;
- url->set_short_name(short_name);
- if (keyword.empty())
- url->set_autogenerate_keyword(true);
- else
- url->set_keyword(keyword);
- url->SetURL(search_url);
- return url;
- }
-
const TemplateURL* FindTemplateURL(const std::string& search_url) {
TemplateURLService::TemplateURLVector urls =
turl_service_->GetTemplateURLs();
@@ -85,12 +86,6 @@
return NULL;
}
- // Adds a copy of |turl| that will be owned by TemplateURLService.
- void AddCopy(TemplateURL* turl) {
- TemplateURL* turl_copy = new TemplateURL(*turl);
- turl_service_->Add(turl_copy);
- }
-
void AddAndSetDefault(TemplateURL* turl) {
turl_service_->Add(turl);
turl_service_->SetDefaultSearchProvider(turl);
@@ -158,7 +153,7 @@
int current_histogram_id =
protector::GetSearchProviderHistogramID(current_url);
- AddCopy(backup_url);
+ turl_service_->Add(new TemplateURL(backup_url->data()));
AddAndSetDefault(current_url);
scoped_ptr<BaseSettingChange> change(
@@ -211,7 +206,7 @@
{
// Backup name too long.
- AddCopy(backup_url_long);
+ turl_service_->Add(new TemplateURL(backup_url_long->data()));
AddAndSetDefault(current_url);
scoped_ptr<BaseSettingChange> change(
@@ -228,7 +223,7 @@
{
// Current name too long.
- AddCopy(backup_url);
+ turl_service_->Add(new TemplateURL(backup_url->data()));
AddAndSetDefault(current_url_long);
scoped_ptr<BaseSettingChange> change(
@@ -360,7 +355,7 @@
MakeTemplateURL(example_info, ASCIIToUTF16("a"), http_example_info);
int backup_histogram_id = protector::GetSearchProviderHistogramID(backup_url);
- AddCopy(backup_url);
+ turl_service_->Add(new TemplateURL(backup_url->data()));
turl_service_->SetDefaultSearchProvider(NULL);
scoped_ptr<BaseSettingChange> change(
@@ -486,7 +481,7 @@
TemplateURL* new_url =
MakeTemplateURL(example_net, ASCIIToUTF16("c"), http_example_net);
- AddCopy(backup_url);
+ turl_service_->Add(new TemplateURL(backup_url->data()));
AddAndSetDefault(current_url);
scoped_ptr<BaseSettingChange> change(
@@ -512,7 +507,7 @@
TemplateURL* current_url =
MakeTemplateURL(example_com, ASCIIToUTF16("b"), http_example_com);
- AddCopy(backup_url);
+ turl_service_->Add(new TemplateURL(backup_url->data()));
AddAndSetDefault(current_url);
scoped_ptr<BaseSettingChange> change(
« no previous file with comments | « chrome/browser/policy/configuration_policy_handler.cc ('k') | chrome/browser/search_engines/search_host_to_urls_map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698