Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: chrome/browser/search_engines/template_url_service.cc

Issue 366523002: Stop depending on chrome/browser/rlz/rlz.h from TemplateURLService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix comment Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/guid.h" 13 #include "base/guid.h"
14 #include "base/i18n/case_conversion.h" 14 #include "base/i18n/case_conversion.h"
15 #include "base/memory/scoped_vector.h" 15 #include "base/memory/scoped_vector.h"
16 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
17 #include "base/prefs/pref_service.h" 17 #include "base/prefs/pref_service.h"
18 #include "base/stl_util.h" 18 #include "base/stl_util.h"
19 #include "base/strings/string_number_conversions.h" 19 #include "base/strings/string_number_conversions.h"
20 #include "base/strings/string_split.h" 20 #include "base/strings/string_split.h"
21 #include "base/strings/string_util.h" 21 #include "base/strings/string_util.h"
22 #include "base/strings/utf_string_conversions.h" 22 #include "base/strings/utf_string_conversions.h"
23 #include "base/time/time.h" 23 #include "base/time/time.h"
24 #include "chrome/browser/chrome_notification_types.h" 24 #include "chrome/browser/chrome_notification_types.h"
25 #include "chrome/browser/google/google_url_tracker_factory.h" 25 #include "chrome/browser/google/google_url_tracker_factory.h"
26 #include "chrome/browser/history/history_service.h" 26 #include "chrome/browser/history/history_service.h"
27 #include "chrome/browser/history/history_service_factory.h" 27 #include "chrome/browser/history/history_service_factory.h"
28 #include "chrome/browser/profiles/profile.h" 28 #include "chrome/browser/profiles/profile.h"
29 #include "chrome/browser/rlz/rlz.h"
30 #include "chrome/browser/search_engines/search_host_to_urls_map.h" 29 #include "chrome/browser/search_engines/search_host_to_urls_map.h"
31 #include "chrome/browser/search_engines/template_url_service_observer.h" 30 #include "chrome/browser/search_engines/template_url_service_observer.h"
32 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" 31 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h"
33 #include "chrome/browser/search_engines/util.h" 32 #include "chrome/browser/search_engines/util.h"
34 #include "chrome/browser/webdata/web_data_service.h" 33 #include "chrome/browser/webdata/web_data_service.h"
35 #include "components/rappor/rappor_service.h" 34 #include "components/rappor/rappor_service.h"
36 #include "components/search_engines/search_engines_pref_names.h" 35 #include "components/search_engines/search_engines_pref_names.h"
37 #include "components/search_engines/template_url.h" 36 #include "components/search_engines/template_url.h"
38 #include "components/search_engines/template_url_prepopulate_data.h" 37 #include "components/search_engines/template_url_prepopulate_data.h"
39 #include "components/url_fixer/url_fixer.h" 38 #include "components/url_fixer/url_fixer.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 return (elem1.second == NULL) ? 179 return (elem1.second == NULL) ?
181 (elem2.first.compare(0, elem1.first.length(), elem1.first) > 0) : 180 (elem2.first.compare(0, elem1.first.length(), elem1.first) > 0) :
182 (elem1.first < elem2.first); 181 (elem1.first < elem2.first);
183 } 182 }
184 }; 183 };
185 184
186 185
187 // TemplateURLService --------------------------------------------------------- 186 // TemplateURLService ---------------------------------------------------------
188 187
189 TemplateURLService::TemplateURLService(Profile* profile, 188 TemplateURLService::TemplateURLService(Profile* profile,
190 rappor::RapporService* rappor_service) 189 rappor::RapporService* rappor_service,
190 const base::Closure& dsp_change_callback)
191 : provider_map_(new SearchHostToURLsMap), 191 : provider_map_(new SearchHostToURLsMap),
192 profile_(profile), 192 profile_(profile),
193 prefs_(profile ? profile->GetPrefs() : NULL), 193 prefs_(profile ? profile->GetPrefs() : NULL),
194 rappor_service_(rappor_service), 194 rappor_service_(rappor_service),
195 search_terms_data_(new UIThreadSearchTermsData(profile)), 195 search_terms_data_(new UIThreadSearchTermsData(profile)),
196 dsp_change_callback_(dsp_change_callback),
196 loaded_(false), 197 loaded_(false),
197 load_failed_(false), 198 load_failed_(false),
198 load_handle_(0), 199 load_handle_(0),
199 default_search_provider_(NULL), 200 default_search_provider_(NULL),
200 next_id_(kInvalidTemplateURLID + 1), 201 next_id_(kInvalidTemplateURLID + 1),
201 time_provider_(&base::Time::Now), 202 time_provider_(&base::Time::Now),
202 models_associated_(false), 203 models_associated_(false),
203 processing_syncer_changes_(false), 204 processing_syncer_changes_(false),
204 dsp_change_origin_(DSP_CHANGE_OTHER), 205 dsp_change_origin_(DSP_CHANGE_OTHER),
205 default_search_manager_( 206 default_search_manager_(
(...skipping 1649 matching lines...) Expand 10 before | Expand all | Expand 10 after
1855 void TemplateURLService::ApplyDefaultSearchChange( 1856 void TemplateURLService::ApplyDefaultSearchChange(
1856 const TemplateURLData* data, 1857 const TemplateURLData* data,
1857 DefaultSearchManager::Source source) { 1858 DefaultSearchManager::Source source) {
1858 if (!ApplyDefaultSearchChangeNoMetrics(data, source)) 1859 if (!ApplyDefaultSearchChangeNoMetrics(data, source))
1859 return; 1860 return;
1860 1861
1861 UMA_HISTOGRAM_ENUMERATION( 1862 UMA_HISTOGRAM_ENUMERATION(
1862 "Search.DefaultSearchChangeOrigin", dsp_change_origin_, DSP_CHANGE_MAX); 1863 "Search.DefaultSearchChangeOrigin", dsp_change_origin_, DSP_CHANGE_MAX);
1863 1864
1864 if (GetDefaultSearchProvider() && 1865 if (GetDefaultSearchProvider() &&
1865 GetDefaultSearchProvider()->HasGoogleBaseURLs(search_terms_data())) { 1866 GetDefaultSearchProvider()->HasGoogleBaseURLs(search_terms_data()) &&
1866 #if defined(ENABLE_RLZ) 1867 !dsp_change_callback_.is_null())
1867 RLZTracker::RecordProductEvent( 1868 dsp_change_callback_.Run();
1868 rlz_lib::CHROME, RLZTracker::ChromeOmnibox(), rlz_lib::SET_TO_GOOGLE);
1869 #endif
1870 }
1871 } 1869 }
1872 1870
1873 bool TemplateURLService::ApplyDefaultSearchChangeNoMetrics( 1871 bool TemplateURLService::ApplyDefaultSearchChangeNoMetrics(
1874 const TemplateURLData* data, 1872 const TemplateURLData* data,
1875 DefaultSearchManager::Source source) { 1873 DefaultSearchManager::Source source) {
1876 if (!loaded_) { 1874 if (!loaded_) {
1877 // Set |initial_default_search_provider_| from the preferences. This is 1875 // Set |initial_default_search_provider_| from the preferences. This is
1878 // mainly so we can hold ownership until we get to the point where the list 1876 // mainly so we can hold ownership until we get to the point where the list
1879 // of keywords from Web Data is the owner of everything including the 1877 // of keywords from Web Data is the owner of everything including the
1880 // default. 1878 // default.
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
2405 2403
2406 if (most_recently_intalled_default) { 2404 if (most_recently_intalled_default) {
2407 base::AutoReset<DefaultSearchChangeOrigin> change_origin( 2405 base::AutoReset<DefaultSearchChangeOrigin> change_origin(
2408 &dsp_change_origin_, DSP_CHANGE_OVERRIDE_SETTINGS_EXTENSION); 2406 &dsp_change_origin_, DSP_CHANGE_OVERRIDE_SETTINGS_EXTENSION);
2409 default_search_manager_.SetExtensionControlledDefaultSearchEngine( 2407 default_search_manager_.SetExtensionControlledDefaultSearchEngine(
2410 most_recently_intalled_default->data()); 2408 most_recently_intalled_default->data());
2411 } else { 2409 } else {
2412 default_search_manager_.ClearExtensionControlledDefaultSearchEngine(); 2410 default_search_manager_.ClearExtensionControlledDefaultSearchEngine();
2413 } 2411 }
2414 } 2412 }
OLDNEW
« no previous file with comments | « chrome/browser/search_engines/template_url_service.h ('k') | chrome/browser/search_engines/template_url_service_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698