Commit 9793fb23 authored by dbeam@chromium.org's avatar dbeam@chromium.org

Implement 'invalid' AutocompleteErrorEvent#reason

R=isherman@chromium.org
BUG=168967

Review URL: https://chromiumcodereview.appspot.com/17391012

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207791 0039d316-1c4b-4281-b951-d872f2087c98
parent f6113071
...@@ -8,13 +8,16 @@ ...@@ -8,13 +8,16 @@
#include "base/message_loop.h" #include "base/message_loop.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/time.h" #include "base/time.h"
#include "chrome/browser/autofill/personal_data_manager_factory.h"
#include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h"
#include "chrome/browser/ui/autofill/autofill_dialog_view.h" #include "chrome/browser/ui/autofill/autofill_dialog_view.h"
#include "chrome/browser/ui/autofill/data_model_wrapper.h" #include "chrome/browser/ui/autofill/data_model_wrapper.h"
#include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h"
#include "chrome/browser/ui/autofill/testable_autofill_dialog_view.h" #include "chrome/browser/ui/autofill/testable_autofill_dialog_view.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/autofill/content/browser/wallet/wallet_test_util.h" #include "components/autofill/content/browser/wallet/wallet_test_util.h"
#include "components/autofill/core/browser/autofill_common_test.h" #include "components/autofill/core/browser/autofill_common_test.h"
#include "components/autofill/core/browser/autofill_metrics.h" #include "components/autofill/core/browser/autofill_metrics.h"
...@@ -23,8 +26,13 @@ ...@@ -23,8 +26,13 @@
#include "components/autofill/core/common/autofill_switches.h" #include "components/autofill/core/common/autofill_switches.h"
#include "components/autofill/core/common/form_data.h" #include "components/autofill/core/common/form_data.h"
#include "components/autofill/core/common/form_field_data.h" #include "components/autofill/core/common/form_field_data.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_utils.h" #include "content/public/test/test_utils.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "third_party/WebKit/public/web/WebInputEvent.h"
namespace autofill { namespace autofill {
...@@ -213,10 +221,85 @@ class AutofillDialogControllerTest : public InProcessBrowserTest { ...@@ -213,10 +221,85 @@ class AutofillDialogControllerTest : public InProcessBrowserTest {
message_loop_runner_->Run(); message_loop_runner_->Run();
} }
// Loads an HTML page in |GetActiveWebContents()| with markup as follows:
// <form>|form_inner_html|</form>. After loading, emulates a click event on
// the page as requestAutocomplete() must be in response to a user gesture.
// Returns the |AutofillDialogControllerImpl| created by this invocation.
AutofillDialogControllerImpl* SetUpHtmlAndInvoke(
const std::string& form_inner_html) {
content::WebContents* contents = GetActiveWebContents();
TabAutofillManagerDelegate* delegate =
TabAutofillManagerDelegate::FromWebContents(contents);
DCHECK(!delegate->GetDialogControllerForTesting());
ui_test_utils::NavigateToURL(
browser(), GURL(std::string("data:text/html,") +
"<!doctype html>"
"<html>"
"<body>"
"<form>" + form_inner_html + "</form>"
"<script>"
"function send(msg) {"
"domAutomationController.setAutomationId(0);"
"domAutomationController.send(msg);"
"}"
"document.forms[0].onautocompleteerror = function(e) {"
"send('error: ' + e.reason);"
"};"
"document.forms[0].onautocomplete = function() {"
"send('success');"
"};"
"window.onclick = function() {"
"document.forms[0].requestAutocomplete();"
"send('clicked');"
"};"
"</script>"
"</body>"
"</html>"));
content::WaitForLoadStop(contents);
dom_message_queue_.reset(new content::DOMMessageQueue);
// Triggers the onclick handler which invokes requestAutocomplete().
content::SimulateMouseClick(contents, 0, WebKit::WebMouseEvent::ButtonLeft);
ExpectDomMessage("clicked");
AutofillDialogControllerImpl* controller =
delegate->GetDialogControllerForTesting();
DCHECK(controller);
return controller;
}
// Wait for a message from the DOM automation controller (from JS in the
// page). Requires |SetUpHtmlAndInvoke()| be called first.
void ExpectDomMessage(const std::string& expected) {
std::string message;
ASSERT_TRUE(dom_message_queue_->WaitForMessage(&message));
dom_message_queue_->ClearQueue();
EXPECT_EQ("\"" + expected + "\"", message);
}
void AddCreditcardToProfile(Profile* profile, const CreditCard& card) {
PersonalDataManagerFactory::GetForProfile(profile)->AddCreditCard(card);
WaitForWebDB();
}
void AddAutofillProfileToProfile(Profile* profile,
const AutofillProfile& autofill_profile) {
PersonalDataManagerFactory::GetForProfile(profile)->AddProfile(
autofill_profile);
WaitForWebDB();
}
void WaitForWebDB() {
content::RunAllPendingInMessageLoop(content::BrowserThread::DB);
}
private: private:
MockAutofillMetrics metric_logger_; MockAutofillMetrics metric_logger_;
TestAutofillDialogController* controller_; // Weak reference. TestAutofillDialogController* controller_; // Weak reference.
scoped_refptr<content::MessageLoopRunner> message_loop_runner_; scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
scoped_ptr<content::DOMMessageQueue> dom_message_queue_;
DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerTest); DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerTest);
}; };
...@@ -226,7 +309,7 @@ class AutofillDialogControllerTest : public InProcessBrowserTest { ...@@ -226,7 +309,7 @@ class AutofillDialogControllerTest : public InProcessBrowserTest {
// Submit the form data. // Submit the form data.
IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Submit) { IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Submit) {
InitializeControllerOfType(DIALOG_TYPE_REQUEST_AUTOCOMPLETE); InitializeControllerOfType(DIALOG_TYPE_REQUEST_AUTOCOMPLETE);
controller()->view()->GetTestableView()->SubmitForTesting(); controller()->GetTestableView()->SubmitForTesting();
RunMessageLoop(); RunMessageLoop();
...@@ -238,7 +321,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Submit) { ...@@ -238,7 +321,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Submit) {
// Cancel out of the dialog. // Cancel out of the dialog.
IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Cancel) { IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Cancel) {
InitializeControllerOfType(DIALOG_TYPE_REQUEST_AUTOCOMPLETE); InitializeControllerOfType(DIALOG_TYPE_REQUEST_AUTOCOMPLETE);
controller()->view()->GetTestableView()->CancelForTesting(); controller()->GetTestableView()->CancelForTesting();
RunMessageLoop(); RunMessageLoop();
...@@ -262,14 +345,14 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Hide) { ...@@ -262,14 +345,14 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Hide) {
// Test Autocheckout success metrics. // Test Autocheckout success metrics.
IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, AutocheckoutSuccess) { IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, AutocheckoutSuccess) {
InitializeControllerOfType(DIALOG_TYPE_AUTOCHECKOUT); InitializeControllerOfType(DIALOG_TYPE_AUTOCHECKOUT);
controller()->view()->GetTestableView()->SubmitForTesting(); controller()->GetTestableView()->SubmitForTesting();
EXPECT_EQ(AutofillMetrics::DIALOG_ACCEPTED, EXPECT_EQ(AutofillMetrics::DIALOG_ACCEPTED,
metric_logger().dialog_dismissal_action()); metric_logger().dialog_dismissal_action());
EXPECT_EQ(DIALOG_TYPE_AUTOCHECKOUT, metric_logger().dialog_type()); EXPECT_EQ(DIALOG_TYPE_AUTOCHECKOUT, metric_logger().dialog_type());
controller()->OnAutocheckoutSuccess(); controller()->OnAutocheckoutSuccess();
controller()->view()->GetTestableView()->CancelForTesting(); controller()->GetTestableView()->CancelForTesting();
RunMessageLoop(); RunMessageLoop();
EXPECT_EQ(AutofillMetrics::AUTOCHECKOUT_SUCCEEDED, EXPECT_EQ(AutofillMetrics::AUTOCHECKOUT_SUCCEEDED,
...@@ -284,14 +367,14 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, AutocheckoutSuccess) { ...@@ -284,14 +367,14 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, AutocheckoutSuccess) {
// Test Autocheckout failure metric. // Test Autocheckout failure metric.
IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, AutocheckoutError) { IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, AutocheckoutError) {
InitializeControllerOfType(DIALOG_TYPE_AUTOCHECKOUT); InitializeControllerOfType(DIALOG_TYPE_AUTOCHECKOUT);
controller()->view()->GetTestableView()->SubmitForTesting(); controller()->GetTestableView()->SubmitForTesting();
EXPECT_EQ(AutofillMetrics::DIALOG_ACCEPTED, EXPECT_EQ(AutofillMetrics::DIALOG_ACCEPTED,
metric_logger().dialog_dismissal_action()); metric_logger().dialog_dismissal_action());
EXPECT_EQ(DIALOG_TYPE_AUTOCHECKOUT, metric_logger().dialog_type()); EXPECT_EQ(DIALOG_TYPE_AUTOCHECKOUT, metric_logger().dialog_type());
controller()->OnAutocheckoutError(); controller()->OnAutocheckoutError();
controller()->view()->GetTestableView()->CancelForTesting(); controller()->GetTestableView()->CancelForTesting();
RunMessageLoop(); RunMessageLoop();
EXPECT_EQ(AutofillMetrics::AUTOCHECKOUT_FAILED, EXPECT_EQ(AutofillMetrics::AUTOCHECKOUT_FAILED,
...@@ -305,13 +388,13 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, AutocheckoutError) { ...@@ -305,13 +388,13 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, AutocheckoutError) {
IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, AutocheckoutCancelled) { IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, AutocheckoutCancelled) {
InitializeControllerOfType(DIALOG_TYPE_AUTOCHECKOUT); InitializeControllerOfType(DIALOG_TYPE_AUTOCHECKOUT);
controller()->view()->GetTestableView()->SubmitForTesting(); controller()->GetTestableView()->SubmitForTesting();
EXPECT_EQ(AutofillMetrics::DIALOG_ACCEPTED, EXPECT_EQ(AutofillMetrics::DIALOG_ACCEPTED,
metric_logger().dialog_dismissal_action()); metric_logger().dialog_dismissal_action());
EXPECT_EQ(DIALOG_TYPE_AUTOCHECKOUT, metric_logger().dialog_type()); EXPECT_EQ(DIALOG_TYPE_AUTOCHECKOUT, metric_logger().dialog_type());
controller()->view()->GetTestableView()->CancelForTesting(); controller()->GetTestableView()->CancelForTesting();
RunMessageLoop(); RunMessageLoop();
EXPECT_EQ(AutofillMetrics::AUTOCHECKOUT_CANCELLED, EXPECT_EQ(AutofillMetrics::AUTOCHECKOUT_CANCELLED,
...@@ -334,7 +417,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, FillInputFromAutofill) { ...@@ -334,7 +417,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, FillInputFromAutofill) {
controller()->RequestedFieldsForSection(SECTION_SHIPPING); controller()->RequestedFieldsForSection(SECTION_SHIPPING);
const DetailInput& triggering_input = inputs[0]; const DetailInput& triggering_input = inputs[0];
string16 value = full_profile.GetRawInfo(triggering_input.type); string16 value = full_profile.GetRawInfo(triggering_input.type);
TestableAutofillDialogView* view = controller()->view()->GetTestableView(); TestableAutofillDialogView* view = controller()->GetTestableView();
view->SetTextContentsOfInput(triggering_input, view->SetTextContentsOfInput(triggering_input,
value.substr(0, value.size() / 2)); value.substr(0, value.size() / 2));
view->ActivateInput(triggering_input); view->ActivateInput(triggering_input);
...@@ -381,7 +464,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, ...@@ -381,7 +464,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest,
EXPECT_TRUE(controller()->ShouldShowDetailArea()); EXPECT_TRUE(controller()->ShouldShowDetailArea());
EXPECT_FALSE(controller()->ShouldShowProgressBar()); EXPECT_FALSE(controller()->ShouldShowProgressBar());
controller()->view()->GetTestableView()->SubmitForTesting(); controller()->GetTestableView()->SubmitForTesting();
EXPECT_FALSE(controller()->ShouldShowDetailArea()); EXPECT_FALSE(controller()->ShouldShowDetailArea());
EXPECT_TRUE(controller()->ShouldShowProgressBar()); EXPECT_TRUE(controller()->ShouldShowProgressBar());
} }
...@@ -394,7 +477,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, ...@@ -394,7 +477,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest,
EXPECT_TRUE(controller()->ShouldShowDetailArea()); EXPECT_TRUE(controller()->ShouldShowDetailArea());
EXPECT_FALSE(controller()->ShouldShowProgressBar()); EXPECT_FALSE(controller()->ShouldShowProgressBar());
controller()->view()->GetTestableView()->SubmitForTesting(); controller()->GetTestableView()->SubmitForTesting();
EXPECT_TRUE(controller()->ShouldShowDetailArea()); EXPECT_TRUE(controller()->ShouldShowDetailArea());
EXPECT_FALSE(controller()->ShouldShowProgressBar()); EXPECT_FALSE(controller()->ShouldShowProgressBar());
} }
...@@ -418,7 +501,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, FillComboboxFromAutofill) { ...@@ -418,7 +501,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, FillComboboxFromAutofill) {
controller()->RequestedFieldsForSection(SECTION_CC); controller()->RequestedFieldsForSection(SECTION_CC);
const DetailInput& triggering_input = inputs[0]; const DetailInput& triggering_input = inputs[0];
string16 value = card1.GetRawInfo(triggering_input.type); string16 value = card1.GetRawInfo(triggering_input.type);
TestableAutofillDialogView* view = controller()->view()->GetTestableView(); TestableAutofillDialogView* view = controller()->GetTestableView();
view->SetTextContentsOfInput(triggering_input, view->SetTextContentsOfInput(triggering_input,
value.substr(0, value.size() / 2)); value.substr(0, value.size() / 2));
view->ActivateInput(triggering_input); view->ActivateInput(triggering_input);
...@@ -561,7 +644,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, LongNotifications) { ...@@ -561,7 +644,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, LongNotifications) {
InitializeControllerOfType(DIALOG_TYPE_REQUEST_AUTOCOMPLETE); InitializeControllerOfType(DIALOG_TYPE_REQUEST_AUTOCOMPLETE);
const gfx::Size no_notification_size = const gfx::Size no_notification_size =
controller()->view()->GetTestableView()->GetSize(); controller()->GetTestableView()->GetSize();
ASSERT_GT(no_notification_size.width(), 0); ASSERT_GT(no_notification_size.width(), 0);
std::vector<DialogNotification> notifications; std::vector<DialogNotification> notifications;
...@@ -578,7 +661,47 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, LongNotifications) { ...@@ -578,7 +661,47 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, LongNotifications) {
controller()->view()->UpdateNotificationArea(); controller()->view()->UpdateNotificationArea();
EXPECT_EQ(no_notification_size.width(), EXPECT_EQ(no_notification_size.width(),
controller()->view()->GetTestableView()->GetSize().width()); controller()->GetTestableView()->GetSize().width());
}
IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, AutocompleteEvent) {
AutofillDialogControllerImpl* controller =
SetUpHtmlAndInvoke("<input autocomplete='cc-name'>");
AddCreditcardToProfile(controller->profile(), test::GetVerifiedCreditCard());
AddAutofillProfileToProfile(controller->profile(),
test::GetVerifiedProfile());
TestableAutofillDialogView* view = controller->GetTestableView();
view->SetTextContentsOfSuggestionInput(SECTION_CC, ASCIIToUTF16("123"));
view->SubmitForTesting();
ExpectDomMessage("success");
}
IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest,
AutocompleteErrorEventReasonInvalid) {
AutofillDialogControllerImpl* controller =
SetUpHtmlAndInvoke("<input autocomplete='cc-name' pattern='.*zebra.*'>");
const CreditCard& credit_card = test::GetVerifiedCreditCard();
ASSERT_TRUE(
credit_card.GetRawInfo(CREDIT_CARD_NAME).find(ASCIIToUTF16("zebra")) ==
base::string16::npos);
AddCreditcardToProfile(controller->profile(), credit_card);
AddAutofillProfileToProfile(controller->profile(),
test::GetVerifiedProfile());
TestableAutofillDialogView* view = controller->GetTestableView();
view->SetTextContentsOfSuggestionInput(SECTION_CC, ASCIIToUTF16("123"));
view->SubmitForTesting();
ExpectDomMessage("error: invalid");
}
IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest,
AutocompleteErrorEventReasonCancel) {
SetUpHtmlAndInvoke("<input autocomplete='cc-name'>")->GetTestableView()->
CancelForTesting();
ExpectDomMessage("error: cancel");
} }
IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, NoCvcSegfault) { IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, NoCvcSegfault) {
...@@ -591,7 +714,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, NoCvcSegfault) { ...@@ -591,7 +714,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, NoCvcSegfault) {
EXPECT_FALSE(controller()->IsEditingExistingData(SECTION_CC)); EXPECT_FALSE(controller()->IsEditingExistingData(SECTION_CC));
ASSERT_NO_FATAL_FAILURE( ASSERT_NO_FATAL_FAILURE(
controller()->view()->GetTestableView()->SubmitForTesting()); controller()->GetTestableView()->SubmitForTesting());
} }
#endif // defined(TOOLKIT_VIEWS) #endif // defined(TOOLKIT_VIEWS)
......
...@@ -597,6 +597,10 @@ void AutofillDialogControllerImpl::OnAutocheckoutSuccess() { ...@@ -597,6 +597,10 @@ void AutofillDialogControllerImpl::OnAutocheckoutSuccess() {
view_->UpdateButtonStrip(); view_->UpdateButtonStrip();
} }
TestableAutofillDialogView* AutofillDialogControllerImpl::GetTestableView() {
return view_ ? view_->GetTestableView() : NULL;
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// AutofillDialogController implementation. // AutofillDialogController implementation.
......
...@@ -53,6 +53,7 @@ class AutofillDataModel; ...@@ -53,6 +53,7 @@ class AutofillDataModel;
class AutofillDialogView; class AutofillDialogView;
class AutofillPopupControllerImpl; class AutofillPopupControllerImpl;
class DataModelWrapper; class DataModelWrapper;
class TestableAutofillDialogView;
namespace risk { namespace risk {
class Fingerprint; class Fingerprint;
...@@ -101,6 +102,10 @@ class AutofillDialogControllerImpl : public AutofillDialogController, ...@@ -101,6 +102,10 @@ class AutofillDialogControllerImpl : public AutofillDialogController,
// Called when an Autocheckout flow completes successfully. // Called when an Autocheckout flow completes successfully.
void OnAutocheckoutSuccess(); void OnAutocheckoutSuccess();
// Returns |view_| as a testable version of itself (if |view_| exists and
// actually implements |AutofillDialogView::GetTestableView()|).
TestableAutofillDialogView* GetTestableView();
// AutofillDialogController implementation. // AutofillDialogController implementation.
virtual string16 DialogTitle() const OVERRIDE; virtual string16 DialogTitle() const OVERRIDE;
virtual string16 AccountChooserText() const OVERRIDE; virtual string16 AccountChooserText() const OVERRIDE;
......
...@@ -75,6 +75,11 @@ class TabAutofillManagerDelegate ...@@ -75,6 +75,11 @@ class TabAutofillManagerDelegate
const content::LoadCommittedDetails& details, const content::LoadCommittedDetails& details,
const content::FrameNavigateParams& params) OVERRIDE; const content::FrameNavigateParams& params) OVERRIDE;
// Exposed for testing.
AutofillDialogControllerImpl* GetDialogControllerForTesting() {
return dialog_controller_.get();
}
private: private:
explicit TabAutofillManagerDelegate(content::WebContents* web_contents); explicit TabAutofillManagerDelegate(content::WebContents* web_contents);
friend class content::WebContentsUserData<TabAutofillManagerDelegate>; friend class content::WebContentsUserData<TabAutofillManagerDelegate>;
......
...@@ -26,6 +26,10 @@ class TestableAutofillDialogView { ...@@ -26,6 +26,10 @@ class TestableAutofillDialogView {
virtual void SetTextContentsOfInput(const DetailInput& input, virtual void SetTextContentsOfInput(const DetailInput& input,
const string16& contents) = 0; const string16& contents) = 0;
// Sets the content of the extra field for a section.
virtual void SetTextContentsOfSuggestionInput(DialogSection section,
const base::string16& text) = 0;
// Simulates a user activatino of the input which is modelled by |input|. // Simulates a user activatino of the input which is modelled by |input|.
virtual void ActivateInput(const DetailInput& input) = 0; virtual void ActivateInput(const DetailInput& input) = 0;
......
...@@ -1219,6 +1219,13 @@ void AutofillDialogViews::SetTextContentsOfInput(const DetailInput& input, ...@@ -1219,6 +1219,13 @@ void AutofillDialogViews::SetTextContentsOfInput(const DetailInput& input,
NOTREACHED(); NOTREACHED();
} }
void AutofillDialogViews::SetTextContentsOfSuggestionInput(
DialogSection section,
const base::string16& text) {
GroupForSection(section)->suggested_info->decorated_textfield()->
SetText(text);
}
void AutofillDialogViews::ActivateInput(const DetailInput& input) { void AutofillDialogViews::ActivateInput(const DetailInput& input) {
TextfieldEditedOrActivated(TextfieldForInput(input), false); TextfieldEditedOrActivated(TextfieldForInput(input), false);
} }
......
...@@ -103,6 +103,9 @@ class AutofillDialogViews : public AutofillDialogView, ...@@ -103,6 +103,9 @@ class AutofillDialogViews : public AutofillDialogView,
virtual string16 GetTextContentsOfInput(const DetailInput& input) OVERRIDE; virtual string16 GetTextContentsOfInput(const DetailInput& input) OVERRIDE;
virtual void SetTextContentsOfInput(const DetailInput& input, virtual void SetTextContentsOfInput(const DetailInput& input,
const string16& contents) OVERRIDE; const string16& contents) OVERRIDE;
virtual void SetTextContentsOfSuggestionInput(
DialogSection section,
const base::string16& text) OVERRIDE;
virtual void ActivateInput(const DetailInput& input) OVERRIDE; virtual void ActivateInput(const DetailInput& input) OVERRIDE;
virtual gfx::Size GetSize() const OVERRIDE; virtual gfx::Size GetSize() const OVERRIDE;
......
...@@ -744,8 +744,11 @@ void AutofillAgent::OnRequestAutocompleteResult( ...@@ -744,8 +744,11 @@ void AutofillAgent::OnRequestAutocompleteResult(
if (in_flight_request_form_.isNull()) if (in_flight_request_form_.isNull())
return; return;
if (result == WebFormElement::AutocompleteResultSuccess) if (result == WebFormElement::AutocompleteResultSuccess) {
FillFormIncludingNonFocusableElements(form_data, in_flight_request_form_); FillFormIncludingNonFocusableElements(form_data, in_flight_request_form_);
if (!in_flight_request_form_.checkValidityWithoutDispatchingEvents())
result = WebFormElement::AutocompleteResultErrorInvalid;
}
in_flight_request_form_.finishRequestAutocomplete(result); in_flight_request_form_.finishRequestAutocomplete(result);
in_flight_request_form_.reset(); in_flight_request_form_.reset();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment