OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_SYNC_SYNC_SETUP_WIZARD_H_ | 5 #ifndef CHROME_BROWSER_SYNC_SYNC_SETUP_WIZARD_H_ |
6 #define CHROME_BROWSER_SYNC_SYNC_SETUP_WIZARD_H_ | 6 #define CHROME_BROWSER_SYNC_SYNC_SETUP_WIZARD_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 | 10 |
11 class SyncSetupFlow; | 11 class SyncSetupFlow; |
12 class SyncSetupFlowContainer; | 12 class SyncSetupFlowContainer; |
13 class SyncSetupFlowHandler; | 13 class SyncSetupFlowHandler; |
14 | 14 |
15 class ProfileSyncService; | 15 class ProfileSyncService; |
16 | 16 |
17 class SyncSetupWizard { | 17 class SyncSetupWizard { |
18 public: | 18 public: |
19 enum State { | 19 enum State { |
20 // Show the Google Account login UI. | |
21 GAIA_LOGIN = 0, | |
22 // Show the Gaia OAuth login UI. | |
23 // TODO(rickcam): After Sync with OAuth works, revisit removing this state. | |
24 OAUTH_LOGIN, | |
25 // A login attempt succeeded. This will wait for an explicit transition | |
26 // (via Step) to the next state. | |
27 GAIA_SUCCESS, | |
28 // Show the screen that confirms everything will be synced. | |
29 SYNC_EVERYTHING, | 20 SYNC_EVERYTHING, |
30 // Show the screen that lets you configure sync. | 21 // Show the screen that lets you configure sync. |
31 // There are two tabs: | 22 // There are two tabs: |
32 // Data Types -- | 23 // Data Types -- |
33 // Choose either "Keep everything synced" or | 24 // Choose either "Keep everything synced" or |
34 // "Choose which data types to sync", and checkboxes for each data type. | 25 // "Choose which data types to sync", and checkboxes for each data type. |
35 // Encryption -- | 26 // Encryption -- |
36 // Choose what to encrypt and whether to use a passphrase. | 27 // Choose what to encrypt and whether to use a passphrase. |
37 CONFIGURE, | 28 CONFIGURE, |
38 // Show the screen that prompts for your passphrase | 29 // Show the screen that prompts for your passphrase |
39 ENTER_PASSPHRASE, | 30 ENTER_PASSPHRASE, |
40 // An error has occurred in the backend. The next appropriate step is picked | |
41 // based on which error has occurred. | |
42 NONFATAL_ERROR, | |
43 // The panic switch. Something went terribly wrong during setup and we can't | 31 // The panic switch. Something went terribly wrong during setup and we can't |
44 // recover. | 32 // recover. |
45 FATAL_ERROR, | 33 FATAL_ERROR, |
46 // The client can't set up sync at the moment due to a concurrent operation | |
47 // to clear cloud data being in progress on the server. | |
48 SETUP_ABORTED_BY_PENDING_CLEAR, | |
49 // Loading screen with throbber. | 34 // Loading screen with throbber. |
50 SETTING_UP, | 35 SETTING_UP, |
51 // A catch-all done case for any setup process. | 36 // A catch-all done case for any setup process. |
52 DONE, | 37 DONE, |
53 // Exit the wizard. | 38 // Exit the wizard (for example, if the user clears the data on the |
| 39 // dashboard while the wizard is open). |
54 ABORT, | 40 ABORT, |
55 }; | 41 }; |
56 | 42 |
57 explicit SyncSetupWizard(ProfileSyncService* service); | 43 explicit SyncSetupWizard(ProfileSyncService* service); |
58 ~SyncSetupWizard(); | 44 ~SyncSetupWizard(); |
59 | 45 |
60 // Advances the wizard to the specified state if possible, or opens a | 46 // Advances the wizard to the specified state if possible, or opens a |
61 // new dialog starting at |advance_state|. If the wizard has never run | 47 // new dialog starting at |advance_state|. If the wizard has never run |
62 // through to completion, it will always attempt to do so. Otherwise, e.g | 48 // through to completion, it will always attempt to do so. Otherwise, e.g |
63 // for a transient auth failure, it will just run as far as is necessary | 49 // for a transient auth failure, it will just run as far as is necessary |
64 // based on |advance_state| (so for auth failure, up to GAIA_SUCCESS). | 50 // based on |advance_state| (so for auth failure, up to GAIA_SUCCESS). |
65 void Step(State advance_state); | 51 void Step(State advance_state); |
66 | 52 |
67 // Whether or not a dialog is currently showing. Useful to determine | 53 // Whether or not a dialog is currently showing. Useful to determine |
68 // if various buttons in the UI should be enabled or disabled. | 54 // if various buttons in the UI should be enabled or disabled. |
69 bool IsVisible() const; | 55 bool IsVisible() const; |
70 | 56 |
71 // Returns either GAIA_LOGIN or OAUTH_LOGIN depending on which | |
72 // authentication scheme is in force. | |
73 static State GetLoginState(); | |
74 | |
75 // Focus the dialog if it is already open. Does nothing if the dialog is | 57 // Focus the dialog if it is already open. Does nothing if the dialog is |
76 // not visible. | 58 // not visible. |
77 void Focus(); | 59 void Focus(); |
78 | 60 |
79 // Attaches |handler| to the flow contained in |flow_container_|. Returns NULL | 61 // Attaches |handler| to the flow contained in |flow_container_|. Returns NULL |
80 // if the flow does not exist or if an existing handler is already attached to | 62 // if the flow does not exist or if an existing handler is already attached to |
81 // the flow. | 63 // the flow. |
82 SyncSetupFlow* AttachSyncSetupHandler(SyncSetupFlowHandler* handler); | 64 SyncSetupFlow* AttachSyncSetupHandler(SyncSetupFlowHandler* handler); |
83 | 65 |
84 private: | 66 private: |
85 ProfileSyncService* service_; | 67 ProfileSyncService* service_; |
86 | 68 |
87 SyncSetupFlowContainer* flow_container_; | 69 SyncSetupFlowContainer* flow_container_; |
88 | 70 |
89 DISALLOW_COPY_AND_ASSIGN(SyncSetupWizard); | 71 DISALLOW_COPY_AND_ASSIGN(SyncSetupWizard); |
90 }; | 72 }; |
91 | 73 |
92 #endif // CHROME_BROWSER_SYNC_SYNC_SETUP_WIZARD_H_ | 74 #endif // CHROME_BROWSER_SYNC_SYNC_SETUP_WIZARD_H_ |
OLD | NEW |