summaryrefslogtreecommitdiffstats
path: root/chrome/browser/search_engines/template_url_prepopulate_data.h
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-14 21:36:02 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-14 21:36:02 +0000
commit623de74f174b29368b6e0c87527c84955212dddd (patch)
tree389eb3b7e11b1d84e3bbcc30defc6c5219e1327e /chrome/browser/search_engines/template_url_prepopulate_data.h
parent004b37467a9957faa835512904381b158501ab9d (diff)
downloadchromium_src-623de74f174b29368b6e0c87527c84955212dddd.zip
chromium_src-623de74f174b29368b6e0c87527c84955212dddd.tar.gz
chromium_src-623de74f174b29368b6e0c87527c84955212dddd.tar.bz2
Clean up TemplateURL prepopulate data:
* Replace a pair of overlapping functions in the API with two distinct accessors for relevant pieces of information about prepopulated URLs. One key side effect here is that we no longer return TemplateURL*s from these, which will make the upcoming refactoring changes slightly cleaner. * Make the implementation of these a bit more robust w.r.t. determining if a provided URL corresponds to Google. This will also be important later as we'll want to be able to match a hand-coded "google.co.uk" entry against an auto-generated "google.de" entry (or similar). * Remove a bunch of string conversions, as well as a lot of passing of raw C-style string pointers. * Remove using statements. * Remove two obscure engines which have the same hostname as another, different engine. These cause problems when we ask for the name or type of an engine because the answer we get back is basically indeterminate. I don't think either of these is very important (they lived at slots 4 and 5 in their respective countries) so just gut them. BUG=none TEST=none Review URL: https://chromiumcodereview.appspot.com/9705021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@126746 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/search_engines/template_url_prepopulate_data.h')
-rw-r--r--chrome/browser/search_engines/template_url_prepopulate_data.h25
1 files changed, 16 insertions, 9 deletions
diff --git a/chrome/browser/search_engines/template_url_prepopulate_data.h b/chrome/browser/search_engines/template_url_prepopulate_data.h
index 74a88d1..b30eff8 100644
--- a/chrome/browser/search_engines/template_url_prepopulate_data.h
+++ b/chrome/browser/search_engines/template_url_prepopulate_data.h
@@ -10,6 +10,9 @@
#include <string>
#include <vector>
+#include "base/string16.h"
+#include "chrome/browser/search_engines/search_engine_type.h"
+
class GURL;
class PrefService;
class TemplateURL;
@@ -35,18 +38,22 @@ void GetPrepopulatedEngines(PrefService* prefs,
// Returns the default search provider specified by the prepopulate data.
// The caller owns the returned value, which may be NULL.
-// If |prefs| is NULL, search provider overrides from preferences are not used.
+// If |prefs| is NULL, any search provider overrides from the preferences are
+// not used.
TemplateURL* GetPrepopulatedDefaultSearch(PrefService* prefs);
-// Returns a TemplateURL from the prepopulated data which has the same origin
-// as the given url. The caller is responsible for deleting the returned
-// TemplateURL.
-TemplateURL* GetEngineForOrigin(PrefService* prefs, const GURL& url_to_find);
+// Both the next two functions use same-origin checks unless the |url| is a
+// Google seach URL, in which case we'll identify any valid Google hostname, or
+// the unsubstituted Google prepopulate URL, as "Google".
+
+// Returns the short name for the matching engine, or url.host() if no engines
+// match. If no engines match and the |url| can't be converted to a valid GURL,
+// returns the string in IDS_UNKNOWN_SEARCH_ENGINE_NAME.
+string16 GetEngineName(const std::string& url);
-// Returns the prepopulated search provider whose search URL origin matches the
-// origin of |search_url| or NULL if none is found. The caller is responsible
-// for deleting the returned TemplateURL.
-TemplateURL* FindPrepopulatedEngine(const std::string& search_url);
+// Returns the type of the matching engine, or SEARCH_ENGINE_OTHER if no engines
+// match.
+SearchEngineType GetEngineType(const std::string& url);
} // namespace TemplateURLPrepopulateData