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

Side by Side Diff: components/search_engines/template_url_prepopulate_data.h

Issue 1983773002: Cache SearchEngineType of TemplateURL (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@refactor-extracting-terms-from-template-url
Patch Set: Move calculation to TemplateURLData Created 4 years, 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_PREPOPULATE_DATA_H_ 5 #ifndef COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_PREPOPULATE_DATA_H_
6 #define COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_PREPOPULATE_DATA_H_ 6 #define COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_PREPOPULATE_DATA_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/memory/scoped_vector.h" 14 #include "base/memory/scoped_vector.h"
15 #include "base/strings/string16.h" 15 #include "base/strings/string16.h"
16 #include "components/search_engines/search_engine_type.h" 16 #include "components/search_engines/search_engine_type.h"
17 17
18 class GURL; 18 class GURL;
19 class PrefService; 19 class PrefService;
20 class SearchTermsData;
21 class TemplateURL;
22 struct TemplateURLData; 20 struct TemplateURLData;
23 21
24 namespace user_prefs { 22 namespace user_prefs {
25 class PrefRegistrySyncable; 23 class PrefRegistrySyncable;
26 } 24 }
27 25
28 namespace TemplateURLPrepopulateData { 26 namespace TemplateURLPrepopulateData {
29 27
30 struct PrepopulatedEngine; 28 struct PrepopulatedEngine;
31 29
(...skipping 10 matching lines...) Expand all
42 // |default_search_provider_index| is set to the index of the default search 40 // |default_search_provider_index| is set to the index of the default search
43 // provider. 41 // provider.
44 ScopedVector<TemplateURLData> GetPrepopulatedEngines( 42 ScopedVector<TemplateURLData> GetPrepopulatedEngines(
45 PrefService* prefs, 43 PrefService* prefs,
46 size_t* default_search_provider_index); 44 size_t* default_search_provider_index);
47 45
48 // Returns a TemplateURLData for the specified prepopulated engine. 46 // Returns a TemplateURLData for the specified prepopulated engine.
49 std::unique_ptr<TemplateURLData> MakeTemplateURLDataFromPrepopulatedEngine( 47 std::unique_ptr<TemplateURLData> MakeTemplateURLDataFromPrepopulatedEngine(
50 const PrepopulatedEngine& engine); 48 const PrepopulatedEngine& engine);
51 49
50 // Returns a list of all the engines that we know about.
51 // This is a big list; it's recommended to use it for testing purposes only.
52 std::vector<const PrepopulatedEngine*> GetAllKnownPrepopulatedEngines();
Peter Kasting 2016/06/09 23:00:56 Nit: I would place this right under GetPrepopulate
Vitaly Baranov 2016/06/12 07:29:15 Done.
53
52 // Removes prepopulated engines and their version stored in user prefs. 54 // Removes prepopulated engines and their version stored in user prefs.
53 void ClearPrepopulatedEnginesInPrefs(PrefService* prefs); 55 void ClearPrepopulatedEnginesInPrefs(PrefService* prefs);
54 56
55 // Returns the default search provider specified by the prepopulate data, which 57 // Returns the default search provider specified by the prepopulate data, which
56 // may be NULL. 58 // may be NULL.
57 // If |prefs| is NULL, any search provider overrides from the preferences are 59 // If |prefs| is NULL, any search provider overrides from the preferences are
58 // not used. 60 // not used.
59 std::unique_ptr<TemplateURLData> GetPrepopulatedDefaultSearch( 61 std::unique_ptr<TemplateURLData> GetPrepopulatedDefaultSearch(
60 PrefService* prefs); 62 PrefService* prefs);
61 63
62 // Returns the type of the provided engine, or SEARCH_ENGINE_OTHER if no engines
63 // match. This checks the TLD+1 for the most part, but will report the type as
64 // SEARCH_ENGINE_GOOGLE for any hostname that causes
65 // google_util::IsGoogleHostname() to return true.
66 //
67 // NOTE: Must be called on the UI thread.
68 SearchEngineType GetEngineType(const TemplateURL& template_url,
69 const SearchTermsData& search_terms_data);
70
71 // Like the above, but takes a GURL which is expected to represent a search URL. 64 // Like the above, but takes a GURL which is expected to represent a search URL.
72 // This may be called on any thread. 65 // This may be called on any thread.
73 SearchEngineType GetEngineType(const GURL& url); 66 SearchEngineType GetEngineType(const GURL& url);
74 67
75 // Returns the identifier for the user current country. Used to update the list 68 // Returns the identifier for the user current country. Used to update the list
76 // of search engines when user switches device region settings. For use on iOS 69 // of search engines when user switches device region settings. For use on iOS
77 // only. 70 // only.
78 // TODO(ios): Once user can customize search engines ( http://crbug.com/153047 ) 71 // TODO(ios): Once user can customize search engines ( http://crbug.com/153047 )
79 // this declaration should be removed and the definition in the .cc file be 72 // this declaration should be removed and the definition in the .cc file be
80 // moved back to the anonymous namespace. 73 // moved back to the anonymous namespace.
81 int GetCurrentCountryID(); 74 int GetCurrentCountryID();
82 75
83 } // namespace TemplateURLPrepopulateData 76 } // namespace TemplateURLPrepopulateData
84 77
85 #endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_PREPOPULATE_DATA_H_ 78 #endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_PREPOPULATE_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698