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

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

Issue 1082183002: Android - Introduce "keyboard accessory" for Autofill suggestions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more dtrainor review Created 5 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 #include "components/autofill/content/renderer/page_click_tracker.h" 5 #include "components/autofill/content/renderer/page_click_tracker.h"
6 6
7 #include "base/command_line.h"
7 #include "components/autofill/content/renderer/form_autofill_util.h" 8 #include "components/autofill/content/renderer/form_autofill_util.h"
8 #include "components/autofill/content/renderer/page_click_listener.h" 9 #include "components/autofill/content/renderer/page_click_listener.h"
10 #include "components/autofill/core/common/autofill_switches.h"
9 #include "content/public/renderer/render_frame.h" 11 #include "content/public/renderer/render_frame.h"
10 #include "content/public/renderer/render_view.h" 12 #include "content/public/renderer/render_view.h"
11 #include "third_party/WebKit/public/platform/WebPoint.h" 13 #include "third_party/WebKit/public/platform/WebPoint.h"
12 #include "third_party/WebKit/public/platform/WebSize.h" 14 #include "third_party/WebKit/public/platform/WebSize.h"
13 #include "third_party/WebKit/public/web/WebDocument.h" 15 #include "third_party/WebKit/public/web/WebDocument.h"
14 #include "third_party/WebKit/public/web/WebHitTestResult.h" 16 #include "third_party/WebKit/public/web/WebHitTestResult.h"
15 #include "third_party/WebKit/public/web/WebInputElement.h" 17 #include "third_party/WebKit/public/web/WebInputElement.h"
16 #include "third_party/WebKit/public/web/WebInputEvent.h" 18 #include "third_party/WebKit/public/web/WebInputEvent.h"
17 #include "third_party/WebKit/public/web/WebLocalFrame.h" 19 #include "third_party/WebKit/public/web/WebLocalFrame.h"
18 #include "third_party/WebKit/public/web/WebTextAreaElement.h" 20 #include "third_party/WebKit/public/web/WebTextAreaElement.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 WebNode tapped_node = render_frame()->GetRenderView()->GetWebView() 93 WebNode tapped_node = render_frame()->GetRenderView()->GetWebView()
92 ->hitTestResultForTap( 94 ->hitTestResultForTap(
93 WebPoint(event.x, event.y), 95 WebPoint(event.x, event.y),
94 WebSize(event.data.tap.width, event.data.tap.height)).node(); 96 WebSize(event.data.tap.width, event.data.tap.height)).node();
95 focused_node_was_last_clicked_ = !tapped_node.isNull() && 97 focused_node_was_last_clicked_ = !tapped_node.isNull() &&
96 tapped_node.focused(); 98 tapped_node.focused();
97 } 99 }
98 100
99 void PageClickTracker::FocusedNodeChanged(const WebNode& node) { 101 void PageClickTracker::FocusedNodeChanged(const WebNode& node) {
100 was_focused_before_now_ = false; 102 was_focused_before_now_ = false;
103
104 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
105 switches::kEnableAccessorySuggestionView)) {
106 focused_node_was_last_clicked_ = true;
107 DoFocusChangeComplete();
108 }
101 } 109 }
102 110
103 void PageClickTracker::FocusChangeComplete() { 111 void PageClickTracker::FocusChangeComplete() {
112 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
113 switches::kEnableAccessorySuggestionView)) {
114 return;
115 }
116
117 DoFocusChangeComplete();
118 }
119
120 void PageClickTracker::DoFocusChangeComplete() {
104 WebNode focused_node = render_frame()->GetFocusedElement(); 121 WebNode focused_node = render_frame()->GetFocusedElement();
105 if (focused_node_was_last_clicked_ && !focused_node.isNull()) { 122 if (focused_node_was_last_clicked_ && !focused_node.isNull()) {
106 const WebInputElement input_element = GetTextWebInputElement(focused_node); 123 const WebInputElement input_element = GetTextWebInputElement(focused_node);
107 if (!input_element.isNull()) { 124 if (!input_element.isNull()) {
108 listener_->FormControlElementClicked(input_element, 125 listener_->FormControlElementClicked(input_element,
109 was_focused_before_now_); 126 was_focused_before_now_);
110 } else { 127 } else {
111 const WebTextAreaElement textarea_element = 128 const WebTextAreaElement textarea_element =
112 GetWebTextAreaElement(focused_node); 129 GetWebTextAreaElement(focused_node);
113 if (!textarea_element.isNull()) { 130 if (!textarea_element.isNull()) {
(...skipping 25 matching lines...) Expand all
139 void PageClickTracker::Legacy::DidHandleGestureEvent( 156 void PageClickTracker::Legacy::DidHandleGestureEvent(
140 const WebGestureEvent& event) { 157 const WebGestureEvent& event) {
141 tracker_->DidHandleGestureEvent(event); 158 tracker_->DidHandleGestureEvent(event);
142 } 159 }
143 160
144 void PageClickTracker::Legacy::FocusChangeComplete() { 161 void PageClickTracker::Legacy::FocusChangeComplete() {
145 tracker_->FocusChangeComplete(); 162 tracker_->FocusChangeComplete();
146 } 163 }
147 164
148 } // namespace autofill 165 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698