blob: 39be4fe33594c147c8886c6c60e396ebc55f7174 (
plain)
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
|
// 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_EXTENSIONS_API_PUSH_MESSAGING_SYNC_SETUP_HELPER_H_
#define CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_SYNC_SETUP_HELPER_H_
#include <string>
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "net/dns/mock_host_resolver.h"
class Profile;
class ProfileSyncServiceHarness;
namespace extensions {
class SyncSetupHelper {
public:
SyncSetupHelper();
~SyncSetupHelper();
// Performs one-time initialization to enable sync for a profile. Does nothing
// if sync is already enabled for the profile.
bool InitializeSync(Profile* profile);
// Helper method used to read GAIA credentials from a local password file.
// Note: The password file must be a plain text file with two lines.
// The username is on the first line and the password is on the second line.
bool ReadPasswordFile(const base::FilePath& passwordFile);
const std::string& client_id() const { return client_id_; }
const std::string& client_secret() const { return client_secret_; }
const std::string& refresh_token() const { return refresh_token_; }
private:
// Block until all sync clients have completed their mutual sync cycles.
// Return true if a quiescent state was successfully reached.
bool AwaitQuiescence();
// GAIA account used by the test case.
std::string username_;
// GAIA password used by the test case.
std::string password_;
// GAIA client id for making the API call to push messaging.
std::string client_id_;
// GAIA client secret for making the API call to push messaging.
std::string client_secret_;
// GAIA refresh token for making the API call to push messaging.
std::string refresh_token_;
// The sync profile used by a test. The profile is owned by the
// ProfileManager.
Profile* profile_;
// Sync client used by a test. A sync client is associated with
// a sync profile, and implements methods that sync the contents of the
// profile with the server.
scoped_ptr<ProfileSyncServiceHarness> client_;
// This test needs to make live DNS requests for access to
// GAIA and sync server URLs under google.com. We use a scoped version
// to override the default resolver while the test is active.
scoped_ptr<net::ScopedDefaultHostResolverProc> mock_host_resolver_override_;
DISALLOW_COPY_AND_ASSIGN(SyncSetupHelper);
};
} // namespace extensions
#endif // CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_SYNC_SETUP_HELPER_H_
|