| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_AUTOFILL_CONTENT_RENDERER_PAGE_CLICK_TRACKER_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CONTENT_RENDERER_PAGE_CLICK_TRACKER_H_ |
| 6 #define COMPONENTS_AUTOFILL_CONTENT_RENDERER_PAGE_CLICK_TRACKER_H_ | 6 #define COMPONENTS_AUTOFILL_CONTENT_RENDERER_PAGE_CLICK_TRACKER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "content/public/renderer/render_view_observer.h" | 12 #include "content/public/renderer/render_view_observer.h" |
| 13 #include "third_party/WebKit/public/web/WebNode.h" | 13 #include "third_party/WebKit/public/web/WebNode.h" |
| 14 | 14 |
| 15 namespace gfx { |
| 16 class RectF; |
| 17 } |
| 18 |
| 15 namespace autofill { | 19 namespace autofill { |
| 16 | 20 |
| 17 class PageClickListener; | 21 class PageClickListener; |
| 18 | 22 |
| 19 // This class is responsible notifying the associated listener when a node is | 23 // This class is responsible notifying the associated listener when a node is |
| 20 // clicked or tapped. It also tracks whether a node was focused before the event | 24 // clicked or tapped. It also tracks whether a node was focused before the event |
| 21 // was handled. | 25 // was handled. |
| 22 // | 26 // |
| 23 // This is useful for password/form autofill where we want to trigger a | 27 // This is useful for password/form autofill where we want to trigger a |
| 24 // suggestion popup when a text input is clicked. | 28 // suggestion popup when a text input is clicked. |
| 25 // | 29 // |
| 26 // There is one PageClickTracker per AutofillAgent. | 30 // There is one PageClickTracker per AutofillAgent. |
| 27 // TODO(estade): migrate to content::RenderFrameObserver. | 31 // TODO(estade): migrate to content::RenderFrameObserver. |
| 28 class PageClickTracker : public content::RenderViewObserver { | 32 class PageClickTracker : public content::RenderViewObserver { |
| 29 public: | 33 public: |
| 30 // The |listener| will be notified when an element is clicked. It must | 34 // The |listener| will be notified when an element is clicked. It must |
| 31 // outlive this class. | 35 // outlive this class. |
| 32 PageClickTracker(content::RenderView* render_view, | 36 PageClickTracker(content::RenderView* render_view, |
| 33 PageClickListener* listener); | 37 PageClickListener* listener); |
| 34 ~PageClickTracker() override; | 38 ~PageClickTracker() override; |
| 35 | 39 |
| 36 private: | 40 private: |
| 37 // RenderView::Observer implementation. | 41 // RenderView::Observer implementation. |
| 38 void OnDestruct() override; | 42 void OnDestruct() override; |
| 39 void DidHandleMouseEvent(const blink::WebMouseEvent& event) override; | 43 void DidHandleMouseEvent(const blink::WebMouseEvent& event) override; |
| 40 void DidHandleGestureEvent(const blink::WebGestureEvent& event) override; | 44 void DidHandleGestureEvent(const blink::WebGestureEvent& event) override; |
| 41 void FocusedNodeChanged(const blink::WebNode& node) override; | 45 void FocusedNodeChanged(const blink::WebNode& node) override; |
| 42 void FocusChangeComplete() override; | 46 void FocusChangeComplete() override; |
| 43 | 47 |
| 44 // Called there is a tap or click at |x|, |y|. | 48 // Called if there is a tap or click at |region|. Clicks are 1x1 regions, but |
| 45 void PotentialActivationAt(int x, int y); | 49 // taps are wider. |
| 50 void PotentialActivationAt(const gfx::RectF& region); |
| 46 | 51 |
| 47 // The node that was clicked. Non-null only when the animations caused by | 52 // The node that was clicked. Non-null only when the animations caused by |
| 48 // focus change are still ongoing. | 53 // focus change are still ongoing. |
| 49 blink::WebNode clicked_node_; | 54 blink::WebNode clicked_node_; |
| 50 | 55 |
| 51 // This is set to false when the focus changes, then set back to true soon | 56 // This is set to false when the focus changes, then set back to true soon |
| 52 // afterwards. This helps track whether an event happened after a node was | 57 // afterwards. This helps track whether an event happened after a node was |
| 53 // already focused, or if it caused the focus to change. | 58 // already focused, or if it caused the focus to change. |
| 54 bool was_focused_before_now_; | 59 bool was_focused_before_now_; |
| 55 | 60 |
| 56 // The listener getting the actual notifications. | 61 // The listener getting the actual notifications. |
| 57 PageClickListener* listener_; | 62 PageClickListener* listener_; |
| 58 | 63 |
| 59 DISALLOW_COPY_AND_ASSIGN(PageClickTracker); | 64 DISALLOW_COPY_AND_ASSIGN(PageClickTracker); |
| 60 }; | 65 }; |
| 61 | 66 |
| 62 } // namespace autofill | 67 } // namespace autofill |
| 63 | 68 |
| 64 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PAGE_CLICK_TRACKER_H_ | 69 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PAGE_CLICK_TRACKER_H_ |
| OLD | NEW |