Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/ui/autofill/chrome_autofill_client.h" | 5 #include "chrome/browser/ui/autofill/chrome_autofill_client.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 246 CreditCardScannerController::ScanCreditCard(web_contents(), callback); | 246 CreditCardScannerController::ScanCreditCard(web_contents(), callback); |
| 247 } | 247 } |
| 248 | 248 |
| 249 void ChromeAutofillClient::ShowAutofillPopup( | 249 void ChromeAutofillClient::ShowAutofillPopup( |
| 250 const gfx::RectF& element_bounds, | 250 const gfx::RectF& element_bounds, |
| 251 base::i18n::TextDirection text_direction, | 251 base::i18n::TextDirection text_direction, |
| 252 const std::vector<autofill::Suggestion>& suggestions, | 252 const std::vector<autofill::Suggestion>& suggestions, |
| 253 base::WeakPtr<AutofillPopupDelegate> delegate) { | 253 base::WeakPtr<AutofillPopupDelegate> delegate) { |
| 254 // Convert element_bounds to be in screen space. | 254 // Convert element_bounds to be in screen space. |
| 255 gfx::Rect client_area = web_contents()->GetContainerBounds(); | 255 gfx::Rect client_area = web_contents()->GetContainerBounds(); |
| 256 | |
| 257 // Element bounds are relative to the viewport (client_area). | |
| 258 if ((element_bounds.y() + element_bounds.height()) < 0 || | |
|
Evan Stade
2017/01/18 00:05:46
nit: element_bounds.bottom()
lgarron
2017/04/05 00:59:42
Ooh, good to know.
| |
| 259 (element_bounds.y() + element_bounds.height()) >= client_area.height()) { | |
|
Evan Stade
2017/01/18 00:05:46
what about the x direction? Seems like this should
lgarron
2017/04/05 00:59:43
Oh, right. I explicitly discussed this with estark
| |
| 260 // The top of the popup would be outside the viewport (and would disappear | |
| 261 // before the relevant field can scroll into the viewport), so we supress | |
|
Evan Stade
2017/01/18 00:05:46
nit: suppress
lgarron
2017/04/05 00:59:41
Done.
| |
| 262 // it to avoid crbug.com/678713 | |
| 263 return; | |
| 264 } | |
| 265 | |
| 256 gfx::RectF element_bounds_in_screen_space = | 266 gfx::RectF element_bounds_in_screen_space = |
| 257 element_bounds + client_area.OffsetFromOrigin(); | 267 element_bounds + client_area.OffsetFromOrigin(); |
| 258 | 268 |
| 259 // Will delete or reuse the old |popup_controller_|. | 269 // Will delete or reuse the old |popup_controller_|. |
| 260 popup_controller_ = | 270 popup_controller_ = |
| 261 AutofillPopupControllerImpl::GetOrCreate(popup_controller_, | 271 AutofillPopupControllerImpl::GetOrCreate(popup_controller_, |
| 262 delegate, | 272 delegate, |
| 263 web_contents(), | 273 web_contents(), |
| 264 web_contents()->GetNativeView(), | 274 web_contents()->GetNativeView(), |
| 265 element_bounds_in_screen_space, | 275 element_bounds_in_screen_space, |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 395 } | 405 } |
| 396 | 406 |
| 397 void ChromeAutofillClient::ShowHttpNotSecureExplanation() { | 407 void ChromeAutofillClient::ShowHttpNotSecureExplanation() { |
| 398 web_contents()->OpenURL(content::OpenURLParams( | 408 web_contents()->OpenURL(content::OpenURLParams( |
| 399 GURL(kSecurityIndicatorHelpCenterUrl), content::Referrer(), | 409 GURL(kSecurityIndicatorHelpCenterUrl), content::Referrer(), |
| 400 WindowOpenDisposition::NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, | 410 WindowOpenDisposition::NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, |
| 401 false /* is_renderer_initiated */)); | 411 false /* is_renderer_initiated */)); |
| 402 } | 412 } |
| 403 | 413 |
| 404 } // namespace autofill | 414 } // namespace autofill |
| OLD | NEW |