Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(282)

Unified Diff: chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc

Issue 12225095: Interactive autofill: Adds footnote view to accept legal documents in the UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..b2b6c38714baafced5b554642c40588e27006fea 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,36 @@ 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::pair<std::vector<string16>, string16>
+ AutofillDialogControllerImpl::FootnoteTextParts() const {
+ string16 full_translation = l10n_util::GetStringFUTF16(
+ IDS_AUTOFILL_DIALOG_ACCEPT_TERMS, ConfirmButtonText());
Evan Stade 2013/02/08 15:38:53 Just make confirmbuttontext part of the translatio
Dan Beam 2013/02/08 20:53:06 Done.
+ TrimWhitespace(full_translation, TRIM_ALL, &full_translation);
+
+ std::vector<string16> sentences;
+ base::SplitString(full_translation, '\n', &sentences);
+ DCHECK_EQ(2U, sentences.size());
+
+ std::vector<string16> parts;
+ base::SplitStringDontTrim(sentences.front(), '|', &parts);
+ DCHECK_EQ(5U, parts.size());
+
+ return std::make_pair(parts, sentences.back());
Evan Stade 2013/02/08 15:38:53 Instead of front and back, use operator[]
Dan Beam 2013/02/08 20:53:06 Done. (but why?)
+}
+
+bool AutofillDialogControllerImpl::IsFootnoteShowing() const {
+ return HasRequiredAction(wallet::ACCEPT_TOS);
+}
+
DialogSignedInState AutofillDialogControllerImpl::SignedInState() const {
if (!wallet_items_)
return REQUIRES_RESPONSE;
@@ -283,13 +321,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 +566,36 @@ 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::ShowTermsOfService() {
+ OpenInNewTab(GURL(kTermsOfServiceUrl));
+}
+
+void AutofillDialogControllerImpl::ShowPrivacyPolicy() {
+ OpenInNewTab(GURL(kPrivacyPolicyUrl));
+}
+
void AutofillDialogControllerImpl::ViewClosed(DialogAction action) {
if (action == ACTION_SUBMIT) {
FillOutputForSection(SECTION_EMAIL);
@@ -537,55 +619,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 +720,7 @@ void AutofillDialogControllerImpl::OnDidGetWalletItems(
wallet_items_ = wallet_items.Pass();
view_->UpdateAccountChooser();
view_->UpdateNotificationArea();
+ view_->UpdateFootnote();
}
void AutofillDialogControllerImpl::OnDidSaveAddress(
@@ -726,6 +760,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_)
@@ -954,4 +992,12 @@ void AutofillDialogControllerImpl::HidePopup() {
popup_controller_->Hide();
}
+void AutofillDialogControllerImpl::OpenInNewTab(const GURL& url) {
+ Browser* browser = chrome::FindOrCreateTabbedBrowser(
+ profile_, chrome::GetActiveDesktop());
Evan Stade 2013/02/08 15:38:53 You want to get the browser from the web contents
Dan Beam 2013/02/08 20:53:06 Done. Btw, can this API ever be triggered by a non
Evan Stade 2013/02/11 01:05:23 Potentially. It could be used in a popup browser w
Dan Beam 2013/02/11 16:45:18 Why wouldn't we want to find or created a *tabbed*
Evan Stade 2013/02/12 01:36:54 Well, the code you currently have might add a new
+ chrome::NavigateParams params(browser, url, content::PAGE_TRANSITION_LINK);
+ params.disposition = NEW_FOREGROUND_TAB;
+ chrome::Navigate(&params);
+}
+
} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698