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 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1344 data.alternate_urls.push_back(specifics.alternate_urls(i)); | 1344 data.alternate_urls.push_back(specifics.alternate_urls(i)); |
1345 data.search_terms_replacement_key = specifics.search_terms_replacement_key(); | 1345 data.search_terms_replacement_key = specifics.search_terms_replacement_key(); |
1346 | 1346 |
1347 std::unique_ptr<TemplateURL> turl(new TemplateURL(data)); | 1347 std::unique_ptr<TemplateURL> turl(new TemplateURL(data)); |
1348 // If this TemplateURL matches a built-in prepopulated template URL, it's | 1348 // If this TemplateURL matches a built-in prepopulated template URL, it's |
1349 // possible that sync is trying to modify fields that should not be touched. | 1349 // possible that sync is trying to modify fields that should not be touched. |
1350 // Revert these fields to the built-in values. | 1350 // Revert these fields to the built-in values. |
1351 UpdateTemplateURLIfPrepopulated(turl.get(), prefs); | 1351 UpdateTemplateURLIfPrepopulated(turl.get(), prefs); |
1352 | 1352 |
1353 // We used to sync keywords associated with omnibox extensions, but no longer | 1353 // We used to sync keywords associated with omnibox extensions, but no longer |
1354 // want to. However, if we delete these keywords from sync, we'll break any | 1354 // want to. Delete them from the server. |
1355 // synced old versions of Chrome which were relying on them. Instead, for now | 1355 // TODO(vasilii): After a few Chrome versions, delete this code together with |
1356 // we simply ignore these. | 1356 // IsOmniboxExtensionURL(). |
1357 // TODO(vasilii): After a few Chrome versions, change this to go ahead and | |
1358 // delete these from sync. | |
1359 DCHECK(client); | 1357 DCHECK(client); |
1360 client->RestoreExtensionInfoIfNecessary(turl.get()); | 1358 if (client->IsOmniboxExtensionURL(turl->url())) { |
1361 if (turl->type() == TemplateURL::OMNIBOX_API_EXTENSION) | 1359 change_list->push_back( |
| 1360 syncer::SyncChange(FROM_HERE, |
| 1361 syncer::SyncChange::ACTION_DELETE, |
| 1362 sync_data)); |
1362 return nullptr; | 1363 return nullptr; |
| 1364 } |
1363 | 1365 |
1364 DCHECK_EQ(TemplateURL::NORMAL, turl->type()); | 1366 DCHECK_EQ(TemplateURL::NORMAL, turl->type()); |
1365 if (reset_keyword || deduped) { | 1367 if (reset_keyword || deduped) { |
1366 if (reset_keyword) | 1368 if (reset_keyword) |
1367 turl->ResetKeywordIfNecessary(search_terms_data, true); | 1369 turl->ResetKeywordIfNecessary(search_terms_data, true); |
1368 syncer::SyncData sync_data = CreateSyncDataFromTemplateURL(*turl); | 1370 syncer::SyncData sync_data = CreateSyncDataFromTemplateURL(*turl); |
1369 change_list->push_back(syncer::SyncChange(FROM_HERE, | 1371 change_list->push_back(syncer::SyncChange(FROM_HERE, |
1370 syncer::SyncChange::ACTION_UPDATE, | 1372 syncer::SyncChange::ACTION_UPDATE, |
1371 sync_data)); | 1373 sync_data)); |
1372 } else if (turl->IsGoogleSearchURLWithReplaceableKeyword(search_terms_data)) { | 1374 } else if (turl->IsGoogleSearchURLWithReplaceableKeyword(search_terms_data)) { |
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2472 | 2474 |
2473 if (most_recently_intalled_default) { | 2475 if (most_recently_intalled_default) { |
2474 base::AutoReset<DefaultSearchChangeOrigin> change_origin( | 2476 base::AutoReset<DefaultSearchChangeOrigin> change_origin( |
2475 &dsp_change_origin_, DSP_CHANGE_OVERRIDE_SETTINGS_EXTENSION); | 2477 &dsp_change_origin_, DSP_CHANGE_OVERRIDE_SETTINGS_EXTENSION); |
2476 default_search_manager_.SetExtensionControlledDefaultSearchEngine( | 2478 default_search_manager_.SetExtensionControlledDefaultSearchEngine( |
2477 most_recently_intalled_default->data()); | 2479 most_recently_intalled_default->data()); |
2478 } else { | 2480 } else { |
2479 default_search_manager_.ClearExtensionControlledDefaultSearchEngine(); | 2481 default_search_manager_.ClearExtensionControlledDefaultSearchEngine(); |
2480 } | 2482 } |
2481 } | 2483 } |
OLD | NEW |