| 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 "base/compiler_specific.h" |
| 12 #include "components/autofill/common/autofill_export.h" |
| 11 #include "content/public/renderer/render_view_observer.h" | 13 #include "content/public/renderer/render_view_observer.h" |
| 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMEventListener.h
" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMEventListener.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 |
| 23 // before it was clicked. | 25 // before it was clicked. |
| 24 // | 26 // |
| 25 // 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 |
| 26 // suggestion popup when a text input is clicked. | 28 // suggestion popup when a text input is clicked. |
| 27 // It only notifies of WebInputElement that are text inputs being clicked, but | 29 // It only notifies of WebInputElement that are text inputs being clicked, but |
| 28 // could easily be changed to report click on any type of WebNode. | 30 // could easily be changed to report click on any type of WebNode. |
| 29 // | 31 // |
| 30 // There is one PageClickTracker per RenderView. | 32 // There is one PageClickTracker per RenderView. |
| 31 class PageClickTracker : public content::RenderViewObserver, | 33 class AUTOFILL_EXPORT PageClickTracker |
| 32 public WebKit::WebDOMEventListener { | 34 : public content::RenderViewObserver, |
| 35 NON_EXPORTED_BASE(public WebKit::WebDOMEventListener) { |
| 33 public: | 36 public: |
| 34 // The |listener| will be notified when an element is clicked. It must | 37 // The |listener| will be notified when an element is clicked. It must |
| 35 // outlive this class. | 38 // outlive this class. |
| 36 PageClickTracker(content::RenderView* render_view, | 39 PageClickTracker(content::RenderView* render_view, |
| 37 PageClickListener* listener); | 40 PageClickListener* listener); |
| 38 virtual ~PageClickTracker(); | 41 virtual ~PageClickTracker(); |
| 39 | 42 |
| 40 private: | 43 private: |
| 41 // RenderView::Observer implementation. | 44 // RenderView::Observer implementation. |
| 42 virtual void DidFinishDocumentLoad(WebKit::WebFrame* frame) OVERRIDE; | 45 virtual void DidFinishDocumentLoad(WebKit::WebFrame* frame) OVERRIDE; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 62 | 65 |
| 63 // The listener getting the actual notifications. | 66 // The listener getting the actual notifications. |
| 64 PageClickListener* listener_; | 67 PageClickListener* listener_; |
| 65 | 68 |
| 66 DISALLOW_COPY_AND_ASSIGN(PageClickTracker); | 69 DISALLOW_COPY_AND_ASSIGN(PageClickTracker); |
| 67 }; | 70 }; |
| 68 | 71 |
| 69 } // namespace autofill | 72 } // namespace autofill |
| 70 | 73 |
| 71 #endif // COMPONENTS_AUTOFILL_RENDERER_PAGE_CLICK_TRACKER_H_ | 74 #endif // COMPONENTS_AUTOFILL_RENDERER_PAGE_CLICK_TRACKER_H_ |
| OLD | NEW |