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

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

Powered by Google App Engine
This is Rietveld 408576698