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

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 2314 matching lines...) Expand 10 before | Expand all | Expand 10 after
2355 return true; 2358 return true;
2356 } 2359 }
2357 2360
2358 return false; 2361 return false;
2359 } 2362 }
2360 2363
2361 bool AutofillDialogControllerImpl::TransmissionWillBeSecure() const { 2364 bool AutofillDialogControllerImpl::TransmissionWillBeSecure() const {
2362 return source_url_.SchemeIs(chrome::kHttpsScheme); 2365 return source_url_.SchemeIs(chrome::kHttpsScheme);
2363 } 2366 }
2364 2367
2368 void AutofillDialogControllerImpl::ShowNewCreditCardBubble(
2369 scoped_ptr<CreditCard> new_card,
2370 scoped_ptr<AutofillProfile> billing_profile) {
2371 #if !defined(OS_ANDROID)
2372 NewCreditCardBubbleController::Show(profile(),
2373 new_card.Pass(),
2374 billing_profile.Pass());
2375 #endif
2376 }
2377
2365 AutofillDialogControllerImpl::AutofillDialogControllerImpl( 2378 AutofillDialogControllerImpl::AutofillDialogControllerImpl(
2366 content::WebContents* contents, 2379 content::WebContents* contents,
2367 const FormData& form_structure, 2380 const FormData& form_structure,
2368 const GURL& source_url, 2381 const GURL& source_url,
2369 const DialogType dialog_type, 2382 const DialogType dialog_type,
2370 const base::Callback<void(const FormStructure*, 2383 const base::Callback<void(const FormStructure*,
2371 const std::string&)>& callback) 2384 const std::string&)>& callback)
2372 : WebContentsObserver(contents), 2385 : WebContentsObserver(contents),
2373 profile_(Profile::FromBrowserContext(contents->GetBrowserContext())), 2386 profile_(Profile::FromBrowserContext(contents->GetBrowserContext())),
2374 initial_user_state_(AutofillMetrics::DIALOG_USER_STATE_UNKNOWN), 2387 initial_user_state_(AutofillMetrics::DIALOG_USER_STATE_UNKNOWN),
(...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after
3469 return has_autofill_profiles ? 3482 return has_autofill_profiles ?
3470 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL : 3483 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL :
3471 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL; 3484 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL;
3472 } 3485 }
3473 3486
3474 void AutofillDialogControllerImpl::MaybeShowCreditCardBubble() { 3487 void AutofillDialogControllerImpl::MaybeShowCreditCardBubble() {
3475 if (!data_was_passed_back_) 3488 if (!data_was_passed_back_)
3476 return; 3489 return;
3477 3490
3478 if (newly_saved_card_) { 3491 if (newly_saved_card_) {
3479 AutofillCreditCardBubbleController::ShowNewCardSavedBubble( 3492 scoped_ptr<AutofillProfile> billing_profile;
3480 web_contents(), newly_saved_card_->TypeAndLastFourDigits()); 3493 if (IsManuallyEditingSection(SECTION_BILLING)) {
3494 // Scrape the view as the user's entering or updating information.
3495 DetailOutputMap outputs;
3496 view_->GetUserInput(SECTION_BILLING, &outputs);
3497 billing_profile.reset(new AutofillProfile);
3498 FillFormGroupFromOutputs(outputs, billing_profile.get());
3499 } else {
3500 // Just snag the currently suggested profile.
3501 std::string item_key = SuggestionsMenuModelForSection(SECTION_BILLING)->
3502 GetItemKeyForCheckedItem();
3503 AutofillProfile* profile = GetManager()->GetProfileByGUID(item_key);
3504 billing_profile.reset(new AutofillProfile(*profile));
3505 }
3506
3507 // The bubble also needs the associated email address.
3508 billing_profile->SetRawInfo(
3509 EMAIL_ADDRESS,
3510 GetValueFromSection(SECTION_EMAIL, EMAIL_ADDRESS));
3511
3512 ShowNewCreditCardBubble(newly_saved_card_.Pass(),
3513 billing_profile.Pass());
3481 return; 3514 return;
3482 } 3515 }
3483 3516
3484 if (!full_wallet_ || !full_wallet_->billing_address()) 3517 if (!full_wallet_ || !full_wallet_->billing_address())
3485 return; 3518 return;
3486 3519
3487 // Don't show GeneratedCardBubble if Autocheckout failed. 3520 // Don't show GeneratedCardBubble if Autocheckout failed.
3488 if (GetDialogType() == DIALOG_TYPE_AUTOCHECKOUT && 3521 if (GetDialogType() == DIALOG_TYPE_AUTOCHECKOUT &&
3489 autocheckout_state_ != AUTOCHECKOUT_SUCCESS) { 3522 autocheckout_state_ != AUTOCHECKOUT_SUCCESS) {
3490 return; 3523 return;
3491 } 3524 }
3492 3525
3493 base::string16 backing_last_four; 3526 base::string16 backing_last_four;
3494 if (ActiveInstrument()) { 3527 if (ActiveInstrument()) {
3495 backing_last_four = ActiveInstrument()->TypeAndLastFourDigits(); 3528 backing_last_four = ActiveInstrument()->TypeAndLastFourDigits();
3496 } else { 3529 } else {
3497 DetailOutputMap output; 3530 DetailOutputMap output;
3498 view_->GetUserInput(SECTION_CC_BILLING, &output); 3531 view_->GetUserInput(SECTION_CC_BILLING, &output);
3499 CreditCard card; 3532 CreditCard card;
3500 GetBillingInfoFromOutputs(output, &card, NULL, NULL); 3533 GetBillingInfoFromOutputs(output, &card, NULL, NULL);
3501 backing_last_four = card.TypeAndLastFourDigits(); 3534 backing_last_four = card.TypeAndLastFourDigits();
3502 } 3535 }
3503 AutofillCreditCardBubbleController::ShowGeneratedCardUI( 3536 #if !defined(OS_ANDROID)
3504 web_contents(), backing_last_four, full_wallet_->TypeAndLastFourDigits()); 3537 GeneratedCreditCardBubbleController::Show(
3538 web_contents(),
3539 backing_last_four,
3540 full_wallet_->TypeAndLastFourDigits());
3541 #endif
3505 } 3542 }
3506 3543
3507 } // namespace autofill 3544 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698