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

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

Issue 21668003: Implement newly saved card bubble for realz and update generated card bubble to (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 4 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/autofill_dialog_controller_impl.h" 5 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "apps/native_app_window.h" 11 #include "apps/native_app_window.h"
12 #include "apps/shell_window.h" 12 #include "apps/shell_window.h"
13 #include "base/base64.h" 13 #include "base/base64.h"
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/i18n/rtl.h" 15 #include "base/i18n/rtl.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/prefs/pref_service.h" 17 #include "base/prefs/pref_service.h"
18 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
19 #include "base/strings/string_split.h" 19 #include "base/strings/string_split.h"
20 #include "base/strings/string_util.h" 20 #include "base/strings/string_util.h"
21 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
22 #include "base/time/time.h" 22 #include "base/time/time.h"
23 #include "chrome/browser/autofill/personal_data_manager_factory.h" 23 #include "chrome/browser/autofill/personal_data_manager_factory.h"
24 #include "chrome/browser/browser_process.h" 24 #include "chrome/browser/browser_process.h"
25 #include "chrome/browser/extensions/shell_window_registry.h" 25 #include "chrome/browser/extensions/shell_window_registry.h"
26 #include "chrome/browser/prefs/scoped_user_pref_update.h" 26 #include "chrome/browser/prefs/scoped_user_pref_update.h"
27 #include "chrome/browser/profiles/profile.h" 27 #include "chrome/browser/profiles/profile.h"
28 #include "chrome/browser/ui/autofill/autofill_credit_card_bubble_controller.h"
29 #include "chrome/browser/ui/autofill/autofill_dialog_view.h" 28 #include "chrome/browser/ui/autofill/autofill_dialog_view.h"
30 #include "chrome/browser/ui/autofill/data_model_wrapper.h" 29 #include "chrome/browser/ui/autofill/data_model_wrapper.h"
30 #if !defined(OS_ANDROID)
31 #include "chrome/browser/ui/autofill/generated_credit_card_bubble_controller.h"
32 #include "chrome/browser/ui/autofill/new_credit_card_bubble_controller.h"
33 #endif
31 #include "chrome/browser/ui/browser.h" 34 #include "chrome/browser/ui/browser.h"
32 #include "chrome/browser/ui/browser_finder.h" 35 #include "chrome/browser/ui/browser_finder.h"
33 #include "chrome/browser/ui/browser_navigator.h" 36 #include "chrome/browser/ui/browser_navigator.h"
34 #include "chrome/browser/ui/browser_window.h" 37 #include "chrome/browser/ui/browser_window.h"
35 #include "chrome/common/chrome_version_info.h" 38 #include "chrome/common/chrome_version_info.h"
36 #include "chrome/common/pref_names.h" 39 #include "chrome/common/pref_names.h"
37 #include "chrome/common/render_messages.h" 40 #include "chrome/common/render_messages.h"
38 #include "chrome/common/url_constants.h" 41 #include "chrome/common/url_constants.h"
39 #include "components/autofill/content/browser/risk/fingerprint.h" 42 #include "components/autofill/content/browser/risk/fingerprint.h"
40 #include "components/autofill/content/browser/risk/proto/fingerprint.pb.h" 43 #include "components/autofill/content/browser/risk/proto/fingerprint.pb.h"
(...skipping 2287 matching lines...) Expand 10 before | Expand all | Expand 10 after
2328 return true; 2331 return true;
2329 } 2332 }
2330 2333
2331 return false; 2334 return false;
2332 } 2335 }
2333 2336
2334 bool AutofillDialogControllerImpl::TransmissionWillBeSecure() const { 2337 bool AutofillDialogControllerImpl::TransmissionWillBeSecure() const {
2335 return source_url_.SchemeIs(chrome::kHttpsScheme); 2338 return source_url_.SchemeIs(chrome::kHttpsScheme);
2336 } 2339 }
2337 2340
2341 void AutofillDialogControllerImpl::ShowNewCreditCardBubble(
2342 scoped_ptr<CreditCard> new_card,
2343 scoped_ptr<AutofillProfile> billing_profile) {
2344 #if !defined(OS_ANDROID)
2345 NewCreditCardBubbleController::Show(profile(),
2346 new_card.Pass(),
2347 billing_profile.Pass());
2348 #endif
2349 }
2350
2338 AutofillDialogControllerImpl::AutofillDialogControllerImpl( 2351 AutofillDialogControllerImpl::AutofillDialogControllerImpl(
2339 content::WebContents* contents, 2352 content::WebContents* contents,
2340 const FormData& form_structure, 2353 const FormData& form_structure,
2341 const GURL& source_url, 2354 const GURL& source_url,
2342 const DialogType dialog_type, 2355 const DialogType dialog_type,
2343 const base::Callback<void(const FormStructure*, 2356 const base::Callback<void(const FormStructure*,
2344 const std::string&)>& callback) 2357 const std::string&)>& callback)
2345 : profile_(Profile::FromBrowserContext(contents->GetBrowserContext())), 2358 : profile_(Profile::FromBrowserContext(contents->GetBrowserContext())),
2346 contents_(contents), 2359 contents_(contents),
2347 initial_user_state_(AutofillMetrics::DIALOG_USER_STATE_UNKNOWN), 2360 initial_user_state_(AutofillMetrics::DIALOG_USER_STATE_UNKNOWN),
(...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after
3439 return has_autofill_profiles ? 3452 return has_autofill_profiles ?
3440 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL : 3453 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL :
3441 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL; 3454 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL;
3442 } 3455 }
3443 3456
3444 void AutofillDialogControllerImpl::MaybeShowCreditCardBubble() { 3457 void AutofillDialogControllerImpl::MaybeShowCreditCardBubble() {
3445 if (!data_was_passed_back_) 3458 if (!data_was_passed_back_)
3446 return; 3459 return;
3447 3460
3448 if (newly_saved_card_) { 3461 if (newly_saved_card_) {
3449 AutofillCreditCardBubbleController::ShowNewCardSavedBubble( 3462 scoped_ptr<AutofillProfile> billing_profile;
3450 web_contents(), newly_saved_card_->TypeAndLastFourDigits()); 3463 if (IsManuallyEditingSection(SECTION_BILLING)) {
3464 // Scrape the view as the user's entering or updating information.
3465 DetailOutputMap outputs;
3466 view_->GetUserInput(SECTION_BILLING, &outputs);
3467 billing_profile.reset(new AutofillProfile);
3468 FillFormGroupFromOutputs(outputs, billing_profile.get());
3469 } else {
3470 // Just snag the currently suggested profile.
3471 std::string item_key = SuggestionsMenuModelForSection(SECTION_BILLING)->
3472 GetItemKeyForCheckedItem();
3473 AutofillProfile* profile = GetManager()->GetProfileByGUID(item_key);
3474 billing_profile.reset(new AutofillProfile(*profile));
3475 }
3476
3477 // The bubble also needs the associated email address.
3478 billing_profile->SetRawInfo(
3479 EMAIL_ADDRESS,
3480 GetValueFromSection(SECTION_EMAIL, EMAIL_ADDRESS));
3481
3482 ShowNewCreditCardBubble(newly_saved_card_.Pass(),
3483 billing_profile.Pass());
3451 return; 3484 return;
3452 } 3485 }
3453 3486
3454 if (!full_wallet_ || !full_wallet_->billing_address()) 3487 if (!full_wallet_ || !full_wallet_->billing_address())
3455 return; 3488 return;
3456 3489
3457 // Don't show GeneratedCardBubble if Autocheckout failed. 3490 // Don't show GeneratedCardBubble if Autocheckout failed.
3458 if (GetDialogType() == DIALOG_TYPE_AUTOCHECKOUT && 3491 if (GetDialogType() == DIALOG_TYPE_AUTOCHECKOUT &&
3459 autocheckout_state_ != AUTOCHECKOUT_SUCCESS) { 3492 autocheckout_state_ != AUTOCHECKOUT_SUCCESS) {
3460 return; 3493 return;
3461 } 3494 }
3462 3495
3463 base::string16 backing_last_four; 3496 base::string16 backing_last_four;
3464 if (ActiveInstrument()) { 3497 if (ActiveInstrument()) {
3465 backing_last_four = ActiveInstrument()->TypeAndLastFourDigits(); 3498 backing_last_four = ActiveInstrument()->TypeAndLastFourDigits();
3466 } else { 3499 } else {
3467 DetailOutputMap output; 3500 DetailOutputMap output;
3468 view_->GetUserInput(SECTION_CC_BILLING, &output); 3501 view_->GetUserInput(SECTION_CC_BILLING, &output);
3469 CreditCard card; 3502 CreditCard card;
3470 GetBillingInfoFromOutputs(output, &card, NULL, NULL); 3503 GetBillingInfoFromOutputs(output, &card, NULL, NULL);
3471 backing_last_four = card.TypeAndLastFourDigits(); 3504 backing_last_four = card.TypeAndLastFourDigits();
3472 } 3505 }
3473 AutofillCreditCardBubbleController::ShowGeneratedCardUI( 3506 #if !defined(OS_ANDROID)
3474 web_contents(), backing_last_four, full_wallet_->TypeAndLastFourDigits()); 3507 GeneratedCreditCardBubbleController::Show(
3508 web_contents(),
3509 backing_last_four,
3510 full_wallet_->TypeAndLastFourDigits());
3511 #endif
3475 } 3512 }
3476 3513
3477 } // namespace autofill 3514 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698