OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/protector/histograms.h" | 5 #include "chrome/browser/protector/histograms.h" |
6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "chrome/browser/search_engines/search_engine_type.h" |
| 9 #include "chrome/browser/search_engines/template_url.h" |
| 10 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" |
| 11 |
7 namespace protector { | 12 namespace protector { |
8 | 13 |
9 const char kProtectorHistogramDefaultSearchProvider[] = | 14 const char kProtectorHistogramDefaultSearchProvider[] = |
10 "Protector.DefaultSearchProvider"; | 15 "Protector.DefaultSearchProvider"; |
11 | 16 |
12 const char kProtectorBackupInvalidCounter[] = | 17 const char kProtectorBackupInvalidCounter[] = |
13 "Protector.BackupInvalidCounter"; | 18 "Protector.BackupInvalidCounter"; |
14 const char kProtectorValueChangedCounter[] = "Protector.ValueChangedCounter"; | 19 const char kProtectorValueChangedCounter[] = "Protector.ValueChangedCounter"; |
15 const char kProtectorValueValidCounter[] = "Protector.ValueValidCounter"; | 20 const char kProtectorValueValidCounter[] = "Protector.ValueValidCounter"; |
16 | 21 |
| 22 const char kProtectorHistogramNewSearchProvider[] = |
| 23 "Protector.NewSearchProvider"; |
| 24 const char kProtectorHistogramSearchProviderApplied[] = |
| 25 "Protector.SearchProviderApplied"; |
| 26 const char kProtectorHistogramSearchProviderDiscarded[] = |
| 27 "Protector.SearchProviderDiscarded"; |
| 28 const char kProtectorHistogramSearchProviderTimeout[] = |
| 29 "Protector.SearchProviderTimeout"; |
| 30 |
| 31 const int kProtectorMaxSearchProviderID = SEARCH_ENGINE_MAX; |
| 32 |
| 33 int GetSearchProviderHistogramID(const TemplateURL* t_url) { |
| 34 if (t_url && t_url->url()) { |
| 35 scoped_ptr<TemplateURL> prepopulated_url( |
| 36 TemplateURLPrepopulateData::FindPrepopulatedEngine( |
| 37 t_url->url()->url())); |
| 38 if (prepopulated_url.get()) |
| 39 return static_cast<int>(prepopulated_url->search_engine_type()); |
| 40 } |
| 41 // If |t_url| is NULL or not among the prepopulated providers, return |
| 42 // SEARCH_ENGINE_OTHER as well. |
| 43 return SEARCH_ENGINE_OTHER; |
| 44 } |
| 45 |
17 } // namespace protector | 46 } // namespace protector |
OLD | NEW |