| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_VIEWS_SYNC_SYNC_SETUP_WIZARD_H_ | 5 #ifndef CHROME_BROWSER_VIEWS_SYNC_SYNC_SETUP_WIZARD_H_ |
| 6 #define CHROME_BROWSER_VIEWS_SYNC_SYNC_SETUP_WIZARD_H_ | 6 #define CHROME_BROWSER_VIEWS_SYNC_SYNC_SETUP_WIZARD_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 | 9 |
| 10 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
| 11 class SyncSetupFlowContainer; | 11 class SyncSetupFlowContainer; |
| 12 #elif defined(OS_LINUX) | 12 #elif defined(OS_LINUX) |
| 13 typedef struct _GtkWidget GtkWidget; | 13 typedef struct _GtkWidget GtkWidget; |
| 14 typedef struct _GtkWindow GtkWindow; | 14 typedef struct _GtkWindow GtkWindow; |
| 15 #endif | 15 #endif |
| 16 | 16 |
| 17 class ProfileSyncService; | 17 class ProfileSyncService; |
| 18 | 18 |
| 19 class SyncSetupWizard { | 19 class SyncSetupWizard { |
| 20 public: | 20 public: |
| 21 enum State { | 21 enum State { |
| 22 // Show the Google Account login UI. |
| 22 GAIA_LOGIN = 0, | 23 GAIA_LOGIN = 0, |
| 24 // A login attempt succeeded. Depending on initial conditions, this may |
| 25 // cause a transition to DONE, or to wait for an explicit transition (via |
| 26 // Step) to the next state. |
| 23 GAIA_SUCCESS, | 27 GAIA_SUCCESS, |
| 28 // The user needs to accept a merge and sync warning to proceed. |
| 24 MERGE_AND_SYNC, | 29 MERGE_AND_SYNC, |
| 30 // The panic switch. Something went terribly wrong during setup and we |
| 31 // can't recover. |
| 25 FATAL_ERROR, | 32 FATAL_ERROR, |
| 33 // A final state for when setup completes and it is possible it is the |
| 34 // user's first time (globally speaking) as the cloud doesn't have any |
| 35 // bookmarks. We show additional info in this case to explain setting up |
| 36 // more computers. |
| 37 DONE_FIRST_TIME, |
| 38 // A catch-all done case for any setup process. |
| 26 DONE | 39 DONE |
| 27 }; | 40 }; |
| 28 | 41 |
| 29 explicit SyncSetupWizard(ProfileSyncService* service); | 42 explicit SyncSetupWizard(ProfileSyncService* service); |
| 30 ~SyncSetupWizard(); | 43 ~SyncSetupWizard(); |
| 31 | 44 |
| 32 // Advances the wizard to the specified state if possible, or opens a | 45 // Advances the wizard to the specified state if possible, or opens a |
| 33 // new dialog starting at |advance_state|. If the wizard has never ran | 46 // new dialog starting at |advance_state|. If the wizard has never ran |
| 34 // through to completion, it will always attempt to do so. Otherwise, e.g | 47 // through to completion, it will always attempt to do so. Otherwise, e.g |
| 35 // for a transient auth failure, it will just run as far as is necessary | 48 // for a transient auth failure, it will just run as far as is necessary |
| 36 // based on |advance_state| (so for auth failure, up to GAIA_SUCCESS). | 49 // based on |advance_state| (so for auth failure, up to GAIA_SUCCESS). |
| 37 void Step(State advance_state); | 50 void Step(State advance_state); |
| 38 | 51 |
| 39 // Whether or not a dialog is currently showing. Useful to determine | 52 // Whether or not a dialog is currently showing. Useful to determine |
| 40 // if various buttons in the UI should be enabled or disabled. | 53 // if various buttons in the UI should be enabled or disabled. |
| 41 bool IsVisible() const; | 54 bool IsVisible() const; |
| 42 | 55 |
| 43 #if defined(OS_LINUX) | 56 #if defined(OS_LINUX) |
| 44 void SetVisible(bool visible) { visible_ = visible; } | 57 void SetVisible(bool visible) { visible_ = visible; } |
| 45 #endif | 58 #endif |
| 46 | 59 |
| 47 private: | 60 private: |
| 48 // If we just need to pop open an individual dialog, say to collect | 61 // If we just need to pop open an individual dialog, say to collect |
| 49 // gaia credentials in the event of a steady-state auth failure, this is | 62 // gaia credentials in the event of a steady-state auth failure, this is |
| 50 // a "discrete" run (as in not a continuous wizard flow). This returns | 63 // a "discrete" run (as in not a continuous wizard flow). This returns |
| 51 // the end state to pass to Run for a given |start_state|. | 64 // the end state to pass to Run for a given |start_state|. |
| 52 static State GetEndStateForDiscreteRun(State start_state); | 65 static State GetEndStateForDiscreteRun(State start_state); |
| 53 | 66 |
| 67 // Helper to return whether |state| warrants starting a new flow. |
| 68 static bool IsTerminalState(State state); |
| 69 |
| 54 ProfileSyncService* service_; | 70 ProfileSyncService* service_; |
| 55 | 71 |
| 56 #if defined(OS_WIN) | 72 #if defined(OS_WIN) |
| 57 SyncSetupFlowContainer* flow_container_; | 73 SyncSetupFlowContainer* flow_container_; |
| 58 #elif defined(OS_LINUX) | 74 #elif defined(OS_LINUX) |
| 59 bool visible_; | 75 bool visible_; |
| 60 #endif | 76 #endif |
| 61 | 77 |
| 62 DISALLOW_COPY_AND_ASSIGN(SyncSetupWizard); | 78 DISALLOW_COPY_AND_ASSIGN(SyncSetupWizard); |
| 63 }; | 79 }; |
| 64 | 80 |
| 65 #endif // CHROME_BROWSER_VIEWS_SYNC_SYNC_SETUP_WIZARD_H_ | 81 #endif // CHROME_BROWSER_VIEWS_SYNC_SYNC_SETUP_WIZARD_H_ |
| OLD | NEW |