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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 (url1->input_encodings() == url2->input_encodings()); | 86 (url1->input_encodings() == url2->input_encodings()); |
87 } | 87 } |
88 | 88 |
89 const char kFirstPotentialEngineHistogramName[] = | 89 const char kFirstPotentialEngineHistogramName[] = |
90 "Search.FirstPotentialEngineCalled"; | 90 "Search.FirstPotentialEngineCalled"; |
91 | 91 |
92 // Values for an enumerated histogram used to track whenever | 92 // Values for an enumerated histogram used to track whenever |
93 // FirstPotentialDefaultEngine is called, and from where. | 93 // FirstPotentialDefaultEngine is called, and from where. |
94 enum FirstPotentialEngineCaller { | 94 enum FirstPotentialEngineCaller { |
95 FIRST_POTENTIAL_CALLSITE_FIND_NEW_DSP, | 95 FIRST_POTENTIAL_CALLSITE_FIND_NEW_DSP, |
| 96 FIRST_POTENTIAL_CALLSITE_FIND_NEW_DSP_PROCESSING_SYNC_CHANGES, |
| 97 FIRST_POTENTIAL_CALLSITE_ON_LOAD, |
96 FIRST_POTENTIAL_CALLSITE_FIND_NEW_DSP_SYNCING, | 98 FIRST_POTENTIAL_CALLSITE_FIND_NEW_DSP_SYNCING, |
97 FIRST_POTENTIAL_CALLSITE_ON_LOAD, | 99 FIRST_POTENTIAL_CALLSITE_FIND_NEW_DSP_NOT_SYNCING, |
98 FIRST_POTENTIAL_CALLSITE_MAX, | 100 FIRST_POTENTIAL_CALLSITE_MAX, |
99 }; | 101 }; |
100 | 102 |
101 TemplateURL* FirstPotentialDefaultEngine( | 103 TemplateURL* FirstPotentialDefaultEngine( |
102 const TemplateURLService::TemplateURLVector& template_urls) { | 104 const TemplateURLService::TemplateURLVector& template_urls) { |
103 for (TemplateURLService::TemplateURLVector::const_iterator i( | 105 for (TemplateURLService::TemplateURLVector::const_iterator i( |
104 template_urls.begin()); i != template_urls.end(); ++i) { | 106 template_urls.begin()); i != template_urls.end(); ++i) { |
105 if ((*i)->ShowInDefaultList()) { | 107 if ((*i)->ShowInDefaultList()) { |
106 DCHECK(!(*i)->IsExtensionKeyword()); | 108 DCHECK(!(*i)->IsExtensionKeyword()); |
107 return *i; | 109 return *i; |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 scoped_ptr<TemplateURL> prepopulated_default( | 607 scoped_ptr<TemplateURL> prepopulated_default( |
606 TemplateURLPrepopulateData::GetPrepopulatedDefaultSearch(profile_)); | 608 TemplateURLPrepopulateData::GetPrepopulatedDefaultSearch(profile_)); |
607 for (TemplateURLVector::iterator i = template_urls_.begin(); | 609 for (TemplateURLVector::iterator i = template_urls_.begin(); |
608 i != template_urls_.end(); ++i) { | 610 i != template_urls_.end(); ++i) { |
609 if ((*i)->prepopulate_id() == prepopulated_default->prepopulate_id()) | 611 if ((*i)->prepopulate_id() == prepopulated_default->prepopulate_id()) |
610 return *i; | 612 return *i; |
611 } | 613 } |
612 // If not, use the first non-extension keyword of the templates that supports | 614 // If not, use the first non-extension keyword of the templates that supports |
613 // search term replacement. | 615 // search term replacement. |
614 if (processing_syncer_changes_) { | 616 if (processing_syncer_changes_) { |
615 UMA_HISTOGRAM_ENUMERATION(kFirstPotentialEngineHistogramName, | 617 UMA_HISTOGRAM_ENUMERATION( |
616 FIRST_POTENTIAL_CALLSITE_FIND_NEW_DSP_SYNCING, | 618 kFirstPotentialEngineHistogramName, |
617 FIRST_POTENTIAL_CALLSITE_MAX); | 619 FIRST_POTENTIAL_CALLSITE_FIND_NEW_DSP_PROCESSING_SYNC_CHANGES, |
| 620 FIRST_POTENTIAL_CALLSITE_MAX); |
618 } else { | 621 } else { |
619 UMA_HISTOGRAM_ENUMERATION(kFirstPotentialEngineHistogramName, | 622 if (sync_processor_.get()) { |
620 FIRST_POTENTIAL_CALLSITE_FIND_NEW_DSP, | 623 // We're not currently in a sync cycle, but we're syncing. |
621 FIRST_POTENTIAL_CALLSITE_MAX); | 624 UMA_HISTOGRAM_ENUMERATION(kFirstPotentialEngineHistogramName, |
| 625 FIRST_POTENTIAL_CALLSITE_FIND_NEW_DSP_SYNCING, |
| 626 FIRST_POTENTIAL_CALLSITE_MAX); |
| 627 } else { |
| 628 // We're not syncing at all. |
| 629 UMA_HISTOGRAM_ENUMERATION( |
| 630 kFirstPotentialEngineHistogramName, |
| 631 FIRST_POTENTIAL_CALLSITE_FIND_NEW_DSP_NOT_SYNCING, |
| 632 FIRST_POTENTIAL_CALLSITE_MAX); |
| 633 } |
622 } | 634 } |
623 return FirstPotentialDefaultEngine(template_urls_); | 635 return FirstPotentialDefaultEngine(template_urls_); |
624 } | 636 } |
625 | 637 |
626 void TemplateURLService::AddObserver(TemplateURLServiceObserver* observer) { | 638 void TemplateURLService::AddObserver(TemplateURLServiceObserver* observer) { |
627 model_observers_.AddObserver(observer); | 639 model_observers_.AddObserver(observer); |
628 } | 640 } |
629 | 641 |
630 void TemplateURLService::RemoveObserver(TemplateURLServiceObserver* observer) { | 642 void TemplateURLService::RemoveObserver(TemplateURLServiceObserver* observer) { |
631 model_observers_.RemoveObserver(observer); | 643 model_observers_.RemoveObserver(observer); |
(...skipping 1841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2473 // TODO(mpcomplete): If we allow editing extension keywords, then those | 2485 // TODO(mpcomplete): If we allow editing extension keywords, then those |
2474 // should be persisted to disk and synced. | 2486 // should be persisted to disk and synced. |
2475 if (template_url->sync_guid().empty() && | 2487 if (template_url->sync_guid().empty() && |
2476 !template_url->IsExtensionKeyword()) { | 2488 !template_url->IsExtensionKeyword()) { |
2477 template_url->data_.sync_guid = base::GenerateGUID(); | 2489 template_url->data_.sync_guid = base::GenerateGUID(); |
2478 if (service_.get()) | 2490 if (service_.get()) |
2479 service_->UpdateKeyword(template_url->data()); | 2491 service_->UpdateKeyword(template_url->data()); |
2480 } | 2492 } |
2481 } | 2493 } |
2482 } | 2494 } |
OLD | NEW |