1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_SYNC_SETUP_HELPER_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_SYNC_SETUP_HELPER_H_
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "net/dns/mock_host_resolver.h"
16 class ProfileSyncServiceHarness;
22 namespace extensions {
24 class SyncSetupHelper {
30 // Performs one-time initialization to enable sync for a profile. Does nothing
31 // if sync is already enabled for the profile.
32 bool InitializeSync(Profile* profile);
34 // Helper method used to read GAIA credentials from a local password file.
35 // Note: The password file must be a plain text file with two lines.
36 // The username is on the first line and the password is on the second line.
37 bool ReadPasswordFile(const base::FilePath& passwordFile);
39 const std::string& client_id() const { return client_id_; }
40 const std::string& client_secret() const { return client_secret_; }
41 const std::string& refresh_token() const { return refresh_token_; }
44 // Block until all sync clients have completed their mutual sync cycles.
45 // Return true if a quiescent state was successfully reached.
46 bool AwaitQuiescence();
48 // GAIA account used by the test case.
49 std::string username_;
51 // GAIA password used by the test case.
52 std::string password_;
54 // GAIA client id for making the API call to push messaging.
55 std::string client_id_;
57 // GAIA client secret for making the API call to push messaging.
58 std::string client_secret_;
60 // GAIA refresh token for making the API call to push messaging.
61 std::string refresh_token_;
63 // The sync profile used by a test. The profile is owned by the
67 // Sync client used by a test. A sync client is associated with
68 // a sync profile, and implements methods that sync the contents of the
69 // profile with the server.
70 scoped_ptr<ProfileSyncServiceHarness> client_;
72 // This test needs to make live DNS requests for access to
73 // GAIA and sync server URLs under google.com. We use a scoped version
74 // to override the default resolver while the test is active.
75 scoped_ptr<net::ScopedDefaultHostResolverProc> mock_host_resolver_override_;
77 DISALLOW_COPY_AND_ASSIGN(SyncSetupHelper);
80 } // namespace extensions
82 #endif // CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_SYNC_SETUP_HELPER_H_