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

Side by Side Diff: chrome/browser/ui/autofill/save_card_bubble_controller_impl.cc

Issue 2955963002: Update Chrome Upstream flow to reflect new UI mocks (Closed)
Patch Set: Code review changes Created 3 years, 5 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/save_card_bubble_controller_impl.h" 5 #include "chrome/browser/ui/autofill/save_card_bubble_controller_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "chrome/browser/ui/autofill/save_card_bubble_view.h" 9 #include "chrome/browser/ui/autofill/save_card_bubble_view.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 card_ = card; 100 card_ = card;
101 save_card_callback_ = save_card_callback; 101 save_card_callback_ = save_card_callback;
102 ShowBubble(); 102 ShowBubble();
103 } 103 }
104 104
105 void SaveCardBubbleControllerImpl::HideBubble() { 105 void SaveCardBubbleControllerImpl::HideBubble() {
106 if (save_card_bubble_view_) { 106 if (save_card_bubble_view_) {
107 save_card_bubble_view_->Hide(); 107 save_card_bubble_view_->Hide();
108 save_card_bubble_view_ = nullptr; 108 save_card_bubble_view_ = nullptr;
109 } 109 }
110 show_upload_confirm_title_ = false;
110 } 111 }
111 112
112 void SaveCardBubbleControllerImpl::ReshowBubble() { 113 void SaveCardBubbleControllerImpl::ReshowBubble() {
113 // Don't show the bubble if it's already visible. 114 // Don't show the bubble if it's already visible.
114 if (save_card_bubble_view_) 115 if (save_card_bubble_view_)
115 return; 116 return;
116 117
117 is_reshow_ = true; 118 is_reshow_ = true;
118 AutofillMetrics::LogSaveCardPromptMetric( 119 AutofillMetrics::LogSaveCardPromptMetric(
119 AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, is_uploading_, 120 AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, is_uploading_,
120 is_reshow_, 121 is_reshow_,
121 pref_service_->GetInteger( 122 pref_service_->GetInteger(
122 prefs::kAutofillAcceptSaveCreditCardPromptState)); 123 prefs::kAutofillAcceptSaveCreditCardPromptState));
123 124
124 ShowBubble(); 125 ShowBubble();
125 } 126 }
126 127
127 bool SaveCardBubbleControllerImpl::IsIconVisible() const { 128 bool SaveCardBubbleControllerImpl::IsIconVisible() const {
128 return !save_card_callback_.is_null(); 129 return !save_card_callback_.is_null();
129 } 130 }
130 131
131 SaveCardBubbleView* SaveCardBubbleControllerImpl::save_card_bubble_view() 132 SaveCardBubbleView* SaveCardBubbleControllerImpl::save_card_bubble_view()
132 const { 133 const {
133 return save_card_bubble_view_; 134 return save_card_bubble_view_;
134 } 135 }
135 136
136 base::string16 SaveCardBubbleControllerImpl::GetWindowTitle() const { 137 base::string16 SaveCardBubbleControllerImpl::GetWindowTitle() const {
137 return l10n_util::GetStringUTF16( 138 if (is_uploading_) {
Mathieu 2017/06/27 21:12:06 if (is_uploading_) { return show_upload_confirm_
Jared Saul 2017/06/27 21:45:55 Done.
138 is_uploading_ ? IDS_AUTOFILL_SAVE_CARD_PROMPT_TITLE_TO_CLOUD 139 if (show_upload_confirm_title_)
139 : IDS_AUTOFILL_SAVE_CARD_PROMPT_TITLE_LOCAL); 140 return l10n_util::GetStringFUTF16(
141 IDS_AUTOFILL_SAVE_CARD_PROMPT_ENTER_CVC_TITLE,
142 card_.NetworkAndLastFourDigits());
143 else
144 return l10n_util::GetStringUTF16(
145 IDS_AUTOFILL_SAVE_CARD_PROMPT_TITLE_TO_CLOUD);
146 } else {
147 return l10n_util::GetStringUTF16(IDS_AUTOFILL_SAVE_CARD_PROMPT_TITLE_LOCAL);
148 }
140 } 149 }
141 150
142 base::string16 SaveCardBubbleControllerImpl::GetExplanatoryMessage() const { 151 base::string16 SaveCardBubbleControllerImpl::GetExplanatoryMessage() const {
143 return is_uploading_ ? l10n_util::GetStringUTF16( 152 return is_uploading_ ? l10n_util::GetStringUTF16(
144 IDS_AUTOFILL_SAVE_CARD_PROMPT_UPLOAD_EXPLANATION) 153 IDS_AUTOFILL_SAVE_CARD_PROMPT_UPLOAD_EXPLANATION)
145 : base::string16(); 154 : base::string16();
146 } 155 }
147 156
148 const CreditCard SaveCardBubbleControllerImpl::GetCard() const { 157 const CreditCard SaveCardBubbleControllerImpl::GetCard() const {
149 return card_; 158 return card_;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 AutofillMetrics::LogSaveCardPromptMetric( 216 AutofillMetrics::LogSaveCardPromptMetric(
208 AutofillMetrics::SAVE_CARD_PROMPT_DISMISS_CLICK_LEGAL_MESSAGE, 217 AutofillMetrics::SAVE_CARD_PROMPT_DISMISS_CLICK_LEGAL_MESSAGE,
209 is_uploading_, is_reshow_, 218 is_uploading_, is_reshow_,
210 pref_service_->GetInteger( 219 pref_service_->GetInteger(
211 prefs::kAutofillAcceptSaveCreditCardPromptState)); 220 prefs::kAutofillAcceptSaveCreditCardPromptState));
212 } 221 }
213 222
214 void SaveCardBubbleControllerImpl::OnBubbleClosed() { 223 void SaveCardBubbleControllerImpl::OnBubbleClosed() {
215 save_card_bubble_view_ = nullptr; 224 save_card_bubble_view_ = nullptr;
216 UpdateIcon(); 225 UpdateIcon();
226 show_upload_confirm_title_ = false;
217 } 227 }
218 228
219 const LegalMessageLines& SaveCardBubbleControllerImpl::GetLegalMessageLines() 229 const LegalMessageLines& SaveCardBubbleControllerImpl::GetLegalMessageLines()
220 const { 230 const {
221 return legal_message_lines_; 231 return legal_message_lines_;
222 } 232 }
223 233
234 void SaveCardBubbleControllerImpl::SetShowUploadConfirmTitle(
235 bool show_upload_confirm_title) {
236 show_upload_confirm_title_ = show_upload_confirm_title;
237 }
238
224 bool SaveCardBubbleControllerImpl::InputCvcIsValid( 239 bool SaveCardBubbleControllerImpl::InputCvcIsValid(
225 const base::string16& input_text) const { 240 const base::string16& input_text) const {
226 base::string16 trimmed_text; 241 base::string16 trimmed_text;
227 base::TrimWhitespace(input_text, base::TRIM_ALL, &trimmed_text); 242 base::TrimWhitespace(input_text, base::TRIM_ALL, &trimmed_text);
228 return IsValidCreditCardSecurityCode(trimmed_text, card_.network()); 243 return IsValidCreditCardSecurityCode(trimmed_text, card_.network());
229 } 244 }
230 245
231 base::TimeDelta SaveCardBubbleControllerImpl::Elapsed() const { 246 base::TimeDelta SaveCardBubbleControllerImpl::Elapsed() const {
232 return timer_->Elapsed(); 247 return timer_->Elapsed();
233 } 248 }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 location_bar->UpdateSaveCreditCardIcon(); 320 location_bar->UpdateSaveCreditCardIcon();
306 } 321 }
307 322
308 void SaveCardBubbleControllerImpl::OpenUrl(const GURL& url) { 323 void SaveCardBubbleControllerImpl::OpenUrl(const GURL& url) {
309 web_contents()->OpenURL(content::OpenURLParams( 324 web_contents()->OpenURL(content::OpenURLParams(
310 url, content::Referrer(), WindowOpenDisposition::NEW_FOREGROUND_TAB, 325 url, content::Referrer(), WindowOpenDisposition::NEW_FOREGROUND_TAB,
311 ui::PAGE_TRANSITION_LINK, false)); 326 ui::PAGE_TRANSITION_LINK, false));
312 } 327 }
313 328
314 } // namespace autofill 329 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698