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" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 14 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
| 15 #include "chrome/browser/autofill/risk_util.h" | 15 #include "chrome/browser/autofill/risk_util.h" |
| 16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/infobars/infobar_service.h" | |
| 18 #include "chrome/browser/password_manager/chrome_password_manager_client.h" | 17 #include "chrome/browser/password_manager/chrome_password_manager_client.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/profiles/profile_manager.h" | 19 #include "chrome/browser/profiles/profile_manager.h" |
| 21 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 20 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 22 #include "chrome/browser/signin/signin_manager_factory.h" | 21 #include "chrome/browser/signin/signin_manager_factory.h" |
| 23 #include "chrome/browser/signin/signin_promo_util.h" | 22 #include "chrome/browser/signin/signin_promo_util.h" |
| 24 #include "chrome/browser/sync/profile_sync_service_factory.h" | 23 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 25 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" | 24 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" |
| 26 #include "chrome/browser/ui/autofill/create_card_unmask_prompt_view.h" | 25 #include "chrome/browser/ui/autofill/create_card_unmask_prompt_view.h" |
| 27 #include "chrome/browser/ui/autofill/credit_card_scanner_controller.h" | 26 #include "chrome/browser/ui/autofill/credit_card_scanner_controller.h" |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 55 #include "chrome/browser/android/chrome_application.h" | 54 #include "chrome/browser/android/chrome_application.h" |
| 56 #include "chrome/browser/ui/android/autofill/autofill_logger_android.h" | 55 #include "chrome/browser/ui/android/autofill/autofill_logger_android.h" |
| 57 #else | 56 #else |
| 58 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 57 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
| 59 #include "components/zoom/zoom_controller.h" | 58 #include "components/zoom/zoom_controller.h" |
| 60 #endif | 59 #endif |
| 61 | 60 |
| 62 #if defined(OS_ANDROID) | 61 #if defined(OS_ANDROID) |
| 63 #include "base/android/context_utils.h" | 62 #include "base/android/context_utils.h" |
| 64 #include "chrome/browser/android/signin/signin_promo_util_android.h" | 63 #include "chrome/browser/android/signin/signin_promo_util_android.h" |
| 64 #include "chrome/browser/infobars/infobar_service.h" | |
| 65 #include "chrome/browser/ui/android/infobars/autofill_credit_card_filling_infoba r.h" | |
| 66 #include "components/autofill/core/browser/autofill_credit_card_filling_infobar_ delegate_mobile.h" | |
| 65 #include "components/autofill/core/browser/autofill_save_card_infobar_delegate_m obile.h" | 67 #include "components/autofill/core/browser/autofill_save_card_infobar_delegate_m obile.h" |
| 66 #include "components/autofill/core/browser/autofill_save_card_infobar_mobile.h" | 68 #include "components/autofill/core/browser/autofill_save_card_infobar_mobile.h" |
| 67 #include "components/infobars/core/infobar.h" | 69 #include "components/infobars/core/infobar.h" |
| 68 #include "content/public/browser/android/content_view_core.h" | 70 #include "content/public/browser/android/content_view_core.h" |
| 69 #endif | 71 #endif |
| 70 | 72 |
| 71 DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::ChromeAutofillClient); | 73 DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::ChromeAutofillClient); |
| 72 | 74 |
| 73 namespace autofill { | 75 namespace autofill { |
| 74 | 76 |
| 75 ChromeAutofillClient::ChromeAutofillClient(content::WebContents* web_contents) | 77 ChromeAutofillClient::ChromeAutofillClient(content::WebContents* web_contents) |
| 76 : content::WebContentsObserver(web_contents), | 78 : content::WebContentsObserver(web_contents), |
| 77 unmask_controller_( | 79 unmask_controller_( |
| 78 user_prefs::UserPrefs::Get(web_contents->GetBrowserContext()), | 80 user_prefs::UserPrefs::Get(web_contents->GetBrowserContext()), |
| 79 Profile::FromBrowserContext(web_contents->GetBrowserContext()) | 81 Profile::FromBrowserContext(web_contents->GetBrowserContext()) |
| 80 ->IsOffTheRecord()) { | 82 ->IsOffTheRecord()), |
| 83 weak_ptr_factory_(this) { | |
| 81 DCHECK(web_contents); | 84 DCHECK(web_contents); |
| 82 | 85 |
| 83 #if !BUILDFLAG(ANDROID_JAVA_UI) | 86 #if !BUILDFLAG(ANDROID_JAVA_UI) |
| 84 // Since ZoomController is also a WebContentsObserver, we need to be careful | 87 // Since ZoomController is also a WebContentsObserver, we need to be careful |
| 85 // about disconnecting from it since the relative order of destruction of | 88 // about disconnecting from it since the relative order of destruction of |
| 86 // WebContentsObservers is not guaranteed. ZoomController silently clears | 89 // WebContentsObservers is not guaranteed. ZoomController silently clears |
| 87 // its ZoomObserver list during WebContentsDestroyed() so there's no need | 90 // its ZoomObserver list during WebContentsDestroyed() so there's no need |
| 88 // to explicitly remove ourselves on destruction. | 91 // to explicitly remove ourselves on destruction. |
| 89 zoom::ZoomController* zoom_controller = | 92 zoom::ZoomController* zoom_controller = |
| 90 zoom::ZoomController::FromWebContents(web_contents); | 93 zoom::ZoomController::FromWebContents(web_contents); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 true, card, std::move(legal_message), callback)))); | 207 true, card, std::move(legal_message), callback)))); |
| 205 #else | 208 #else |
| 206 // Do lazy initialization of SaveCardBubbleControllerImpl. | 209 // Do lazy initialization of SaveCardBubbleControllerImpl. |
| 207 autofill::SaveCardBubbleControllerImpl::CreateForWebContents(web_contents()); | 210 autofill::SaveCardBubbleControllerImpl::CreateForWebContents(web_contents()); |
| 208 autofill::SaveCardBubbleControllerImpl* controller = | 211 autofill::SaveCardBubbleControllerImpl* controller = |
| 209 autofill::SaveCardBubbleControllerImpl::FromWebContents(web_contents()); | 212 autofill::SaveCardBubbleControllerImpl::FromWebContents(web_contents()); |
| 210 controller->ShowBubbleForUpload(card, std::move(legal_message), callback); | 213 controller->ShowBubbleForUpload(card, std::move(legal_message), callback); |
| 211 #endif | 214 #endif |
| 212 } | 215 } |
| 213 | 216 |
| 217 void ChromeAutofillClient::ConfirmCreditCardFillAssist( | |
| 218 const CreditCard& card, | |
| 219 const base::Closure& callback) { | |
| 220 #if defined(OS_ANDROID) | |
| 221 AutofillCreditCardFillingInfoBarDelegateMobile::Create( | |
|
Evan Stade
2016/08/02 13:46:41
is it possible to avoid adding CreateCreditCardFil
| |
| 222 InfoBarService::FromWebContents(web_contents()), | |
| 223 weak_ptr_factory_.GetWeakPtr(), card, callback); | |
| 224 #endif | |
| 225 } | |
| 226 | |
| 227 #if defined(OS_ANDROID) | |
| 228 std::unique_ptr<infobars::InfoBar> | |
| 229 ChromeAutofillClient::CreateCreditCardFillingInfoBar( | |
| 230 std::unique_ptr<AutofillCreditCardFillingInfoBarDelegateMobile> delegate) { | |
| 231 return base::WrapUnique( | |
| 232 new AutofillCreditCardFillingInfoBar(std::move(delegate))); | |
| 233 } | |
| 234 #endif | |
| 235 | |
| 214 void ChromeAutofillClient::LoadRiskData( | 236 void ChromeAutofillClient::LoadRiskData( |
| 215 const base::Callback<void(const std::string&)>& callback) { | 237 const base::Callback<void(const std::string&)>& callback) { |
| 216 ::autofill::LoadRiskData(0, web_contents(), callback); | 238 ::autofill::LoadRiskData(0, web_contents(), callback); |
| 217 } | 239 } |
| 218 | 240 |
| 219 bool ChromeAutofillClient::HasCreditCardScanFeature() { | 241 bool ChromeAutofillClient::HasCreditCardScanFeature() { |
| 220 return CreditCardScannerController::HasCreditCardScanFeature(); | 242 return CreditCardScannerController::HasCreditCardScanFeature(); |
| 221 } | 243 } |
| 222 | 244 |
| 223 void ChromeAutofillClient::ScanCreditCard( | 245 void ChromeAutofillClient::ScanCreditCard( |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 364 chrome::FindBrowserWithWebContents(web_contents()) | 386 chrome::FindBrowserWithWebContents(web_contents()) |
| 365 ->window() | 387 ->window() |
| 366 ->ShowAvatarBubbleFromAvatarButton( | 388 ->ShowAvatarBubbleFromAvatarButton( |
| 367 BrowserWindow::AVATAR_BUBBLE_MODE_SIGNIN, | 389 BrowserWindow::AVATAR_BUBBLE_MODE_SIGNIN, |
| 368 signin::ManageAccountsParams(), | 390 signin::ManageAccountsParams(), |
| 369 signin_metrics::AccessPoint::ACCESS_POINT_AUTOFILL_DROPDOWN); | 391 signin_metrics::AccessPoint::ACCESS_POINT_AUTOFILL_DROPDOWN); |
| 370 #endif | 392 #endif |
| 371 } | 393 } |
| 372 | 394 |
| 373 } // namespace autofill | 395 } // namespace autofill |
| OLD | NEW |