| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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_FLOW_H_ | 5 #ifndef CHROME_BROWSER_SYNC_SYNC_SETUP_FLOW_H_ |
| 6 #define CHROME_BROWSER_SYNC_SYNC_SETUP_FLOW_H_ | 6 #define CHROME_BROWSER_SYNC_SYNC_SETUP_FLOW_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 SyncSetupFlowContainer* container, | 51 SyncSetupFlowContainer* container, |
| 52 SyncSetupWizard::State start, | 52 SyncSetupWizard::State start, |
| 53 SyncSetupWizard::State end); | 53 SyncSetupWizard::State end); |
| 54 | 54 |
| 55 // Fills |args| with "user" and "error" arguments by querying |service|. | 55 // Fills |args| with "user" and "error" arguments by querying |service|. |
| 56 static void GetArgsForGaiaLogin( | 56 static void GetArgsForGaiaLogin( |
| 57 const ProfileSyncService* service, | 57 const ProfileSyncService* service, |
| 58 DictionaryValue* args); | 58 DictionaryValue* args); |
| 59 | 59 |
| 60 // Fills |args| for the configure screen (Choose Data Types/Encryption) | 60 // Fills |args| for the configure screen (Choose Data Types/Encryption) |
| 61 static void GetArgsForConfigure( | 61 void GetArgsForConfigure(ProfileSyncService* service, DictionaryValue* args); |
| 62 ProfileSyncService* service, | |
| 63 DictionaryValue* args); | |
| 64 | 62 |
| 65 // Attaches the |handler| to this flow. Returns true if successful and false | 63 // Attaches the |handler| to this flow. Returns true if successful and false |
| 66 // if a handler has already been attached. | 64 // if a handler has already been attached. |
| 67 bool AttachSyncSetupHandler(SyncSetupFlowHandler* handler); | 65 bool AttachSyncSetupHandler(SyncSetupFlowHandler* handler); |
| 68 | 66 |
| 69 // Returns true if a handler is attached to this flow. | 67 // Returns true if a handler is attached to this flow. |
| 70 bool IsAttached() const; | 68 bool IsAttached() const; |
| 71 | 69 |
| 72 // Triggers a state machine transition to advance_state. | 70 // Triggers a state machine transition to advance_state. |
| 73 void Advance(SyncSetupWizard::State advance_state); | 71 void Advance(SyncSetupWizard::State advance_state); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 103 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, DiscreteRunChooseDataTypes); | 101 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, DiscreteRunChooseDataTypes); |
| 104 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, | 102 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, |
| 105 DiscreteRunChooseDataTypesAbortedByPendingClear); | 103 DiscreteRunChooseDataTypesAbortedByPendingClear); |
| 106 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, EnterPassphraseRequired); | 104 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, EnterPassphraseRequired); |
| 107 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, NonFatalError); | 105 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, NonFatalError); |
| 108 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, CrosAuthSetup); | 106 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, CrosAuthSetup); |
| 109 | 107 |
| 110 // Use static Run method to get an instance. | 108 // Use static Run method to get an instance. |
| 111 SyncSetupFlow(SyncSetupWizard::State start_state, | 109 SyncSetupFlow(SyncSetupWizard::State start_state, |
| 112 SyncSetupWizard::State end_state, | 110 SyncSetupWizard::State end_state, |
| 113 const std::string& args, | |
| 114 SyncSetupFlowContainer* container, | 111 SyncSetupFlowContainer* container, |
| 115 ProfileSyncService* service); | 112 ProfileSyncService* service); |
| 116 | 113 |
| 117 // Returns true if |this| should transition its state machine to |state| | 114 // Returns true if |this| should transition its state machine to |state| |
| 118 // based on |current_state_|, or false if that would be nonsense or is | 115 // based on |current_state_|, or false if that would be nonsense or is |
| 119 // a no-op. | 116 // a no-op. |
| 120 bool ShouldAdvance(SyncSetupWizard::State state); | 117 bool ShouldAdvance(SyncSetupWizard::State state); |
| 121 | 118 |
| 122 void ActivateState(SyncSetupWizard::State state); | 119 void ActivateState(SyncSetupWizard::State state); |
| 123 | 120 |
| 124 SyncSetupFlowContainer* container_; // Our container. Don't own this. | 121 SyncSetupFlowContainer* container_; // Our container. Don't own this. |
| 125 std::string dialog_start_args_; // The args to pass to the initial page. | |
| 126 | 122 |
| 127 SyncSetupWizard::State current_state_; | 123 SyncSetupWizard::State current_state_; |
| 128 SyncSetupWizard::State end_state_; // The goal. | 124 SyncSetupWizard::State end_state_; // The goal. |
| 129 | 125 |
| 130 // Time that the GAIA_LOGIN step was received. | 126 // Time that the GAIA_LOGIN step was received. |
| 131 base::TimeTicks login_start_time_; | 127 base::TimeTicks login_start_time_; |
| 132 | 128 |
| 133 // The handler needed for the entire flow. Weak reference. | 129 // The handler needed for the entire flow. Weak reference. |
| 134 SyncSetupFlowHandler* flow_handler_; | 130 SyncSetupFlowHandler* flow_handler_; |
| 135 | 131 |
| 136 // We need this to propagate back all user settings changes. Weak reference. | 132 // We need this to propagate back all user settings changes. Weak reference. |
| 137 ProfileSyncService* service_; | 133 ProfileSyncService* service_; |
| 138 | 134 |
| 139 // Set to true if we've tried creating/setting an explicit passphrase, so we | 135 // Set to true if we've tried creating/setting an explicit passphrase, so we |
| 140 // can appropriately reflect this in the UI. | 136 // can appropriately reflect this in the UI. |
| 141 bool tried_creating_explicit_passphrase_; | 137 bool tried_creating_explicit_passphrase_; |
| 142 bool tried_setting_explicit_passphrase_; | 138 bool tried_setting_explicit_passphrase_; |
| 143 | 139 |
| 140 // We track the passphrase the user entered so we can set it when configuring |
| 141 // the ProfileSyncService. |
| 142 std::string cached_passphrase_; |
| 143 |
| 144 DISALLOW_COPY_AND_ASSIGN(SyncSetupFlow); | 144 DISALLOW_COPY_AND_ASSIGN(SyncSetupFlow); |
| 145 }; | 145 }; |
| 146 | 146 |
| 147 // A really simple wrapper for a SyncSetupFlow so that we don't have to | 147 // A really simple wrapper for a SyncSetupFlow so that we don't have to |
| 148 // add any public methods to the public SyncSetupWizard interface to notify it | 148 // add any public methods to the public SyncSetupWizard interface to notify it |
| 149 // when the dialog closes. | 149 // when the dialog closes. |
| 150 class SyncSetupFlowContainer { | 150 class SyncSetupFlowContainer { |
| 151 public: | 151 public: |
| 152 SyncSetupFlowContainer() : flow_(NULL) { } | 152 SyncSetupFlowContainer() : flow_(NULL) { } |
| 153 void set_flow(SyncSetupFlow* flow) { | 153 void set_flow(SyncSetupFlow* flow) { |
| 154 DCHECK(!flow_ || !flow); | 154 DCHECK(!flow_ || !flow); |
| 155 flow_ = flow; | 155 flow_ = flow; |
| 156 } | 156 } |
| 157 | 157 |
| 158 SyncSetupFlow* get_flow() { return flow_; } | 158 SyncSetupFlow* get_flow() { return flow_; } |
| 159 private: | 159 private: |
| 160 SyncSetupFlow* flow_; | 160 SyncSetupFlow* flow_; |
| 161 | 161 |
| 162 DISALLOW_COPY_AND_ASSIGN(SyncSetupFlowContainer); | 162 DISALLOW_COPY_AND_ASSIGN(SyncSetupFlowContainer); |
| 163 }; | 163 }; |
| 164 | 164 |
| 165 #endif // CHROME_BROWSER_SYNC_SYNC_SETUP_FLOW_H_ | 165 #endif // CHROME_BROWSER_SYNC_SYNC_SETUP_FLOW_H_ |
| OLD | NEW |