| 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/new_credit_card_bubble_controller.h" | 5 #include "chrome/browser/ui/autofill/new_credit_card_bubble_controller.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/logging.h" | 10 #include "base/logging.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 11 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/ui/autofill/data_model_wrapper.h" | 14 #include "chrome/browser/ui/autofill/data_model_wrapper.h" |
| 14 #include "chrome/browser/ui/autofill/new_credit_card_bubble_view.h" | 15 #include "chrome/browser/ui/autofill/new_credit_card_bubble_view.h" |
| 15 #include "chrome/browser/ui/browser_finder.h" | 16 #include "chrome/browser/ui/browser_finder.h" |
| 16 #include "chrome/browser/ui/chrome_pages.h" | 17 #include "chrome/browser/ui/chrome_pages.h" |
| 17 #include "chrome/browser/ui/host_desktop.h" | 18 #include "chrome/browser/ui/host_desktop.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 32 | 33 |
| 33 NewCreditCardBubbleController::~NewCreditCardBubbleController() { | 34 NewCreditCardBubbleController::~NewCreditCardBubbleController() { |
| 34 Hide(); | 35 Hide(); |
| 35 } | 36 } |
| 36 | 37 |
| 37 // static | 38 // static |
| 38 void NewCreditCardBubbleController::Show( | 39 void NewCreditCardBubbleController::Show( |
| 39 content::WebContents* web_contents, | 40 content::WebContents* web_contents, |
| 40 scoped_ptr<CreditCard> new_card, | 41 scoped_ptr<CreditCard> new_card, |
| 41 scoped_ptr<AutofillProfile> billing_profile) { | 42 scoped_ptr<AutofillProfile> billing_profile) { |
| 42 (new NewCreditCardBubbleController(web_contents))->SetupAndShow( | 43 (new NewCreditCardBubbleController(web_contents)) |
| 43 new_card.Pass(), | 44 ->SetupAndShow(std::move(new_card), std::move(billing_profile)); |
| 44 billing_profile.Pass()); | |
| 45 } | 45 } |
| 46 | 46 |
| 47 const base::string16& NewCreditCardBubbleController::TitleText() const { | 47 const base::string16& NewCreditCardBubbleController::TitleText() const { |
| 48 return title_text_; | 48 return title_text_; |
| 49 } | 49 } |
| 50 | 50 |
| 51 const CreditCardDescription& NewCreditCardBubbleController::CardDescription() | 51 const CreditCardDescription& NewCreditCardBubbleController::CardDescription() |
| 52 const { | 52 const { |
| 53 return card_desc_; | 53 return card_desc_; |
| 54 } | 54 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 85 bubble() { | 85 bubble() { |
| 86 return bubble_; | 86 return bubble_; |
| 87 } | 87 } |
| 88 | 88 |
| 89 void NewCreditCardBubbleController::SetupAndShow( | 89 void NewCreditCardBubbleController::SetupAndShow( |
| 90 scoped_ptr<CreditCard> new_card, | 90 scoped_ptr<CreditCard> new_card, |
| 91 scoped_ptr<AutofillProfile> billing_profile) { | 91 scoped_ptr<AutofillProfile> billing_profile) { |
| 92 DCHECK(new_card); | 92 DCHECK(new_card); |
| 93 DCHECK(billing_profile); | 93 DCHECK(billing_profile); |
| 94 | 94 |
| 95 new_card_ = new_card.Pass(); | 95 new_card_ = std::move(new_card); |
| 96 billing_profile_ = billing_profile.Pass(); | 96 billing_profile_ = std::move(billing_profile); |
| 97 | 97 |
| 98 const base::string16 card_number = | 98 const base::string16 card_number = |
| 99 new_card_->GetRawInfo(CREDIT_CARD_NUMBER); | 99 new_card_->GetRawInfo(CREDIT_CARD_NUMBER); |
| 100 ui::ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 100 ui::ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 101 card_desc_.icon = rb.GetImageNamed( | 101 card_desc_.icon = rb.GetImageNamed( |
| 102 CreditCard::IconResourceId(CreditCard::GetCreditCardType(card_number))); | 102 CreditCard::IconResourceId(CreditCard::GetCreditCardType(card_number))); |
| 103 card_desc_.name = new_card_->TypeAndLastFourDigits(); | 103 card_desc_.name = new_card_->TypeAndLastFourDigits(); |
| 104 | 104 |
| 105 AutofillProfileWrapper wrapper(billing_profile_.get()); | 105 AutofillProfileWrapper wrapper(billing_profile_.get()); |
| 106 base::string16 unused; | 106 base::string16 unused; |
| 107 wrapper.GetDisplayText(&card_desc_.description, &unused); | 107 wrapper.GetDisplayText(&card_desc_.description, &unused); |
| 108 | 108 |
| 109 bubble_ = CreateBubble(); | 109 bubble_ = CreateBubble(); |
| 110 if (!bubble_) { | 110 if (!bubble_) { |
| 111 // TODO(dbeam): Make a bubble on all applicable platforms. | 111 // TODO(dbeam): Make a bubble on all applicable platforms. |
| 112 delete this; | 112 delete this; |
| 113 return; | 113 return; |
| 114 } | 114 } |
| 115 | 115 |
| 116 bubble_->Show(); | 116 bubble_->Show(); |
| 117 } | 117 } |
| 118 | 118 |
| 119 void NewCreditCardBubbleController::Hide() { | 119 void NewCreditCardBubbleController::Hide() { |
| 120 if (bubble_) | 120 if (bubble_) |
| 121 bubble_->Hide(); | 121 bubble_->Hide(); |
| 122 } | 122 } |
| 123 | 123 |
| 124 } // namespace autofill | 124 } // namespace autofill |
| OLD | NEW |