OLD | NEW |
1 // Copyright (c) 2012 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_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_IMPL_H_ | 5 #ifndef CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_IMPL_H_ |
6 #define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_IMPL_H_ | 6 #define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/string16.h" | 14 #include "base/string16.h" |
15 #include "base/time.h" | 15 #include "base/time.h" |
| 16 #include "chrome/browser/ui/autofill/account_chooser_model.h" |
16 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h" | 17 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h" |
17 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" | 18 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" |
18 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" | 19 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" |
19 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" | 20 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" |
20 #include "chrome/browser/ui/autofill/country_combobox_model.h" | 21 #include "chrome/browser/ui/autofill/country_combobox_model.h" |
21 #include "components/autofill/browser/autofill_manager_delegate.h" | 22 #include "components/autofill/browser/autofill_manager_delegate.h" |
22 #include "components/autofill/browser/autofill_metrics.h" | 23 #include "components/autofill/browser/autofill_metrics.h" |
23 #include "components/autofill/browser/autofill_popup_delegate.h" | 24 #include "components/autofill/browser/autofill_popup_delegate.h" |
24 #include "components/autofill/browser/field_types.h" | 25 #include "components/autofill/browser/field_types.h" |
25 #include "components/autofill/browser/form_structure.h" | 26 #include "components/autofill/browser/form_structure.h" |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 virtual void OnWalletError( | 197 virtual void OnWalletError( |
197 wallet::WalletClient::ErrorType error_type) OVERRIDE; | 198 wallet::WalletClient::ErrorType error_type) OVERRIDE; |
198 virtual void OnMalformedResponse() OVERRIDE; | 199 virtual void OnMalformedResponse() OVERRIDE; |
199 virtual void OnNetworkError(int response_code) OVERRIDE; | 200 virtual void OnNetworkError(int response_code) OVERRIDE; |
200 | 201 |
201 // PersonalDataManagerObserver implementation. | 202 // PersonalDataManagerObserver implementation. |
202 virtual void OnPersonalDataChanged() OVERRIDE; | 203 virtual void OnPersonalDataChanged() OVERRIDE; |
203 | 204 |
204 // AccountChooserModelDelegate implementation. | 205 // AccountChooserModelDelegate implementation. |
205 virtual void AccountChoiceChanged() OVERRIDE; | 206 virtual void AccountChoiceChanged() OVERRIDE; |
| 207 virtual void UpdateAccountChooserView() OVERRIDE; |
206 | 208 |
207 // wallet::WalletSigninHelperDelegate implementation. | 209 // wallet::WalletSigninHelperDelegate implementation. |
208 virtual void OnPassiveSigninSuccess( | 210 virtual void OnPassiveSigninSuccess(const std::string& username) OVERRIDE; |
209 const std::string& auth_username) OVERRIDE; | |
210 virtual void OnPassiveSigninFailure( | 211 virtual void OnPassiveSigninFailure( |
211 const GoogleServiceAuthError& error) OVERRIDE; | 212 const GoogleServiceAuthError& error) OVERRIDE; |
212 virtual void OnAutomaticSigninSuccess( | 213 virtual void OnAutomaticSigninSuccess(const std::string& username) OVERRIDE; |
213 const std::string& auth_username) OVERRIDE; | |
214 virtual void OnAutomaticSigninFailure( | 214 virtual void OnAutomaticSigninFailure( |
215 const GoogleServiceAuthError& error) OVERRIDE; | 215 const GoogleServiceAuthError& error) OVERRIDE; |
216 virtual void OnUserNameFetchSuccess( | 216 virtual void OnUserNameFetchSuccess(const std::string& username) OVERRIDE; |
217 const std::string& auth_username) OVERRIDE; | |
218 virtual void OnUserNameFetchFailure( | 217 virtual void OnUserNameFetchFailure( |
219 const GoogleServiceAuthError& error) OVERRIDE; | 218 const GoogleServiceAuthError& error) OVERRIDE; |
220 | 219 |
221 DialogType dialog_type() const { return dialog_type_; } | 220 DialogType dialog_type() const { return dialog_type_; } |
222 | 221 |
223 protected: | 222 protected: |
224 // Exposed for testing. | 223 // Exposed for testing. |
225 AutofillDialogControllerImpl( | 224 AutofillDialogControllerImpl( |
226 content::WebContents* contents, | 225 content::WebContents* contents, |
227 const FormData& form_structure, | 226 const FormData& form_structure, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 // address info. Incomplete profiles will not be displayed in the dropdown | 265 // address info. Incomplete profiles will not be displayed in the dropdown |
267 // menu. | 266 // menu. |
268 bool IsCompleteProfile(const AutofillProfile& profile); | 267 bool IsCompleteProfile(const AutofillProfile& profile); |
269 | 268 |
270 // Whether the user's wallet items have at least one address and instrument. | 269 // Whether the user's wallet items have at least one address and instrument. |
271 bool HasCompleteWallet() const; | 270 bool HasCompleteWallet() const; |
272 | 271 |
273 // Starts fetching the wallet items from Online Wallet. | 272 // Starts fetching the wallet items from Online Wallet. |
274 void GetWalletItems(); | 273 void GetWalletItems(); |
275 | 274 |
| 275 // Handles the SignedInState() on Wallet or sign-in state update. |
| 276 // Triggers the user name fetch and the passive/automatic sign-in. |
| 277 void SignedInStateUpdated(); |
| 278 |
276 // Refreshes the model on Wallet or sign-in state update. | 279 // Refreshes the model on Wallet or sign-in state update. |
277 void OnWalletOrSigninUpdate(); | 280 void OnWalletOrSigninUpdate(); |
278 | 281 |
279 // Should be called on the Wallet sign-in error. | 282 // Should be called on the Wallet sign-in error. |
280 void OnWalletSigninError(); | 283 void OnWalletSigninError(); |
281 | 284 |
282 // Calculates |legal_documents_text_| and |legal_document_link_ranges_| if | 285 // Calculates |legal_documents_text_| and |legal_document_link_ranges_| if |
283 // they have not already been calculated. | 286 // they have not already been calculated. |
284 void EnsureLegalDocumentsText(); | 287 void EnsureLegalDocumentsText(); |
285 | 288 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 base::Callback<void(const FormStructure*, const std::string&)> callback_; | 409 base::Callback<void(const FormStructure*, const std::string&)> callback_; |
407 | 410 |
408 // The AccountChooserModel acts as the MenuModel for the account chooser, | 411 // The AccountChooserModel acts as the MenuModel for the account chooser, |
409 // and also tracks which data source the dialog is using. | 412 // and also tracks which data source the dialog is using. |
410 AccountChooserModel account_chooser_model_; | 413 AccountChooserModel account_chooser_model_; |
411 | 414 |
412 // The sign-in helper to fetch the user info and perform passive sign-in. | 415 // The sign-in helper to fetch the user info and perform passive sign-in. |
413 // The helper is set only during fetch/sign-in, and NULL otherwise. | 416 // The helper is set only during fetch/sign-in, and NULL otherwise. |
414 scoped_ptr<wallet::WalletSigninHelper> signin_helper_; | 417 scoped_ptr<wallet::WalletSigninHelper> signin_helper_; |
415 | 418 |
416 // The user account name (email). | |
417 // Valid only if PayingWithWallet() and SigninState() == SIGNED_IN. | |
418 // Set whenever the sign-in helper fetches the user info. | |
419 // TODO(aruslan): this should be removed (AccountChooser should deal with it). | |
420 std::string current_username_; | |
421 | |
422 // A client to talk to the Online Wallet API. | 419 // A client to talk to the Online Wallet API. |
423 wallet::WalletClient wallet_client_; | 420 wallet::WalletClient wallet_client_; |
424 | 421 |
425 // Recently received items retrieved via |wallet_client_|. | 422 // Recently received items retrieved via |wallet_client_|. |
426 scoped_ptr<wallet::WalletItems> wallet_items_; | 423 scoped_ptr<wallet::WalletItems> wallet_items_; |
427 scoped_ptr<wallet::FullWallet> full_wallet_; | 424 scoped_ptr<wallet::FullWallet> full_wallet_; |
428 | 425 |
429 // The text to display when the user is accepting new terms of service, etc. | 426 // The text to display when the user is accepting new terms of service, etc. |
430 string16 legal_documents_text_; | 427 string16 legal_documents_text_; |
431 // The ranges within |legal_documents_text_| to linkify. | 428 // The ranges within |legal_documents_text_| to linkify. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 | 496 |
500 // Whether or not there was an error in the Autocheckout flow. | 497 // Whether or not there was an error in the Autocheckout flow. |
501 bool had_autocheckout_error_; | 498 bool had_autocheckout_error_; |
502 | 499 |
503 DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerImpl); | 500 DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerImpl); |
504 }; | 501 }; |
505 | 502 |
506 } // namespace autofill | 503 } // namespace autofill |
507 | 504 |
508 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_IMPL_H_ | 505 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_IMPL_H_ |
OLD | NEW |