Chromium Code Reviews| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 #include "components/prefs/pref_service.h" | 42 #include "components/prefs/pref_service.h" |
| 43 #include "components/signin/core/browser/profile_identity_provider.h" | 43 #include "components/signin/core/browser/profile_identity_provider.h" |
| 44 #include "components/signin/core/browser/signin_header_helper.h" | 44 #include "components/signin/core/browser/signin_header_helper.h" |
| 45 #include "components/signin/core/browser/signin_metrics.h" | 45 #include "components/signin/core/browser/signin_metrics.h" |
| 46 #include "components/user_prefs/user_prefs.h" | 46 #include "components/user_prefs/user_prefs.h" |
| 47 #include "content/public/browser/navigation_entry.h" | 47 #include "content/public/browser/navigation_entry.h" |
| 48 #include "content/public/browser/render_frame_host.h" | 48 #include "content/public/browser/render_frame_host.h" |
| 49 #include "content/public/browser/ssl_status.h" | 49 #include "content/public/browser/ssl_status.h" |
| 50 #include "ui/gfx/geometry/rect.h" | 50 #include "ui/gfx/geometry/rect.h" |
| 51 | 51 |
| 52 #if BUILDFLAG(ANDROID_JAVA_UI) | 52 #if defined(OS_ANDROID) |
| 53 #include "chrome/browser/android/chrome_application.h" | 53 #include "chrome/browser/android/chrome_application.h" |
| 54 #include "chrome/browser/ui/android/autofill/autofill_logger_android.h" | 54 #include "chrome/browser/ui/android/autofill/autofill_logger_android.h" |
| 55 #else | 55 #else |
| 56 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 56 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
| 57 #include "components/zoom/zoom_controller.h" | 57 #include "components/zoom/zoom_controller.h" |
| 58 #endif | 58 #endif |
| 59 | 59 |
| 60 #if defined(OS_ANDROID) | 60 #if defined(OS_ANDROID) |
|
Ted C
2017/01/06 22:33:30
combine with above
F
2017/01/09 21:36:33
Done.
| |
| 61 #include "base/android/context_utils.h" | 61 #include "base/android/context_utils.h" |
| 62 #include "chrome/browser/android/signin/signin_promo_util_android.h" | 62 #include "chrome/browser/android/signin/signin_promo_util_android.h" |
| 63 #include "chrome/browser/infobars/infobar_service.h" | 63 #include "chrome/browser/infobars/infobar_service.h" |
| 64 #include "chrome/browser/ui/android/infobars/autofill_credit_card_filling_infoba r.h" | 64 #include "chrome/browser/ui/android/infobars/autofill_credit_card_filling_infoba r.h" |
| 65 #include "components/autofill/core/browser/autofill_credit_card_filling_infobar_ delegate_mobile.h" | 65 #include "components/autofill/core/browser/autofill_credit_card_filling_infobar_ delegate_mobile.h" |
| 66 #include "components/autofill/core/browser/autofill_save_card_infobar_delegate_m obile.h" | 66 #include "components/autofill/core/browser/autofill_save_card_infobar_delegate_m obile.h" |
| 67 #include "components/autofill/core/browser/autofill_save_card_infobar_mobile.h" | 67 #include "components/autofill/core/browser/autofill_save_card_infobar_mobile.h" |
| 68 #include "components/infobars/core/infobar.h" | 68 #include "components/infobars/core/infobar.h" |
| 69 #include "content/public/browser/android/content_view_core.h" | 69 #include "content/public/browser/android/content_view_core.h" |
| 70 #else // !OS_ANDROID | 70 #else // !OS_ANDROID |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 83 } // anonymous namespace | 83 } // anonymous namespace |
| 84 | 84 |
| 85 ChromeAutofillClient::ChromeAutofillClient(content::WebContents* web_contents) | 85 ChromeAutofillClient::ChromeAutofillClient(content::WebContents* web_contents) |
| 86 : content::WebContentsObserver(web_contents), | 86 : content::WebContentsObserver(web_contents), |
| 87 unmask_controller_( | 87 unmask_controller_( |
| 88 user_prefs::UserPrefs::Get(web_contents->GetBrowserContext()), | 88 user_prefs::UserPrefs::Get(web_contents->GetBrowserContext()), |
| 89 Profile::FromBrowserContext(web_contents->GetBrowserContext()) | 89 Profile::FromBrowserContext(web_contents->GetBrowserContext()) |
| 90 ->IsOffTheRecord()) { | 90 ->IsOffTheRecord()) { |
| 91 DCHECK(web_contents); | 91 DCHECK(web_contents); |
| 92 | 92 |
| 93 #if !BUILDFLAG(ANDROID_JAVA_UI) | 93 #if !defined(OS_ANDROID) |
| 94 // Since ZoomController is also a WebContentsObserver, we need to be careful | 94 // Since ZoomController is also a WebContentsObserver, we need to be careful |
| 95 // about disconnecting from it since the relative order of destruction of | 95 // about disconnecting from it since the relative order of destruction of |
| 96 // WebContentsObservers is not guaranteed. ZoomController silently clears | 96 // WebContentsObservers is not guaranteed. ZoomController silently clears |
| 97 // its ZoomObserver list during WebContentsDestroyed() so there's no need | 97 // its ZoomObserver list during WebContentsDestroyed() so there's no need |
| 98 // to explicitly remove ourselves on destruction. | 98 // to explicitly remove ourselves on destruction. |
| 99 zoom::ZoomController* zoom_controller = | 99 zoom::ZoomController* zoom_controller = |
| 100 zoom::ZoomController::FromWebContents(web_contents); | 100 zoom::ZoomController::FromWebContents(web_contents); |
| 101 // There may not always be a ZoomController, e.g. in tests. | 101 // There may not always be a ZoomController, e.g. in tests. |
| 102 if (zoom_controller) | 102 if (zoom_controller) |
| 103 zoom_controller->AddObserver(this); | 103 zoom_controller->AddObserver(this); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 136 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
| 137 return ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); | 137 return ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); |
| 138 } | 138 } |
| 139 | 139 |
| 140 IdentityProvider* ChromeAutofillClient::GetIdentityProvider() { | 140 IdentityProvider* ChromeAutofillClient::GetIdentityProvider() { |
| 141 if (!identity_provider_) { | 141 if (!identity_provider_) { |
| 142 Profile* profile = | 142 Profile* profile = |
| 143 Profile::FromBrowserContext(web_contents()->GetBrowserContext()) | 143 Profile::FromBrowserContext(web_contents()->GetBrowserContext()) |
| 144 ->GetOriginalProfile(); | 144 ->GetOriginalProfile(); |
| 145 base::Closure login_callback; | 145 base::Closure login_callback; |
| 146 #if !BUILDFLAG(ANDROID_JAVA_UI) | 146 #if !defined(OS_ANDROID) |
| 147 login_callback = | 147 login_callback = |
| 148 LoginUIServiceFactory::GetShowLoginPopupCallbackForProfile(profile); | 148 LoginUIServiceFactory::GetShowLoginPopupCallbackForProfile(profile); |
| 149 #endif | 149 #endif |
| 150 identity_provider_.reset(new ProfileIdentityProvider( | 150 identity_provider_.reset(new ProfileIdentityProvider( |
| 151 SigninManagerFactory::GetForProfile(profile), | 151 SigninManagerFactory::GetForProfile(profile), |
| 152 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), | 152 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), |
| 153 login_callback)); | 153 login_callback)); |
| 154 } | 154 } |
| 155 | 155 |
| 156 return identity_provider_.get(); | 156 return identity_provider_.get(); |
| 157 } | 157 } |
| 158 | 158 |
| 159 rappor::RapporServiceImpl* ChromeAutofillClient::GetRapporServiceImpl() { | 159 rappor::RapporServiceImpl* ChromeAutofillClient::GetRapporServiceImpl() { |
| 160 return g_browser_process->rappor_service(); | 160 return g_browser_process->rappor_service(); |
| 161 } | 161 } |
| 162 | 162 |
| 163 void ChromeAutofillClient::ShowAutofillSettings() { | 163 void ChromeAutofillClient::ShowAutofillSettings() { |
| 164 #if BUILDFLAG(ANDROID_JAVA_UI) | 164 #if defined(OS_ANDROID) |
| 165 chrome::android::ChromeApplication::ShowAutofillSettings(); | 165 chrome::android::ChromeApplication::ShowAutofillSettings(); |
| 166 #else | 166 #else |
| 167 Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); | 167 Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); |
| 168 if (browser) | 168 if (browser) |
| 169 chrome::ShowSettingsSubPage(browser, chrome::kAutofillSubPage); | 169 chrome::ShowSettingsSubPage(browser, chrome::kAutofillSubPage); |
| 170 #endif // #if BUILDFLAG(ANDROID_JAVA_UI) | 170 #endif // #if defined(OS_ANDROID) |
| 171 } | 171 } |
| 172 | 172 |
| 173 void ChromeAutofillClient::ShowUnmaskPrompt( | 173 void ChromeAutofillClient::ShowUnmaskPrompt( |
| 174 const CreditCard& card, | 174 const CreditCard& card, |
| 175 UnmaskCardReason reason, | 175 UnmaskCardReason reason, |
| 176 base::WeakPtr<CardUnmaskDelegate> delegate) { | 176 base::WeakPtr<CardUnmaskDelegate> delegate) { |
| 177 unmask_controller_.ShowPrompt( | 177 unmask_controller_.ShowPrompt( |
| 178 CreateCardUnmaskPromptView(&unmask_controller_, web_contents()), | 178 CreateCardUnmaskPromptView(&unmask_controller_, web_contents()), |
| 179 card, reason, delegate); | 179 card, reason, delegate); |
| 180 } | 180 } |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 291 if (password_client) | 291 if (password_client) |
| 292 password_client->HidePasswordGenerationPopup(); | 292 password_client->HidePasswordGenerationPopup(); |
| 293 } | 293 } |
| 294 | 294 |
| 295 bool ChromeAutofillClient::IsAutocompleteEnabled() { | 295 bool ChromeAutofillClient::IsAutocompleteEnabled() { |
| 296 // For browser, Autocomplete is always enabled as part of Autofill. | 296 // For browser, Autocomplete is always enabled as part of Autofill. |
| 297 return GetPrefs()->GetBoolean(prefs::kAutofillEnabled); | 297 return GetPrefs()->GetBoolean(prefs::kAutofillEnabled); |
| 298 } | 298 } |
| 299 | 299 |
| 300 void ChromeAutofillClient::MainFrameWasResized(bool width_changed) { | 300 void ChromeAutofillClient::MainFrameWasResized(bool width_changed) { |
| 301 #if BUILDFLAG(ANDROID_JAVA_UI) | 301 #if defined(OS_ANDROID) |
| 302 // Ignore virtual keyboard showing and hiding a strip of suggestions. | 302 // Ignore virtual keyboard showing and hiding a strip of suggestions. |
| 303 if (!width_changed) | 303 if (!width_changed) |
| 304 return; | 304 return; |
| 305 #endif | 305 #endif |
| 306 | 306 |
| 307 HideAutofillPopup(); | 307 HideAutofillPopup(); |
| 308 } | 308 } |
| 309 | 309 |
| 310 void ChromeAutofillClient::WebContentsDestroyed() { | 310 void ChromeAutofillClient::WebContentsDestroyed() { |
| 311 HideAutofillPopup(); | 311 HideAutofillPopup(); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 325 if (driver) { | 325 if (driver) { |
| 326 driver->GetPasswordGenerationManager()->DetectFormsEligibleForGeneration( | 326 driver->GetPasswordGenerationManager()->DetectFormsEligibleForGeneration( |
| 327 forms); | 327 forms); |
| 328 driver->GetPasswordManager()->ProcessAutofillPredictions(driver, forms); | 328 driver->GetPasswordManager()->ProcessAutofillPredictions(driver, forms); |
| 329 } | 329 } |
| 330 } | 330 } |
| 331 | 331 |
| 332 void ChromeAutofillClient::DidFillOrPreviewField( | 332 void ChromeAutofillClient::DidFillOrPreviewField( |
| 333 const base::string16& autofilled_value, | 333 const base::string16& autofilled_value, |
| 334 const base::string16& profile_full_name) { | 334 const base::string16& profile_full_name) { |
| 335 #if BUILDFLAG(ANDROID_JAVA_UI) | 335 #if defined(OS_ANDROID) |
| 336 AutofillLoggerAndroid::DidFillOrPreviewField(autofilled_value, | 336 AutofillLoggerAndroid::DidFillOrPreviewField(autofilled_value, |
| 337 profile_full_name); | 337 profile_full_name); |
| 338 #endif // BUILDFLAG(ANDROID_JAVA_UI) | 338 #endif // defined(OS_ANDROID) |
| 339 } | 339 } |
| 340 | 340 |
| 341 void ChromeAutofillClient::OnFirstUserGestureObserved() { | 341 void ChromeAutofillClient::OnFirstUserGestureObserved() { |
| 342 ContentAutofillDriverFactory* factory = | 342 ContentAutofillDriverFactory* factory = |
| 343 ContentAutofillDriverFactory::FromWebContents(web_contents()); | 343 ContentAutofillDriverFactory::FromWebContents(web_contents()); |
| 344 DCHECK(factory); | 344 DCHECK(factory); |
| 345 | 345 |
| 346 for (content::RenderFrameHost* frame : web_contents()->GetAllFrames()) { | 346 for (content::RenderFrameHost* frame : web_contents()->GetAllFrames()) { |
| 347 // No need to notify non-live frames. | 347 // No need to notify non-live frames. |
| 348 // And actually they have no corresponding drivers in the factory's map. | 348 // And actually they have no corresponding drivers in the factory's map. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 400 } | 400 } |
| 401 | 401 |
| 402 void ChromeAutofillClient::ShowHttpNotSecureExplanation() { | 402 void ChromeAutofillClient::ShowHttpNotSecureExplanation() { |
| 403 web_contents()->OpenURL(content::OpenURLParams( | 403 web_contents()->OpenURL(content::OpenURLParams( |
| 404 GURL(kSecurityIndicatorHelpCenterUrl), content::Referrer(), | 404 GURL(kSecurityIndicatorHelpCenterUrl), content::Referrer(), |
| 405 WindowOpenDisposition::NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, | 405 WindowOpenDisposition::NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, |
| 406 false /* is_renderer_initiated */)); | 406 false /* is_renderer_initiated */)); |
| 407 } | 407 } |
| 408 | 408 |
| 409 } // namespace autofill | 409 } // namespace autofill |
| OLD | NEW |