File: search_engines_helper.h

package info (click to toggle)
chromium-browser 57.0.2987.98-1~deb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 2,637,852 kB
  • ctags: 2,544,394
  • sloc: cpp: 12,815,961; ansic: 3,676,222; python: 1,147,112; asm: 526,608; java: 523,212; xml: 286,794; perl: 92,654; sh: 86,408; objc: 73,271; makefile: 27,698; cs: 18,487; yacc: 13,031; tcl: 12,957; pascal: 4,875; ml: 4,716; lex: 3,904; sql: 3,862; ruby: 1,982; lisp: 1,508; php: 1,368; exp: 404; awk: 325; csh: 117; jsp: 39; sed: 37
file content (83 lines) | stat: -rw-r--r-- 3,067 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_SEARCH_ENGINES_HELPER_H_
#define CHROME_BROWSER_SYNC_TEST_INTEGRATION_SEARCH_ENGINES_HELPER_H_

#include <map>
#include <memory>
#include <string>

#include "base/strings/string16.h"
#include "chrome/browser/sync/test/integration/await_match_status_change_checker.h"

class Profile;
class TemplateURL;
class TemplateURLService;

typedef std::map<std::string, const TemplateURL*> GUIDToTURLMap;

namespace search_engines_helper {

// Used to access the search engines within a particular sync profile.
TemplateURLService* GetServiceForBrowserContext(int profile_index);

// Used to access the search engines within the verifier sync profile.
TemplateURLService* GetVerifierService();

// Compared a single TemplateURLService for a given profile to the verifier.
// Retrns true iff their user-visible fields match.
bool ServiceMatchesVerifier(int profile_index);

// Returns true iff all TemplateURLServices match with the verifier.
bool AllServicesMatch();

// Create a TemplateURL with some test values based on |seed|.
std::unique_ptr<TemplateURL> CreateTestTemplateURL(
    Profile* profile,
    int seed,
    const base::string16& keyword,
    const std::string& sync_guid);
std::unique_ptr<TemplateURL> CreateTestTemplateURL(
    Profile* profile,
    int seed,
    const base::string16& keyword,
    const std::string& url,
    const std::string& sync_guid);

// Add a search engine based on a seed to the service at index |profile_index|
// and the verifier if it is used.
void AddSearchEngine(int profile_index, int seed);

// Retrieves a search engine from the service at index |profile_index| with
// original keyword |keyword| and changes its user-visible fields. Does the same
// to the verifier, if it is used.
void EditSearchEngine(int profile_index,
                      const base::string16& keyword,
                      const base::string16& short_name,
                      const base::string16& new_keyword,
                      const std::string& url);

// Deletes a search engine from the service at index |profile_index| which was
// generated by seed |seed|.
void DeleteSearchEngineBySeed(int profile_index, int seed);

// Change the search engine generated with |seed| in service at index
// |profile_index| to be the new default. Does the same to the verifier, if it
// is used.
void ChangeDefaultSearchProvider(int profile_index, int seed);

// Returns true if the profile at |profile_index| has a search engine matching
// the search engine generated with |seed|.
bool HasSearchEngine(int profile_index, int seed);

}  // namespace search_engines_helper

// Checker that blocks until all services have the same search engine data.
class SearchEnginesMatchChecker : public AwaitMatchStatusChangeChecker {
 public:
  SearchEnginesMatchChecker();
};

#endif  // CHROME_BROWSER_SYNC_TEST_INTEGRATION_SEARCH_ENGINES_HELPER_H_