1f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#include "chrome/browser/ui/autofill/chrome_autofill_client.h"
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/logging.h"
82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/prefs/pref_service.h"
92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/autofill/autofill_cc_infobar_delegate.h"
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/autofill/personal_data_manager_factory.h"
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/infobars/infobar_service.h"
125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "chrome/browser/password_manager/chrome_password_manager_client.h"
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/profiles/profile.h"
14ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch#include "chrome/browser/ui/autofill/autofill_dialog_controller.h"
15c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h"
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/browser.h"
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/browser_finder.h"
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/browser_window.h"
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/chrome_pages.h"
2058e6fbe4ee35d65e14b626c557d37565bf8ad179Ben Murdoch#include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
21116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "chrome/browser/ui/zoom/zoom_controller.h"
22a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include "chrome/browser/webdata/web_data_service_factory.h"
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/common/url_constants.h"
24a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "components/autofill/content/browser/content_autofill_driver.h"
255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "components/autofill/content/common/autofill_messages.h"
26eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "components/autofill/core/common/autofill_pref_names.h"
27bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch#include "content/public/browser/render_view_host.h"
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/gfx/rect.h"
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
30a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#if defined(OS_ANDROID)
311320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "chrome/browser/android/chromium_application.h"
32a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "chrome/browser/ui/android/autofill/autofill_logger_android.h"
33a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#endif
34a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
35f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::ChromeAutofillClient);
362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace autofill {
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
39f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)ChromeAutofillClient::ChromeAutofillClient(content::WebContents* web_contents)
40f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)    : content::WebContentsObserver(web_contents), web_contents_(web_contents) {
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DCHECK(web_contents);
42116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // Since ZoomController is also a WebContentsObserver, we need to be careful
43116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // about disconnecting from it since the relative order of destruction of
44116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // WebContentsObservers is not guaranteed. ZoomController silently clears
45116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // its ZoomObserver list during WebContentsDestroyed() so there's no need
46116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // to explicitly remove ourselves on destruction.
47116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  ZoomController* zoom_controller =
48116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch      ZoomController::FromWebContents(web_contents);
49116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // There may not always be a ZoomController, e.g. on Android.
50116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  if (zoom_controller)
51116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch    zoom_controller->AddObserver(this);
526d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#if defined(OS_MACOSX) && !defined(OS_IOS)
536d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)  RegisterForKeystoneNotifications();
546d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#endif  // defined(OS_MACOSX) && !defined(OS_IOS)
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
57f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)ChromeAutofillClient::~ChromeAutofillClient() {
587dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  // NOTE: It is too late to clean up the autofill popup; that cleanup process
597dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  // requires that the WebContents instance still be valid and it is not at
607dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  // this point (in particular, the WebContentsImpl destructor has already
617dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  // finished running and we are now in the base class destructor).
627dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  DCHECK(!popup_controller_);
636d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#if defined(OS_MACOSX) && !defined(OS_IOS)
646d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)  UnregisterFromKeystoneNotifications();
656d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#endif  // defined(OS_MACOSX) && !defined(OS_IOS)
665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
68f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)void ChromeAutofillClient::TabActivated() {
6958e6fbe4ee35d65e14b626c557d37565bf8ad179Ben Murdoch  if (dialog_controller_.get())
7058e6fbe4ee35d65e14b626c557d37565bf8ad179Ben Murdoch    dialog_controller_->TabActivated();
7158e6fbe4ee35d65e14b626c557d37565bf8ad179Ben Murdoch}
7258e6fbe4ee35d65e14b626c557d37565bf8ad179Ben Murdoch
73f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)PersonalDataManager* ChromeAutofillClient::GetPersonalDataManager() {
742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  Profile* profile =
752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      Profile::FromBrowserContext(web_contents_->GetBrowserContext());
762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return PersonalDataManagerFactory::GetForProfile(
772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      profile->GetOriginalProfile());
785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
80f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)scoped_refptr<AutofillWebDataService> ChromeAutofillClient::GetDatabase() {
81a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  Profile* profile =
82a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)      Profile::FromBrowserContext(web_contents_->GetBrowserContext());
83a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  return WebDataServiceFactory::GetAutofillWebDataForProfile(
84a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)      profile, Profile::EXPLICIT_ACCESS);
85f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)}
86f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
87f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)PrefService* ChromeAutofillClient::GetPrefs() {
88f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  return Profile::FromBrowserContext(web_contents_->GetBrowserContext())
89f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)      ->GetPrefs();
905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
92f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)void ChromeAutofillClient::ShowAutofillSettings() {
935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_ANDROID)
941320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  chrome::android::ChromiumApplication::ShowAutofillSettings();
955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#else
962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  Browser* browser = chrome::FindBrowserWithWebContents(web_contents_);
975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (browser)
985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    chrome::ShowSettingsSubPage(browser, chrome::kAutofillSubPage);
995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // #if defined(OS_ANDROID)
1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
102f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)void ChromeAutofillClient::ConfirmSaveCreditCard(
1032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const AutofillMetrics& metric_logger,
1042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const base::Closure& save_card_callback) {
1052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  InfoBarService* infobar_service =
1062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      InfoBarService::FromWebContents(web_contents_);
1072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  AutofillCCInfoBarDelegate::Create(
1082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      infobar_service, &metric_logger, save_card_callback);
1092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
1102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
111f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)void ChromeAutofillClient::ShowRequestAutocompleteDialog(
1122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const FormData& form,
1132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const GURL& source_url,
114a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch    const ResultCallback& callback) {
1152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  HideRequestAutocompleteDialog();
1162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
117f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  dialog_controller_ = AutofillDialogController::Create(
118f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)      web_contents_, form, source_url, callback);
119ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch  if (dialog_controller_) {
120ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch    dialog_controller_->Show();
121ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch  } else {
122f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)    callback.Run(AutofillClient::AutocompleteResultErrorDisabled,
123a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch                 base::string16(),
124a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch                 NULL);
125ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch    NOTIMPLEMENTED();
126ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch  }
1272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
1282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
129f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)void ChromeAutofillClient::ShowAutofillPopup(
1302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const gfx::RectF& element_bounds,
1317d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)    base::i18n::TextDirection text_direction,
1325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    const std::vector<base::string16>& values,
1335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    const std::vector<base::string16>& labels,
1345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    const std::vector<base::string16>& icons,
1352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const std::vector<int>& identifiers,
136c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    base::WeakPtr<AutofillPopupDelegate> delegate) {
1372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Convert element_bounds to be in screen space.
138010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  gfx::Rect client_area = web_contents_->GetContainerBounds();
1392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  gfx::RectF element_bounds_in_screen_space =
1402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      element_bounds + client_area.OffsetFromOrigin();
1412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Will delete or reuse the old |popup_controller_|.
143f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  popup_controller_ =
144f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)      AutofillPopupControllerImpl::GetOrCreate(popup_controller_,
145f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)                                               delegate,
146f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)                                               web_contents(),
147f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)                                               web_contents()->GetNativeView(),
148f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)                                               element_bounds_in_screen_space,
149f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)                                               text_direction);
1502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  popup_controller_->Show(values, labels, icons, identifiers);
1522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
1532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
154f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)void ChromeAutofillClient::UpdateAutofillPopupDataListValues(
155ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch    const std::vector<base::string16>& values,
156ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch    const std::vector<base::string16>& labels) {
157ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch  if (popup_controller_.get())
158ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch    popup_controller_->UpdateDataListValues(values, labels);
159ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch}
160ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch
161f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)void ChromeAutofillClient::HideAutofillPopup() {
162868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  if (popup_controller_.get())
1632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    popup_controller_->Hide();
1645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
1655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Password generation popups behave in the same fashion and should also
1665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // be hidden.
167a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  ChromePasswordManagerClient* password_client =
168a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      ChromePasswordManagerClient::FromWebContents(web_contents_);
169a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  if (password_client)
170a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    password_client->HidePasswordGenerationPopup();
1712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
1722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
173f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)bool ChromeAutofillClient::IsAutocompleteEnabled() {
174eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  // For browser, Autocomplete is always enabled as part of Autofill.
175eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  return GetPrefs()->GetBoolean(prefs::kAutofillEnabled);
1762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
1772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
178f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)void ChromeAutofillClient::HideRequestAutocompleteDialog() {
179868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  if (dialog_controller_.get())
1802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    dialog_controller_->Hide();
1812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
1822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
183f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)void ChromeAutofillClient::WebContentsDestroyed() {
1847dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  HideAutofillPopup();
1857dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch}
1867dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch
187116680a4aac90f2aa7413d9095a592090648e557Ben Murdochvoid ChromeAutofillClient::OnZoomChanged(
188116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch    const ZoomController::ZoomChangedEventData& data) {
189116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  HideAutofillPopup();
190116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch}
191116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
192f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)void ChromeAutofillClient::DetectAccountCreationForms(
19358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)    const std::vector<autofill::FormStructure*>& forms) {
194c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  password_manager::PasswordGenerationManager* manager =
1955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      ChromePasswordManagerClient::GetGenerationManagerFromWebContents(
1965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)          web_contents_);
19758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  if (manager)
19858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)    manager->DetectAccountCreationForms(forms);
19958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)}
20058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)
201f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)void ChromeAutofillClient::DidFillOrPreviewField(
202a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    const base::string16& autofilled_value,
203a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    const base::string16& profile_full_name) {
204a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#if defined(OS_ANDROID)
205f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  AutofillLoggerAndroid::DidFillOrPreviewField(autofilled_value,
206f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)                                               profile_full_name);
207a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#endif  // defined(OS_ANDROID)
208a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
209a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
2102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}  // namespace autofill
211