| 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..2401cf16dcbebd397bc46d73178d1ebdb091a477 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,16 +31,22 @@
|
| #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 {
|
|
|
| namespace {
|
|
|
| +// TODO(dbeam): real URLs.
|
| +const char kPrivacyPolicyUrl[] = "chrome://policy";
|
| +const char kTermsOfServiceUrl[] = "chrome://terms";
|
| +
|
| // Returns true if |input| should be shown when |field| has been requested.
|
| bool InputTypeMatchesFieldType(const DetailInput& input,
|
| const AutofillField& field) {
|
| @@ -270,6 +278,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:
|
| + text = l10n_util::GetStringFUTF16(
|
| + IDS_AUTOFILL_DIALOG_LEGAL_DOC_LINKS_3,
|
| + ASCIIToUTF16(documents[0]->display_name()),
|
| + ASCIIToUTF16(documents[1]->display_name()),
|
| + ASCIIToUTF16(documents[2]->display_name()));
|
| + break;
|
| + }
|
| + 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 +343,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 +588,40 @@ 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());
|
| +
|
| + Browser* browser = chrome::FindBrowserWithWebContents(web_contents());
|
| + GURL url(wallet_items_->legal_documents()[index]->GetUrl());
|
| + chrome::NavigateParams params(browser, url, content::PAGE_TRANSITION_LINK);
|
| + params.disposition = NEW_FOREGROUND_TAB;
|
| +
|
| + chrome::Navigate(¶ms);
|
| +}
|
| +
|
| void AutofillDialogControllerImpl::ViewClosed(DialogAction action) {
|
| if (action == ACTION_SUBMIT) {
|
| FillOutputForSection(SECTION_EMAIL);
|
| @@ -537,55 +645,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 +746,7 @@ void AutofillDialogControllerImpl::OnDidGetWalletItems(
|
| wallet_items_ = wallet_items.Pass();
|
| view_->UpdateAccountChooser();
|
| view_->UpdateNotificationArea();
|
| + view_->UpdateFootnote();
|
| }
|
|
|
| void AutofillDialogControllerImpl::OnDidSaveAddress(
|
| @@ -726,6 +786,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_)
|
|
|