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

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: merge 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 "apps/shell_window_registry.h" 13 #include "apps/shell_window_registry.h"
14 #include "base/base64.h" 14 #include "base/base64.h"
15 #include "base/bind.h" 15 #include "base/bind.h"
16 #include "base/i18n/rtl.h" 16 #include "base/i18n/rtl.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/prefs/pref_service.h" 18 #include "base/prefs/pref_service.h"
19 #include "base/strings/string_number_conversions.h" 19 #include "base/strings/string_number_conversions.h"
20 #include "base/strings/string_split.h" 20 #include "base/strings/string_split.h"
21 #include "base/strings/string_util.h" 21 #include "base/strings/string_util.h"
22 #include "base/strings/utf_string_conversions.h" 22 #include "base/strings/utf_string_conversions.h"
23 #include "base/time/time.h" 23 #include "base/time/time.h"
24 #include "chrome/browser/autofill/personal_data_manager_factory.h" 24 #include "chrome/browser/autofill/personal_data_manager_factory.h"
25 #include "chrome/browser/browser_process.h" 25 #include "chrome/browser/browser_process.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_common.h" 28 #include "chrome/browser/ui/autofill/autofill_dialog_common.h"
30 #include "chrome/browser/ui/autofill/autofill_dialog_view.h" 29 #include "chrome/browser/ui/autofill/autofill_dialog_view.h"
31 #include "chrome/browser/ui/autofill/data_model_wrapper.h" 30 #include "chrome/browser/ui/autofill/data_model_wrapper.h"
31 #if !defined(OS_ANDROID)
32 #include "chrome/browser/ui/autofill/generated_credit_card_bubble_controller.h"
33 #include "chrome/browser/ui/autofill/new_credit_card_bubble_controller.h"
34 #endif
32 #include "chrome/browser/ui/browser.h" 35 #include "chrome/browser/ui/browser.h"
33 #include "chrome/browser/ui/browser_finder.h" 36 #include "chrome/browser/ui/browser_finder.h"
34 #include "chrome/browser/ui/browser_navigator.h" 37 #include "chrome/browser/ui/browser_navigator.h"
35 #include "chrome/browser/ui/browser_window.h" 38 #include "chrome/browser/ui/browser_window.h"
36 #include "chrome/common/chrome_version_info.h" 39 #include "chrome/common/chrome_version_info.h"
37 #include "chrome/common/pref_names.h" 40 #include "chrome/common/pref_names.h"
38 #include "chrome/common/render_messages.h" 41 #include "chrome/common/render_messages.h"
39 #include "chrome/common/url_constants.h" 42 #include "chrome/common/url_constants.h"
40 #include "components/autofill/content/browser/risk/fingerprint.h" 43 #include "components/autofill/content/browser/risk/fingerprint.h"
41 #include "components/autofill/content/browser/risk/proto/fingerprint.pb.h" 44 #include "components/autofill/content/browser/risk/proto/fingerprint.pb.h"
(...skipping 2238 matching lines...) Expand 10 before | Expand all | Expand 10 after
2280 return true; 2283 return true;
2281 } 2284 }
2282 2285
2283 return false; 2286 return false;
2284 } 2287 }
2285 2288
2286 bool AutofillDialogControllerImpl::TransmissionWillBeSecure() const { 2289 bool AutofillDialogControllerImpl::TransmissionWillBeSecure() const {
2287 return source_url_.SchemeIs(chrome::kHttpsScheme); 2290 return source_url_.SchemeIs(chrome::kHttpsScheme);
2288 } 2291 }
2289 2292
2293 void AutofillDialogControllerImpl::ShowNewCreditCardBubble(
2294 scoped_ptr<CreditCard> new_card,
2295 scoped_ptr<AutofillProfile> billing_profile) {
2296 #if !defined(OS_ANDROID)
2297 NewCreditCardBubbleController::Show(profile(),
2298 new_card.Pass(),
2299 billing_profile.Pass());
2300 #endif
2301 }
2302
2290 AutofillDialogControllerImpl::AutofillDialogControllerImpl( 2303 AutofillDialogControllerImpl::AutofillDialogControllerImpl(
2291 content::WebContents* contents, 2304 content::WebContents* contents,
2292 const FormData& form_structure, 2305 const FormData& form_structure,
2293 const GURL& source_url, 2306 const GURL& source_url,
2294 const DialogType dialog_type, 2307 const DialogType dialog_type,
2295 const base::Callback<void(const FormStructure*, 2308 const base::Callback<void(const FormStructure*,
2296 const std::string&)>& callback) 2309 const std::string&)>& callback)
2297 : WebContentsObserver(contents), 2310 : WebContentsObserver(contents),
2298 profile_(Profile::FromBrowserContext(contents->GetBrowserContext())), 2311 profile_(Profile::FromBrowserContext(contents->GetBrowserContext())),
2299 initial_user_state_(AutofillMetrics::DIALOG_USER_STATE_UNKNOWN), 2312 initial_user_state_(AutofillMetrics::DIALOG_USER_STATE_UNKNOWN),
(...skipping 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after
3390 return has_autofill_profiles ? 3403 return has_autofill_profiles ?
3391 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL : 3404 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL :
3392 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL; 3405 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL;
3393 } 3406 }
3394 3407
3395 void AutofillDialogControllerImpl::MaybeShowCreditCardBubble() { 3408 void AutofillDialogControllerImpl::MaybeShowCreditCardBubble() {
3396 if (!data_was_passed_back_) 3409 if (!data_was_passed_back_)
3397 return; 3410 return;
3398 3411
3399 if (newly_saved_card_) { 3412 if (newly_saved_card_) {
3400 AutofillCreditCardBubbleController::ShowNewCardSavedBubble( 3413 scoped_ptr<AutofillProfile> billing_profile;
3401 web_contents(), newly_saved_card_->TypeAndLastFourDigits()); 3414 if (IsManuallyEditingSection(SECTION_BILLING)) {
3415 // Scrape the view as the user's entering or updating information.
3416 DetailOutputMap outputs;
3417 view_->GetUserInput(SECTION_BILLING, &outputs);
3418 billing_profile.reset(new AutofillProfile);
3419 FillFormGroupFromOutputs(outputs, billing_profile.get());
3420 } else {
3421 // Just snag the currently suggested profile.
3422 std::string item_key = SuggestionsMenuModelForSection(SECTION_BILLING)->
3423 GetItemKeyForCheckedItem();
3424 AutofillProfile* profile = GetManager()->GetProfileByGUID(item_key);
3425 billing_profile.reset(new AutofillProfile(*profile));
3426 }
3427
3428 // The bubble also needs the associated email address.
3429 billing_profile->SetRawInfo(
3430 EMAIL_ADDRESS,
3431 GetValueFromSection(SECTION_EMAIL, EMAIL_ADDRESS));
3432
3433 ShowNewCreditCardBubble(newly_saved_card_.Pass(),
3434 billing_profile.Pass());
3402 return; 3435 return;
3403 } 3436 }
3404 3437
3405 if (!full_wallet_ || !full_wallet_->billing_address()) 3438 if (!full_wallet_ || !full_wallet_->billing_address())
3406 return; 3439 return;
3407 3440
3408 // Don't show GeneratedCardBubble if Autocheckout failed. 3441 // Don't show GeneratedCardBubble if Autocheckout failed.
3409 if (GetDialogType() == DIALOG_TYPE_AUTOCHECKOUT && 3442 if (GetDialogType() == DIALOG_TYPE_AUTOCHECKOUT &&
3410 autocheckout_state_ != AUTOCHECKOUT_SUCCESS) { 3443 autocheckout_state_ != AUTOCHECKOUT_SUCCESS) {
3411 return; 3444 return;
3412 } 3445 }
3413 3446
3414 base::string16 backing_last_four; 3447 base::string16 backing_last_four;
3415 if (ActiveInstrument()) { 3448 if (ActiveInstrument()) {
3416 backing_last_four = ActiveInstrument()->TypeAndLastFourDigits(); 3449 backing_last_four = ActiveInstrument()->TypeAndLastFourDigits();
3417 } else { 3450 } else {
3418 DetailOutputMap output; 3451 DetailOutputMap output;
3419 view_->GetUserInput(SECTION_CC_BILLING, &output); 3452 view_->GetUserInput(SECTION_CC_BILLING, &output);
3420 CreditCard card; 3453 CreditCard card;
3421 GetBillingInfoFromOutputs(output, &card, NULL, NULL); 3454 GetBillingInfoFromOutputs(output, &card, NULL, NULL);
3422 backing_last_four = card.TypeAndLastFourDigits(); 3455 backing_last_four = card.TypeAndLastFourDigits();
3423 } 3456 }
3424 AutofillCreditCardBubbleController::ShowGeneratedCardUI( 3457 #if !defined(OS_ANDROID)
3425 web_contents(), backing_last_four, full_wallet_->TypeAndLastFourDigits()); 3458 GeneratedCreditCardBubbleController::Show(
3459 web_contents(),
3460 backing_last_four,
3461 full_wallet_->TypeAndLastFourDigits());
3462 #endif
3426 } 3463 }
3427 3464
3428 } // namespace autofill 3465 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698