blob: 0e96ae971ff6fb3aea98c6ba7e88e6859c0e8331 [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"
[email protected]01ef4a662012-05-29 15:58:2516#include "chrome/browser/search_engines/template_url_service.h"
[email protected]96788b02010-06-26 21:45:3417
18class Profile;
[email protected]e1ddda02010-08-26 19:43:4819class TemplateURL;
20class WDTypedResult;
21class WebDataService;
[email protected]96788b02010-06-26 21:45:3422
23// Returns the short name of the default search engine, or the empty string if
24// none is set. |profile| may be NULL.
25string16 GetDefaultSearchEngineName(Profile* profile);
26
[email protected]e1ddda02010-08-26 19:43:4827// Processes the results of WebDataService::GetKeywords, combining it with
28// prepopulated search providers to result in:
29// * a set of template_urls (search providers). The caller owns the
30// TemplateURL* returned in template_urls.
31// * the default search provider (and if *default_search_provider is not NULL,
32// it is contained in template_urls).
33// * whether there is a new resource keyword version (and the value).
34// |*new_resource_keyword_version| is set to 0 if no new value. Otherwise,
35// it is the new value.
36// Only pass in a non-NULL value for service if the WebDataService should be
[email protected]2eff6b12012-05-16 20:07:0537// updated. If |removed_keyword_guids| is not NULL, any TemplateURLs removed
38// from the keyword table in the WebDataService will have their Sync GUIDs
39// added to it.
[email protected]e1ddda02010-08-26 19:43:4840void GetSearchProvidersUsingKeywordResult(
41 const WDTypedResult& result,
42 WebDataService* service,
[email protected]16fca9b82012-04-23 18:40:2643 Profile* profile,
[email protected]01ef4a662012-05-29 15:58:2544 TemplateURLService::TemplateURLVector* template_urls,
[email protected]3613347d2012-04-27 20:27:3745 TemplateURL** default_search_provider,
[email protected]2eff6b12012-05-16 20:07:0546 int* new_resource_keyword_version,
47 std::set<std::string>* removed_keyword_guids);
[email protected]e1ddda02010-08-26 19:43:4848
[email protected]75a4eca2011-10-26 20:40:0949// Returns true if the default search provider setting has been changed or
50// corrupted. Returns the backup setting in |backup_default_search_provider|.
51// |*backup_default_search_provider| can be NULL if the original setting is
52// lost.
53bool DidDefaultSearchProviderChange(
54 const WDTypedResult& result,
[email protected]16fca9b82012-04-23 18:40:2655 Profile* profile,
[email protected]2ede21312011-12-22 13:31:2656 scoped_ptr<TemplateURL>* backup_default_search_provider);
[email protected]75a4eca2011-10-26 20:40:0957
[email protected]01ef4a662012-05-29 15:58:2558// Removes (and deletes) TemplateURLs from |template_urls| and |service| if they
59// have duplicate prepopulate ids. If |removed_keyword_guids| is not NULL, the
60// Sync GUID of each item removed from the DB will be added to it. This is a
61// helper used by GetSearchProvidersUsingKeywordResult(), but is declared here
62// so it's accessible by unittests.
63void RemoveDuplicatePrepopulateIDs(
64 WebDataService* service,
65 const ScopedVector<TemplateURL>& prepopulated_urls,
66 TemplateURL* default_search_provider,
67 TemplateURLService::TemplateURLVector* template_urls,
68 std::set<std::string>* removed_keyword_guids);
69
[email protected]96788b02010-06-26 21:45:3470#endif // CHROME_BROWSER_SEARCH_ENGINES_UTIL_H_