| 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" |
| 11 #include "chrome/browser/infobars/infobar_service.h" | 11 #include "chrome/browser/infobars/infobar_service.h" |
| 12 #include "chrome/browser/password_manager/chrome_password_manager_client.h" | 12 #include "chrome/browser/password_manager/chrome_password_manager_client.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h" | 14 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h" |
| 15 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" | 15 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" |
| 16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/browser_finder.h" | 17 #include "chrome/browser/ui/browser_finder.h" |
| 18 #include "chrome/browser/ui/browser_window.h" | 18 #include "chrome/browser/ui/browser_window.h" |
| 19 #include "chrome/browser/ui/chrome_pages.h" | 19 #include "chrome/browser/ui/chrome_pages.h" |
| 20 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" | 20 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" |
| 21 #include "chrome/browser/ui/zoom/zoom_controller.h" | |
| 22 #include "chrome/browser/webdata/web_data_service_factory.h" | 21 #include "chrome/browser/webdata/web_data_service_factory.h" |
| 23 #include "chrome/common/url_constants.h" | 22 #include "chrome/common/url_constants.h" |
| 24 #include "components/autofill/content/browser/content_autofill_driver.h" | 23 #include "components/autofill/content/browser/content_autofill_driver.h" |
| 25 #include "components/autofill/content/common/autofill_messages.h" | 24 #include "components/autofill/content/common/autofill_messages.h" |
| 26 #include "components/autofill/core/common/autofill_pref_names.h" | 25 #include "components/autofill/core/common/autofill_pref_names.h" |
| 27 #include "content/public/browser/render_view_host.h" | 26 #include "content/public/browser/render_view_host.h" |
| 28 #include "ui/gfx/rect.h" | 27 #include "ui/gfx/rect.h" |
| 29 | 28 |
| 30 #if defined(OS_ANDROID) | 29 #if defined(OS_ANDROID) |
| 31 #include "chrome/browser/android/chromium_application.h" | 30 #include "chrome/browser/android/chromium_application.h" |
| 32 #include "chrome/browser/ui/android/autofill/autofill_logger_android.h" | 31 #include "chrome/browser/ui/android/autofill/autofill_logger_android.h" |
| 32 #else |
| 33 #include "chrome/browser/ui/zoom/zoom_controller.h" |
| 33 #endif | 34 #endif |
| 34 | 35 |
| 35 DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::ChromeAutofillClient); | 36 DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::ChromeAutofillClient); |
| 36 | 37 |
| 37 namespace autofill { | 38 namespace autofill { |
| 38 | 39 |
| 39 ChromeAutofillClient::ChromeAutofillClient(content::WebContents* web_contents) | 40 ChromeAutofillClient::ChromeAutofillClient(content::WebContents* web_contents) |
| 40 : content::WebContentsObserver(web_contents), web_contents_(web_contents) { | 41 : content::WebContentsObserver(web_contents), web_contents_(web_contents) { |
| 41 DCHECK(web_contents); | 42 DCHECK(web_contents); |
| 43 |
| 44 #if !defined(OS_ANDROID) |
| 42 // Since ZoomController is also a WebContentsObserver, we need to be careful | 45 // Since ZoomController is also a WebContentsObserver, we need to be careful |
| 43 // about disconnecting from it since the relative order of destruction of | 46 // about disconnecting from it since the relative order of destruction of |
| 44 // WebContentsObservers is not guaranteed. ZoomController silently clears | 47 // WebContentsObservers is not guaranteed. ZoomController silently clears |
| 45 // its ZoomObserver list during WebContentsDestroyed() so there's no need | 48 // its ZoomObserver list during WebContentsDestroyed() so there's no need |
| 46 // to explicitly remove ourselves on destruction. | 49 // to explicitly remove ourselves on destruction. |
| 47 ZoomController* zoom_controller = | 50 ZoomController* zoom_controller = |
| 48 ZoomController::FromWebContents(web_contents); | 51 ZoomController::FromWebContents(web_contents); |
| 49 // There may not always be a ZoomController, e.g. on Android. | 52 // There may not always be a ZoomController, e.g. in tests. |
| 50 if (zoom_controller) | 53 if (zoom_controller) |
| 51 zoom_controller->AddObserver(this); | 54 zoom_controller->AddObserver(this); |
| 55 #endif |
| 56 |
| 52 #if defined(OS_MACOSX) && !defined(OS_IOS) | 57 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 53 RegisterForKeystoneNotifications(); | 58 RegisterForKeystoneNotifications(); |
| 54 #endif // defined(OS_MACOSX) && !defined(OS_IOS) | 59 #endif // defined(OS_MACOSX) && !defined(OS_IOS) |
| 55 } | 60 } |
| 56 | 61 |
| 57 ChromeAutofillClient::~ChromeAutofillClient() { | 62 ChromeAutofillClient::~ChromeAutofillClient() { |
| 58 // NOTE: It is too late to clean up the autofill popup; that cleanup process | 63 // NOTE: It is too late to clean up the autofill popup; that cleanup process |
| 59 // requires that the WebContents instance still be valid and it is not at | 64 // requires that the WebContents instance still be valid and it is not at |
| 60 // this point (in particular, the WebContentsImpl destructor has already | 65 // this point (in particular, the WebContentsImpl destructor has already |
| 61 // finished running and we are now in the base class destructor). | 66 // finished running and we are now in the base class destructor). |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 void ChromeAutofillClient::DidFillOrPreviewField( | 206 void ChromeAutofillClient::DidFillOrPreviewField( |
| 202 const base::string16& autofilled_value, | 207 const base::string16& autofilled_value, |
| 203 const base::string16& profile_full_name) { | 208 const base::string16& profile_full_name) { |
| 204 #if defined(OS_ANDROID) | 209 #if defined(OS_ANDROID) |
| 205 AutofillLoggerAndroid::DidFillOrPreviewField(autofilled_value, | 210 AutofillLoggerAndroid::DidFillOrPreviewField(autofilled_value, |
| 206 profile_full_name); | 211 profile_full_name); |
| 207 #endif // defined(OS_ANDROID) | 212 #endif // defined(OS_ANDROID) |
| 208 } | 213 } |
| 209 | 214 |
| 210 } // namespace autofill | 215 } // namespace autofill |
| OLD | NEW |