Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/search_engines/template_url_service.h" | 5 #include "components/search_engines/template_url_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 1326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1337 data.alternate_urls.push_back(specifics.alternate_urls(i)); | 1337 data.alternate_urls.push_back(specifics.alternate_urls(i)); |
| 1338 data.search_terms_replacement_key = specifics.search_terms_replacement_key(); | 1338 data.search_terms_replacement_key = specifics.search_terms_replacement_key(); |
| 1339 | 1339 |
| 1340 std::unique_ptr<TemplateURL> turl(new TemplateURL(data)); | 1340 std::unique_ptr<TemplateURL> turl(new TemplateURL(data)); |
| 1341 // If this TemplateURL matches a built-in prepopulated template URL, it's | 1341 // If this TemplateURL matches a built-in prepopulated template URL, it's |
| 1342 // possible that sync is trying to modify fields that should not be touched. | 1342 // possible that sync is trying to modify fields that should not be touched. |
| 1343 // Revert these fields to the built-in values. | 1343 // Revert these fields to the built-in values. |
| 1344 UpdateTemplateURLIfPrepopulated(turl.get(), prefs); | 1344 UpdateTemplateURLIfPrepopulated(turl.get(), prefs); |
| 1345 | 1345 |
| 1346 // We used to sync keywords associated with omnibox extensions, but no longer | 1346 // We used to sync keywords associated with omnibox extensions, but no longer |
| 1347 // want to. However, if we delete these keywords from sync, we'll break any | 1347 // want to. Delete them from the server. |
| 1348 // synced old versions of Chrome which were relying on them. Instead, for now | 1348 // TODO(vasilii): After a few Chrome versions, delete this code together with |
| 1349 // we simply ignore these. | 1349 // RestoreExtensionInfoIfNecessary(). |
|
Peter Kasting
2016/09/22 19:01:44
Just to make sure I understand: is RestoreExtensio
vasilii
2016/09/28 10:00:11
Until few days ago there was no |type_| in the Tem
Peter Kasting
2016/09/28 19:34:34
What I'm thinking is, we don't actually need Resto
vasilii
2016/09/29 11:48:06
We could but it's a layering violation. The compon
| |
| 1350 // TODO(vasilii): After a few Chrome versions, change this to go ahead and | |
| 1351 // delete these from sync. | |
| 1352 DCHECK(client); | 1350 DCHECK(client); |
| 1353 client->RestoreExtensionInfoIfNecessary(turl.get()); | 1351 client->RestoreExtensionInfoIfNecessary(turl.get()); |
| 1354 if (turl->GetType() == TemplateURL::OMNIBOX_API_EXTENSION) | 1352 if (turl->GetType() == TemplateURL::OMNIBOX_API_EXTENSION) { |
| 1353 change_list->push_back( | |
| 1354 syncer::SyncChange(FROM_HERE, | |
| 1355 syncer::SyncChange::ACTION_DELETE, | |
| 1356 sync_data)); | |
| 1355 return nullptr; | 1357 return nullptr; |
| 1358 } | |
| 1356 | 1359 |
| 1357 DCHECK_EQ(TemplateURL::NORMAL, turl->GetType()); | 1360 DCHECK_EQ(TemplateURL::NORMAL, turl->GetType()); |
| 1358 if (reset_keyword || deduped) { | 1361 if (reset_keyword || deduped) { |
| 1359 if (reset_keyword) | 1362 if (reset_keyword) |
| 1360 turl->ResetKeywordIfNecessary(search_terms_data, true); | 1363 turl->ResetKeywordIfNecessary(search_terms_data, true); |
| 1361 syncer::SyncData sync_data = CreateSyncDataFromTemplateURL(*turl); | 1364 syncer::SyncData sync_data = CreateSyncDataFromTemplateURL(*turl); |
| 1362 change_list->push_back(syncer::SyncChange(FROM_HERE, | 1365 change_list->push_back(syncer::SyncChange(FROM_HERE, |
| 1363 syncer::SyncChange::ACTION_UPDATE, | 1366 syncer::SyncChange::ACTION_UPDATE, |
| 1364 sync_data)); | 1367 sync_data)); |
| 1365 } else if (turl->IsGoogleSearchURLWithReplaceableKeyword(search_terms_data)) { | 1368 } else if (turl->IsGoogleSearchURLWithReplaceableKeyword(search_terms_data)) { |
| (...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2465 | 2468 |
| 2466 if (most_recently_intalled_default) { | 2469 if (most_recently_intalled_default) { |
| 2467 base::AutoReset<DefaultSearchChangeOrigin> change_origin( | 2470 base::AutoReset<DefaultSearchChangeOrigin> change_origin( |
| 2468 &dsp_change_origin_, DSP_CHANGE_OVERRIDE_SETTINGS_EXTENSION); | 2471 &dsp_change_origin_, DSP_CHANGE_OVERRIDE_SETTINGS_EXTENSION); |
| 2469 default_search_manager_.SetExtensionControlledDefaultSearchEngine( | 2472 default_search_manager_.SetExtensionControlledDefaultSearchEngine( |
| 2470 most_recently_intalled_default->data()); | 2473 most_recently_intalled_default->data()); |
| 2471 } else { | 2474 } else { |
| 2472 default_search_manager_.ClearExtensionControlledDefaultSearchEngine(); | 2475 default_search_manager_.ClearExtensionControlledDefaultSearchEngine(); |
| 2473 } | 2476 } |
| 2474 } | 2477 } |
| OLD | NEW |