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

Side by Side Diff: chrome/browser/ui/autofill/chrome_autofill_client.cc

Issue 1931043002: Remove requestAutocomplete (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 7 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 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"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "chrome/browser/autofill/personal_data_manager_factory.h" 14 #include "chrome/browser/autofill/personal_data_manager_factory.h"
15 #include "chrome/browser/autofill/risk_util.h" 15 #include "chrome/browser/autofill/risk_util.h"
16 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/infobars/infobar_service.h" 17 #include "chrome/browser/infobars/infobar_service.h"
18 #include "chrome/browser/password_manager/chrome_password_manager_client.h" 18 #include "chrome/browser/password_manager/chrome_password_manager_client.h"
19 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 20 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
21 #include "chrome/browser/signin/signin_manager_factory.h" 21 #include "chrome/browser/signin/signin_manager_factory.h"
22 #include "chrome/browser/sync/profile_sync_service_factory.h" 22 #include "chrome/browser/sync/profile_sync_service_factory.h"
23 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h"
24 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" 23 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h"
25 #include "chrome/browser/ui/autofill/create_card_unmask_prompt_view.h" 24 #include "chrome/browser/ui/autofill/create_card_unmask_prompt_view.h"
26 #include "chrome/browser/ui/autofill/credit_card_scanner_controller.h" 25 #include "chrome/browser/ui/autofill/credit_card_scanner_controller.h"
27 #include "chrome/browser/ui/autofill/save_card_bubble_controller_impl.h" 26 #include "chrome/browser/ui/autofill/save_card_bubble_controller_impl.h"
28 #include "chrome/browser/ui/browser.h" 27 #include "chrome/browser/ui/browser.h"
29 #include "chrome/browser/ui/browser_finder.h" 28 #include "chrome/browser/ui/browser_finder.h"
30 #include "chrome/browser/ui/browser_window.h" 29 #include "chrome/browser/ui/browser_window.h"
31 #include "chrome/browser/ui/chrome_pages.h" 30 #include "chrome/browser/ui/chrome_pages.h"
32 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" 31 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
33 #include "chrome/browser/web_data_service_factory.h" 32 #include "chrome/browser/web_data_service_factory.h"
(...skipping 30 matching lines...) Expand all
64 63
65 DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::ChromeAutofillClient); 64 DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::ChromeAutofillClient);
66 65
67 namespace autofill { 66 namespace autofill {
68 67
69 ChromeAutofillClient::ChromeAutofillClient(content::WebContents* web_contents) 68 ChromeAutofillClient::ChromeAutofillClient(content::WebContents* web_contents)
70 : content::WebContentsObserver(web_contents), 69 : content::WebContentsObserver(web_contents),
71 unmask_controller_( 70 unmask_controller_(
72 user_prefs::UserPrefs::Get(web_contents->GetBrowserContext()), 71 user_prefs::UserPrefs::Get(web_contents->GetBrowserContext()),
73 Profile::FromBrowserContext(web_contents->GetBrowserContext()) 72 Profile::FromBrowserContext(web_contents->GetBrowserContext())
74 ->IsOffTheRecord()), 73 ->IsOffTheRecord()) {
75 last_rfh_to_rac_(nullptr) {
76 DCHECK(web_contents); 74 DCHECK(web_contents);
77 75
78 #if !BUILDFLAG(ANDROID_JAVA_UI) 76 #if !BUILDFLAG(ANDROID_JAVA_UI)
79 // Since ZoomController is also a WebContentsObserver, we need to be careful 77 // Since ZoomController is also a WebContentsObserver, we need to be careful
80 // about disconnecting from it since the relative order of destruction of 78 // about disconnecting from it since the relative order of destruction of
81 // WebContentsObservers is not guaranteed. ZoomController silently clears 79 // WebContentsObservers is not guaranteed. ZoomController silently clears
82 // its ZoomObserver list during WebContentsDestroyed() so there's no need 80 // its ZoomObserver list during WebContentsDestroyed() so there's no need
83 // to explicitly remove ourselves on destruction. 81 // to explicitly remove ourselves on destruction.
84 ui_zoom::ZoomController* zoom_controller = 82 ui_zoom::ZoomController* zoom_controller =
85 ui_zoom::ZoomController::FromWebContents(web_contents); 83 ui_zoom::ZoomController::FromWebContents(web_contents);
86 // There may not always be a ZoomController, e.g. in tests. 84 // There may not always be a ZoomController, e.g. in tests.
87 if (zoom_controller) 85 if (zoom_controller)
88 zoom_controller->AddObserver(this); 86 zoom_controller->AddObserver(this);
89 #endif 87 #endif
90 } 88 }
91 89
92 ChromeAutofillClient::~ChromeAutofillClient() { 90 ChromeAutofillClient::~ChromeAutofillClient() {
93 // NOTE: It is too late to clean up the autofill popup; that cleanup process 91 // NOTE: It is too late to clean up the autofill popup; that cleanup process
94 // requires that the WebContents instance still be valid and it is not at 92 // requires that the WebContents instance still be valid and it is not at
95 // this point (in particular, the WebContentsImpl destructor has already 93 // this point (in particular, the WebContentsImpl destructor has already
96 // finished running and we are now in the base class destructor). 94 // finished running and we are now in the base class destructor).
97 DCHECK(!popup_controller_); 95 DCHECK(!popup_controller_);
98 } 96 }
99 97
100 void ChromeAutofillClient::TabActivated() {
101 if (dialog_controller_.get())
102 dialog_controller_->TabActivated();
103 }
104
105 PersonalDataManager* ChromeAutofillClient::GetPersonalDataManager() { 98 PersonalDataManager* ChromeAutofillClient::GetPersonalDataManager() {
106 Profile* profile = 99 Profile* profile =
107 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); 100 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
108 return PersonalDataManagerFactory::GetForProfile( 101 return PersonalDataManagerFactory::GetForProfile(
109 profile->GetOriginalProfile()); 102 profile->GetOriginalProfile());
110 } 103 }
111 104
112 scoped_refptr<AutofillWebDataService> ChromeAutofillClient::GetDatabase() { 105 scoped_refptr<AutofillWebDataService> ChromeAutofillClient::GetDatabase() {
113 Profile* profile = 106 Profile* profile =
114 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); 107 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 211
219 bool ChromeAutofillClient::HasCreditCardScanFeature() { 212 bool ChromeAutofillClient::HasCreditCardScanFeature() {
220 return CreditCardScannerController::HasCreditCardScanFeature(); 213 return CreditCardScannerController::HasCreditCardScanFeature();
221 } 214 }
222 215
223 void ChromeAutofillClient::ScanCreditCard( 216 void ChromeAutofillClient::ScanCreditCard(
224 const CreditCardScanCallback& callback) { 217 const CreditCardScanCallback& callback) {
225 CreditCardScannerController::ScanCreditCard(web_contents(), callback); 218 CreditCardScannerController::ScanCreditCard(web_contents(), callback);
226 } 219 }
227 220
228 void ChromeAutofillClient::ShowRequestAutocompleteDialog(
229 const FormData& form,
230 content::RenderFrameHost* render_frame_host,
231 const ResultCallback& callback) {
232 HideRequestAutocompleteDialog();
233 last_rfh_to_rac_ = render_frame_host;
234 GURL frame_url = render_frame_host->GetLastCommittedURL();
235 dialog_controller_ = AutofillDialogController::Create(web_contents(), form,
236 frame_url, callback);
237 if (dialog_controller_) {
238 dialog_controller_->Show();
239 } else {
240 callback.Run(AutofillClient::AutocompleteResultErrorDisabled,
241 base::string16(),
242 NULL);
243 NOTIMPLEMENTED();
244 }
245 }
246
247 void ChromeAutofillClient::ShowAutofillPopup( 221 void ChromeAutofillClient::ShowAutofillPopup(
248 const gfx::RectF& element_bounds, 222 const gfx::RectF& element_bounds,
249 base::i18n::TextDirection text_direction, 223 base::i18n::TextDirection text_direction,
250 const std::vector<autofill::Suggestion>& suggestions, 224 const std::vector<autofill::Suggestion>& suggestions,
251 base::WeakPtr<AutofillPopupDelegate> delegate) { 225 base::WeakPtr<AutofillPopupDelegate> delegate) {
252 // Convert element_bounds to be in screen space. 226 // Convert element_bounds to be in screen space.
253 gfx::Rect client_area = web_contents()->GetContainerBounds(); 227 gfx::Rect client_area = web_contents()->GetContainerBounds();
254 gfx::RectF element_bounds_in_screen_space = 228 gfx::RectF element_bounds_in_screen_space =
255 element_bounds + client_area.OffsetFromOrigin(); 229 element_bounds + client_area.OffsetFromOrigin();
256 230
(...skipping 26 matching lines...) Expand all
283 ChromePasswordManagerClient::FromWebContents(web_contents()); 257 ChromePasswordManagerClient::FromWebContents(web_contents());
284 if (password_client) 258 if (password_client)
285 password_client->HidePasswordGenerationPopup(); 259 password_client->HidePasswordGenerationPopup();
286 } 260 }
287 261
288 bool ChromeAutofillClient::IsAutocompleteEnabled() { 262 bool ChromeAutofillClient::IsAutocompleteEnabled() {
289 // For browser, Autocomplete is always enabled as part of Autofill. 263 // For browser, Autocomplete is always enabled as part of Autofill.
290 return GetPrefs()->GetBoolean(prefs::kAutofillEnabled); 264 return GetPrefs()->GetBoolean(prefs::kAutofillEnabled);
291 } 265 }
292 266
293 void ChromeAutofillClient::HideRequestAutocompleteDialog() {
294 if (dialog_controller_)
295 dialog_controller_->Hide();
296 }
297
298 void ChromeAutofillClient::RenderFrameDeleted(
299 content::RenderFrameHost* render_frame_host) {
300 if (dialog_controller_ && render_frame_host == last_rfh_to_rac_)
301 HideRequestAutocompleteDialog();
302 }
303
304 void ChromeAutofillClient::DidNavigateAnyFrame(
305 content::RenderFrameHost* render_frame_host,
306 const content::LoadCommittedDetails& details,
307 const content::FrameNavigateParams& params) {
308 if (dialog_controller_ && render_frame_host == last_rfh_to_rac_)
309 HideRequestAutocompleteDialog();
310 }
311
312 void ChromeAutofillClient::MainFrameWasResized(bool width_changed) { 267 void ChromeAutofillClient::MainFrameWasResized(bool width_changed) {
313 #if BUILDFLAG(ANDROID_JAVA_UI) 268 #if BUILDFLAG(ANDROID_JAVA_UI)
314 // Ignore virtual keyboard showing and hiding a strip of suggestions. 269 // Ignore virtual keyboard showing and hiding a strip of suggestions.
315 if (!width_changed) 270 if (!width_changed)
316 return; 271 return;
317 #endif 272 #endif
318 273
319 HideAutofillPopup(); 274 HideAutofillPopup();
320 } 275 }
321 276
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 326
372 ssl_status = navigation_entry->GetSSL(); 327 ssl_status = navigation_entry->GetSSL();
373 // Note: If changing the implementation below, also change 328 // Note: If changing the implementation below, also change
374 // AwAutofillClient::IsContextSecure. See crbug.com/505388 329 // AwAutofillClient::IsContextSecure. See crbug.com/505388
375 return ssl_status.security_style == content::SECURITY_STYLE_AUTHENTICATED && 330 return ssl_status.security_style == content::SECURITY_STYLE_AUTHENTICATED &&
376 !(ssl_status.content_status & 331 !(ssl_status.content_status &
377 content::SSLStatus::RAN_INSECURE_CONTENT); 332 content::SSLStatus::RAN_INSECURE_CONTENT);
378 } 333 }
379 334
380 } // namespace autofill 335 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/autofill/chrome_autofill_client.h ('k') | chrome/browser/ui/autofill/country_combobox_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698