[email protected] | b4db6d4 | 2014-06-07 04:36:58 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors. All rights reserved. |
[email protected] | 8d4cc15e | 2012-08-30 00:33:10 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | b4db6d4 | 2014-06-07 04:36:58 | [diff] [blame] | 5 | #include "chrome/browser/ui/autofill/chrome_autofill_client.h" |
[email protected] | 8d4cc15e | 2012-08-30 00:33:10 | [diff] [blame] | 6 | |
| 7 | #include "base/logging.h" |
[email protected] | 3853a4c | 2013-02-11 17:15:57 | [diff] [blame] | 8 | #include "base/prefs/pref_service.h" |
[email protected] | 6f3ccf5 | 2013-02-21 03:55:23 | [diff] [blame] | 9 | #include "chrome/browser/autofill/personal_data_manager_factory.h" |
mathp | 94e3f0b | 2015-03-18 00:16:16 | [diff] [blame] | 10 | #include "chrome/browser/browser_process.h" |
[email protected] | 4a8adfa0 | 2013-03-19 22:37:46 | [diff] [blame] | 11 | #include "chrome/browser/infobars/infobar_service.h" |
[email protected] | 7d7e0b7 | 2014-02-10 18:36:05 | [diff] [blame] | 12 | #include "chrome/browser/password_manager/chrome_password_manager_client.h" |
[email protected] | 8d4cc15e | 2012-08-30 00:33:10 | [diff] [blame] | 13 | #include "chrome/browser/profiles/profile.h" |
estade | 494f8e6 | 2015-01-26 23:28:13 | [diff] [blame] | 14 | #include "chrome/browser/signin/profile_identity_provider.h" |
| 15 | #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 16 | #include "chrome/browser/signin/signin_manager_factory.h" |
[email protected] | a55c674 | 2013-08-10 07:28:48 | [diff] [blame] | 17 | #include "chrome/browser/ui/autofill/autofill_dialog_controller.h" |
[email protected] | bfd4b81 | 2013-04-11 02:02:11 | [diff] [blame] | 18 | #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" |
estade | ecb659d | 2014-12-11 03:53:16 | [diff] [blame] | 19 | #include "chrome/browser/ui/autofill/card_unmask_prompt_view.h" |
rouslan | 497109da | 2014-11-26 20:30:34 | [diff] [blame] | 20 | #include "chrome/browser/ui/autofill/credit_card_scanner_controller.h" |
[email protected] | cc5419d | 2012-08-30 02:29:46 | [diff] [blame] | 21 | #include "chrome/browser/ui/browser.h" |
| 22 | #include "chrome/browser/ui/browser_finder.h" |
| 23 | #include "chrome/browser/ui/browser_window.h" |
| 24 | #include "chrome/browser/ui/chrome_pages.h" |
[email protected] | 10090d5 | 2013-07-25 20:41:37 | [diff] [blame] | 25 | #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" |
[email protected] | 34b5946 | 2013-12-03 14:08:32 | [diff] [blame] | 26 | #include "chrome/browser/webdata/web_data_service_factory.h" |
[email protected] | cc5419d | 2012-08-30 02:29:46 | [diff] [blame] | 27 | #include "chrome/common/url_constants.h" |
[email protected] | e13549e | 2014-03-12 20:34:36 | [diff] [blame] | 28 | #include "components/autofill/content/browser/content_autofill_driver.h" |
[email protected] | 45b53fb | 2013-12-12 19:28:06 | [diff] [blame] | 29 | #include "components/autofill/content/common/autofill_messages.h" |
pritam.nikam | 2cd65ab9 | 2015-01-13 08:13:02 | [diff] [blame] | 30 | #include "components/autofill/core/browser/autofill_cc_infobar_delegate.h" |
[email protected] | 6c7dcb2f2 | 2013-06-22 00:57:48 | [diff] [blame] | 31 | #include "components/autofill/core/common/autofill_pref_names.h" |
estade | b1bc9bd | 2014-12-02 22:44:11 | [diff] [blame] | 32 | #include "components/password_manager/content/browser/content_password_manager_driver.h" |
estade | 1dbe123 | 2015-01-06 22:45:04 | [diff] [blame] | 33 | #include "content/public/browser/render_frame_host.h" |
tfarina | 3b0452d | 2014-12-31 15:20:09 | [diff] [blame] | 34 | #include "ui/gfx/geometry/rect.h" |
[email protected] | 8d4cc15e | 2012-08-30 00:33:10 | [diff] [blame] | 35 | |
[email protected] | 5b466c4 | 2014-02-25 17:56:36 | [diff] [blame] | 36 | #if defined(OS_ANDROID) |
estade | 57722ec | 2014-08-27 23:52:33 | [diff] [blame] | 37 | #include "chrome/browser/android/chromium_application.h" |
[email protected] | 5b466c4 | 2014-02-25 17:56:36 | [diff] [blame] | 38 | #include "chrome/browser/ui/android/autofill/autofill_logger_android.h" |
thestig | 2c8c41e | 2014-10-23 02:56:50 | [diff] [blame] | 39 | #else |
estade | 494f8e6 | 2015-01-26 23:28:13 | [diff] [blame] | 40 | #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
wjmaclean | 7f63c6b | 2014-12-09 14:59:55 | [diff] [blame] | 41 | #include "components/ui/zoom/zoom_controller.h" |
[email protected] | 5b466c4 | 2014-02-25 17:56:36 | [diff] [blame] | 42 | #endif |
| 43 | |
[email protected] | b4db6d4 | 2014-06-07 04:36:58 | [diff] [blame] | 44 | DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::ChromeAutofillClient); |
[email protected] | bfb4d6721 | 2013-02-14 20:32:29 | [diff] [blame] | 45 | |
| 46 | namespace autofill { |
[email protected] | 698bdf74 | 2012-10-01 21:13:50 | [diff] [blame] | 47 | |
[email protected] | b4db6d4 | 2014-06-07 04:36:58 | [diff] [blame] | 48 | ChromeAutofillClient::ChromeAutofillClient(content::WebContents* web_contents) |
estade | 7c369d4 | 2014-12-18 01:46:23 | [diff] [blame] | 49 | : content::WebContentsObserver(web_contents), |
estade | 1dbe123 | 2015-01-06 22:45:04 | [diff] [blame] | 50 | unmask_controller_(web_contents), |
| 51 | last_rfh_to_rac_(nullptr) { |
[email protected] | 698bdf74 | 2012-10-01 21:13:50 | [diff] [blame] | 52 | DCHECK(web_contents); |
thestig | 2c8c41e | 2014-10-23 02:56:50 | [diff] [blame] | 53 | |
| 54 | #if !defined(OS_ANDROID) |
[email protected] | 76a5450 | 2014-07-10 22:59:34 | [diff] [blame] | 55 | // Since ZoomController is also a WebContentsObserver, we need to be careful |
| 56 | // about disconnecting from it since the relative order of destruction of |
| 57 | // WebContentsObservers is not guaranteed. ZoomController silently clears |
| 58 | // its ZoomObserver list during WebContentsDestroyed() so there's no need |
| 59 | // to explicitly remove ourselves on destruction. |
wjmaclean | 7f63c6b | 2014-12-09 14:59:55 | [diff] [blame] | 60 | ui_zoom::ZoomController* zoom_controller = |
| 61 | ui_zoom::ZoomController::FromWebContents(web_contents); |
thestig | 2c8c41e | 2014-10-23 02:56:50 | [diff] [blame] | 62 | // There may not always be a ZoomController, e.g. in tests. |
[email protected] | 76a5450 | 2014-07-10 22:59:34 | [diff] [blame] | 63 | if (zoom_controller) |
| 64 | zoom_controller->AddObserver(this); |
thestig | 2c8c41e | 2014-10-23 02:56:50 | [diff] [blame] | 65 | #endif |
| 66 | |
[email protected] | 34cd671 | 2014-06-19 03:19:26 | [diff] [blame] | 67 | #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 68 | RegisterForKeystoneNotifications(); |
| 69 | #endif // defined(OS_MACOSX) && !defined(OS_IOS) |
[email protected] | 8d4cc15e | 2012-08-30 00:33:10 | [diff] [blame] | 70 | } |
| 71 | |
[email protected] | b4db6d4 | 2014-06-07 04:36:58 | [diff] [blame] | 72 | ChromeAutofillClient::~ChromeAutofillClient() { |
[email protected] | 9256a936 | 2013-07-04 22:11:48 | [diff] [blame] | 73 | // NOTE: It is too late to clean up the autofill popup; that cleanup process |
| 74 | // requires that the WebContents instance still be valid and it is not at |
| 75 | // this point (in particular, the WebContentsImpl destructor has already |
| 76 | // finished running and we are now in the base class destructor). |
| 77 | DCHECK(!popup_controller_); |
[email protected] | 34cd671 | 2014-06-19 03:19:26 | [diff] [blame] | 78 | #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 79 | UnregisterFromKeystoneNotifications(); |
| 80 | #endif // defined(OS_MACOSX) && !defined(OS_IOS) |
[email protected] | 8ac8bfd | 2013-02-27 05:18:08 | [diff] [blame] | 81 | } |
| 82 | |
[email protected] | b4db6d4 | 2014-06-07 04:36:58 | [diff] [blame] | 83 | void ChromeAutofillClient::TabActivated() { |
[email protected] | 10090d5 | 2013-07-25 20:41:37 | [diff] [blame] | 84 | if (dialog_controller_.get()) |
| 85 | dialog_controller_->TabActivated(); |
| 86 | } |
| 87 | |
[email protected] | b4db6d4 | 2014-06-07 04:36:58 | [diff] [blame] | 88 | PersonalDataManager* ChromeAutofillClient::GetPersonalDataManager() { |
[email protected] | 6f3ccf5 | 2013-02-21 03:55:23 | [diff] [blame] | 89 | Profile* profile = |
estade | ecb659d | 2014-12-11 03:53:16 | [diff] [blame] | 90 | Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
[email protected] | 6f3ccf5 | 2013-02-21 03:55:23 | [diff] [blame] | 91 | return PersonalDataManagerFactory::GetForProfile( |
| 92 | profile->GetOriginalProfile()); |
| 93 | } |
| 94 | |
[email protected] | b4db6d4 | 2014-06-07 04:36:58 | [diff] [blame] | 95 | scoped_refptr<AutofillWebDataService> ChromeAutofillClient::GetDatabase() { |
[email protected] | 34b5946 | 2013-12-03 14:08:32 | [diff] [blame] | 96 | Profile* profile = |
estade | ecb659d | 2014-12-11 03:53:16 | [diff] [blame] | 97 | Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
[email protected] | 34b5946 | 2013-12-03 14:08:32 | [diff] [blame] | 98 | return WebDataServiceFactory::GetAutofillWebDataForProfile( |
sdefresne | e9ea3c2 | 2015-01-10 10:10:04 | [diff] [blame] | 99 | profile, ServiceAccessType::EXPLICIT_ACCESS); |
[email protected] | 29079a27 | 2013-11-19 14:51:24 | [diff] [blame] | 100 | } |
| 101 | |
[email protected] | b4db6d4 | 2014-06-07 04:36:58 | [diff] [blame] | 102 | PrefService* ChromeAutofillClient::GetPrefs() { |
estade | ecb659d | 2014-12-11 03:53:16 | [diff] [blame] | 103 | return Profile::FromBrowserContext(web_contents()->GetBrowserContext()) |
[email protected] | b4db6d4 | 2014-06-07 04:36:58 | [diff] [blame] | 104 | ->GetPrefs(); |
[email protected] | 8d4cc15e | 2012-08-30 00:33:10 | [diff] [blame] | 105 | } |
| 106 | |
estade | 494f8e6 | 2015-01-26 23:28:13 | [diff] [blame] | 107 | IdentityProvider* ChromeAutofillClient::GetIdentityProvider() { |
| 108 | if (!identity_provider_) { |
| 109 | Profile* profile = |
estade | 1baedb1 | 2015-03-23 22:59:29 | [diff] [blame^] | 110 | Profile::FromBrowserContext(web_contents()->GetBrowserContext()) |
| 111 | ->GetOriginalProfile(); |
estade | 494f8e6 | 2015-01-26 23:28:13 | [diff] [blame] | 112 | LoginUIService* login_service = nullptr; |
| 113 | #if !defined(OS_ANDROID) |
| 114 | login_service = LoginUIServiceFactory::GetForProfile(profile); |
| 115 | #endif |
| 116 | identity_provider_.reset(new ProfileIdentityProvider( |
| 117 | SigninManagerFactory::GetForProfile(profile), |
| 118 | ProfileOAuth2TokenServiceFactory::GetForProfile(profile), |
| 119 | login_service)); |
| 120 | } |
| 121 | |
| 122 | return identity_provider_.get(); |
| 123 | } |
| 124 | |
mathp | 94e3f0b | 2015-03-18 00:16:16 | [diff] [blame] | 125 | rappor::RapporService* ChromeAutofillClient::GetRapporService() { |
| 126 | return g_browser_process->rappor_service(); |
| 127 | } |
| 128 | |
[email protected] | b4db6d4 | 2014-06-07 04:36:58 | [diff] [blame] | 129 | void ChromeAutofillClient::ShowAutofillSettings() { |
[email protected] | cc5419d | 2012-08-30 02:29:46 | [diff] [blame] | 130 | #if defined(OS_ANDROID) |
estade | 57722ec | 2014-08-27 23:52:33 | [diff] [blame] | 131 | chrome::android::ChromiumApplication::ShowAutofillSettings(); |
[email protected] | cc5419d | 2012-08-30 02:29:46 | [diff] [blame] | 132 | #else |
estade | ecb659d | 2014-12-11 03:53:16 | [diff] [blame] | 133 | Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); |
[email protected] | cc5419d | 2012-08-30 02:29:46 | [diff] [blame] | 134 | if (browser) |
| 135 | chrome::ShowSettingsSubPage(browser, chrome::kAutofillSubPage); |
| 136 | #endif // #if defined(OS_ANDROID) |
| 137 | } |
| 138 | |
estade | 39f6049 | 2014-12-30 23:35:19 | [diff] [blame] | 139 | void ChromeAutofillClient::ShowUnmaskPrompt( |
| 140 | const CreditCard& card, |
| 141 | base::WeakPtr<CardUnmaskDelegate> delegate) { |
| 142 | unmask_controller_.ShowPrompt(card, delegate); |
estade | ecb659d | 2014-12-11 03:53:16 | [diff] [blame] | 143 | } |
| 144 | |
estade | fb1d774 | 2015-03-03 02:57:07 | [diff] [blame] | 145 | void ChromeAutofillClient::OnUnmaskVerificationResult(GetRealPanResult result) { |
| 146 | unmask_controller_.OnVerificationResult(result); |
estade | ecb659d | 2014-12-11 03:53:16 | [diff] [blame] | 147 | } |
| 148 | |
[email protected] | b4db6d4 | 2014-06-07 04:36:58 | [diff] [blame] | 149 | void ChromeAutofillClient::ConfirmSaveCreditCard( |
[email protected] | 90804a50 | 2013-03-06 22:07:18 | [diff] [blame] | 150 | const base::Closure& save_card_callback) { |
pritam.nikam | 2cd65ab9 | 2015-01-13 08:13:02 | [diff] [blame] | 151 | AutofillCCInfoBarDelegate::Create( |
| 152 | InfoBarService::FromWebContents(web_contents()), this, |
| 153 | save_card_callback); |
[email protected] | 90804a50 | 2013-03-06 22:07:18 | [diff] [blame] | 154 | } |
| 155 | |
rouslan | 497109da | 2014-11-26 20:30:34 | [diff] [blame] | 156 | bool ChromeAutofillClient::HasCreditCardScanFeature() { |
| 157 | return CreditCardScannerController::HasCreditCardScanFeature(); |
| 158 | } |
| 159 | |
| 160 | void ChromeAutofillClient::ScanCreditCard( |
| 161 | const CreditCardScanCallback& callback) { |
| 162 | CreditCardScannerController::ScanCreditCard(web_contents(), callback); |
| 163 | } |
| 164 | |
[email protected] | b4db6d4 | 2014-06-07 04:36:58 | [diff] [blame] | 165 | void ChromeAutofillClient::ShowRequestAutocompleteDialog( |
[email protected] | 4ff3252 | 2013-01-26 00:37:58 | [diff] [blame] | 166 | const FormData& form, |
estade | 1dbe123 | 2015-01-06 22:45:04 | [diff] [blame] | 167 | content::RenderFrameHost* render_frame_host, |
[email protected] | ce24d87 | 2014-04-11 20:45:28 | [diff] [blame] | 168 | const ResultCallback& callback) { |
[email protected] | 364481b | 2013-01-29 01:52:28 | [diff] [blame] | 169 | HideRequestAutocompleteDialog(); |
estade | 1dbe123 | 2015-01-06 22:45:04 | [diff] [blame] | 170 | last_rfh_to_rac_ = render_frame_host; |
| 171 | GURL frame_url = render_frame_host->GetLastCommittedURL(); |
estade | ecb659d | 2014-12-11 03:53:16 | [diff] [blame] | 172 | dialog_controller_ = AutofillDialogController::Create(web_contents(), form, |
estade | 1dbe123 | 2015-01-06 22:45:04 | [diff] [blame] | 173 | frame_url, callback); |
[email protected] | a55c674 | 2013-08-10 07:28:48 | [diff] [blame] | 174 | if (dialog_controller_) { |
| 175 | dialog_controller_->Show(); |
| 176 | } else { |
[email protected] | b4db6d4 | 2014-06-07 04:36:58 | [diff] [blame] | 177 | callback.Run(AutofillClient::AutocompleteResultErrorDisabled, |
[email protected] | dbdd6027 | 2014-04-14 22:48:40 | [diff] [blame] | 178 | base::string16(), |
[email protected] | ce24d87 | 2014-04-11 20:45:28 | [diff] [blame] | 179 | NULL); |
[email protected] | a55c674 | 2013-08-10 07:28:48 | [diff] [blame] | 180 | NOTIMPLEMENTED(); |
| 181 | } |
[email protected] | 364481b | 2013-01-29 01:52:28 | [diff] [blame] | 182 | } |
| 183 | |
[email protected] | b4db6d4 | 2014-06-07 04:36:58 | [diff] [blame] | 184 | void ChromeAutofillClient::ShowAutofillPopup( |
[email protected] | 8ac8bfd | 2013-02-27 05:18:08 | [diff] [blame] | 185 | const gfx::RectF& element_bounds, |
[email protected] | 46cb7e9 | 2013-06-12 15:32:31 | [diff] [blame] | 186 | base::i18n::TextDirection text_direction, |
brettw | 5f88815 | 2014-12-15 23:31:26 | [diff] [blame] | 187 | const std::vector<autofill::Suggestion>& suggestions, |
[email protected] | 1f66a389 | 2013-04-22 18:57:14 | [diff] [blame] | 188 | base::WeakPtr<AutofillPopupDelegate> delegate) { |
[email protected] | 8ac8bfd | 2013-02-27 05:18:08 | [diff] [blame] | 189 | // Convert element_bounds to be in screen space. |
estade | ecb659d | 2014-12-11 03:53:16 | [diff] [blame] | 190 | gfx::Rect client_area = web_contents()->GetContainerBounds(); |
[email protected] | 8ac8bfd | 2013-02-27 05:18:08 | [diff] [blame] | 191 | gfx::RectF element_bounds_in_screen_space = |
| 192 | element_bounds + client_area.OffsetFromOrigin(); |
| 193 | |
| 194 | // Will delete or reuse the old |popup_controller_|. |
noms | 9139a6a | 2015-02-19 19:42:29 | [diff] [blame] | 195 | popup_controller_ = |
| 196 | AutofillPopupControllerImpl::GetOrCreate(popup_controller_, |
| 197 | delegate, |
| 198 | web_contents(), |
| 199 | web_contents()->GetNativeView(), |
| 200 | element_bounds_in_screen_space, |
| 201 | text_direction); |
[email protected] | 8ac8bfd | 2013-02-27 05:18:08 | [diff] [blame] | 202 | |
brettw | 5f88815 | 2014-12-15 23:31:26 | [diff] [blame] | 203 | popup_controller_->Show(suggestions); |
[email protected] | 8ac8bfd | 2013-02-27 05:18:08 | [diff] [blame] | 204 | } |
| 205 | |
[email protected] | b4db6d4 | 2014-06-07 04:36:58 | [diff] [blame] | 206 | void ChromeAutofillClient::UpdateAutofillPopupDataListValues( |
[email protected] | ead7fb0 | 2013-07-18 18:50:12 | [diff] [blame] | 207 | const std::vector<base::string16>& values, |
| 208 | const std::vector<base::string16>& labels) { |
| 209 | if (popup_controller_.get()) |
| 210 | popup_controller_->UpdateDataListValues(values, labels); |
| 211 | } |
| 212 | |
[email protected] | b4db6d4 | 2014-06-07 04:36:58 | [diff] [blame] | 213 | void ChromeAutofillClient::HideAutofillPopup() { |
[email protected] | e8dad9b | 2013-06-04 04:43:45 | [diff] [blame] | 214 | if (popup_controller_.get()) |
[email protected] | 8ac8bfd | 2013-02-27 05:18:08 | [diff] [blame] | 215 | popup_controller_->Hide(); |
[email protected] | 3cbdf936 | 2014-01-31 23:12:23 | [diff] [blame] | 216 | |
| 217 | // Password generation popups behave in the same fashion and should also |
| 218 | // be hidden. |
[email protected] | 53e4e6d | 2014-02-25 14:09:43 | [diff] [blame] | 219 | ChromePasswordManagerClient* password_client = |
estade | ecb659d | 2014-12-11 03:53:16 | [diff] [blame] | 220 | ChromePasswordManagerClient::FromWebContents(web_contents()); |
[email protected] | 53e4e6d | 2014-02-25 14:09:43 | [diff] [blame] | 221 | if (password_client) |
| 222 | password_client->HidePasswordGenerationPopup(); |
[email protected] | 364481b | 2013-01-29 01:52:28 | [diff] [blame] | 223 | } |
| 224 | |
[email protected] | b4db6d4 | 2014-06-07 04:36:58 | [diff] [blame] | 225 | bool ChromeAutofillClient::IsAutocompleteEnabled() { |
[email protected] | 6c7dcb2f2 | 2013-06-22 00:57:48 | [diff] [blame] | 226 | // For browser, Autocomplete is always enabled as part of Autofill. |
| 227 | return GetPrefs()->GetBoolean(prefs::kAutofillEnabled); |
| 228 | } |
| 229 | |
[email protected] | b4db6d4 | 2014-06-07 04:36:58 | [diff] [blame] | 230 | void ChromeAutofillClient::HideRequestAutocompleteDialog() { |
estade | 1dbe123 | 2015-01-06 22:45:04 | [diff] [blame] | 231 | if (dialog_controller_) |
[email protected] | 8ac8bfd | 2013-02-27 05:18:08 | [diff] [blame] | 232 | dialog_controller_->Hide(); |
[email protected] | 364481b | 2013-01-29 01:52:28 | [diff] [blame] | 233 | } |
| 234 | |
estade | 1dbe123 | 2015-01-06 22:45:04 | [diff] [blame] | 235 | void ChromeAutofillClient::RenderFrameDeleted( |
| 236 | content::RenderFrameHost* render_frame_host) { |
| 237 | if (dialog_controller_ && render_frame_host == last_rfh_to_rac_) |
| 238 | HideRequestAutocompleteDialog(); |
| 239 | } |
| 240 | |
| 241 | void ChromeAutofillClient::DidNavigateAnyFrame( |
| 242 | content::RenderFrameHost* render_frame_host, |
| 243 | const content::LoadCommittedDetails& details, |
| 244 | const content::FrameNavigateParams& params) { |
| 245 | if (dialog_controller_ && render_frame_host == last_rfh_to_rac_) |
| 246 | HideRequestAutocompleteDialog(); |
| 247 | } |
| 248 | |
rouslan | 2f5993f | 2015-01-29 00:18:31 | [diff] [blame] | 249 | void ChromeAutofillClient::MainFrameWasResized(bool width_changed) { |
| 250 | #if defined(OS_ANDROID) |
| 251 | // Ignore virtual keyboard showing and hiding a strip of suggestions. |
| 252 | if (!width_changed) |
| 253 | return; |
| 254 | #endif |
| 255 | |
estade | d0a0c99 | 2015-01-21 14:12:06 | [diff] [blame] | 256 | HideAutofillPopup(); |
| 257 | } |
| 258 | |
[email protected] | b4db6d4 | 2014-06-07 04:36:58 | [diff] [blame] | 259 | void ChromeAutofillClient::WebContentsDestroyed() { |
[email protected] | 9256a936 | 2013-07-04 22:11:48 | [diff] [blame] | 260 | HideAutofillPopup(); |
| 261 | } |
| 262 | |
[email protected] | 76a5450 | 2014-07-10 22:59:34 | [diff] [blame] | 263 | void ChromeAutofillClient::OnZoomChanged( |
wjmaclean | 7f63c6b | 2014-12-09 14:59:55 | [diff] [blame] | 264 | const ui_zoom::ZoomController::ZoomChangedEventData& data) { |
[email protected] | 76a5450 | 2014-07-10 22:59:34 | [diff] [blame] | 265 | HideAutofillPopup(); |
| 266 | } |
| 267 | |
[email protected] | b4db6d4 | 2014-06-07 04:36:58 | [diff] [blame] | 268 | void ChromeAutofillClient::DetectAccountCreationForms( |
estade | b1bc9bd | 2014-12-02 22:44:11 | [diff] [blame] | 269 | content::RenderFrameHost* rfh, |
[email protected] | 375564a | 2013-09-06 20:36:40 | [diff] [blame] | 270 | const std::vector<autofill::FormStructure*>& forms) { |
estade | cde16351 | 2014-12-04 22:14:05 | [diff] [blame] | 271 | password_manager::ContentPasswordManagerDriver* driver = |
| 272 | password_manager::ContentPasswordManagerDriver::GetForRenderFrameHost( |
| 273 | rfh); |
| 274 | if (driver) |
| 275 | driver->GetPasswordGenerationManager()->DetectAccountCreationForms(forms); |
[email protected] | 375564a | 2013-09-06 20:36:40 | [diff] [blame] | 276 | } |
| 277 | |
[email protected] | b4db6d4 | 2014-06-07 04:36:58 | [diff] [blame] | 278 | void ChromeAutofillClient::DidFillOrPreviewField( |
[email protected] | 5b466c4 | 2014-02-25 17:56:36 | [diff] [blame] | 279 | const base::string16& autofilled_value, |
| 280 | const base::string16& profile_full_name) { |
| 281 | #if defined(OS_ANDROID) |
[email protected] | b4db6d4 | 2014-06-07 04:36:58 | [diff] [blame] | 282 | AutofillLoggerAndroid::DidFillOrPreviewField(autofilled_value, |
| 283 | profile_full_name); |
[email protected] | 5b466c4 | 2014-02-25 17:56:36 | [diff] [blame] | 284 | #endif // defined(OS_ANDROID) |
| 285 | } |
| 286 | |
estade | b1bc9bd | 2014-12-02 22:44:11 | [diff] [blame] | 287 | void ChromeAutofillClient::OnFirstUserGestureObserved() { |
| 288 | web_contents()->SendToAllFrames( |
| 289 | new AutofillMsg_FirstUserGestureObservedInTab(routing_id())); |
| 290 | } |
| 291 | |
pritam.nikam | 2cd65ab9 | 2015-01-13 08:13:02 | [diff] [blame] | 292 | void ChromeAutofillClient::LinkClicked(const GURL& url, |
| 293 | WindowOpenDisposition disposition) { |
| 294 | web_contents()->OpenURL(content::OpenURLParams( |
| 295 | url, content::Referrer(), disposition, ui::PAGE_TRANSITION_LINK, false)); |
| 296 | } |
| 297 | |
[email protected] | bfb4d6721 | 2013-02-14 20:32:29 | [diff] [blame] | 298 | } // namespace autofill |