OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_RENDERER_PAGE_CLICK_TRACKER_H_ | 5 #ifndef COMPONENTS_AUTOFILL_RENDERER_PAGE_CLICK_TRACKER_H_ |
6 #define COMPONENTS_AUTOFILL_RENDERER_PAGE_CLICK_TRACKER_H_ | 6 #define COMPONENTS_AUTOFILL_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 "components/autofill/renderer/page_click_listener.h" | |
11 #include "content/public/renderer/render_view_observer.h" | 12 #include "content/public/renderer/render_view_observer.h" |
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMEventListener.h " | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMEventListener.h " |
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | |
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" |
14 | 16 |
15 namespace autofill { | 17 namespace autofill { |
16 | 18 |
17 class PageClickListener; | 19 class PageClickListener; |
18 | 20 |
19 // This class is responsible for tracking clicks on elements in web pages and | 21 // This class is responsible for tracking clicks on elements in web pages and |
20 // notifiying the associated listener when a node is clicked. | 22 // notifiying the associated listener when a node is clicked. |
21 // Compared to a simple WebDOMEventListener, it offers the added capability of | 23 // Compared to a simple WebDOMEventListener, it offers the added capability of |
22 // notifying the listeners of whether the clicked node was already focused | 24 // notifying the listeners of whether the clicked node was already focused |
(...skipping 11 matching lines...) Expand all Loading... | |
34 // The |listener| will be notified when an element is clicked. It must | 36 // The |listener| will be notified when an element is clicked. It must |
35 // outlive this class. | 37 // outlive this class. |
36 PageClickTracker(content::RenderView* render_view, | 38 PageClickTracker(content::RenderView* render_view, |
37 PageClickListener* listener); | 39 PageClickListener* listener); |
38 virtual ~PageClickTracker(); | 40 virtual ~PageClickTracker(); |
39 | 41 |
40 private: | 42 private: |
41 // RenderView::Observer implementation. | 43 // RenderView::Observer implementation. |
42 virtual void DidFinishDocumentLoad(WebKit::WebFrame* frame) OVERRIDE; | 44 virtual void DidFinishDocumentLoad(WebKit::WebFrame* frame) OVERRIDE; |
43 virtual void FrameDetached(WebKit::WebFrame* frame) OVERRIDE; | 45 virtual void FrameDetached(WebKit::WebFrame* frame) OVERRIDE; |
44 virtual void DidHandleMouseEvent(const WebKit::WebMouseEvent& event) OVERRIDE; | 46 virtual void DidHandleMouseEvent( |
47 const WebKit::WebMouseEvent& event) OVERRIDE; | |
48 virtual void DidHandleGestureEvent( | |
49 const WebKit::WebGestureEvent& event) OVERRIDE; | |
45 | 50 |
46 // WebKit::WebDOMEventListener implementation. | 51 // WebKit::WebDOMEventListener implementation. |
47 virtual void handleEvent(const WebKit::WebDOMEvent& event); | 52 virtual void handleEvent(const WebKit::WebDOMEvent& event); |
48 | 53 |
49 // Checks to see if a text field is losing focus and inform listeners if | 54 // Checks to see if a text field is losing focus and inform listeners if |
50 // it is. | 55 // it is. |
51 void HandleTextFieldMaybeLosingFocus( | 56 void HandleTextFieldMaybeLosingFocus( |
52 const WebKit::WebNode& newly_clicked_node); | 57 const WebKit::WebNode& newly_clicked_node); |
53 | 58 |
59 // Helper method for DidHandleMouseEvent and DidHandleGestureEvent. | |
60 void DidHandleMouseOrGestureEvent( | |
61 const WebKit::WebInputEvent& event, | |
62 WebKit::WebInputEvent::Type expected_type, | |
63 autofill::InputEventSource source); | |
Ilya Sherman
2013/06/06 20:35:08
nit: No need for the "autofill::" prefix, as this
| |
64 | |
54 // The last node that was clicked and had focus. | 65 // The last node that was clicked and had focus. |
55 WebKit::WebNode last_node_clicked_; | 66 WebKit::WebNode last_node_clicked_; |
56 | 67 |
57 // Whether the last clicked node had focused before it was clicked. | 68 // Whether the last clicked node had focused before it was clicked. |
58 bool was_focused_; | 69 bool was_focused_; |
59 | 70 |
60 // The frames we are listening to for mouse events. | 71 // The frames we are listening to for mouse events. |
61 std::vector<WebKit::WebFrame*> tracked_frames_; | 72 std::vector<WebKit::WebFrame*> tracked_frames_; |
62 | 73 |
63 // The listener getting the actual notifications. | 74 // The listener getting the actual notifications. |
64 PageClickListener* listener_; | 75 PageClickListener* listener_; |
65 | 76 |
66 DISALLOW_COPY_AND_ASSIGN(PageClickTracker); | 77 DISALLOW_COPY_AND_ASSIGN(PageClickTracker); |
67 }; | 78 }; |
68 | 79 |
69 } // namespace autofill | 80 } // namespace autofill |
70 | 81 |
71 #endif // COMPONENTS_AUTOFILL_RENDERER_PAGE_CLICK_TRACKER_H_ | 82 #endif // COMPONENTS_AUTOFILL_RENDERER_PAGE_CLICK_TRACKER_H_ |
OLD | NEW |