Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / components / autofill / content / renderer / page_click_tracker.h
blob0c6585af0111e446abaffcc0be322c29a9852ba3
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_AUTOFILL_CONTENT_RENDERER_PAGE_CLICK_TRACKER_H_
6 #define COMPONENTS_AUTOFILL_CONTENT_RENDERER_PAGE_CLICK_TRACKER_H_
8 #include <vector>
10 #include "base/basictypes.h"
11 #include "base/memory/weak_ptr.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"
16 namespace autofill {
18 class PageClickListener;
20 // 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
22 // was handled.
24 // This is useful for password/form autofill where we want to trigger a
25 // suggestion popup when a text input is clicked.
27 // There is one PageClickTracker per AutofillAgent.
28 class PageClickTracker : public content::RenderFrameObserver {
29 public:
30 // The |listener| will be notified when an element is clicked. It must
31 // outlive this class.
32 PageClickTracker(content::RenderFrame* render_frame,
33 PageClickListener* listener);
34 ~PageClickTracker() override;
36 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);
43 // RenderViewObserver implementation.
44 void OnDestruct() override;
45 void DidHandleMouseEvent(const blink::WebMouseEvent& event) override;
46 void DidHandleGestureEvent(const blink::WebGestureEvent& event) override;
47 void FocusChangeComplete() override;
49 private:
50 PageClickTracker* tracker_;
52 friend class Legacy;
54 // RenderFrameObserver implementation.
55 void FocusedNodeChanged(const blink::WebNode& node) override;
57 // RenderViewObserver methods forwarded from Legacy. Should be
58 // merged into RenderFrameObserver.
59 void DidHandleMouseEvent(const blink::WebMouseEvent& event);
60 void DidHandleGestureEvent(const blink::WebGestureEvent& event);
61 void FocusChangeComplete();
62 void DoFocusChangeComplete();
64 // True when the last click was on the focused node.
65 bool focused_node_was_last_clicked_;
67 // This is set to false when the focus changes, then set back to true soon
68 // afterwards. This helps track whether an event happened after a node was
69 // already focused, or if it caused the focus to change.
70 bool was_focused_before_now_;
72 // The listener getting the actual notifications.
73 PageClickListener* listener_;
75 Legacy legacy_;
77 DISALLOW_COPY_AND_ASSIGN(PageClickTracker);
80 } // namespace autofill
82 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PAGE_CLICK_TRACKER_H_