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 <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/environment.h" | 13 #include "base/environment.h" |
14 #include "base/guid.h" | 14 #include "base/guid.h" |
15 #include "base/i18n/case_conversion.h" | 15 #include "base/i18n/case_conversion.h" |
16 #include "base/memory/scoped_vector.h" | 16 #include "base/memory/scoped_vector.h" |
17 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
18 #include "base/prefs/pref_service.h" | 18 #include "base/prefs/pref_service.h" |
19 #include "base/stl_util.h" | 19 #include "base/stl_util.h" |
20 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
21 #include "base/strings/string_split.h" | 21 #include "base/strings/string_split.h" |
22 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
23 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" |
24 #include "base/time/time.h" | 24 #include "base/time/time.h" |
| 25 #include "chrome/browser/browser_process.h" |
25 #include "chrome/browser/chrome_notification_types.h" | 26 #include "chrome/browser/chrome_notification_types.h" |
26 #include "chrome/browser/extensions/extension_service.h" | 27 #include "chrome/browser/extensions/extension_service.h" |
27 #include "chrome/browser/google/google_url_tracker_factory.h" | 28 #include "chrome/browser/google/google_url_tracker_factory.h" |
28 #include "chrome/browser/history/history_notifications.h" | 29 #include "chrome/browser/history/history_notifications.h" |
29 #include "chrome/browser/history/history_service.h" | 30 #include "chrome/browser/history/history_service.h" |
30 #include "chrome/browser/history/history_service_factory.h" | 31 #include "chrome/browser/history/history_service_factory.h" |
31 #include "chrome/browser/profiles/profile.h" | 32 #include "chrome/browser/profiles/profile.h" |
32 #include "chrome/browser/rlz/rlz.h" | 33 #include "chrome/browser/rlz/rlz.h" |
33 #include "chrome/browser/search_engines/search_host_to_urls_map.h" | 34 #include "chrome/browser/search_engines/search_host_to_urls_map.h" |
34 #include "chrome/browser/search_engines/search_terms_data.h" | 35 #include "chrome/browser/search_engines/search_terms_data.h" |
35 #include "chrome/browser/search_engines/template_url.h" | 36 #include "chrome/browser/search_engines/template_url.h" |
36 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" | 37 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" |
37 #include "chrome/browser/search_engines/template_url_service_observer.h" | 38 #include "chrome/browser/search_engines/template_url_service_observer.h" |
38 #include "chrome/browser/search_engines/util.h" | 39 #include "chrome/browser/search_engines/util.h" |
39 #include "chrome/browser/webdata/web_data_service.h" | 40 #include "chrome/browser/webdata/web_data_service.h" |
40 #include "chrome/common/chrome_switches.h" | 41 #include "chrome/common/chrome_switches.h" |
41 #include "chrome/common/env_vars.h" | 42 #include "chrome/common/env_vars.h" |
42 #include "chrome/common/extensions/api/omnibox/omnibox_handler.h" | 43 #include "chrome/common/extensions/api/omnibox/omnibox_handler.h" |
43 #include "chrome/common/net/url_fixer_upper.h" | 44 #include "chrome/common/net/url_fixer_upper.h" |
44 #include "chrome/common/pref_names.h" | 45 #include "chrome/common/pref_names.h" |
45 #include "chrome/common/url_constants.h" | 46 #include "chrome/common/url_constants.h" |
| 47 #include "components/rappor/rappor_utils.h" |
46 #include "content/public/browser/notification_service.h" | 48 #include "content/public/browser/notification_service.h" |
47 #include "extensions/common/constants.h" | 49 #include "extensions/common/constants.h" |
48 #include "net/base/net_util.h" | 50 #include "net/base/net_util.h" |
49 #include "sync/api/sync_change.h" | 51 #include "sync/api/sync_change.h" |
50 #include "sync/api/sync_error_factory.h" | 52 #include "sync/api/sync_error_factory.h" |
51 #include "sync/protocol/search_engine_specifics.pb.h" | 53 #include "sync/protocol/search_engine_specifics.pb.h" |
52 #include "sync/protocol/sync.pb.h" | 54 #include "sync/protocol/sync.pb.h" |
53 #include "ui/base/l10n/l10n_util.h" | 55 #include "ui/base/l10n/l10n_util.h" |
54 #include "url/gurl.h" | 56 #include "url/gurl.h" |
55 | 57 |
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
962 UpdateKeywordSearchTermsForURL(visits_to_add_[i]); | 964 UpdateKeywordSearchTermsForURL(visits_to_add_[i]); |
963 visits_to_add_.clear(); | 965 visits_to_add_.clear(); |
964 | 966 |
965 if (new_resource_keyword_version) | 967 if (new_resource_keyword_version) |
966 service_->SetBuiltinKeywordVersion(new_resource_keyword_version); | 968 service_->SetBuiltinKeywordVersion(new_resource_keyword_version); |
967 | 969 |
968 if (default_search_provider_) { | 970 if (default_search_provider_) { |
969 UMA_HISTOGRAM_ENUMERATION("Search.DefaultSearchProviderType", | 971 UMA_HISTOGRAM_ENUMERATION("Search.DefaultSearchProviderType", |
970 TemplateURLPrepopulateData::GetEngineType(*default_search_provider_), | 972 TemplateURLPrepopulateData::GetEngineType(*default_search_provider_), |
971 SEARCH_ENGINE_MAX); | 973 SEARCH_ENGINE_MAX); |
| 974 rappor::SampleETLDp1(g_browser_process->rappor_service(), |
| 975 "Search.DefaultSearchProvider", |
| 976 default_search_provider_->url_ref().GetHost()); |
972 } | 977 } |
973 } | 978 } |
974 | 979 |
975 base::string16 TemplateURLService::GetKeywordShortName( | 980 base::string16 TemplateURLService::GetKeywordShortName( |
976 const base::string16& keyword, | 981 const base::string16& keyword, |
977 bool* is_omnibox_api_extension_keyword) { | 982 bool* is_omnibox_api_extension_keyword) { |
978 const TemplateURL* template_url = GetTemplateURLForKeyword(keyword); | 983 const TemplateURL* template_url = GetTemplateURLForKeyword(keyword); |
979 | 984 |
980 // TODO(sky): Once LocationBarView adds a listener to the TemplateURLService | 985 // TODO(sky): Once LocationBarView adds a listener to the TemplateURLService |
981 // to track changes to the model, this should become a DCHECK. | 986 // to track changes to the model, this should become a DCHECK. |
(...skipping 1543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2525 | 2530 |
2526 if (most_recently_intalled_default) { | 2531 if (most_recently_intalled_default) { |
2527 base::AutoReset<DefaultSearchChangeOrigin> change_origin( | 2532 base::AutoReset<DefaultSearchChangeOrigin> change_origin( |
2528 &dsp_change_origin_, DSP_CHANGE_OVERRIDE_SETTINGS_EXTENSION); | 2533 &dsp_change_origin_, DSP_CHANGE_OVERRIDE_SETTINGS_EXTENSION); |
2529 default_search_manager_.SetExtensionControlledDefaultSearchEngine( | 2534 default_search_manager_.SetExtensionControlledDefaultSearchEngine( |
2530 most_recently_intalled_default->data()); | 2535 most_recently_intalled_default->data()); |
2531 } else { | 2536 } else { |
2532 default_search_manager_.ClearExtensionControlledDefaultSearchEngine(); | 2537 default_search_manager_.ClearExtensionControlledDefaultSearchEngine(); |
2533 } | 2538 } |
2534 } | 2539 } |
OLD | NEW |