OLD | NEW |
---|---|
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 |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
458 GetMetricLogger().LogDialogInitialUserState( | 458 GetMetricLogger().LogDialogInitialUserState( |
459 GetDialogType(), initial_user_state_); | 459 GetDialogType(), initial_user_state_); |
460 | 460 |
461 if (deemphasized_render_view_) { | 461 if (deemphasized_render_view_) { |
462 web_contents()->GetRenderViewHost()->Send( | 462 web_contents()->GetRenderViewHost()->Send( |
463 new ChromeViewMsg_SetVisuallyDeemphasized( | 463 new ChromeViewMsg_SetVisuallyDeemphasized( |
464 web_contents()->GetRenderViewHost()->GetRoutingID(), false)); | 464 web_contents()->GetRenderViewHost()->GetRoutingID(), false)); |
465 } | 465 } |
466 } | 466 } |
467 | 467 |
468 #if !defined(OS_ANDROID) | |
Dan Beam
2013/08/01 19:23:53
^ why are any of these files compiled on android a
aruslan
2013/08/01 19:34:33
Because TabAutofillManagerDelegate depends on Auto
| |
468 // static | 469 // static |
469 base::WeakPtr<AutofillDialogControllerImpl> | 470 base::WeakPtr<AutofillDialogControllerImpl> |
470 AutofillDialogControllerImpl::Create( | 471 AutofillDialogControllerImpl::Create( |
471 content::WebContents* contents, | 472 content::WebContents* contents, |
472 const FormData& form_structure, | 473 const FormData& form_structure, |
473 const GURL& source_url, | 474 const GURL& source_url, |
474 const DialogType dialog_type, | 475 const DialogType dialog_type, |
475 const base::Callback<void(const FormStructure*, | 476 const base::Callback<void(const FormStructure*, |
476 const std::string&)>& callback) { | 477 const std::string&)>& callback) { |
477 // AutofillDialogControllerImpl owns itself. | 478 // AutofillDialogControllerImpl owns itself. |
478 AutofillDialogControllerImpl* autofill_dialog_controller = | 479 AutofillDialogControllerImpl* autofill_dialog_controller = |
479 new AutofillDialogControllerImpl(contents, | 480 new AutofillDialogControllerImpl(contents, |
480 form_structure, | 481 form_structure, |
481 source_url, | 482 source_url, |
482 dialog_type, | 483 dialog_type, |
483 callback); | 484 callback); |
484 return autofill_dialog_controller->weak_ptr_factory_.GetWeakPtr(); | 485 return autofill_dialog_controller->weak_ptr_factory_.GetWeakPtr(); |
485 } | 486 } |
487 #endif // !defined(OS_ANDROID) | |
486 | 488 |
487 // static | 489 // static |
488 void AutofillDialogControllerImpl::RegisterProfilePrefs( | 490 void AutofillDialogControllerImpl::RegisterProfilePrefs( |
489 user_prefs::PrefRegistrySyncable* registry) { | 491 user_prefs::PrefRegistrySyncable* registry) { |
490 registry->RegisterIntegerPref( | 492 registry->RegisterIntegerPref( |
491 ::prefs::kAutofillDialogShowCount, | 493 ::prefs::kAutofillDialogShowCount, |
492 0, | 494 0, |
493 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 495 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
494 registry->RegisterBooleanPref( | 496 registry->RegisterBooleanPref( |
495 ::prefs::kAutofillDialogHasPaidWithWallet, | 497 ::prefs::kAutofillDialogHasPaidWithWallet, |
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1222 | 1224 |
1223 // For other sections, only show a menu if there's at least one suggestion. | 1225 // For other sections, only show a menu if there's at least one suggestion. |
1224 for (int i = 0; i < model->GetItemCount(); ++i) { | 1226 for (int i = 0; i < model->GetItemCount(); ++i) { |
1225 if (IsASuggestionItemKey(model->GetItemKeyAt(i))) | 1227 if (IsASuggestionItemKey(model->GetItemKeyAt(i))) |
1226 return model; | 1228 return model; |
1227 } | 1229 } |
1228 | 1230 |
1229 return NULL; | 1231 return NULL; |
1230 } | 1232 } |
1231 | 1233 |
1232 #if defined(OS_ANDROID) | |
1233 ui::MenuModel* AutofillDialogControllerImpl::MenuModelForSectionHack( | |
1234 DialogSection section) { | |
1235 return SuggestionsMenuModelForSection(section); | |
1236 } | |
1237 #endif | |
1238 | |
1239 ui::MenuModel* AutofillDialogControllerImpl::MenuModelForAccountChooser() { | 1234 ui::MenuModel* AutofillDialogControllerImpl::MenuModelForAccountChooser() { |
1240 // If there were unrecoverable Wallet errors, or if there are choices other | 1235 // If there were unrecoverable Wallet errors, or if there are choices other |
1241 // than "Pay without the wallet", show the full menu. | 1236 // than "Pay without the wallet", show the full menu. |
1242 if (account_chooser_model_.HadWalletError() || | 1237 if (account_chooser_model_.HadWalletError() || |
1243 account_chooser_model_.HasAccountsToChoose()) { | 1238 account_chooser_model_.HasAccountsToChoose()) { |
1244 return &account_chooser_model_; | 1239 return &account_chooser_model_; |
1245 } | 1240 } |
1246 | 1241 |
1247 // Otherwise, there is no menu, just a sign in link. | 1242 // Otherwise, there is no menu, just a sign in link. |
1248 return NULL; | 1243 return NULL; |
(...skipping 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2405 risk_data_.clear(); | 2400 risk_data_.clear(); |
2406 | 2401 |
2407 uint64 obfuscated_gaia_id = 0; | 2402 uint64 obfuscated_gaia_id = 0; |
2408 bool success = base::StringToUint64(wallet_items_->obfuscated_gaia_id(), | 2403 bool success = base::StringToUint64(wallet_items_->obfuscated_gaia_id(), |
2409 &obfuscated_gaia_id); | 2404 &obfuscated_gaia_id); |
2410 DCHECK(success); | 2405 DCHECK(success); |
2411 | 2406 |
2412 gfx::Rect window_bounds; | 2407 gfx::Rect window_bounds; |
2413 #if !defined(OS_ANDROID) | 2408 #if !defined(OS_ANDROID) |
2414 window_bounds = GetBaseWindowForWebContents(web_contents())->GetBounds(); | 2409 window_bounds = GetBaseWindowForWebContents(web_contents())->GetBounds(); |
2415 #else | |
2416 // TODO(dbeam): figure out the correct browser window size to pass along for | |
2417 // android. | |
2418 #endif | 2410 #endif |
2419 | 2411 |
2420 PrefService* user_prefs = profile_->GetPrefs(); | 2412 PrefService* user_prefs = profile_->GetPrefs(); |
2421 std::string charset = user_prefs->GetString(::prefs::kDefaultCharset); | 2413 std::string charset = user_prefs->GetString(::prefs::kDefaultCharset); |
2422 std::string accept_languages = | 2414 std::string accept_languages = |
2423 user_prefs->GetString(::prefs::kAcceptLanguages); | 2415 user_prefs->GetString(::prefs::kAcceptLanguages); |
2424 base::Time install_time = base::Time::FromTimeT( | 2416 base::Time install_time = base::Time::FromTimeT( |
2425 g_browser_process->local_state()->GetInt64(::prefs::kInstallDate)); | 2417 g_browser_process->local_state()->GetInt64(::prefs::kInstallDate)); |
2426 | 2418 |
2427 risk::GetFingerprint( | 2419 risk::GetFingerprint( |
(...skipping 17 matching lines...) Expand all Loading... | |
2445 } | 2437 } |
2446 | 2438 |
2447 void AutofillDialogControllerImpl::OpenTabWithUrl(const GURL& url) { | 2439 void AutofillDialogControllerImpl::OpenTabWithUrl(const GURL& url) { |
2448 #if !defined(OS_ANDROID) | 2440 #if !defined(OS_ANDROID) |
2449 chrome::NavigateParams params( | 2441 chrome::NavigateParams params( |
2450 chrome::FindBrowserWithWebContents(web_contents()), | 2442 chrome::FindBrowserWithWebContents(web_contents()), |
2451 url, | 2443 url, |
2452 content::PAGE_TRANSITION_AUTO_BOOKMARK); | 2444 content::PAGE_TRANSITION_AUTO_BOOKMARK); |
2453 params.disposition = NEW_FOREGROUND_TAB; | 2445 params.disposition = NEW_FOREGROUND_TAB; |
2454 chrome::Navigate(¶ms); | 2446 chrome::Navigate(¶ms); |
2455 #else | |
2456 // TODO(estade): use TabModelList? | |
2457 #endif | 2447 #endif |
2458 } | 2448 } |
2459 | 2449 |
2460 bool AutofillDialogControllerImpl::IsEditingExistingData( | 2450 bool AutofillDialogControllerImpl::IsEditingExistingData( |
2461 DialogSection section) const { | 2451 DialogSection section) const { |
2462 return section_editing_state_.count(section) > 0; | 2452 return section_editing_state_.count(section) > 0; |
2463 } | 2453 } |
2464 | 2454 |
2465 bool AutofillDialogControllerImpl::IsManuallyEditingSection( | 2455 bool AutofillDialogControllerImpl::IsManuallyEditingSection( |
2466 DialogSection section) const { | 2456 DialogSection section) const { |
(...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3480 view_->GetUserInput(SECTION_CC_BILLING, &output); | 3470 view_->GetUserInput(SECTION_CC_BILLING, &output); |
3481 CreditCard card; | 3471 CreditCard card; |
3482 GetBillingInfoFromOutputs(output, &card, NULL, NULL); | 3472 GetBillingInfoFromOutputs(output, &card, NULL, NULL); |
3483 backing_last_four = card.TypeAndLastFourDigits(); | 3473 backing_last_four = card.TypeAndLastFourDigits(); |
3484 } | 3474 } |
3485 AutofillCreditCardBubbleController::ShowGeneratedCardBubble( | 3475 AutofillCreditCardBubbleController::ShowGeneratedCardBubble( |
3486 web_contents(), backing_last_four, full_wallet_->TypeAndLastFourDigits()); | 3476 web_contents(), backing_last_four, full_wallet_->TypeAndLastFourDigits()); |
3487 } | 3477 } |
3488 | 3478 |
3489 } // namespace autofill | 3479 } // namespace autofill |
OLD | NEW |