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

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

Issue 63273002: Rename WebKit namespace to blink (part 4) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
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 #include "components/autofill/content/renderer/page_click_tracker.h" 5 #include "components/autofill/content/renderer/page_click_tracker.h"
6 6
7 #include "components/autofill/content/renderer/form_autofill_util.h" 7 #include "components/autofill/content/renderer/form_autofill_util.h"
8 #include "components/autofill/content/renderer/page_click_listener.h" 8 #include "components/autofill/content/renderer/page_click_listener.h"
9 #include "content/public/renderer/render_view.h" 9 #include "content/public/renderer/render_view.h"
10 #include "third_party/WebKit/public/platform/WebString.h" 10 #include "third_party/WebKit/public/platform/WebString.h"
11 #include "third_party/WebKit/public/web/WebDOMMouseEvent.h" 11 #include "third_party/WebKit/public/web/WebDOMMouseEvent.h"
12 #include "third_party/WebKit/public/web/WebDocument.h" 12 #include "third_party/WebKit/public/web/WebDocument.h"
13 #include "third_party/WebKit/public/web/WebFrame.h" 13 #include "third_party/WebKit/public/web/WebFrame.h"
14 #include "third_party/WebKit/public/web/WebInputElement.h" 14 #include "third_party/WebKit/public/web/WebInputElement.h"
15 #include "third_party/WebKit/public/web/WebInputEvent.h" 15 #include "third_party/WebKit/public/web/WebInputEvent.h"
16 #include "third_party/WebKit/public/web/WebView.h" 16 #include "third_party/WebKit/public/web/WebView.h"
17 17
18 using WebKit::WebDOMEvent; 18 using blink::WebDOMEvent;
19 using WebKit::WebDOMMouseEvent; 19 using blink::WebDOMMouseEvent;
20 using WebKit::WebElement; 20 using blink::WebElement;
21 using WebKit::WebFormControlElement; 21 using blink::WebFormControlElement;
22 using WebKit::WebFrame; 22 using blink::WebFrame;
23 using WebKit::WebInputElement; 23 using blink::WebInputElement;
24 using WebKit::WebInputEvent; 24 using blink::WebInputEvent;
25 using WebKit::WebMouseEvent; 25 using blink::WebMouseEvent;
26 using WebKit::WebNode; 26 using blink::WebNode;
27 using WebKit::WebString; 27 using blink::WebString;
28 using WebKit::WebView; 28 using blink::WebView;
29 29
30 namespace { 30 namespace {
31 31
32 // Casts |node| to a WebInputElement. 32 // Casts |node| to a WebInputElement.
33 // Returns an empty (isNull()) WebInputElement if |node| is not a text field. 33 // Returns an empty (isNull()) WebInputElement if |node| is not a text field.
34 const WebInputElement GetTextWebInputElement(const WebNode& node) { 34 const WebInputElement GetTextWebInputElement(const WebNode& node) {
35 if (!node.isElementNode()) 35 if (!node.isElementNode())
36 return WebInputElement(); 36 return WebInputElement();
37 const WebElement element = node.toConst<WebElement>(); 37 const WebElement element = node.toConst<WebElement>();
38 if (!element.hasTagName("input")) 38 if (!element.hasTagName("input"))
39 return WebInputElement(); 39 return WebInputElement();
40 const WebInputElement* input = WebKit::toWebInputElement(&element); 40 const WebInputElement* input = blink::toWebInputElement(&element);
41 if (!autofill::IsTextInput(input)) 41 if (!autofill::IsTextInput(input))
42 return WebInputElement(); 42 return WebInputElement();
43 return *input; 43 return *input;
44 } 44 }
45 45
46 // Checks to see if a text field was the previously selected node and is now 46 // Checks to see if a text field was the previously selected node and is now
47 // losing its focus. 47 // losing its focus.
48 bool DidSelectedTextFieldLoseFocus(const WebNode& newly_clicked_node) { 48 bool DidSelectedTextFieldLoseFocus(const WebNode& newly_clicked_node) {
49 WebKit::WebNode focused_node = newly_clicked_node.document().focusedNode(); 49 blink::WebNode focused_node = newly_clicked_node.document().focusedNode();
50 50
51 if (focused_node.isNull() || GetTextWebInputElement(focused_node).isNull()) 51 if (focused_node.isNull() || GetTextWebInputElement(focused_node).isNull())
52 return false; 52 return false;
53 53
54 return focused_node != newly_clicked_node; 54 return focused_node != newly_clicked_node;
55 } 55 }
56 56
57 } // namespace 57 } // namespace
58 58
59 namespace autofill { 59 namespace autofill {
(...skipping 23 matching lines...) Expand all
83 // We are only interested in text field clicks. 83 // We are only interested in text field clicks.
84 const WebInputElement input_element = 84 const WebInputElement input_element =
85 GetTextWebInputElement(last_node_clicked_); 85 GetTextWebInputElement(last_node_clicked_);
86 if (input_element.isNull()) 86 if (input_element.isNull())
87 return; 87 return;
88 88
89 bool is_focused = (last_node_clicked_ == render_view()->GetFocusedNode()); 89 bool is_focused = (last_node_clicked_ == render_view()->GetFocusedNode());
90 listener_->InputElementClicked(input_element, was_focused_, is_focused); 90 listener_->InputElementClicked(input_element, was_focused_, is_focused);
91 } 91 }
92 92
93 void PageClickTracker::DidFinishDocumentLoad(WebKit::WebFrame* frame) { 93 void PageClickTracker::DidFinishDocumentLoad(blink::WebFrame* frame) {
94 tracked_frames_.push_back(frame); 94 tracked_frames_.push_back(frame);
95 frame->document().addEventListener("mousedown", this, false); 95 frame->document().addEventListener("mousedown", this, false);
96 } 96 }
97 97
98 void PageClickTracker::FrameDetached(WebKit::WebFrame* frame) { 98 void PageClickTracker::FrameDetached(blink::WebFrame* frame) {
99 std::vector<WebKit::WebFrame*>::iterator iter = 99 std::vector<blink::WebFrame*>::iterator iter =
100 std::find(tracked_frames_.begin(), tracked_frames_.end(), frame); 100 std::find(tracked_frames_.begin(), tracked_frames_.end(), frame);
101 if (iter == tracked_frames_.end()) { 101 if (iter == tracked_frames_.end()) {
102 // Some frames might never load contents so we may not have a listener on 102 // Some frames might never load contents so we may not have a listener on
103 // them. Calling removeEventListener() on them would trigger an assert, so 103 // them. Calling removeEventListener() on them would trigger an assert, so
104 // we need to keep track of which frames we are listening to. 104 // we need to keep track of which frames we are listening to.
105 return; 105 return;
106 } 106 }
107 tracked_frames_.erase(iter); 107 tracked_frames_.erase(iter);
108 } 108 }
109 109
(...skipping 27 matching lines...) Expand all
137 was_focused_ = (node.document().focusedNode() == last_node_clicked_); 137 was_focused_ = (node.document().focusedNode() == last_node_clicked_);
138 } 138 }
139 139
140 void PageClickTracker::HandleTextFieldMaybeLosingFocus( 140 void PageClickTracker::HandleTextFieldMaybeLosingFocus(
141 const WebNode& newly_clicked_node) { 141 const WebNode& newly_clicked_node) {
142 if (DidSelectedTextFieldLoseFocus(newly_clicked_node)) 142 if (DidSelectedTextFieldLoseFocus(newly_clicked_node))
143 listener_->InputElementLostFocus(); 143 listener_->InputElementLostFocus();
144 } 144 }
145 145
146 } // namespace autofill 146 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698