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/environment.h" | 9 #include "base/environment.h" |
10 #include "base/guid.h" | 10 #include "base/guid.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 url1->HasSameKeywordAs(*url2) && | 79 url1->HasSameKeywordAs(*url2) && |
80 (url1->url() == url2->url()) && | 80 (url1->url() == url2->url()) && |
81 (url1->suggestions_url() == url2->suggestions_url()) && | 81 (url1->suggestions_url() == url2->suggestions_url()) && |
82 (url1->instant_url() == url2->instant_url()) && | 82 (url1->instant_url() == url2->instant_url()) && |
83 (url1->favicon_url() == url2->favicon_url()) && | 83 (url1->favicon_url() == url2->favicon_url()) && |
84 (url1->safe_for_autoreplace() == url2->safe_for_autoreplace()) && | 84 (url1->safe_for_autoreplace() == url2->safe_for_autoreplace()) && |
85 (url1->show_in_default_list() == url2->show_in_default_list()) && | 85 (url1->show_in_default_list() == url2->show_in_default_list()) && |
86 (url1->input_encodings() == url2->input_encodings()); | 86 (url1->input_encodings() == url2->input_encodings()); |
87 } | 87 } |
88 | 88 |
89 const char kFirstPotentialEngineHistogramName[] = | |
90 "Search.FirstPotentialEngineCalled"; | |
91 | |
92 // Values for an enumerated histogram used to track whenever | |
93 // FirstPotentialDefaultEngine is called, and from where. | |
94 enum FirstPotentialEngineCaller { | |
95 FIRST_POTENTIAL_CALLSITE_FIND_NEW_DSP, | |
96 FIRST_POTENTIAL_CALLSITE_FIND_NEW_DSP_SYNCING, | |
97 FIRST_POTENTIAL_CALLSITE_ON_LOAD, | |
98 FIRST_POTENTIAL_CALLSITE_MAX, | |
99 }; | |
100 | |
89 TemplateURL* FirstPotentialDefaultEngine( | 101 TemplateURL* FirstPotentialDefaultEngine( |
90 const TemplateURLService::TemplateURLVector& template_urls) { | 102 const TemplateURLService::TemplateURLVector& template_urls) { |
91 for (TemplateURLService::TemplateURLVector::const_iterator i( | 103 for (TemplateURLService::TemplateURLVector::const_iterator i( |
92 template_urls.begin()); i != template_urls.end(); ++i) { | 104 template_urls.begin()); i != template_urls.end(); ++i) { |
93 if ((*i)->ShowInDefaultList()) { | 105 if ((*i)->ShowInDefaultList()) { |
94 DCHECK(!(*i)->IsExtensionKeyword()); | 106 DCHECK(!(*i)->IsExtensionKeyword()); |
95 return *i; | 107 return *i; |
96 } | 108 } |
97 } | 109 } |
98 return NULL; | 110 return NULL; |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
592 // See if the prepopulated default still exists. | 604 // See if the prepopulated default still exists. |
593 scoped_ptr<TemplateURL> prepopulated_default( | 605 scoped_ptr<TemplateURL> prepopulated_default( |
594 TemplateURLPrepopulateData::GetPrepopulatedDefaultSearch(profile_)); | 606 TemplateURLPrepopulateData::GetPrepopulatedDefaultSearch(profile_)); |
595 for (TemplateURLVector::iterator i = template_urls_.begin(); | 607 for (TemplateURLVector::iterator i = template_urls_.begin(); |
596 i != template_urls_.end(); ++i) { | 608 i != template_urls_.end(); ++i) { |
597 if ((*i)->prepopulate_id() == prepopulated_default->prepopulate_id()) | 609 if ((*i)->prepopulate_id() == prepopulated_default->prepopulate_id()) |
598 return *i; | 610 return *i; |
599 } | 611 } |
600 // If not, use the first non-extension keyword of the templates that supports | 612 // If not, use the first non-extension keyword of the templates that supports |
601 // search term replacement. | 613 // search term replacement. |
614 if (sync_processor_.get()) { | |
Nicolas Zea
2012/07/09 17:57:41
perhaps check processing_sync_changes_ instead? Th
SteveT
2012/07/09 18:13:38
Ah, yeah, that's the correct thing to do. Done.
| |
615 UMA_HISTOGRAM_ENUMERATION(kFirstPotentialEngineHistogramName, | |
616 FIRST_POTENTIAL_CALLSITE_FIND_NEW_DSP_SYNCING, | |
617 FIRST_POTENTIAL_CALLSITE_MAX); | |
618 } else { | |
619 UMA_HISTOGRAM_ENUMERATION(kFirstPotentialEngineHistogramName, | |
620 FIRST_POTENTIAL_CALLSITE_FIND_NEW_DSP, | |
621 FIRST_POTENTIAL_CALLSITE_MAX); | |
622 } | |
602 return FirstPotentialDefaultEngine(template_urls_); | 623 return FirstPotentialDefaultEngine(template_urls_); |
603 } | 624 } |
604 | 625 |
605 void TemplateURLService::AddObserver(TemplateURLServiceObserver* observer) { | 626 void TemplateURLService::AddObserver(TemplateURLServiceObserver* observer) { |
606 model_observers_.AddObserver(observer); | 627 model_observers_.AddObserver(observer); |
607 } | 628 } |
608 | 629 |
609 void TemplateURLService::RemoveObserver(TemplateURLServiceObserver* observer) { | 630 void TemplateURLService::RemoveObserver(TemplateURLServiceObserver* observer) { |
610 model_observers_.RemoveObserver(observer); | 631 model_observers_.RemoveObserver(observer); |
611 } | 632 } |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
714 } | 735 } |
715 } else { | 736 } else { |
716 // If we had a managed default, replace it with the synced default if | 737 // If we had a managed default, replace it with the synced default if |
717 // applicable, or the first provider of the list. | 738 // applicable, or the first provider of the list. |
718 TemplateURL* synced_default = GetPendingSyncedDefaultSearchProvider(); | 739 TemplateURL* synced_default = GetPendingSyncedDefaultSearchProvider(); |
719 if (synced_default) { | 740 if (synced_default) { |
720 default_search_provider = synced_default; | 741 default_search_provider = synced_default; |
721 pending_synced_default_search_ = false; | 742 pending_synced_default_search_ = false; |
722 } else if (database_specified_a_default && | 743 } else if (database_specified_a_default && |
723 default_search_provider == NULL) { | 744 default_search_provider == NULL) { |
745 UMA_HISTOGRAM_ENUMERATION(kFirstPotentialEngineHistogramName, | |
746 FIRST_POTENTIAL_CALLSITE_ON_LOAD, FIRST_POTENTIAL_CALLSITE_MAX); | |
724 default_search_provider = FirstPotentialDefaultEngine(template_urls); | 747 default_search_provider = FirstPotentialDefaultEngine(template_urls); |
725 } | 748 } |
726 | 749 |
727 // If the default search provider existed previously, then just | 750 // If the default search provider existed previously, then just |
728 // set the member variable. Otherwise, we'll set it using the method | 751 // set the member variable. Otherwise, we'll set it using the method |
729 // to ensure that it is saved properly after its id is set. | 752 // to ensure that it is saved properly after its id is set. |
730 if (default_search_provider && | 753 if (default_search_provider && |
731 (default_search_provider->id() != kInvalidTemplateURLID)) { | 754 (default_search_provider->id() != kInvalidTemplateURLID)) { |
732 default_search_provider_ = default_search_provider; | 755 default_search_provider_ = default_search_provider; |
733 default_search_provider = NULL; | 756 default_search_provider = NULL; |
(...skipping 1671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2405 // TODO(mpcomplete): If we allow editing extension keywords, then those | 2428 // TODO(mpcomplete): If we allow editing extension keywords, then those |
2406 // should be persisted to disk and synced. | 2429 // should be persisted to disk and synced. |
2407 if (template_url->sync_guid().empty() && | 2430 if (template_url->sync_guid().empty() && |
2408 !template_url->IsExtensionKeyword()) { | 2431 !template_url->IsExtensionKeyword()) { |
2409 template_url->data_.sync_guid = base::GenerateGUID(); | 2432 template_url->data_.sync_guid = base::GenerateGUID(); |
2410 if (service_.get()) | 2433 if (service_.get()) |
2411 service_->UpdateKeyword(template_url->data()); | 2434 service_->UpdateKeyword(template_url->data()); |
2412 } | 2435 } |
2413 } | 2436 } |
2414 } | 2437 } |
OLD | NEW |