diff options
27 files changed, 102 insertions, 33 deletions
diff --git a/android_webview/browser/aw_autofill_manager_delegate.cc b/android_webview/browser/aw_autofill_manager_delegate.cc index 46b43ad..bc9c726 100644 --- a/android_webview/browser/aw_autofill_manager_delegate.cc +++ b/android_webview/browser/aw_autofill_manager_delegate.cc @@ -109,6 +109,7 @@ void AwAutofillManagerDelegate::ShowRequestAutocompleteDialog( void AwAutofillManagerDelegate::ShowAutofillPopup( const gfx::RectF& element_bounds, + base::i18n::TextDirection text_direction, const std::vector<string16>& values, const std::vector<string16>& labels, const std::vector<string16>& icons, diff --git a/android_webview/browser/aw_autofill_manager_delegate.h b/android_webview/browser/aw_autofill_manager_delegate.h index c65b736..b1635d2 100644 --- a/android_webview/browser/aw_autofill_manager_delegate.h +++ b/android_webview/browser/aw_autofill_manager_delegate.h @@ -68,6 +68,7 @@ class AwAutofillManagerDelegate : const std::string&)>& callback) OVERRIDE; virtual void ShowAutofillPopup( const gfx::RectF& element_bounds, + base::i18n::TextDirection text_direction, const std::vector<string16>& values, const std::vector<string16>& labels, const std::vector<string16>& icons, diff --git a/base/i18n/rtl.h b/base/i18n/rtl.h index 5cae05e..c80d2f8 100644 --- a/base/i18n/rtl.h +++ b/base/i18n/rtl.h @@ -31,6 +31,7 @@ enum TextDirection { UNKNOWN_DIRECTION = 0, RIGHT_TO_LEFT = 1, LEFT_TO_RIGHT = 2, + TEXT_DIRECTION_NUM_DIRECTIONS = 3, }; // Get the locale that the currently running process has been configured to use. diff --git a/chrome/browser/autofill/autofill_external_delegate_browsertest.cc b/chrome/browser/autofill/autofill_external_delegate_browsertest.cc index 87c7200..b0d2fe57 100644 --- a/chrome/browser/autofill/autofill_external_delegate_browsertest.cc +++ b/chrome/browser/autofill/autofill_external_delegate_browsertest.cc @@ -39,8 +39,9 @@ class MockAutofillManagerDelegate return prefs_.registry(); } - MOCK_METHOD6(ShowAutofillPopup, + MOCK_METHOD7(ShowAutofillPopup, void(const gfx::RectF& element_bounds, + base::i18n::TextDirection text_direction, const std::vector<string16>& values, const std::vector<string16>& labels, const std::vector<string16>& icons, diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc index c942a38..12deabdd 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc @@ -10,6 +10,7 @@ #include "base/base64.h" #include "base/bind.h" +#include "base/i18n/rtl.h" #include "base/logging.h" #include "base/prefs/pref_service.h" #include "base/strings/string_number_conversions.h" @@ -1459,7 +1460,9 @@ void AutofillDialogControllerImpl::UserEditedOrActivatedInput( popup_controller_, weak_ptr_factory_.GetWeakPtr(), parent_view, - content_bounds); + content_bounds, + base::i18n::IsRTL() ? + base::i18n::RIGHT_TO_LEFT : base::i18n::LEFT_TO_RIGHT); popup_controller_->Show(popup_values, popup_labels, popup_icons, diff --git a/chrome/browser/ui/autofill/autofill_popup_controller.h b/chrome/browser/ui/autofill/autofill_popup_controller.h index ed2326c..bd01635 100644 --- a/chrome/browser/ui/autofill/autofill_popup_controller.h +++ b/chrome/browser/ui/autofill/autofill_popup_controller.h @@ -67,6 +67,9 @@ class AutofillPopupController { // The bounds of the form field element (screen coordinates). virtual const gfx::RectF& element_bounds() const = 0; + // If the current popup should be displayed in RTL mode. + virtual bool IsRTL() const = 0; + // TODO(csharp): The names, subtexts and icon getters can probably be adjusted // to take in the row index and return a single element, instead of the // whole vector. diff --git a/chrome/browser/ui/autofill/autofill_popup_controller_impl.cc b/chrome/browser/ui/autofill/autofill_popup_controller_impl.cc index b87fb40..d6a5596 100644 --- a/chrome/browser/ui/autofill/autofill_popup_controller_impl.cc +++ b/chrome/browser/ui/autofill/autofill_popup_controller_impl.cc @@ -72,7 +72,8 @@ WeakPtr<AutofillPopupControllerImpl> AutofillPopupControllerImpl::GetOrCreate( WeakPtr<AutofillPopupControllerImpl> previous, WeakPtr<AutofillPopupDelegate> delegate, gfx::NativeView container_view, - const gfx::RectF& element_bounds) { + const gfx::RectF& element_bounds, + base::i18n::TextDirection text_direction) { DCHECK(!previous.get() || previous->delegate_.get() == delegate.get()); if (previous.get() && previous->container_view() == container_view && @@ -85,18 +86,21 @@ WeakPtr<AutofillPopupControllerImpl> AutofillPopupControllerImpl::GetOrCreate( previous->Hide(); AutofillPopupControllerImpl* controller = - new AutofillPopupControllerImpl(delegate, container_view, element_bounds); + new AutofillPopupControllerImpl( + delegate, container_view, element_bounds, text_direction); return controller->GetWeakPtr(); } AutofillPopupControllerImpl::AutofillPopupControllerImpl( base::WeakPtr<AutofillPopupDelegate> delegate, gfx::NativeView container_view, - const gfx::RectF& element_bounds) + const gfx::RectF& element_bounds, + base::i18n::TextDirection text_direction) : view_(NULL), delegate_(delegate), container_view_(container_view), element_bounds_(element_bounds), + text_direction_(text_direction), weak_ptr_factory_(this) { ClearState(); #if !defined(OS_ANDROID) @@ -296,6 +300,10 @@ const gfx::RectF& AutofillPopupControllerImpl::element_bounds() const { return element_bounds_; } +bool AutofillPopupControllerImpl::IsRTL() const { + return text_direction_ == base::i18n::RIGHT_TO_LEFT; +} + const std::vector<string16>& AutofillPopupControllerImpl::names() const { return names_; } diff --git a/chrome/browser/ui/autofill/autofill_popup_controller_impl.h b/chrome/browser/ui/autofill/autofill_popup_controller_impl.h index a25ad9d..f26fcf9 100644 --- a/chrome/browser/ui/autofill/autofill_popup_controller_impl.h +++ b/chrome/browser/ui/autofill/autofill_popup_controller_impl.h @@ -6,6 +6,7 @@ #define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_IMPL_H_ #include "base/gtest_prod_util.h" +#include "base/i18n/rtl.h" #include "base/memory/weak_ptr.h" #include "base/strings/string16.h" #include "chrome/browser/ui/autofill/autofill_popup_controller.h" @@ -40,7 +41,8 @@ class AutofillPopupControllerImpl : public AutofillPopupController, base::WeakPtr<AutofillPopupControllerImpl> previous, base::WeakPtr<AutofillPopupDelegate> delegate, gfx::NativeView container_view, - const gfx::RectF& element_bounds); + const gfx::RectF& element_bounds, + base::i18n::TextDirection text_direction); // Shows the popup, or updates the existing popup with the given values. void Show(const std::vector<string16>& names, @@ -67,7 +69,8 @@ class AutofillPopupControllerImpl : public AutofillPopupController, AutofillPopupControllerImpl(base::WeakPtr<AutofillPopupDelegate> delegate, gfx::NativeView container_view, - const gfx::RectF& element_bounds); + const gfx::RectF& element_bounds, + base::i18n::TextDirection text_direction); virtual ~AutofillPopupControllerImpl(); // AutofillPopupController implementation. @@ -83,6 +86,7 @@ class AutofillPopupControllerImpl : public AutofillPopupController, virtual const gfx::Rect& popup_bounds() const OVERRIDE; virtual gfx::NativeView container_view() const OVERRIDE; virtual const gfx::RectF& element_bounds() const OVERRIDE; + virtual bool IsRTL() const OVERRIDE; virtual const std::vector<string16>& names() const OVERRIDE; virtual const std::vector<string16>& subtexts() const OVERRIDE; @@ -191,6 +195,9 @@ class AutofillPopupControllerImpl : public AutofillPopupController, // The bounds of the Autofill popup. gfx::Rect popup_bounds_; + // The text direction of the popup. + base::i18n::TextDirection text_direction_; + // The current Autofill query values. std::vector<string16> names_; std::vector<string16> subtexts_; diff --git a/chrome/browser/ui/autofill/autofill_popup_controller_unittest.cc b/chrome/browser/ui/autofill/autofill_popup_controller_unittest.cc index c3c3fe1..7c60bd56 100644 --- a/chrome/browser/ui/autofill/autofill_popup_controller_unittest.cc +++ b/chrome/browser/ui/autofill/autofill_popup_controller_unittest.cc @@ -64,7 +64,9 @@ class TestAutofillPopupController : public AutofillPopupControllerImpl { explicit TestAutofillPopupController( base::WeakPtr<AutofillExternalDelegate> external_delegate, const gfx::RectF& element_bounds) - : AutofillPopupControllerImpl(external_delegate, NULL, element_bounds) {} + : AutofillPopupControllerImpl( + external_delegate, NULL, element_bounds, + base::i18n::UNKNOWN_DIRECTION) {} virtual ~TestAutofillPopupController() {} void set_display(const gfx::Display display) { @@ -364,21 +366,22 @@ TEST_F(AutofillPopupControllerUnitTest, GetOrCreate) { WeakPtr<AutofillPopupControllerImpl> controller = AutofillPopupControllerImpl::GetOrCreate( WeakPtr<AutofillPopupControllerImpl>(), delegate.GetWeakPtr(), NULL, - gfx::Rect()); + gfx::Rect(), base::i18n::UNKNOWN_DIRECTION); EXPECT_TRUE(controller.get()); controller->Hide(); controller = AutofillPopupControllerImpl::GetOrCreate( WeakPtr<AutofillPopupControllerImpl>(), delegate.GetWeakPtr(), NULL, - gfx::Rect()); + gfx::Rect(), base::i18n::UNKNOWN_DIRECTION); EXPECT_TRUE(controller.get()); WeakPtr<AutofillPopupControllerImpl> controller2 = AutofillPopupControllerImpl::GetOrCreate(controller, delegate.GetWeakPtr(), NULL, - gfx::Rect()); + gfx::Rect(), + base::i18n::UNKNOWN_DIRECTION); EXPECT_EQ(controller.get(), controller2.get()); controller->Hide(); @@ -393,7 +396,8 @@ TEST_F(AutofillPopupControllerUnitTest, GetOrCreate) { test_controller->GetWeakPtr(), delegate.GetWeakPtr(), NULL, - bounds); + bounds, + base::i18n::UNKNOWN_DIRECTION); EXPECT_EQ( bounds, static_cast<AutofillPopupController*>(controller3.get())-> @@ -416,7 +420,8 @@ TEST_F(AutofillPopupControllerUnitTest, ProperlyResetController) { popup_controller()->GetWeakPtr(), delegate()->GetWeakPtr(), NULL, - gfx::Rect()); + gfx::Rect(), + base::i18n::UNKNOWN_DIRECTION); EXPECT_NE(0, controller->selected_line()); EXPECT_TRUE(controller->names().empty()); } diff --git a/chrome/browser/ui/autofill/tab_autofill_manager_delegate.cc b/chrome/browser/ui/autofill/tab_autofill_manager_delegate.cc index 3ff5414..9d38578 100644 --- a/chrome/browser/ui/autofill/tab_autofill_manager_delegate.cc +++ b/chrome/browser/ui/autofill/tab_autofill_manager_delegate.cc @@ -139,6 +139,7 @@ void TabAutofillManagerDelegate::ShowRequestAutocompleteDialog( void TabAutofillManagerDelegate::ShowAutofillPopup( const gfx::RectF& element_bounds, + base::i18n::TextDirection text_direction, const std::vector<string16>& values, const std::vector<string16>& labels, const std::vector<string16>& icons, @@ -155,7 +156,8 @@ void TabAutofillManagerDelegate::ShowAutofillPopup( popup_controller_, delegate, web_contents()->GetView()->GetNativeView(), - element_bounds_in_screen_space); + element_bounds_in_screen_space, + text_direction); popup_controller_->Show(values, labels, icons, identifiers); } diff --git a/chrome/browser/ui/autofill/tab_autofill_manager_delegate.h b/chrome/browser/ui/autofill/tab_autofill_manager_delegate.h index d917e35..9864f1d 100644 --- a/chrome/browser/ui/autofill/tab_autofill_manager_delegate.h +++ b/chrome/browser/ui/autofill/tab_autofill_manager_delegate.h @@ -7,6 +7,7 @@ #include "base/callback.h" #include "base/compiler_specific.h" +#include "base/i18n/rtl.h" #include "base/memory/weak_ptr.h" #include "chrome/browser/ui/autofill/autofill_dialog_types.h" #include "components/autofill/browser/autofill_manager_delegate.h" @@ -60,6 +61,7 @@ class TabAutofillManagerDelegate const std::string&)>& callback) OVERRIDE; virtual void ShowAutofillPopup( const gfx::RectF& element_bounds, + base::i18n::TextDirection text_direction, const std::vector<string16>& values, const std::vector<string16>& labels, const std::vector<string16>& icons, diff --git a/chrome/browser/ui/cocoa/autofill/autofill_popup_view_cocoa.mm b/chrome/browser/ui/cocoa/autofill/autofill_popup_view_cocoa.mm index 351cefe..c88a270 100644 --- a/chrome/browser/ui/cocoa/autofill/autofill_popup_view_cocoa.mm +++ b/chrome/browser/ui/cocoa/autofill/autofill_popup_view_cocoa.mm @@ -4,7 +4,6 @@ #import "chrome/browser/ui/cocoa/autofill/autofill_popup_view_cocoa.h" -#include "base/i18n/rtl.h" #include "base/logging.h" #include "base/strings/sys_string_conversions.h" #include "chrome/browser/ui/autofill/autofill_popup_controller.h" @@ -196,7 +195,7 @@ NSColor* SubtextColor() { [NSBezierPath fillRect:bounds]; } - BOOL isRTL = base::i18n::IsRTL(); + BOOL isRTL = controller_->IsRTL(); NSDictionary* nameAttributes = [NSDictionary dictionaryWithObjectsAndKeys: diff --git a/chrome/browser/ui/gtk/autofill/autofill_popup_view_gtk.cc b/chrome/browser/ui/gtk/autofill/autofill_popup_view_gtk.cc index 9668609..a9dde63 100644 --- a/chrome/browser/ui/gtk/autofill/autofill_popup_view_gtk.cc +++ b/chrome/browser/ui/gtk/autofill/autofill_popup_view_gtk.cc @@ -6,7 +6,6 @@ #include <gdk/gdkkeysyms.h> -#include "base/i18n/rtl.h" #include "base/logging.h" #include "base/strings/utf_string_conversions.h" #include "chrome/browser/ui/autofill/autofill_popup_controller.h" @@ -237,7 +236,7 @@ void AutofillPopupViewGtk::DrawAutofillEntry(cairo_t* cairo_context, entry_rect.y() + (row_height - controller_->GetNameFontForRow(index).GetHeight()) / 2); - bool is_rtl = base::i18n::IsRTL(); + bool is_rtl = controller_->IsRTL(); int value_content_x = is_rtl ? entry_rect.width() - value_text_width - kEndPadding : kEndPadding; diff --git a/chrome/browser/ui/views/autofill/autofill_popup_view_views.cc b/chrome/browser/ui/views/autofill/autofill_popup_view_views.cc index bdc8e32..61f8b53 100644 --- a/chrome/browser/ui/views/autofill/autofill_popup_view_views.cc +++ b/chrome/browser/ui/views/autofill/autofill_popup_view_views.cc @@ -174,7 +174,7 @@ void AutofillPopupViewViews::DrawAutofillEntry(gfx::Canvas* canvas, if (controller_->selected_line() == index) canvas->FillRect(entry_rect, kHoveredBackgroundColor); - bool is_rtl = base::i18n::IsRTL(); + bool is_rtl = controller_->IsRTL(); int value_text_width = controller_->GetNameFontForRow(index).GetStringWidth( controller_->names()[index]); int value_content_x = is_rtl ? diff --git a/components/autofill/browser/autocheckout_manager.cc b/components/autofill/browser/autocheckout_manager.cc index 0536e85..c978553 100644 --- a/components/autofill/browser/autocheckout_manager.cc +++ b/components/autofill/browser/autocheckout_manager.cc @@ -96,6 +96,8 @@ AutofillMetrics::AutocheckoutBuyFlowMetric AutocheckoutStatusToUmaMetric( return AutofillMetrics::AUTOCHECKOUT_BUY_FLOW_MISSING_ADVANCE_ELEMENT; case CANNOT_PROCEED: return AutofillMetrics::AUTOCHECKOUT_BUY_FLOW_CANNOT_PROCEED; + case AUTOCHECKOUT_STATUS_NUM_STATUS: + NOTREACHED(); } NOTREACHED(); diff --git a/components/autofill/browser/autofill_external_delegate.cc b/components/autofill/browser/autofill_external_delegate.cc index 26e53bf..d5ac726 100644 --- a/components/autofill/browser/autofill_external_delegate.cc +++ b/components/autofill/browser/autofill_external_delegate.cc @@ -133,7 +133,13 @@ void AutofillExternalDelegate::OnSuggestionsReturned( // Send to display. if (autofill_query_field_.is_focusable) { autofill_manager_->delegate()->ShowAutofillPopup( - element_bounds_, values, labels, icons, ids, GetWeakPtr()); + element_bounds_, + autofill_query_field_.text_direction, + values, + labels, + icons, + ids, + GetWeakPtr()); } } @@ -153,7 +159,13 @@ void AutofillExternalDelegate::OnShowPasswordSuggestions( std::vector<int> password_ids(suggestions.size(), WebAutofillClient::MenuItemIDPasswordEntry); autofill_manager_->delegate()->ShowAutofillPopup( - element_bounds_, suggestions, empty, empty, password_ids, GetWeakPtr()); + element_bounds_, + autofill_query_field_.text_direction, + suggestions, + empty, + empty, + password_ids, + GetWeakPtr()); } void AutofillExternalDelegate::SetCurrentDataListValues( diff --git a/components/autofill/browser/autofill_external_delegate_unittest.cc b/components/autofill/browser/autofill_external_delegate_unittest.cc index cba86df..cd011fc 100644 --- a/components/autofill/browser/autofill_external_delegate_unittest.cc +++ b/components/autofill/browser/autofill_external_delegate_unittest.cc @@ -52,8 +52,9 @@ class MockAutofillManagerDelegate public: MockAutofillManagerDelegate() {} - MOCK_METHOD6(ShowAutofillPopup, + MOCK_METHOD7(ShowAutofillPopup, void(const gfx::RectF& element_bounds, + base::i18n::TextDirection text_direction, const std::vector<base::string16>& values, const std::vector<base::string16>& labels, const std::vector<base::string16>& icons, @@ -135,7 +136,7 @@ TEST_F(AutofillExternalDelegateUnitTest, TestExternalDelegateVirtualCalls) { // The enums must be cast to ints to prevent compile errors on linux_rel. EXPECT_CALL(manager_delegate_, ShowAutofillPopup( - _, _, _, _, + _, _, _, _, _, testing::ElementsAre( kAutofillProfileId, static_cast<int>(WebAutofillClient::MenuItemIDSeparator), @@ -181,7 +182,7 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateDataList) { // The enums must be cast to ints to prevent compile errors on linux_rel. EXPECT_CALL(manager_delegate_, ShowAutofillPopup( - _, _, _, _, + _, _, _, _, _, testing::ElementsAre( static_cast<int>( WebAutofillClient::MenuItemIDDataListEntry), @@ -208,7 +209,7 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateDataList) { // The enum must be cast to an int to prevent compile errors on linux_rel. EXPECT_CALL(manager_delegate_, ShowAutofillPopup( - _, _, _, _, + _, _, _, _, _, testing::ElementsAre( static_cast<int>( WebAutofillClient::MenuItemIDDataListEntry)), @@ -232,7 +233,7 @@ TEST_F(AutofillExternalDelegateUnitTest, AutofillWarnings) { // The enums must be cast to ints to prevent compile errors on linux_rel. EXPECT_CALL(manager_delegate_, ShowAutofillPopup( - _, _, _, _, + _, _, _, _, _, testing::ElementsAre( static_cast<int>( WebAutofillClient::MenuItemIDWarningMessage)), @@ -283,7 +284,7 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateClearPreviewedForm) { // Test that the popup is hidden once we are done editing the autofill field. TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateHidePopupAfterEditing) { - EXPECT_CALL(manager_delegate_, ShowAutofillPopup(_, _, _, _, _, _)); + EXPECT_CALL(manager_delegate_, ShowAutofillPopup(_, _, _, _, _, _, _)); autofill::GenerateTestAutofillPopup(external_delegate_.get()); EXPECT_CALL(manager_delegate_, HideAutofillPopup()); @@ -311,7 +312,7 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegatePasswordSuggestions) { // The enums must be cast to ints to prevent compile errors on linux_rel. EXPECT_CALL(manager_delegate_, ShowAutofillPopup( - _, _, _, _, + _, _, _, _, _, testing::ElementsAre( static_cast<int>( WebAutofillClient::MenuItemIDPasswordEntry)), diff --git a/components/autofill/browser/autofill_manager_delegate.h b/components/autofill/browser/autofill_manager_delegate.h index 5563b9f..287530a 100644 --- a/components/autofill/browser/autofill_manager_delegate.h +++ b/components/autofill/browser/autofill_manager_delegate.h @@ -8,6 +8,7 @@ #include <vector> #include "base/callback_forward.h" +#include "base/i18n/rtl.h" #include "base/memory/weak_ptr.h" #include "base/strings/string16.h" @@ -116,6 +117,7 @@ class AutofillManagerDelegate { // notified of popup events. virtual void ShowAutofillPopup( const gfx::RectF& element_bounds, + base::i18n::TextDirection text_direction, const std::vector<base::string16>& values, const std::vector<base::string16>& labels, const std::vector<base::string16>& icons, diff --git a/components/autofill/browser/test_autofill_manager_delegate.cc b/components/autofill/browser/test_autofill_manager_delegate.cc index 7e4f8dc..69e615b 100644 --- a/components/autofill/browser/test_autofill_manager_delegate.cc +++ b/components/autofill/browser/test_autofill_manager_delegate.cc @@ -51,6 +51,7 @@ void TestAutofillManagerDelegate::ShowRequestAutocompleteDialog( void TestAutofillManagerDelegate::ShowAutofillPopup( const gfx::RectF& element_bounds, + base::i18n::TextDirection text_direction, const std::vector<base::string16>& values, const std::vector<base::string16>& labels, const std::vector<base::string16>& icons, diff --git a/components/autofill/browser/test_autofill_manager_delegate.h b/components/autofill/browser/test_autofill_manager_delegate.h index 8ba1dc7..fc3dc41 100644 --- a/components/autofill/browser/test_autofill_manager_delegate.h +++ b/components/autofill/browser/test_autofill_manager_delegate.h @@ -6,6 +6,7 @@ #define COMPONENTS_AUTOFILL_BROWSER_TEST_AUTOFILL_MANAGER_DELEGATE_H_ #include "base/compiler_specific.h" +#include "base/i18n/rtl.h" #include "components/autofill/browser/autofill_manager_delegate.h" namespace autofill { @@ -43,6 +44,7 @@ class TestAutofillManagerDelegate : public AutofillManagerDelegate { const std::string&)>& callback) OVERRIDE; virtual void ShowAutofillPopup( const gfx::RectF& element_bounds, + base::i18n::TextDirection text_direction, const std::vector<base::string16>& values, const std::vector<base::string16>& labels, const std::vector<base::string16>& icons, diff --git a/components/autofill/common/autocheckout_status.h b/components/autofill/common/autocheckout_status.h index a0bfcdd..182bba8 100644 --- a/components/autofill/common/autocheckout_status.h +++ b/components/autofill/common/autocheckout_status.h @@ -14,6 +14,7 @@ enum AutocheckoutStatus { MISSING_CLICK_ELEMENT_BEFORE_FORM_FILLING, MISSING_CLICK_ELEMENT_AFTER_FORM_FILLING, CANNOT_PROCEED, + AUTOCHECKOUT_STATUS_NUM_STATUS, }; } // namespace autofill diff --git a/components/autofill/common/autofill_messages.h b/components/autofill/common/autofill_messages.h index 0c48f33..cf1ff3d 100644 --- a/components/autofill/common/autofill_messages.h +++ b/components/autofill/common/autofill_messages.h @@ -27,8 +27,12 @@ #define IPC_MESSAGE_START AutofillMsgStart -IPC_ENUM_TRAITS(autofill::AutocheckoutStatus) -IPC_ENUM_TRAITS(autofill::FormsSeenState) +IPC_ENUM_TRAITS_MAX_VALUE(autofill::AutocheckoutStatus, + autofill::AUTOCHECKOUT_STATUS_NUM_STATUS - 1) +IPC_ENUM_TRAITS_MAX_VALUE(autofill::FormsSeenState, + autofill::FORMS_SEEN_STATE_NUM_STATES - 1) +IPC_ENUM_TRAITS_MAX_VALUE(base::i18n::TextDirection, + base::i18n::TEXT_DIRECTION_NUM_DIRECTIONS - 1) IPC_STRUCT_TRAITS_BEGIN(autofill::WebElementDescriptor) IPC_STRUCT_TRAITS_MEMBER(descriptor) @@ -49,6 +53,7 @@ IPC_STRUCT_TRAITS_BEGIN(autofill::FormFieldData) IPC_STRUCT_TRAITS_MEMBER(is_checkable) IPC_STRUCT_TRAITS_MEMBER(is_focusable) IPC_STRUCT_TRAITS_MEMBER(should_autocomplete) + IPC_STRUCT_TRAITS_MEMBER(text_direction) IPC_STRUCT_TRAITS_MEMBER(option_values) IPC_STRUCT_TRAITS_MEMBER(option_contents) IPC_STRUCT_TRAITS_END() diff --git a/components/autofill/common/form_field_data.cc b/components/autofill/common/form_field_data.cc index 9040137..6e01c32 100644 --- a/components/autofill/common/form_field_data.cc +++ b/components/autofill/common/form_field_data.cc @@ -15,7 +15,8 @@ FormFieldData::FormFieldData() is_checked(false), is_checkable(false), is_focusable(false), - should_autocomplete(true) { + should_autocomplete(true), + text_direction(base::i18n::UNKNOWN_DIRECTION) { } FormFieldData::~FormFieldData() { @@ -64,7 +65,9 @@ std::ostream& operator<<(std::ostream& os, const FormFieldData& field) { << " " << (field.is_focusable ? "true" : "false") << " " - << (field.should_autocomplete ? "true" : "false"); + << (field.should_autocomplete ? "true" : "false") + << " " + << field.text_direction; } } // namespace autofill diff --git a/components/autofill/common/form_field_data.h b/components/autofill/common/form_field_data.h index 9b87d15..64f3cc28 100644 --- a/components/autofill/common/form_field_data.h +++ b/components/autofill/common/form_field_data.h @@ -7,6 +7,7 @@ #include <vector> +#include "base/i18n/rtl.h" #include "base/strings/string16.h" namespace autofill { @@ -36,6 +37,7 @@ struct FormFieldData { bool is_checkable; bool is_focusable; bool should_autocomplete; + base::i18n::TextDirection text_direction; // For the HTML snippet |<option value="US">United States</option>|, the // value is "US" and the contents are "United States". diff --git a/components/autofill/common/forms_seen_state.h b/components/autofill/common/forms_seen_state.h index 5f6f582..da417f9 100644 --- a/components/autofill/common/forms_seen_state.h +++ b/components/autofill/common/forms_seen_state.h @@ -15,6 +15,8 @@ enum FormsSeenState { PARTIAL_FORMS_SEEN = 1, // Forms were added dynamically post-page load. DYNAMIC_FORMS_SEEN = 2, + // Number of states. + FORMS_SEEN_STATE_NUM_STATES = 3, }; } // namespace autofill diff --git a/components/autofill/content/browser/wallet/wallet_client.cc b/components/autofill/content/browser/wallet/wallet_client.cc index e37c240..2f5da59 100644 --- a/components/autofill/content/browser/wallet/wallet_client.cc +++ b/components/autofill/content/browser/wallet/wallet_client.cc @@ -47,6 +47,8 @@ std::string AutocheckoutStatusToString(AutocheckoutStatus status) { // SUCCESS cannot be sent to the server as it will result in a failure. NOTREACHED(); return "ERROR"; + case AUTOCHECKOUT_STATUS_NUM_STATUS: + NOTREACHED(); } NOTREACHED(); return "NOT_POSSIBLE"; diff --git a/components/autofill/content/renderer/form_autofill_util.cc b/components/autofill/content/renderer/form_autofill_util.cc index 18d4de9..2d96965 100644 --- a/components/autofill/content/renderer/form_autofill_util.cc +++ b/components/autofill/content/renderer/form_autofill_util.cc @@ -714,9 +714,11 @@ void WebFormControlElementToFormField(const WebFormControlElement& element, field->is_autofilled = input_element->isAutofilled(); field->is_focusable = input_element->isFocusable(); - field->should_autocomplete = input_element->autoComplete(); field->is_checkable = IsCheckableElement(input_element); field->is_checked = input_element->isChecked(); + field->should_autocomplete = input_element->autoComplete(); + field->text_direction = input_element->directionForFormData() == "rtl" ? + base::i18n::RIGHT_TO_LEFT : base::i18n::LEFT_TO_RIGHT; } else if (extract_mask & EXTRACT_OPTIONS) { // Set option strings on the field if available. DCHECK(IsSelectElement(element)); |