blob: c480f53d7ca30588d0c52ceab07b222db8e3ef8c [file] [log] [blame]
[email protected]16fca9b82012-04-23 18:40:261// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]96788b02010-06-26 21:45:342// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_SEARCH_ENGINES_UTIL_H_
6#define CHROME_BROWSER_SEARCH_ENGINES_UTIL_H_
[email protected]32b76ef2010-07-26 23:08:247#pragma once
[email protected]96788b02010-06-26 21:45:348
9// This file contains utility functions for search engine functionality.
[email protected]2eff6b12012-05-16 20:07:0510#include <set>
11#include <string>
[email protected]e1ddda02010-08-26 19:43:4812#include <vector>
[email protected]96788b02010-06-26 21:45:3413
[email protected]2ede21312011-12-22 13:31:2614#include "base/memory/scoped_ptr.h"
[email protected]96788b02010-06-26 21:45:3415#include "base/string16.h"
16
17class Profile;
[email protected]e1ddda02010-08-26 19:43:4818class TemplateURL;
19class WDTypedResult;
20class WebDataService;
[email protected]96788b02010-06-26 21:45:3421
22// Returns the short name of the default search engine, or the empty string if
23// none is set. |profile| may be NULL.
24string16 GetDefaultSearchEngineName(Profile* profile);
25
[email protected]e1ddda02010-08-26 19:43:4826// Processes the results of WebDataService::GetKeywords, combining it with
27// prepopulated search providers to result in:
28// * a set of template_urls (search providers). The caller owns the
29// TemplateURL* returned in template_urls.
30// * the default search provider (and if *default_search_provider is not NULL,
31// it is contained in template_urls).
32// * whether there is a new resource keyword version (and the value).
33// |*new_resource_keyword_version| is set to 0 if no new value. Otherwise,
34// it is the new value.
35// Only pass in a non-NULL value for service if the WebDataService should be
[email protected]2eff6b12012-05-16 20:07:0536// updated. If |removed_keyword_guids| is not NULL, any TemplateURLs removed
37// from the keyword table in the WebDataService will have their Sync GUIDs
38// added to it.
[email protected]e1ddda02010-08-26 19:43:4839void GetSearchProvidersUsingKeywordResult(
40 const WDTypedResult& result,
41 WebDataService* service,
[email protected]16fca9b82012-04-23 18:40:2642 Profile* profile,
[email protected]e1ddda02010-08-26 19:43:4843 std::vector<TemplateURL*>* template_urls,
[email protected]3613347d2012-04-27 20:27:3744 TemplateURL** default_search_provider,
[email protected]2eff6b12012-05-16 20:07:0545 int* new_resource_keyword_version,
46 std::set<std::string>* removed_keyword_guids);
[email protected]e1ddda02010-08-26 19:43:4847
[email protected]75a4eca2011-10-26 20:40:0948// Returns true if the default search provider setting has been changed or
49// corrupted. Returns the backup setting in |backup_default_search_provider|.
50// |*backup_default_search_provider| can be NULL if the original setting is
51// lost.
52bool DidDefaultSearchProviderChange(
53 const WDTypedResult& result,
[email protected]16fca9b82012-04-23 18:40:2654 Profile* profile,
[email protected]2ede21312011-12-22 13:31:2655 scoped_ptr<TemplateURL>* backup_default_search_provider);
[email protected]75a4eca2011-10-26 20:40:0956
[email protected]96788b02010-06-26 21:45:3457#endif // CHROME_BROWSER_SEARCH_ENGINES_UTIL_H_