• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2011 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_SYNC_SYNC_SETUP_WIZARD_H_
6 #define CHROME_BROWSER_SYNC_SYNC_SETUP_WIZARD_H_
7 #pragma once
8 
9 #include "base/basictypes.h"
10 
11 class SyncSetupFlow;
12 class SyncSetupFlowContainer;
13 class SyncSetupFlowHandler;
14 
15 class ProfileSyncService;
16 
17 class SyncSetupWizard {
18  public:
19   enum State {
20     // Show the Google Account login UI.
21     GAIA_LOGIN = 0,
22     // A login attempt succeeded.  This will wait for an explicit transition
23     // (via Step) to the next state.
24     GAIA_SUCCESS,
25     // Show the screen that confirms everything will be synced.
26     SYNC_EVERYTHING,
27     // Show the screen that lets you configure sync.
28     // There are two tabs:
29     //  Data Types --
30     //   Choose either "Keep everything synced" or
31     //   "Choose which data types to sync", and checkboxes for each data type.
32     //  Encryption --
33     //   Choose what to encrypt and whether to use a passphrase.
34     CONFIGURE,
35     // Show the screen that prompts for your passphrase
36     ENTER_PASSPHRASE,
37     // Show the passphrase "first time" screen for migrating users, where all
38     // is explained and they choose between google password/custom passphrase.
39     PASSPHRASE_MIGRATION,
40     // The panic switch.  Something went terribly wrong during setup and we
41     // can't recover.
42     FATAL_ERROR,
43     // The client can't set up sync at the moment due to a concurrent operation
44     // to clear cloud data being in progress on the server.
45     SETUP_ABORTED_BY_PENDING_CLEAR,
46     // Loading screen with spinny throbber.
47     SETTING_UP,
48     // A final state for when setup completes and it is possible it is the
49     // user's first time (globally speaking) as the cloud doesn't have any
50     // bookmarks.  We show additional info in this case to explain setting up
51     // more computers.
52     DONE_FIRST_TIME,
53     // A catch-all done case for any setup process.
54     DONE
55   };
56 
57   explicit SyncSetupWizard(ProfileSyncService* service);
58   ~SyncSetupWizard();
59 
60   // Advances the wizard to the specified state if possible, or opens a
61   // new dialog starting at |advance_state|.  If the wizard has never ran
62   // 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
64   // based on |advance_state| (so for auth failure, up to GAIA_SUCCESS).
65   void Step(State advance_state);
66 
67   // Whether or not a dialog is currently showing.  Useful to determine
68   // if various buttons in the UI should be enabled or disabled.
69   bool IsVisible() const;
70 
71   // Focus the dialog if it is already open.  Does nothing if the dialog is
72   // not visible.
73   void Focus();
74 
75   SyncSetupFlow* AttachSyncSetupHandler(SyncSetupFlowHandler* handler);
76 
77  private:
78   // If we just need to pop open an individual dialog, say to collect
79   // gaia credentials in the event of a steady-state auth failure, this is
80   // a "discrete" run (as in not a continuous wizard flow).  This returns
81   // the end state to pass to Run for a given |start_state|.
82   static State GetEndStateForDiscreteRun(State start_state);
83 
84   // Helper to return whether |state| warrants starting a new flow.
85   static bool IsTerminalState(State state);
86 
87   ProfileSyncService* service_;
88 
89   SyncSetupFlowContainer* flow_container_;
90 
91   SyncSetupFlowHandler* flow_handler_;
92 
93   DISALLOW_COPY_AND_ASSIGN(SyncSetupWizard);
94 };
95 
96 #endif  // CHROME_BROWSER_SYNC_SYNC_SETUP_WIZARD_H_
97