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 "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "chrome/browser/autofill/autofill_cc_infobar_delegate.h" | 9 #include "chrome/browser/autofill/autofill_cc_infobar_delegate.h" |
10 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 10 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "components/autofill/content/common/autofill_messages.h" | 25 #include "components/autofill/content/common/autofill_messages.h" |
26 #include "components/autofill/core/common/autofill_pref_names.h" | 26 #include "components/autofill/core/common/autofill_pref_names.h" |
27 #include "components/password_manager/content/browser/content_password_manager_d
river.h" | 27 #include "components/password_manager/content/browser/content_password_manager_d
river.h" |
28 #include "content/public/browser/render_view_host.h" | 28 #include "content/public/browser/render_view_host.h" |
29 #include "ui/gfx/rect.h" | 29 #include "ui/gfx/rect.h" |
30 | 30 |
31 #if defined(OS_ANDROID) | 31 #if defined(OS_ANDROID) |
32 #include "chrome/browser/android/chromium_application.h" | 32 #include "chrome/browser/android/chromium_application.h" |
33 #include "chrome/browser/ui/android/autofill/autofill_logger_android.h" | 33 #include "chrome/browser/ui/android/autofill/autofill_logger_android.h" |
34 #else | 34 #else |
35 #include "chrome/browser/ui/zoom/zoom_controller.h" | 35 #include "components/ui/zoom/zoom_controller.h" |
36 #endif | 36 #endif |
37 | 37 |
38 DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::ChromeAutofillClient); | 38 DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::ChromeAutofillClient); |
39 | 39 |
40 namespace autofill { | 40 namespace autofill { |
41 | 41 |
42 ChromeAutofillClient::ChromeAutofillClient(content::WebContents* web_contents) | 42 ChromeAutofillClient::ChromeAutofillClient(content::WebContents* web_contents) |
43 : content::WebContentsObserver(web_contents), web_contents_(web_contents) { | 43 : content::WebContentsObserver(web_contents), web_contents_(web_contents) { |
44 DCHECK(web_contents); | 44 DCHECK(web_contents); |
45 | 45 |
46 #if !defined(OS_ANDROID) | 46 #if !defined(OS_ANDROID) |
47 // Since ZoomController is also a WebContentsObserver, we need to be careful | 47 // Since ZoomController is also a WebContentsObserver, we need to be careful |
48 // about disconnecting from it since the relative order of destruction of | 48 // about disconnecting from it since the relative order of destruction of |
49 // WebContentsObservers is not guaranteed. ZoomController silently clears | 49 // WebContentsObservers is not guaranteed. ZoomController silently clears |
50 // its ZoomObserver list during WebContentsDestroyed() so there's no need | 50 // its ZoomObserver list during WebContentsDestroyed() so there's no need |
51 // to explicitly remove ourselves on destruction. | 51 // to explicitly remove ourselves on destruction. |
52 ZoomController* zoom_controller = | 52 ui_zoom::ZoomController* zoom_controller = |
53 ZoomController::FromWebContents(web_contents); | 53 ui_zoom::ZoomController::FromWebContents(web_contents); |
54 // There may not always be a ZoomController, e.g. in tests. | 54 // There may not always be a ZoomController, e.g. in tests. |
55 if (zoom_controller) | 55 if (zoom_controller) |
56 zoom_controller->AddObserver(this); | 56 zoom_controller->AddObserver(this); |
57 #endif | 57 #endif |
58 | 58 |
59 #if defined(OS_MACOSX) && !defined(OS_IOS) | 59 #if defined(OS_MACOSX) && !defined(OS_IOS) |
60 RegisterForKeystoneNotifications(); | 60 RegisterForKeystoneNotifications(); |
61 #endif // defined(OS_MACOSX) && !defined(OS_IOS) | 61 #endif // defined(OS_MACOSX) && !defined(OS_IOS) |
62 } | 62 } |
63 | 63 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 void ChromeAutofillClient::HideRequestAutocompleteDialog() { | 192 void ChromeAutofillClient::HideRequestAutocompleteDialog() { |
193 if (dialog_controller_.get()) | 193 if (dialog_controller_.get()) |
194 dialog_controller_->Hide(); | 194 dialog_controller_->Hide(); |
195 } | 195 } |
196 | 196 |
197 void ChromeAutofillClient::WebContentsDestroyed() { | 197 void ChromeAutofillClient::WebContentsDestroyed() { |
198 HideAutofillPopup(); | 198 HideAutofillPopup(); |
199 } | 199 } |
200 | 200 |
201 void ChromeAutofillClient::OnZoomChanged( | 201 void ChromeAutofillClient::OnZoomChanged( |
202 const ZoomController::ZoomChangedEventData& data) { | 202 const ui_zoom::ZoomController::ZoomChangedEventData& data) { |
203 HideAutofillPopup(); | 203 HideAutofillPopup(); |
204 } | 204 } |
205 | 205 |
206 void ChromeAutofillClient::DetectAccountCreationForms( | 206 void ChromeAutofillClient::DetectAccountCreationForms( |
207 content::RenderFrameHost* rfh, | 207 content::RenderFrameHost* rfh, |
208 const std::vector<autofill::FormStructure*>& forms) { | 208 const std::vector<autofill::FormStructure*>& forms) { |
209 password_manager::ContentPasswordManagerDriver* driver = | 209 password_manager::ContentPasswordManagerDriver* driver = |
210 password_manager::ContentPasswordManagerDriver::GetForRenderFrameHost( | 210 password_manager::ContentPasswordManagerDriver::GetForRenderFrameHost( |
211 rfh); | 211 rfh); |
212 if (driver) | 212 if (driver) |
213 driver->GetPasswordGenerationManager()->DetectAccountCreationForms(forms); | 213 driver->GetPasswordGenerationManager()->DetectAccountCreationForms(forms); |
214 } | 214 } |
215 | 215 |
216 void ChromeAutofillClient::DidFillOrPreviewField( | 216 void ChromeAutofillClient::DidFillOrPreviewField( |
217 const base::string16& autofilled_value, | 217 const base::string16& autofilled_value, |
218 const base::string16& profile_full_name) { | 218 const base::string16& profile_full_name) { |
219 #if defined(OS_ANDROID) | 219 #if defined(OS_ANDROID) |
220 AutofillLoggerAndroid::DidFillOrPreviewField(autofilled_value, | 220 AutofillLoggerAndroid::DidFillOrPreviewField(autofilled_value, |
221 profile_full_name); | 221 profile_full_name); |
222 #endif // defined(OS_ANDROID) | 222 #endif // defined(OS_ANDROID) |
223 } | 223 } |
224 | 224 |
225 void ChromeAutofillClient::OnFirstUserGestureObserved() { | 225 void ChromeAutofillClient::OnFirstUserGestureObserved() { |
226 web_contents()->SendToAllFrames( | 226 web_contents()->SendToAllFrames( |
227 new AutofillMsg_FirstUserGestureObservedInTab(routing_id())); | 227 new AutofillMsg_FirstUserGestureObservedInTab(routing_id())); |
228 } | 228 } |
229 | 229 |
230 } // namespace autofill | 230 } // namespace autofill |
OLD | NEW |