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 23 matching lines...) Expand all Loading... |
34 #include "chrome/browser/ui/android/autofill/autofill_logger_android.h" | 34 #include "chrome/browser/ui/android/autofill/autofill_logger_android.h" |
35 #else | 35 #else |
36 #include "components/ui/zoom/zoom_controller.h" | 36 #include "components/ui/zoom/zoom_controller.h" |
37 #endif | 37 #endif |
38 | 38 |
39 DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::ChromeAutofillClient); | 39 DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::ChromeAutofillClient); |
40 | 40 |
41 namespace autofill { | 41 namespace autofill { |
42 | 42 |
43 ChromeAutofillClient::ChromeAutofillClient(content::WebContents* web_contents) | 43 ChromeAutofillClient::ChromeAutofillClient(content::WebContents* web_contents) |
44 : content::WebContentsObserver(web_contents), weak_pointer_factory_(this) { | 44 : content::WebContentsObserver(web_contents), |
| 45 weak_pointer_factory_(this), |
| 46 screen_observer_(this) { |
45 DCHECK(web_contents); | 47 DCHECK(web_contents); |
46 | 48 |
47 #if !defined(OS_ANDROID) | 49 #if !defined(OS_ANDROID) |
48 // Since ZoomController is also a WebContentsObserver, we need to be careful | 50 // Since ZoomController is also a WebContentsObserver, we need to be careful |
49 // about disconnecting from it since the relative order of destruction of | 51 // about disconnecting from it since the relative order of destruction of |
50 // WebContentsObservers is not guaranteed. ZoomController silently clears | 52 // WebContentsObservers is not guaranteed. ZoomController silently clears |
51 // its ZoomObserver list during WebContentsDestroyed() so there's no need | 53 // its ZoomObserver list during WebContentsDestroyed() so there's no need |
52 // to explicitly remove ourselves on destruction. | 54 // to explicitly remove ourselves on destruction. |
53 ui_zoom::ZoomController* zoom_controller = | 55 ui_zoom::ZoomController* zoom_controller = |
54 ui_zoom::ZoomController::FromWebContents(web_contents); | 56 ui_zoom::ZoomController::FromWebContents(web_contents); |
55 // There may not always be a ZoomController, e.g. in tests. | 57 // There may not always be a ZoomController, e.g. in tests. |
56 if (zoom_controller) | 58 if (zoom_controller) |
57 zoom_controller->AddObserver(this); | 59 zoom_controller->AddObserver(this); |
58 #endif | 60 #endif |
59 | 61 |
60 #if defined(OS_MACOSX) && !defined(OS_IOS) | 62 #if defined(OS_MACOSX) && !defined(OS_IOS) |
61 RegisterForKeystoneNotifications(); | 63 RegisterForKeystoneNotifications(); |
62 #endif // defined(OS_MACOSX) && !defined(OS_IOS) | 64 #endif // defined(OS_MACOSX) && !defined(OS_IOS) |
| 65 |
| 66 screen_observer_.Add( |
| 67 gfx::Screen::GetScreenFor(web_contents->GetNativeView())); |
63 } | 68 } |
64 | 69 |
65 ChromeAutofillClient::~ChromeAutofillClient() { | 70 ChromeAutofillClient::~ChromeAutofillClient() { |
66 // NOTE: It is too late to clean up the autofill popup; that cleanup process | 71 // NOTE: It is too late to clean up the autofill popup; that cleanup process |
67 // requires that the WebContents instance still be valid and it is not at | 72 // requires that the WebContents instance still be valid and it is not at |
68 // this point (in particular, the WebContentsImpl destructor has already | 73 // this point (in particular, the WebContentsImpl destructor has already |
69 // finished running and we are now in the base class destructor). | 74 // finished running and we are now in the base class destructor). |
70 DCHECK(!popup_controller_); | 75 DCHECK(!popup_controller_); |
71 #if defined(OS_MACOSX) && !defined(OS_IOS) | 76 #if defined(OS_MACOSX) && !defined(OS_IOS) |
72 UnregisterFromKeystoneNotifications(); | 77 UnregisterFromKeystoneNotifications(); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 | 211 |
207 void ChromeAutofillClient::WebContentsDestroyed() { | 212 void ChromeAutofillClient::WebContentsDestroyed() { |
208 HideAutofillPopup(); | 213 HideAutofillPopup(); |
209 } | 214 } |
210 | 215 |
211 void ChromeAutofillClient::OnZoomChanged( | 216 void ChromeAutofillClient::OnZoomChanged( |
212 const ui_zoom::ZoomController::ZoomChangedEventData& data) { | 217 const ui_zoom::ZoomController::ZoomChangedEventData& data) { |
213 HideAutofillPopup(); | 218 HideAutofillPopup(); |
214 } | 219 } |
215 | 220 |
| 221 void ChromeAutofillClient::OnDisplayAdded(const gfx::Display& new_display) { |
| 222 } |
| 223 |
| 224 void ChromeAutofillClient::OnDisplayRemoved(const gfx::Display& old_display) { |
| 225 } |
| 226 |
| 227 void ChromeAutofillClient::OnDisplayMetricsChanged(const gfx::Display& display, |
| 228 uint32_t metrics) { |
| 229 if (metrics | DisplayObserver::DISPLAY_METRIC_ROTATION) |
| 230 HideAutofillPopup(); |
| 231 } |
| 232 |
216 void ChromeAutofillClient::DetectAccountCreationForms( | 233 void ChromeAutofillClient::DetectAccountCreationForms( |
217 content::RenderFrameHost* rfh, | 234 content::RenderFrameHost* rfh, |
218 const std::vector<autofill::FormStructure*>& forms) { | 235 const std::vector<autofill::FormStructure*>& forms) { |
219 password_manager::ContentPasswordManagerDriver* driver = | 236 password_manager::ContentPasswordManagerDriver* driver = |
220 password_manager::ContentPasswordManagerDriver::GetForRenderFrameHost( | 237 password_manager::ContentPasswordManagerDriver::GetForRenderFrameHost( |
221 rfh); | 238 rfh); |
222 if (driver) | 239 if (driver) |
223 driver->GetPasswordGenerationManager()->DetectAccountCreationForms(forms); | 240 driver->GetPasswordGenerationManager()->DetectAccountCreationForms(forms); |
224 } | 241 } |
225 | 242 |
226 void ChromeAutofillClient::DidFillOrPreviewField( | 243 void ChromeAutofillClient::DidFillOrPreviewField( |
227 const base::string16& autofilled_value, | 244 const base::string16& autofilled_value, |
228 const base::string16& profile_full_name) { | 245 const base::string16& profile_full_name) { |
229 #if defined(OS_ANDROID) | 246 #if defined(OS_ANDROID) |
230 AutofillLoggerAndroid::DidFillOrPreviewField(autofilled_value, | 247 AutofillLoggerAndroid::DidFillOrPreviewField(autofilled_value, |
231 profile_full_name); | 248 profile_full_name); |
232 #endif // defined(OS_ANDROID) | 249 #endif // defined(OS_ANDROID) |
233 } | 250 } |
234 | 251 |
235 void ChromeAutofillClient::OnFirstUserGestureObserved() { | 252 void ChromeAutofillClient::OnFirstUserGestureObserved() { |
236 web_contents()->SendToAllFrames( | 253 web_contents()->SendToAllFrames( |
237 new AutofillMsg_FirstUserGestureObservedInTab(routing_id())); | 254 new AutofillMsg_FirstUserGestureObservedInTab(routing_id())); |
238 } | 255 } |
239 | 256 |
240 } // namespace autofill | 257 } // namespace autofill |
OLD | NEW |