Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Side by Side Diff: components/autofill/content/renderer/page_click_tracker.h

Issue 2766053002: [refactor] Fix autofill features for payments when the form is inside an OOPIF (Closed)
Patch Set: Using Node& instead of Node* Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "content/public/renderer/render_frame_observer.h" 12 #include "content/public/renderer/render_frame_observer.h"
13 #include "content/public/renderer/render_view_observer.h"
14 #include "third_party/WebKit/public/web/WebNode.h" 13 #include "third_party/WebKit/public/web/WebNode.h"
15 14
16 namespace autofill { 15 namespace autofill {
17 16
18 class PageClickListener; 17 class PageClickListener;
19 18
20 // This class is responsible notifying the associated listener when a node is 19 // This class is responsible notifying the associated listener when a node is
21 // clicked or tapped. It also tracks whether a node was focused before the event 20 // clicked or tapped. It also tracks whether a node was focused before the event
22 // was handled. 21 // was handled.
23 // 22 //
24 // This is useful for password/form autofill where we want to trigger a 23 // This is useful for password/form autofill where we want to trigger a
25 // suggestion popup when a text input is clicked. 24 // suggestion popup when a text input is clicked.
26 // 25 //
27 // There is one PageClickTracker per AutofillAgent. 26 // There is one PageClickTracker per AutofillAgent.
28 class PageClickTracker : public content::RenderFrameObserver { 27 class PageClickTracker : public content::RenderFrameObserver {
29 public: 28 public:
30 // The |listener| will be notified when an element is clicked. It must 29 // The |listener| will be notified when an element is clicked. It must
31 // outlive this class. 30 // outlive this class.
32 PageClickTracker(content::RenderFrame* render_frame, 31 PageClickTracker(content::RenderFrame* render_frame,
33 PageClickListener* listener); 32 PageClickListener* listener);
34 ~PageClickTracker() override; 33 ~PageClickTracker() override;
35 34
36 private: 35 private:
37 // TODO(estade): migrate this stuff to content::RenderFrameObserver, and
38 // remove this class.
39 class Legacy : public content::RenderViewObserver {
40 public:
41 Legacy(PageClickTracker* tracker);
42
43 // RenderViewObserver implementation.
44 void OnDestruct() override;
45 void OnMouseDown(const blink::WebNode& mouse_down_node) override;
46 void FocusChangeComplete() override;
47
48 private:
49 PageClickTracker* tracker_;
50 };
51 friend class Legacy;
52 36
53 // RenderFrameObserver implementation. 37 // RenderFrameObserver implementation.
54 void FocusedNodeChanged(const blink::WebNode& node) override; 38 void FocusedNodeChanged(const blink::WebNode& node) override;
39 void DidCompleteFocusChangeInFrame() override;
40 void DidCompleteLeftMouseDownOrGestureTapInNode(
41 const blink::WebNode& node) override;
55 void OnDestruct() override; 42 void OnDestruct() override;
56 43
57 // RenderViewObserver methods forwarded from Legacy. Should be
58 // merged into RenderFrameObserver.
59 void OnMouseDown(const blink::WebNode& mouse_down_node);
60 void FocusChangeComplete();
61 void DoFocusChangeComplete(); 44 void DoFocusChangeComplete();
62 45
63 // True when the last click was on the focused node. 46 // True when the last click was on the focused node.
64 bool focused_node_was_last_clicked_; 47 bool focused_node_was_last_clicked_;
65 48
66 // This is set to false when the focus changes, then set back to true soon 49 // This is set to false when the focus changes, then set back to true soon
67 // afterwards. This helps track whether an event happened after a node was 50 // afterwards. This helps track whether an event happened after a node was
68 // already focused, or if it caused the focus to change. 51 // already focused, or if it caused the focus to change.
69 bool was_focused_before_now_; 52 bool was_focused_before_now_;
70 53
71 // The listener getting the actual notifications. 54 // The listener getting the actual notifications.
72 PageClickListener* listener_; 55 PageClickListener* listener_;
73 56
74 Legacy legacy_;
75
76 DISALLOW_COPY_AND_ASSIGN(PageClickTracker); 57 DISALLOW_COPY_AND_ASSIGN(PageClickTracker);
77 }; 58 };
78 59
79 } // namespace autofill 60 } // namespace autofill
80 61
81 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PAGE_CLICK_TRACKER_H_ 62 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PAGE_CLICK_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698