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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::ChromeAutofillClient); | 69 DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::ChromeAutofillClient); |
70 | 70 |
71 namespace autofill { | 71 namespace autofill { |
72 | 72 |
73 ChromeAutofillClient::ChromeAutofillClient(content::WebContents* web_contents) | 73 ChromeAutofillClient::ChromeAutofillClient(content::WebContents* web_contents) |
74 : content::WebContentsObserver(web_contents), | 74 : content::WebContentsObserver(web_contents), |
75 unmask_controller_( | 75 unmask_controller_( |
76 user_prefs::UserPrefs::Get(web_contents->GetBrowserContext()), | 76 user_prefs::UserPrefs::Get(web_contents->GetBrowserContext()), |
77 Profile::FromBrowserContext(web_contents->GetBrowserContext()) | 77 Profile::FromBrowserContext(web_contents->GetBrowserContext()) |
78 ->IsOffTheRecord()) { | 78 ->IsOffTheRecord()) { |
79 DCHECK(web_contents); | |
80 | |
81 #if !defined(OS_ANDROID) | 79 #if !defined(OS_ANDROID) |
82 // Since ZoomController is also a WebContentsObserver, we need to be careful | 80 // Since ZoomController is also a WebContentsObserver, we need to be careful |
83 // about disconnecting from it since the relative order of destruction of | 81 // about disconnecting from it since the relative order of destruction of |
84 // WebContentsObservers is not guaranteed. ZoomController silently clears | 82 // WebContentsObservers is not guaranteed. ZoomController silently clears |
85 // its ZoomObserver list during WebContentsDestroyed() so there's no need | 83 // its ZoomObserver list during WebContentsDestroyed() so there's no need |
86 // to explicitly remove ourselves on destruction. | 84 // to explicitly remove ourselves on destruction. |
87 zoom::ZoomController* zoom_controller = | 85 zoom::ZoomController* zoom_controller = |
88 zoom::ZoomController::FromWebContents(web_contents); | 86 zoom::ZoomController::FromWebContents(web_contents); |
89 // There may not always be a ZoomController, e.g. in tests. | 87 // There may not always be a ZoomController, e.g. in tests. |
90 if (zoom_controller) | 88 if (zoom_controller) |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 } | 183 } |
186 | 184 |
187 void ChromeAutofillClient::ConfirmSaveCreditCardLocally( | 185 void ChromeAutofillClient::ConfirmSaveCreditCardLocally( |
188 const CreditCard& card, | 186 const CreditCard& card, |
189 const base::Closure& callback) { | 187 const base::Closure& callback) { |
190 #if defined(OS_ANDROID) | 188 #if defined(OS_ANDROID) |
191 InfoBarService::FromWebContents(web_contents()) | 189 InfoBarService::FromWebContents(web_contents()) |
192 ->AddInfoBar(CreateSaveCardInfoBarMobile( | 190 ->AddInfoBar(CreateSaveCardInfoBarMobile( |
193 base::MakeUnique<AutofillSaveCardInfoBarDelegateMobile>( | 191 base::MakeUnique<AutofillSaveCardInfoBarDelegateMobile>( |
194 false, card, std::unique_ptr<base::DictionaryValue>(nullptr), | 192 false, card, std::unique_ptr<base::DictionaryValue>(nullptr), |
195 callback))); | 193 callback, GetPrefs()))); |
196 #else | 194 #else |
197 // Do lazy initialization of SaveCardBubbleControllerImpl. | 195 // Do lazy initialization of SaveCardBubbleControllerImpl. |
198 autofill::SaveCardBubbleControllerImpl::CreateForWebContents( | 196 autofill::SaveCardBubbleControllerImpl::CreateForWebContents( |
199 web_contents()); | 197 web_contents()); |
200 autofill::SaveCardBubbleControllerImpl* controller = | 198 autofill::SaveCardBubbleControllerImpl* controller = |
201 autofill::SaveCardBubbleControllerImpl::FromWebContents(web_contents()); | 199 autofill::SaveCardBubbleControllerImpl::FromWebContents(web_contents()); |
202 controller->ShowBubbleForLocalSave(card, callback); | 200 controller->ShowBubbleForLocalSave(card, callback); |
203 #endif | 201 #endif |
204 } | 202 } |
205 | 203 |
206 void ChromeAutofillClient::ConfirmSaveCreditCardToCloud( | 204 void ChromeAutofillClient::ConfirmSaveCreditCardToCloud( |
207 const CreditCard& card, | 205 const CreditCard& card, |
208 std::unique_ptr<base::DictionaryValue> legal_message, | 206 std::unique_ptr<base::DictionaryValue> legal_message, |
209 bool should_cvc_be_requested, | 207 bool should_cvc_be_requested, |
210 const base::Closure& callback) { | 208 const base::Closure& callback) { |
211 #if defined(OS_ANDROID) | 209 #if defined(OS_ANDROID) |
212 InfoBarService::FromWebContents(web_contents()) | 210 InfoBarService::FromWebContents(web_contents()) |
213 ->AddInfoBar(CreateSaveCardInfoBarMobile( | 211 ->AddInfoBar(CreateSaveCardInfoBarMobile( |
214 base::MakeUnique<AutofillSaveCardInfoBarDelegateMobile>( | 212 base::MakeUnique<AutofillSaveCardInfoBarDelegateMobile>( |
215 true, card, std::move(legal_message), callback))); | 213 true, card, std::move(legal_message), callback, GetPrefs()))); |
216 #else | 214 #else |
217 // Do lazy initialization of SaveCardBubbleControllerImpl. | 215 // Do lazy initialization of SaveCardBubbleControllerImpl. |
218 autofill::SaveCardBubbleControllerImpl::CreateForWebContents(web_contents()); | 216 autofill::SaveCardBubbleControllerImpl::CreateForWebContents(web_contents()); |
219 autofill::SaveCardBubbleControllerImpl* controller = | 217 autofill::SaveCardBubbleControllerImpl* controller = |
220 autofill::SaveCardBubbleControllerImpl::FromWebContents(web_contents()); | 218 autofill::SaveCardBubbleControllerImpl::FromWebContents(web_contents()); |
221 controller->ShowBubbleForUpload(card, std::move(legal_message), | 219 controller->ShowBubbleForUpload(card, std::move(legal_message), |
222 should_cvc_be_requested, callback); | 220 should_cvc_be_requested, callback); |
223 #endif | 221 #endif |
224 } | 222 } |
225 | 223 |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 // directly. | 389 // directly. |
392 const GURL kSecurityIndicatorHelpCenterUrl( | 390 const GURL kSecurityIndicatorHelpCenterUrl( |
393 "https://support.google.com/chrome/?p=ui_security_indicator"); | 391 "https://support.google.com/chrome/?p=ui_security_indicator"); |
394 web_contents()->OpenURL(content::OpenURLParams( | 392 web_contents()->OpenURL(content::OpenURLParams( |
395 GURL(kSecurityIndicatorHelpCenterUrl), content::Referrer(), | 393 GURL(kSecurityIndicatorHelpCenterUrl), content::Referrer(), |
396 WindowOpenDisposition::NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, | 394 WindowOpenDisposition::NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, |
397 false /* is_renderer_initiated */)); | 395 false /* is_renderer_initiated */)); |
398 } | 396 } |
399 | 397 |
400 } // namespace autofill | 398 } // namespace autofill |
OLD | NEW |