summaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorblundell@chromium.org <blundell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-01 19:57:09 +0000
committerblundell@chromium.org <blundell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-01 19:57:09 +0000
commit3cf16416510de2d885e8bd38bd8e56522995eac9 (patch)
treee40d97a8fd24665a2f55a5ef5b1b8dd6440a2a4d /components
parent8472f85d6aed73c59f73f5eb6c3fbd459e0a15a3 (diff)
downloadchromium_src-3cf16416510de2d885e8bd38bd8e56522995eac9.zip
chromium_src-3cf16416510de2d885e8bd38bd8e56522995eac9.tar.gz
chromium_src-3cf16416510de2d885e8bd38bd8e56522995eac9.tar.bz2
Move Autofill keyboard listening into AutofillPopupControllerImpl
AutofillPopupDelegate is part of the core Autofill code and thus cannot reference content::KeyboardListener. This CL eliminates keyboard listening from the AutofillPopupDelegate API and moves the responsibility of deciding whether AutofillPopupControllerImpl should listen for keyboard input into the creator of AutofillPopupControllerImpl: the creator should pass AutofillPopupControllerImpl the WebContents instance in which input should be listened for, or NULL if it is not desired that the AutofillPopupControllerImpl listen for keyboard input. BUG=302499 Review URL: https://codereview.chromium.org/49133003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@232448 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components')
-rw-r--r--components/autofill/core/browser/autofill_external_delegate.cc21
-rw-r--r--components/autofill/core/browser/autofill_external_delegate.h11
-rw-r--r--components/autofill/core/browser/autofill_external_delegate_unittest.cc4
-rw-r--r--components/autofill/core/browser/autofill_popup_delegate.h15
4 files changed, 11 insertions, 40 deletions
diff --git a/components/autofill/core/browser/autofill_external_delegate.cc b/components/autofill/core/browser/autofill_external_delegate.cc
index f8b0fbc..dc93f97 100644
--- a/components/autofill/core/browser/autofill_external_delegate.cc
+++ b/components/autofill/core/browser/autofill_external_delegate.cc
@@ -32,7 +32,6 @@ AutofillExternalDelegate::AutofillExternalDelegate(
display_warning_if_disabled_(false),
has_autofill_suggestion_(false),
has_shown_autofill_popup_for_current_edit_(false),
- registered_key_press_event_callback_with_(NULL),
weak_ptr_factory_(this) {
DCHECK(autofill_manager);
}
@@ -157,29 +156,13 @@ void AutofillExternalDelegate::SetCurrentDataListValues(
data_list_labels);
}
-void AutofillExternalDelegate::OnPopupShown(
- content::RenderWidgetHost::KeyPressEventCallback* callback) {
- if (callback && !registered_key_press_event_callback_with_) {
- registered_key_press_event_callback_with_ =
- web_contents_->GetRenderViewHost();
- registered_key_press_event_callback_with_->AddKeyPressEventCallback(
- *callback);
- }
-
+void AutofillExternalDelegate::OnPopupShown() {
autofill_manager_->OnDidShowAutofillSuggestions(
has_autofill_suggestion_ && !has_shown_autofill_popup_for_current_edit_);
has_shown_autofill_popup_for_current_edit_ |= has_autofill_suggestion_;
}
-void AutofillExternalDelegate::OnPopupHidden(
- content::RenderWidgetHost::KeyPressEventCallback* callback) {
- if (callback && (!web_contents_->IsBeingDestroyed()) &&
- (registered_key_press_event_callback_with_ ==
- web_contents_->GetRenderViewHost())) {
- web_contents_->GetRenderViewHost()->RemoveKeyPressEventCallback(*callback);
- }
-
- registered_key_press_event_callback_with_ = NULL;
+void AutofillExternalDelegate::OnPopupHidden() {
}
bool AutofillExternalDelegate::ShouldRepostEvent(const ui::MouseEvent& event) {
diff --git a/components/autofill/core/browser/autofill_external_delegate.h b/components/autofill/core/browser/autofill_external_delegate.h
index 0a0093e..8c3b63c 100644
--- a/components/autofill/core/browser/autofill_external_delegate.h
+++ b/components/autofill/core/browser/autofill_external_delegate.h
@@ -22,7 +22,6 @@ class Rect;
}
namespace content {
-class RenderViewHost;
class WebContents;
}
@@ -47,10 +46,8 @@ class AutofillExternalDelegate
virtual ~AutofillExternalDelegate();
// AutofillPopupDelegate implementation.
- virtual void OnPopupShown(
- content::RenderWidgetHost::KeyPressEventCallback* callback) OVERRIDE;
- virtual void OnPopupHidden(
- content::RenderWidgetHost::KeyPressEventCallback* callback) OVERRIDE;
+ virtual void OnPopupShown() OVERRIDE;
+ virtual void OnPopupHidden() OVERRIDE;
virtual bool ShouldRepostEvent(const ui::MouseEvent& event) OVERRIDE;
virtual void DidSelectSuggestion(int identifier) OVERRIDE;
virtual void DidAcceptSuggestion(const base::string16& value,
@@ -170,10 +167,6 @@ class AutofillExternalDelegate
// currently editing? Used to keep track of state for metrics logging.
bool has_shown_autofill_popup_for_current_edit_;
- // The RenderViewHost that this object has been registered with as a key press
- // event callback.
- content::RenderViewHost* registered_key_press_event_callback_with_;
-
// The current data list values.
std::vector<base::string16> data_list_values_;
std::vector<base::string16> data_list_labels_;
diff --git a/components/autofill/core/browser/autofill_external_delegate_unittest.cc b/components/autofill/core/browser/autofill_external_delegate_unittest.cc
index ae863ca..2809b01 100644
--- a/components/autofill/core/browser/autofill_external_delegate_unittest.cc
+++ b/components/autofill/core/browser/autofill_external_delegate_unittest.cc
@@ -272,9 +272,9 @@ TEST_F(AutofillExternalDelegateUnitTest, UpdateDataListWhileShowingPopup) {
autofill_item,
autofill_ids);
- // This would normally get called from ShowAutofillPopup, but it is mocked
+ // This would normally get called from ShowAutofillPopup, but it is mocked so
// we need to call OnPopupShown ourselves.
- external_delegate_->OnPopupShown(NULL);
+ external_delegate_->OnPopupShown();
// Update the current data list and ensure the popup is updated.
data_list_items.push_back(base::string16());
diff --git a/components/autofill/core/browser/autofill_popup_delegate.h b/components/autofill/core/browser/autofill_popup_delegate.h
index 86b5eff..dec139c 100644
--- a/components/autofill/core/browser/autofill_popup_delegate.h
+++ b/components/autofill/core/browser/autofill_popup_delegate.h
@@ -6,7 +6,6 @@
#define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_POPUP_DELEGATE_H_
#include "base/strings/string16.h"
-#include "content/public/browser/render_view_host.h"
namespace ui {
class MouseEvent;
@@ -18,15 +17,11 @@ namespace autofill {
// of events by the controller.
class AutofillPopupDelegate {
public:
- // Called when the Autofill popup is shown. |callback| may be used to pass
- // keyboard events to the popup.
- virtual void OnPopupShown(
- content::RenderWidgetHost::KeyPressEventCallback* callback) = 0;
-
- // Called when the Autofill popup is hidden. |callback| must be unregistered
- // if it was registered in OnPopupShown.
- virtual void OnPopupHidden(
- content::RenderWidgetHost::KeyPressEventCallback* callback) = 0;
+ // Called when the Autofill popup is shown.
+ virtual void OnPopupShown() = 0;
+
+ // Called when the Autofill popup is hidden.
+ virtual void OnPopupHidden() = 0;
// Called when the Autofill popup recieves a click outside of the popup view
// to determine if the event should be reposted to the native window manager.