Chromium Code Reviews| 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 0f687368e28d1f41b877715f4ed5d7108d737e58..1b5dfd7caa103bfed26ad1b6066115854b5648f0 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" |
| @@ -29,11 +31,13 @@ |
| #include "content/public/browser/notification_types.h" |
| #include "content/public/browser/web_contents.h" |
| #include "content/public/common/url_constants.h" |
| +#include "googleurl/src/gurl.h" |
| #include "grit/chromium_strings.h" |
| #include "grit/generated_resources.h" |
| #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 { |
| @@ -270,6 +274,58 @@ string16 AutofillDialogControllerImpl::CancelSignInText() const { |
| return string16(ASCIIToUTF16("Don't sign in.")); |
| } |
| +string16 AutofillDialogControllerImpl::SaveLocallyText() const { |
| + return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SAVE_LOCALLY_CHECKBOX); |
| +} |
| + |
| +string16 AutofillDialogControllerImpl::ProgressBarText() const { |
| + return l10n_util::GetStringUTF16( |
| + IDS_AUTOFILL_DIALOG_AUTOCHECKOUT_PROGRESS_BAR); |
| +} |
| + |
| +std::vector<string16> AutofillDialogControllerImpl::FootnoteLinkParts() const { |
| + if (!wallet_items_ || wallet_items_->legal_documents().empty() || |
| + wallet_items_->legal_documents().size() > 3U) { |
| + return std::vector<string16>(); |
| + } |
| + |
| + const std::vector<wallet::WalletItems::LegalDocument*>& documents = |
| + wallet_items_->legal_documents(); |
| + |
| + string16 text; |
| + switch (documents.size()) { |
| + case 1U: |
| + text = l10n_util::GetStringFUTF16( |
| + IDS_AUTOFILL_DIALOG_LEGAL_DOC_LINKS_1, |
| + ASCIIToUTF16(documents[0]->display_name())); |
| + break; |
| + case 2U: |
| + text = l10n_util::GetStringFUTF16( |
| + IDS_AUTOFILL_DIALOG_LEGAL_DOC_LINKS_2, |
| + ASCIIToUTF16(documents[0]->display_name()), |
| + ASCIIToUTF16(documents[1]->display_name())); |
| + break; |
| + case 3U: |
|
ahutter
2013/02/11 16:00:53
Based in our conversations on Friday; this case is
Dan Beam
2013/02/11 19:27:50
Done.
|
| + text = l10n_util::GetStringFUTF16( |
| + IDS_AUTOFILL_DIALOG_LEGAL_DOC_LINKS_3, |
| + ASCIIToUTF16(documents[0]->display_name()), |
|
Evan Stade
2013/02/11 01:05:23
The display name should be string16. That needs to
ahutter
2013/02/11 16:00:53
Can any chrome UI be displayed without string16?
Dan Beam
2013/02/11 19:27:50
Anything that's translated should be string16. Alm
|
| + ASCIIToUTF16(documents[1]->display_name()), |
| + ASCIIToUTF16(documents[2]->display_name())); |
| + break; |
|
Evan Stade
2013/02/11 01:05:23
default: notreached
Dan Beam
2013/02/11 19:27:50
size_t can't be negative, was bailing if size() >
|
| + } |
| + TrimWhitespace(text, TRIM_ALL, &text); |
| + |
| + std::vector<string16> parts; |
| + base::SplitStringDontTrim(text, '|', &parts); |
| + DCHECK_EQ(1U, parts.size() % 2); |
| + |
| + return parts; |
| +} |
| + |
| +string16 AutofillDialogControllerImpl::AcceptChangesText() const { |
| + return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_ACCEPT_CHANGES); |
| +} |
| + |
| DialogSignedInState AutofillDialogControllerImpl::SignedInState() const { |
| if (!wallet_items_) |
| return REQUIRES_RESPONSE; |
| @@ -283,13 +339,27 @@ DialogSignedInState AutofillDialogControllerImpl::SignedInState() const { |
| return SIGNED_IN; |
| } |
| -string16 AutofillDialogControllerImpl::SaveLocallyText() const { |
| - return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SAVE_LOCALLY_CHECKBOX); |
| -} |
| +DialogNotification AutofillDialogControllerImpl::CurrentNotification() const { |
| + if (HasRequiredAction(wallet::VERIFY_CVV)) { |
| + return DialogNotification( |
| + DialogNotification::REQUIRED_ACTION, |
| + l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_VERIFY_CVV)); |
| + } |
| -string16 AutofillDialogControllerImpl::ProgressBarText() const { |
| - return l10n_util::GetStringUTF16( |
| - IDS_AUTOFILL_DIALOG_AUTOCHECKOUT_PROGRESS_BAR); |
| + 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()))); |
| + } |
| + |
| + return DialogNotification(); |
| } |
| const DetailInputs& AutofillDialogControllerImpl::RequestedFieldsForSection( |
| @@ -514,6 +584,43 @@ void AutofillDialogControllerImpl::FocusMoved() { |
| HidePopup(); |
| } |
| +Profile* AutofillDialogControllerImpl::profile() { |
| + return profile_; |
| +} |
| + |
| +content::WebContents* AutofillDialogControllerImpl::web_contents() { |
| + return contents_; |
| +} |
| + |
| +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(); |
| +} |
| + |
| +void AutofillDialogControllerImpl::LegalDocumentLinkClicked(size_t index) { |
| + DCHECK(wallet_items_); |
| + DCHECK_LT(index, wallet_items_->legal_documents().size()); |
| + |
| + GURL url(wallet_items_->legal_documents()[index]->GetUrl()); |
| +#if defined(OS_ANDROID) |
|
Dan Beam
2013/02/09 02:57:13
So I guess Android is failing to compile because i
Evan Stade
2013/02/11 01:05:23
Looks like unit tests and test shell aren't compil
Dan Beam
2013/02/11 19:27:50
Done.
|
| + NOTIMPLEMENTED() << " open: " << url.spec(); |
| +#else |
| + Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); |
| + 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); |
| @@ -537,55 +644,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()))); |
| - } |
| - |
| - 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 |
| @@ -687,6 +745,7 @@ void AutofillDialogControllerImpl::OnDidGetWalletItems( |
| wallet_items_ = wallet_items.Pass(); |
| view_->UpdateAccountChooser(); |
| view_->UpdateNotificationArea(); |
| + view_->UpdateFootnote(); |
| } |
| void AutofillDialogControllerImpl::OnDidSaveAddress( |
| @@ -726,6 +785,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_) |