Index: chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc |
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc |
index 98ab9b1e525ff6e1ae54dac064d183887875a280..7d7bba5667e7ba6a341cc9b87a9718abb7727b68 100644 |
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc |
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc |
@@ -21,6 +21,8 @@ |
#include "chrome/browser/autofill/wallet/wallet_service_url.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/ui/autofill/autofill_dialog_view.h" |
+#include "chrome/browser/ui/browser_finder.h" |
+#include "chrome/browser/ui/browser_navigator.h" |
#include "chrome/common/form_data.h" |
#include "content/public/browser/navigation_controller.h" |
#include "content/public/browser/navigation_details.h" |
@@ -34,6 +36,7 @@ |
#include "net/base/cert_status_flags.h" |
#include "ui/base/l10n/l10n_util.h" |
#include "ui/base/resource/resource_bundle.h" |
+#include "ui/base/window_open_disposition.h" |
namespace autofill { |
@@ -235,6 +238,8 @@ void AutofillDialogControllerImpl::Hide() { |
//////////////////////////////////////////////////////////////////////////////// |
// AutofillDialogController implementation. |
+// Strings --------------------------------------------------------------------- |
+ |
string16 AutofillDialogControllerImpl::DialogTitle() const { |
return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_TITLE); |
} |
@@ -275,21 +280,46 @@ string16 AutofillDialogControllerImpl::ProgressBarText() const { |
IDS_AUTOFILL_DIALOG_AUTOCHECKOUT_PROGRESS_BAR); |
} |
-DialogSignedInState AutofillDialogControllerImpl::SignedInState() const { |
- if (!wallet_items_) |
- return REQUIRES_RESPONSE; |
+std::vector<string16> AutofillDialogControllerImpl::FootnoteLinkParts() const { |
+ if (!wallet_items_ || wallet_items_->legal_documents().empty()) |
+ return std::vector<string16>(); |
- if (HasRequiredAction(wallet::GAIA_AUTH)) |
- return REQUIRES_SIGN_IN; |
+ const std::vector<wallet::WalletItems::LegalDocument*>& documents = |
+ wallet_items_->legal_documents(); |
+ DCHECK_LE(documents.size(), 2U); |
- if (HasRequiredAction(wallet::PASSIVE_GAIA_AUTH)) |
- return REQUIRES_PASSIVE_SIGN_IN; |
+ const bool new_user = HasRequiredAction(wallet::SETUP_WALLET); |
- return SIGNED_IN; |
+ string16 text; |
+ switch (documents.size()) { |
+ case 1U: |
+ text = l10n_util::GetStringFUTF16( |
+ new_user ? IDS_AUTOFILL_DIALOG_LEGAL_LINKS_NEW_2 : |
+ IDS_AUTOFILL_DIALOG_LEGAL_LINKS_UPDATED_2, |
+ documents[0]->display_name(), |
+ l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_PRIVACY_NOTICE)); |
+ break; |
+ case 2U: |
+ text = l10n_util::GetStringFUTF16( |
+ new_user ? IDS_AUTOFILL_DIALOG_LEGAL_LINKS_NEW_3 : |
+ IDS_AUTOFILL_DIALOG_LEGAL_LINKS_UPDATED_3, |
+ documents[0]->display_name(), |
+ documents[1]->display_name(), |
+ l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_PRIVACY_NOTICE)); |
+ break; |
+ } |
+ TrimWhitespace(text, TRIM_ALL, &text); |
+ |
+ std::vector<string16> parts; |
+ base::SplitStringDontTrim(text, '|', &parts); |
+ DCHECK_EQ(1U, parts.size() % 2); |
+ |
+ return parts; |
} |
-bool AutofillDialogControllerImpl::CanPayWithWallet() const { |
- return !had_wallet_error_; |
+string16 AutofillDialogControllerImpl::AcceptFootnoteLinksText() const { |
+ return l10n_util::GetStringUTF16(HasRequiredAction(wallet::SETUP_WALLET) ? |
+ IDS_AUTOFILL_DIALOG_ACCEPT_NEW : IDS_AUTOFILL_DIALOG_ACCEPT_UPDATE); |
} |
string16 AutofillDialogControllerImpl::AccountChooserText() const { |
@@ -302,6 +332,8 @@ string16 AutofillDialogControllerImpl::AccountChooserText() const { |
ASCIIToUTF16("user@example.com"); |
} |
+// State ----------------------------------------------------------------------- |
+ |
bool AutofillDialogControllerImpl::AccountChooserEnabled() const { |
if (!CanPayWithWallet()) |
return false; |
@@ -310,6 +342,57 @@ bool AutofillDialogControllerImpl::AccountChooserEnabled() const { |
return state != REQUIRES_RESPONSE && state != SIGNED_IN; |
} |
+bool AutofillDialogControllerImpl::CanPayWithWallet() const { |
+ return !had_wallet_error_; |
+} |
+ |
+DialogNotification AutofillDialogControllerImpl::CurrentNotification() const { |
+ if (HasRequiredAction(wallet::VERIFY_CVV)) { |
+ return DialogNotification( |
+ DialogNotification::REQUIRED_ACTION, |
+ l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_VERIFY_CVV)); |
+ } |
+ |
+ if (RequestingCreditCardInfo() && !TransmissionWillBeSecure()) { |
+ return DialogNotification( |
+ DialogNotification::SECURITY_WARNING, |
+ l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SECURITY_WARNING)); |
+ } |
+ |
+ if (!invoked_from_same_origin_) { |
+ return DialogNotification( |
+ DialogNotification::SECURITY_WARNING, |
+ l10n_util::GetStringFUTF16( |
+ IDS_AUTOFILL_DIALOG_SITE_WARNING, UTF8ToUTF16(source_url_.host()))); |
+ } |
+ |
+ if (!CanPayWithWallet()) { |
+ // TODO(dbeam): pass along the Wallet error or remove from the translation. |
+ return DialogNotification( |
+ DialogNotification::WALLET_ERROR, |
+ l10n_util::GetStringFUTF16( |
+ IDS_AUTOFILL_DIALOG_COMPLETE_WITHOUT_WALLET, |
+ ASCIIToUTF16("Oops, [Wallet-Error]."))); |
+ } |
+ |
+ return DialogNotification(); |
+} |
+ |
+DialogSignedInState AutofillDialogControllerImpl::SignedInState() const { |
+ if (!wallet_items_) |
+ return REQUIRES_RESPONSE; |
+ |
+ if (HasRequiredAction(wallet::GAIA_AUTH)) |
+ return REQUIRES_SIGN_IN; |
+ |
+ if (HasRequiredAction(wallet::PASSIVE_GAIA_AUTH)) |
+ return REQUIRES_PASSIVE_SIGN_IN; |
+ |
+ return SIGNED_IN; |
+} |
+ |
+// Detail inputs --------------------------------------------------------------- |
+ |
const DetailInputs& AutofillDialogControllerImpl::RequestedFieldsForSection( |
DialogSection section) const { |
switch (section) { |
@@ -554,6 +637,52 @@ void AutofillDialogControllerImpl::FocusMoved() { |
HidePopup(); |
} |
+// Actions --------------------------------------------------------------------- |
+ |
+void AutofillDialogControllerImpl::StartSignInFlow() { |
+ DCHECK(registrar_.IsEmpty()); |
+ |
+ content::Source<content::NavigationController> source( |
+ &view_->ShowSignIn()); |
+ registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, source); |
+} |
+ |
+void AutofillDialogControllerImpl::EndSignInFlow() { |
+ DCHECK(!registrar_.IsEmpty()); |
+ registrar_.RemoveAll(); |
+ view_->HideSignIn(); |
+} |
+ |
+// Accessors ------------------------------------------------------------------- |
+ |
+Profile* AutofillDialogControllerImpl::profile() { |
+ return profile_; |
+} |
+ |
+content::WebContents* AutofillDialogControllerImpl::web_contents() { |
+ return contents_; |
+} |
+ |
+// Event handlers -------------------------------------------------------------- |
+ |
+void AutofillDialogControllerImpl::LegalDocumentLinkClicked(int index) { |
+ DCHECK(wallet_items_); |
+ DCHECK_GE(index, 0); |
+ DCHECK_LE(index, static_cast<int>(wallet_items_->legal_documents().size())); |
+ |
+#if defined(OS_ANDROID) |
+ // TODO(dbeam): make this work on Android, right now it's not compiling. |
+#else |
+ Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); |
+ GURL url(index == static_cast<int>(wallet_items_->legal_documents().size()) ? |
+ GURL(wallet::kPrivacyNoticeUrl) : |
+ wallet_items_->legal_documents()[index]->GetUrl()); |
+ chrome::NavigateParams params(browser, url, content::PAGE_TRANSITION_LINK); |
+ params.disposition = NEW_FOREGROUND_TAB; |
+ chrome::Navigate(¶ms); |
+#endif |
+} |
+ |
void AutofillDialogControllerImpl::ViewClosed(DialogAction action) { |
if (action == ACTION_SUBMIT) { |
FillOutputForSection(SECTION_EMAIL); |
@@ -577,63 +706,6 @@ void AutofillDialogControllerImpl::ViewClosed(DialogAction action) { |
delete this; |
} |
-void AutofillDialogControllerImpl::UpdateProgressBar(double value) { |
- view_->UpdateProgressBar(value); |
-} |
- |
-DialogNotification AutofillDialogControllerImpl::CurrentNotification() const { |
- if (HasRequiredAction(wallet::VERIFY_CVV)) { |
- return DialogNotification( |
- DialogNotification::REQUIRED_ACTION, |
- l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_VERIFY_CVV)); |
- } |
- |
- if (RequestingCreditCardInfo() && !TransmissionWillBeSecure()) { |
- return DialogNotification( |
- DialogNotification::SECURITY_WARNING, |
- l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SECURITY_WARNING)); |
- } |
- |
- if (!invoked_from_same_origin_) { |
- return DialogNotification( |
- DialogNotification::SECURITY_WARNING, |
- l10n_util::GetStringFUTF16( |
- IDS_AUTOFILL_DIALOG_SITE_WARNING, UTF8ToUTF16(source_url_.host()))); |
- } |
- |
- if (!CanPayWithWallet()) { |
- // TODO(dbeam): pass along the Wallet error or remove from the translation. |
- return DialogNotification( |
- DialogNotification::WALLET_ERROR, |
- l10n_util::GetStringFUTF16( |
- IDS_AUTOFILL_DIALOG_COMPLETE_WITHOUT_WALLET, |
- ASCIIToUTF16("Oops, [Wallet-Error]."))); |
- } |
- |
- return DialogNotification(); |
-} |
- |
-void AutofillDialogControllerImpl::StartSignInFlow() { |
- DCHECK(registrar_.IsEmpty()); |
- |
- content::Source<content::NavigationController> source(&view_->ShowSignIn()); |
- registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, source); |
-} |
- |
-void AutofillDialogControllerImpl::EndSignInFlow() { |
- DCHECK(!registrar_.IsEmpty()); |
- registrar_.RemoveAll(); |
- view_->HideSignIn(); |
-} |
- |
-Profile* AutofillDialogControllerImpl::profile() { |
- return profile_; |
-} |
- |
-content::WebContents* AutofillDialogControllerImpl::web_contents() { |
- return contents_; |
-} |
- |
//////////////////////////////////////////////////////////////////////////////// |
// AutofillPopupDelegate |
@@ -738,6 +810,7 @@ void AutofillDialogControllerImpl::OnDidGetWalletItems( |
if (items_changed) { |
view_->UpdateAccountChooser(); |
view_->UpdateNotificationArea(); |
+ view_->UpdateFootnote(); |
} |
} |
@@ -784,6 +857,10 @@ void AutofillDialogControllerImpl::OnNetworkError(int response_code) { |
//////////////////////////////////////////////////////////////////////////////// |
+void AutofillDialogControllerImpl::UpdateProgressBar(double value) { |
+ view_->UpdateProgressBar(value); |
+} |
+ |
bool AutofillDialogControllerImpl::HandleKeyPressEventInInput( |
const content::NativeWebKeyboardEvent& event) { |
if (popup_controller_) |