Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(289)

Side by Side Diff: chrome/browser/ui/autofill/chrome_autofill_client.cc

Issue 377423002: Make ChromeAutofillClient a ZoomObserver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix typo in comment. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/autofill/chrome_autofill_client.h ('k') | chrome/browser/ui/tab_helpers.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
21 #include "chrome/browser/webdata/web_data_service_factory.h" 22 #include "chrome/browser/webdata/web_data_service_factory.h"
22 #include "chrome/common/url_constants.h" 23 #include "chrome/common/url_constants.h"
23 #include "components/autofill/content/browser/content_autofill_driver.h" 24 #include "components/autofill/content/browser/content_autofill_driver.h"
24 #include "components/autofill/content/common/autofill_messages.h" 25 #include "components/autofill/content/common/autofill_messages.h"
25 #include "components/autofill/core/common/autofill_pref_names.h" 26 #include "components/autofill/core/common/autofill_pref_names.h"
26 #include "content/public/browser/render_view_host.h" 27 #include "content/public/browser/render_view_host.h"
27 #include "ui/gfx/rect.h" 28 #include "ui/gfx/rect.h"
28 29
29 #if defined(OS_ANDROID) 30 #if defined(OS_ANDROID)
30 #include "chrome/browser/ui/android/autofill/autofill_logger_android.h" 31 #include "chrome/browser/ui/android/autofill/autofill_logger_android.h"
31 #endif 32 #endif
32 33
33 DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::ChromeAutofillClient); 34 DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::ChromeAutofillClient);
34 35
35 namespace autofill { 36 namespace autofill {
36 37
37 ChromeAutofillClient::ChromeAutofillClient(content::WebContents* web_contents) 38 ChromeAutofillClient::ChromeAutofillClient(content::WebContents* web_contents)
38 : content::WebContentsObserver(web_contents), web_contents_(web_contents) { 39 : content::WebContentsObserver(web_contents), web_contents_(web_contents) {
39 DCHECK(web_contents); 40 DCHECK(web_contents);
41 // Since ZoomController is also a WebContentsObserver, we need to be careful
42 // about disconnecting from it since the relative order of destruction of
43 // WebContentsObservers is not guaranteed. ZoomController silently clears
44 // its ZoomObserver list during WebContentsDestroyed() so there's no need
45 // to explicitly remove ourselves on destruction.
46 ZoomController* zoom_controller =
47 ZoomController::FromWebContents(web_contents);
48 // There may not always be a ZoomController, e.g. on Android.
49 if (zoom_controller)
50 zoom_controller->AddObserver(this);
40 #if defined(OS_MACOSX) && !defined(OS_IOS) 51 #if defined(OS_MACOSX) && !defined(OS_IOS)
41 RegisterForKeystoneNotifications(); 52 RegisterForKeystoneNotifications();
42 #endif // defined(OS_MACOSX) && !defined(OS_IOS) 53 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
43 } 54 }
44 55
45 ChromeAutofillClient::~ChromeAutofillClient() { 56 ChromeAutofillClient::~ChromeAutofillClient() {
46 // NOTE: It is too late to clean up the autofill popup; that cleanup process 57 // NOTE: It is too late to clean up the autofill popup; that cleanup process
47 // requires that the WebContents instance still be valid and it is not at 58 // requires that the WebContents instance still be valid and it is not at
48 // this point (in particular, the WebContentsImpl destructor has already 59 // this point (in particular, the WebContentsImpl destructor has already
49 // finished running and we are now in the base class destructor). 60 // finished running and we are now in the base class destructor).
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 176
166 void ChromeAutofillClient::HideRequestAutocompleteDialog() { 177 void ChromeAutofillClient::HideRequestAutocompleteDialog() {
167 if (dialog_controller_.get()) 178 if (dialog_controller_.get())
168 dialog_controller_->Hide(); 179 dialog_controller_->Hide();
169 } 180 }
170 181
171 void ChromeAutofillClient::WebContentsDestroyed() { 182 void ChromeAutofillClient::WebContentsDestroyed() {
172 HideAutofillPopup(); 183 HideAutofillPopup();
173 } 184 }
174 185
186 void ChromeAutofillClient::OnZoomChanged(
187 const ZoomController::ZoomChangedEventData& data) {
188 HideAutofillPopup();
189 }
190
175 void ChromeAutofillClient::DetectAccountCreationForms( 191 void ChromeAutofillClient::DetectAccountCreationForms(
176 const std::vector<autofill::FormStructure*>& forms) { 192 const std::vector<autofill::FormStructure*>& forms) {
177 password_manager::PasswordGenerationManager* manager = 193 password_manager::PasswordGenerationManager* manager =
178 ChromePasswordManagerClient::GetGenerationManagerFromWebContents( 194 ChromePasswordManagerClient::GetGenerationManagerFromWebContents(
179 web_contents_); 195 web_contents_);
180 if (manager) 196 if (manager)
181 manager->DetectAccountCreationForms(forms); 197 manager->DetectAccountCreationForms(forms);
182 } 198 }
183 199
184 void ChromeAutofillClient::DidFillOrPreviewField( 200 void ChromeAutofillClient::DidFillOrPreviewField(
185 const base::string16& autofilled_value, 201 const base::string16& autofilled_value,
186 const base::string16& profile_full_name) { 202 const base::string16& profile_full_name) {
187 #if defined(OS_ANDROID) 203 #if defined(OS_ANDROID)
188 AutofillLoggerAndroid::DidFillOrPreviewField(autofilled_value, 204 AutofillLoggerAndroid::DidFillOrPreviewField(autofilled_value,
189 profile_full_name); 205 profile_full_name);
190 #endif // defined(OS_ANDROID) 206 #endif // defined(OS_ANDROID)
191 } 207 }
192 208
193 } // namespace autofill 209 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/autofill/chrome_autofill_client.h ('k') | chrome/browser/ui/tab_helpers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698