OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_SYNC_SETUP_HELPER_H_ | |
6 #define CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_SYNC_SETUP_HELPER_H_ | |
7 | |
8 #include <string> | |
9 | |
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" | |
14 | |
15 class Profile; | |
16 class ProfileSyncServiceHarness; | |
17 | |
18 namespace base { | |
19 class FilePath; | |
20 } | |
21 | |
22 namespace extensions { | |
23 | |
24 class SyncSetupHelper { | |
25 public: | |
26 SyncSetupHelper(); | |
27 | |
28 ~SyncSetupHelper(); | |
29 | |
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); | |
33 | |
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); | |
38 | |
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_; } | |
42 | |
43 private: | |
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(); | |
47 | |
48 // GAIA account used by the test case. | |
49 std::string username_; | |
50 | |
51 // GAIA password used by the test case. | |
52 std::string password_; | |
53 | |
54 // GAIA client id for making the API call to push messaging. | |
55 std::string client_id_; | |
56 | |
57 // GAIA client secret for making the API call to push messaging. | |
58 std::string client_secret_; | |
59 | |
60 // GAIA refresh token for making the API call to push messaging. | |
61 std::string refresh_token_; | |
62 | |
63 // The sync profile used by a test. The profile is owned by the | |
64 // ProfileManager. | |
65 Profile* profile_; | |
66 | |
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_; | |
71 | |
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_; | |
76 | |
77 DISALLOW_COPY_AND_ASSIGN(SyncSetupHelper); | |
78 }; | |
79 | |
80 } // namespace extensions | |
81 | |
82 #endif // CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_SYNC_SETUP_HELPER_H_ | |
OLD | NEW |