| 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/gtest_prod_util.h" |
| 11 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 12 #include "content/public/renderer/render_frame_observer.h" | 13 #include "content/public/renderer/render_frame_observer.h" |
| 13 #include "content/public/renderer/render_view_observer.h" | 14 #include "content/public/renderer/render_view_observer.h" |
| 14 #include "third_party/WebKit/public/web/WebNode.h" | 15 #include "third_party/WebKit/public/web/WebNode.h" |
| 15 | 16 |
| 16 namespace autofill { | 17 namespace autofill { |
| 17 | 18 |
| 18 class PageClickListener; | 19 class PageClickListener; |
| 19 | 20 |
| 20 // This class is responsible notifying the associated listener when a node is | 21 // This class is responsible notifying the associated listener when a node is |
| (...skipping 22 matching lines...) Expand all Loading... |
| 43 // RenderViewObserver implementation. | 44 // RenderViewObserver implementation. |
| 44 void OnDestruct() override; | 45 void OnDestruct() override; |
| 45 void OnMouseDown(const blink::WebNode& mouse_down_node) override; | 46 void OnMouseDown(const blink::WebNode& mouse_down_node) override; |
| 46 void FocusChangeComplete() override; | 47 void FocusChangeComplete() override; |
| 47 | 48 |
| 48 private: | 49 private: |
| 49 PageClickTracker* tracker_; | 50 PageClickTracker* tracker_; |
| 50 }; | 51 }; |
| 51 friend class Legacy; | 52 friend class Legacy; |
| 52 | 53 |
| 54 FRIEND_TEST_ALL_PREFIXES( |
| 55 PageClickTrackerTest, KeyboardAccessoryForMouseDown); |
| 56 FRIEND_TEST_ALL_PREFIXES( |
| 57 PageClickTrackerTest, KeyboardAccessoryForUserGestureFocusedNodeChange); |
| 58 FRIEND_TEST_ALL_PREFIXES( |
| 59 PageClickTrackerTest, |
| 60 NoKeyboardAccessoryForNonUserGestureFocusedNodeChange); |
| 61 FRIEND_TEST_ALL_PREFIXES( |
| 62 PageClickTrackerTest, NoKeyboardAccessoryForFocusChangeComplete); |
| 63 |
| 53 // RenderFrameObserver implementation. | 64 // RenderFrameObserver implementation. |
| 54 void FocusedNodeChanged(const blink::WebNode& node) override; | 65 void FocusedNodeChanged(const blink::WebNode& node) override; |
| 55 | 66 |
| 67 // Returns true if the focused node change is due to a user gesture. Can be |
| 68 // overridden in tests. |
| 69 virtual bool IsUserGesture() const; |
| 70 |
| 71 // Returns true if keyboard accessory is enabled. Can be overridden in tests. |
| 72 virtual bool IsKeyboardAccessory() const; |
| 73 |
| 56 // RenderViewObserver methods forwarded from Legacy. Should be | 74 // RenderViewObserver methods forwarded from Legacy. Should be |
| 57 // merged into RenderFrameObserver. | 75 // merged into RenderFrameObserver. |
| 58 void OnMouseDown(const blink::WebNode& mouse_down_node); | 76 void OnMouseDown(const blink::WebNode& mouse_down_node); |
| 59 void FocusChangeComplete(); | 77 void FocusChangeComplete(); |
| 60 void DoFocusChangeComplete(); | 78 void DoFocusChangeComplete(); |
| 61 | 79 |
| 62 // True when the last click was on the focused node. | 80 // True when the last click was on the focused node. |
| 63 bool focused_node_was_last_clicked_; | 81 bool focused_node_was_last_clicked_; |
| 64 | 82 |
| 65 // This is set to false when the focus changes, then set back to true soon | 83 // This is set to false when the focus changes, then set back to true soon |
| 66 // afterwards. This helps track whether an event happened after a node was | 84 // afterwards. This helps track whether an event happened after a node was |
| 67 // already focused, or if it caused the focus to change. | 85 // already focused, or if it caused the focus to change. |
| 68 bool was_focused_before_now_; | 86 bool was_focused_before_now_; |
| 69 | 87 |
| 70 // The listener getting the actual notifications. | 88 // The listener getting the actual notifications. |
| 71 PageClickListener* listener_; | 89 PageClickListener* listener_; |
| 72 | 90 |
| 73 Legacy legacy_; | 91 Legacy legacy_; |
| 74 | 92 |
| 75 DISALLOW_COPY_AND_ASSIGN(PageClickTracker); | 93 DISALLOW_COPY_AND_ASSIGN(PageClickTracker); |
| 76 }; | 94 }; |
| 77 | 95 |
| 78 } // namespace autofill | 96 } // namespace autofill |
| 79 | 97 |
| 80 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PAGE_CLICK_TRACKER_H_ | 98 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PAGE_CLICK_TRACKER_H_ |
| OLD | NEW |