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

Side by Side Diff: chrome/browser/autofill/autofill_external_delegate.cc

Issue 12188020: Adding the page and DPI scale adjustment for Autofill Popups. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/utf_string_conversions.h" 5 #include "base/utf_string_conversions.h"
6 #include "chrome/browser/autofill/autocomplete_history_manager.h" 6 #include "chrome/browser/autofill/autocomplete_history_manager.h"
7 #include "chrome/browser/autofill/autofill_external_delegate.h" 7 #include "chrome/browser/autofill/autofill_external_delegate.h"
8 #include "chrome/browser/autofill/autofill_manager.h" 8 #include "chrome/browser/autofill/autofill_manager.h"
9 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" 9 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h"
10 #include "chrome/common/autofill_messages.h" 10 #include "chrome/common/autofill_messages.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 } 64 }
65 65
66 AutofillExternalDelegate::~AutofillExternalDelegate() { 66 AutofillExternalDelegate::~AutofillExternalDelegate() {
67 if (controller_) 67 if (controller_)
68 controller_->Hide(); 68 controller_->Hide();
69 } 69 }
70 70
71 void AutofillExternalDelegate::OnQuery(int query_id, 71 void AutofillExternalDelegate::OnQuery(int query_id,
72 const FormData& form, 72 const FormData& form,
73 const FormFieldData& field, 73 const FormFieldData& field,
74 const gfx::Rect& element_bounds, 74 const gfx::RectF& element_bounds,
75 bool display_warning_if_disabled) { 75 bool display_warning_if_disabled) {
76 autofill_query_form_ = form; 76 autofill_query_form_ = form;
77 autofill_query_field_ = field; 77 autofill_query_field_ = field;
78 display_warning_if_disabled_ = display_warning_if_disabled; 78 display_warning_if_disabled_ = display_warning_if_disabled;
79 autofill_query_id_ = query_id; 79 autofill_query_id_ = query_id;
80 80
81 EnsurePopupForElement(element_bounds); 81 EnsurePopupForElement(element_bounds);
82 } 82 }
83 83
84 void AutofillExternalDelegate::OnSuggestionsReturned( 84 void AutofillExternalDelegate::OnSuggestionsReturned(
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 autofill_manager_->OnDidShowAutofillSuggestions( 140 autofill_manager_->OnDidShowAutofillSuggestions(
141 has_autofill_item && !has_shown_autofill_popup_for_current_edit_); 141 has_autofill_item && !has_shown_autofill_popup_for_current_edit_);
142 } 142 }
143 has_shown_autofill_popup_for_current_edit_ |= has_autofill_item; 143 has_shown_autofill_popup_for_current_edit_ |= has_autofill_item;
144 } 144 }
145 } 145 }
146 146
147 void AutofillExternalDelegate::OnShowPasswordSuggestions( 147 void AutofillExternalDelegate::OnShowPasswordSuggestions(
148 const std::vector<string16>& suggestions, 148 const std::vector<string16>& suggestions,
149 const FormFieldData& field, 149 const FormFieldData& field,
150 const gfx::Rect& element_bounds) { 150 const gfx::RectF& element_bounds) {
151 autofill_query_field_ = field; 151 autofill_query_field_ = field;
152 EnsurePopupForElement(element_bounds); 152 EnsurePopupForElement(element_bounds);
153 153
154 if (suggestions.empty()) { 154 if (suggestions.empty()) {
155 HideAutofillPopup(); 155 HideAutofillPopup();
156 return; 156 return;
157 } 157 }
158 158
159 std::vector<string16> empty(suggestions.size()); 159 std::vector<string16> empty(suggestions.size());
160 std::vector<int> password_ids(suggestions.size(), 160 std::vector<int> password_ids(suggestions.size(),
161 WebAutofillClient::MenuItemIDPasswordEntry); 161 WebAutofillClient::MenuItemIDPasswordEntry);
162 ApplyAutofillSuggestions(suggestions, empty, empty, password_ids); 162 ApplyAutofillSuggestions(suggestions, empty, empty, password_ids);
163 } 163 }
164 164
165 void AutofillExternalDelegate::EnsurePopupForElement( 165 void AutofillExternalDelegate::EnsurePopupForElement(
166 const gfx::Rect& element_bounds) { 166 const gfx::RectF& element_bounds) {
167 // Convert element_bounds to be in screen space. If |web_contents_| is NULL 167 // Convert element_bounds to be in screen space. If |web_contents_| is NULL
168 // then assume the element_bounds is already in screen space (since we don't 168 // then assume the element_bounds is already in screen space (since we don't
169 // have any other way of converting to screen space). 169 // have any other way of converting to screen space).
170 gfx::Rect element_bounds_in_screen_space = element_bounds; 170 gfx::RectF element_bounds_in_screen_space = element_bounds;
171 if (web_contents_) { 171 if (web_contents_) {
172 gfx::Rect client_area; 172 gfx::Rect client_area;
173 web_contents_->GetContainerBounds(&client_area); 173 web_contents_->GetContainerBounds(&client_area);
174 element_bounds_in_screen_space += client_area.OffsetFromOrigin(); 174 element_bounds_in_screen_space += client_area.OffsetFromOrigin();
175 } 175 }
176 176
177 // |controller_| owns itself. 177 // |controller_| owns itself.
178 controller_ = AutofillPopupControllerImpl::GetOrCreate( 178 controller_ = AutofillPopupControllerImpl::GetOrCreate(
179 controller_, 179 controller_,
180 this, 180 this,
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 const content::NotificationDetails& details) { 414 const content::NotificationDetails& details) {
415 if (type == content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED) { 415 if (type == content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED) {
416 if (!*content::Details<bool>(details).ptr()) 416 if (!*content::Details<bool>(details).ptr())
417 HideAutofillPopup(); 417 HideAutofillPopup();
418 } else if (type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) { 418 } else if (type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) {
419 HideAutofillPopup(); 419 HideAutofillPopup();
420 } else { 420 } else {
421 NOTREACHED(); 421 NOTREACHED();
422 } 422 }
423 } 423 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698