OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/search_engines/template_url_service.h" | 5 #include "chrome/browser/search_engines/template_url_service.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/environment.h" | 10 #include "base/environment.h" |
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
749 // Note that this saves the default search provider to prefs. | 749 // Note that this saves the default search provider to prefs. |
750 if (!default_search_provider || | 750 if (!default_search_provider || |
751 (!default_search_provider->IsExtensionKeyword() && | 751 (!default_search_provider->IsExtensionKeyword() && |
752 default_search_provider->SupportsReplacement())) { | 752 default_search_provider->SupportsReplacement())) { |
753 bool success = SetDefaultSearchProviderNoNotify(default_search_provider); | 753 bool success = SetDefaultSearchProviderNoNotify(default_search_provider); |
754 DCHECK(success); | 754 DCHECK(success); |
755 } | 755 } |
756 } else { | 756 } else { |
757 // If we had a managed default, replace it with the synced default if | 757 // If we had a managed default, replace it with the synced default if |
758 // applicable, or the first provider of the list. | 758 // applicable, or the first provider of the list. |
759 TemplateURL* synced_default = GetPendingSyncedDefaultSearchProvider(); | 759 TemplateURL* synced_default = GetPendingSyncedDefaultSearchProvider(); |
Nicolas Zea
2012/08/15 21:46:28
Doesn't this logic handle the case this patch addr
SteveT
2012/08/15 21:56:57
This doesn't seem to do the trick for the case whe
Nicolas Zea
2012/08/15 22:26:03
Huh, I thought it ran on all webdb requests, but o
SteveT
2012/08/16 19:50:53
Ah sorry, you are right - OnWebDataServiceRequestD
| |
760 if (synced_default) { | 760 if (synced_default) { |
761 default_search_provider = synced_default; | 761 default_search_provider = synced_default; |
762 pending_synced_default_search_ = false; | 762 pending_synced_default_search_ = false; |
763 } else if (database_specified_a_default && | 763 } else if (database_specified_a_default && |
764 default_search_provider == NULL) { | 764 default_search_provider == NULL) { |
765 UMA_HISTOGRAM_ENUMERATION(kFirstPotentialEngineHistogramName, | 765 UMA_HISTOGRAM_ENUMERATION(kFirstPotentialEngineHistogramName, |
766 FIRST_POTENTIAL_CALLSITE_ON_LOAD, FIRST_POTENTIAL_CALLSITE_MAX); | 766 FIRST_POTENTIAL_CALLSITE_ON_LOAD, FIRST_POTENTIAL_CALLSITE_MAX); |
767 default_search_provider = FirstPotentialDefaultEngine(template_urls); | 767 default_search_provider = FirstPotentialDefaultEngine(template_urls); |
768 } | 768 } |
769 | 769 |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1084 | 1084 |
1085 // We just started syncing, so set our wait-for-default flag if we are | 1085 // We just started syncing, so set our wait-for-default flag if we are |
1086 // expecting a default from Sync. | 1086 // expecting a default from Sync. |
1087 if (GetPrefs()) { | 1087 if (GetPrefs()) { |
1088 std::string default_guid = GetPrefs()->GetString( | 1088 std::string default_guid = GetPrefs()->GetString( |
1089 prefs::kSyncedDefaultSearchProviderGUID); | 1089 prefs::kSyncedDefaultSearchProviderGUID); |
1090 const TemplateURL* current_default = GetDefaultSearchProvider(); | 1090 const TemplateURL* current_default = GetDefaultSearchProvider(); |
1091 | 1091 |
1092 if (!default_guid.empty() && | 1092 if (!default_guid.empty() && |
1093 (!current_default || current_default->sync_guid() != default_guid)) | 1093 (!current_default || current_default->sync_guid() != default_guid)) |
1094 pending_synced_default_search_ = true; | 1094 pending_synced_default_search_ = true; |
Nicolas Zea
2012/08/15 21:46:28
we should be hitting this logic right?
SteveT
2012/08/15 21:56:57
We should be, but the real problem is that there i
| |
1095 } | 1095 } |
1096 | 1096 |
1097 // We do a lot of calls to Add/Remove/ResetTemplateURL here, so ensure we | 1097 // We do a lot of calls to Add/Remove/ResetTemplateURL here, so ensure we |
1098 // don't step on our own toes. | 1098 // don't step on our own toes. |
1099 AutoReset<bool> processing_changes(&processing_syncer_changes_, true); | 1099 AutoReset<bool> processing_changes(&processing_syncer_changes_, true); |
1100 | 1100 |
1101 // We've started syncing, so set our origin member to the base Sync value. | 1101 // We've started syncing, so set our origin member to the base Sync value. |
1102 // As we move through Sync Code, we may set this to increasingly specific | 1102 // As we move through Sync Code, we may set this to increasingly specific |
1103 // origins so we can tell what exactly caused a DSP change. | 1103 // origins so we can tell what exactly caused a DSP change. |
1104 AutoReset<DefaultSearchChangeOrigin> change_origin(&dsp_change_origin_, | 1104 AutoReset<DefaultSearchChangeOrigin> change_origin(&dsp_change_origin_, |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1148 NotifyObservers(); | 1148 NotifyObservers(); |
1149 } else if (sync_turl->last_modified() < local_turl->last_modified()) { | 1149 } else if (sync_turl->last_modified() < local_turl->last_modified()) { |
1150 // Otherwise, we know we have newer data, so update Sync with our | 1150 // Otherwise, we know we have newer data, so update Sync with our |
1151 // data fields. | 1151 // data fields. |
1152 new_changes.push_back( | 1152 new_changes.push_back( |
1153 syncer::SyncChange(FROM_HERE, | 1153 syncer::SyncChange(FROM_HERE, |
1154 syncer::SyncChange::ACTION_UPDATE, | 1154 syncer::SyncChange::ACTION_UPDATE, |
1155 local_data_map[local_turl->sync_guid()])); | 1155 local_data_map[local_turl->sync_guid()])); |
1156 } | 1156 } |
1157 local_data_map.erase(iter->first); | 1157 local_data_map.erase(iter->first); |
1158 | |
1159 // Attempt to reset the default search provider incase it was changed | |
Nicolas Zea
2012/08/15 21:46:28
incase -> in case
SteveT
2012/08/15 21:56:57
Done.
| |
1160 // since the last time search engines was synced. | |
1161 SetDefaultSearchProviderIfNewlySynced(local_turl->sync_guid()); | |
Nicolas Zea
2012/08/15 22:26:03
Would moving this to the end of MergeData and call
SteveT
2012/08/16 19:50:53
That makes a lot of sense for MergeDataAndStartSyn
| |
1158 } else { | 1162 } else { |
1159 // The search engine from the cloud has not been synced locally. Merge it | 1163 // The search engine from the cloud has not been synced locally. Merge it |
1160 // into our local model. This will handle any conflicts with local (and | 1164 // into our local model. This will handle any conflicts with local (and |
1161 // already-synced) TemplateURLs. It will prefer to keep entries from Sync | 1165 // already-synced) TemplateURLs. It will prefer to keep entries from Sync |
1162 // over not-yet-synced TemplateURLs. | 1166 // over not-yet-synced TemplateURLs. |
1163 MergeInSyncTemplateURL(sync_turl.get(), sync_data_map, &new_changes, | 1167 MergeInSyncTemplateURL(sync_turl.get(), sync_data_map, &new_changes, |
1164 &local_data_map); | 1168 &local_data_map); |
1165 } | 1169 } |
1166 } | 1170 } |
1167 | 1171 |
(...skipping 1305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2473 // TODO(mpcomplete): If we allow editing extension keywords, then those | 2477 // TODO(mpcomplete): If we allow editing extension keywords, then those |
2474 // should be persisted to disk and synced. | 2478 // should be persisted to disk and synced. |
2475 if (template_url->sync_guid().empty() && | 2479 if (template_url->sync_guid().empty() && |
2476 !template_url->IsExtensionKeyword()) { | 2480 !template_url->IsExtensionKeyword()) { |
2477 template_url->data_.sync_guid = base::GenerateGUID(); | 2481 template_url->data_.sync_guid = base::GenerateGUID(); |
2478 if (service_.get()) | 2482 if (service_.get()) |
2479 service_->UpdateKeyword(template_url->data()); | 2483 service_->UpdateKeyword(template_url->data()); |
2480 } | 2484 } |
2481 } | 2485 } |
2482 } | 2486 } |
OLD | NEW |