OLD | NEW |
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 29 matching lines...) Expand all Loading... |
40 } | 40 } |
41 | 41 |
42 SaveCardBubbleControllerImpl::~SaveCardBubbleControllerImpl() { | 42 SaveCardBubbleControllerImpl::~SaveCardBubbleControllerImpl() { |
43 if (save_card_bubble_view_) | 43 if (save_card_bubble_view_) |
44 save_card_bubble_view_->Hide(); | 44 save_card_bubble_view_->Hide(); |
45 } | 45 } |
46 | 46 |
47 void SaveCardBubbleControllerImpl::ShowBubbleForLocalSave( | 47 void SaveCardBubbleControllerImpl::ShowBubbleForLocalSave( |
48 const CreditCard& card, | 48 const CreditCard& card, |
49 const base::Closure& save_card_callback) { | 49 const base::Closure& save_card_callback) { |
| 50 // Don't show the bubble if it's already visible. |
| 51 if (save_card_bubble_view_) |
| 52 return; |
| 53 |
50 is_uploading_ = false; | 54 is_uploading_ = false; |
51 is_reshow_ = false; | 55 is_reshow_ = false; |
52 should_cvc_be_requested_ = false; | 56 should_cvc_be_requested_ = false; |
53 legal_message_lines_.clear(); | 57 legal_message_lines_.clear(); |
54 | 58 |
55 AutofillMetrics::LogSaveCardPromptMetric( | 59 AutofillMetrics::LogSaveCardPromptMetric( |
56 AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, is_uploading_, | 60 AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, is_uploading_, |
57 is_reshow_); | 61 is_reshow_); |
58 | 62 |
59 card_ = card; | 63 card_ = card; |
60 save_card_callback_ = save_card_callback; | 64 save_card_callback_ = save_card_callback; |
61 ShowBubble(); | 65 ShowBubble(); |
62 } | 66 } |
63 | 67 |
64 void SaveCardBubbleControllerImpl::ShowBubbleForUpload( | 68 void SaveCardBubbleControllerImpl::ShowBubbleForUpload( |
65 const CreditCard& card, | 69 const CreditCard& card, |
66 std::unique_ptr<base::DictionaryValue> legal_message, | 70 std::unique_ptr<base::DictionaryValue> legal_message, |
67 bool should_cvc_be_requested, | 71 bool should_cvc_be_requested, |
68 const base::Closure& save_card_callback) { | 72 const base::Closure& save_card_callback) { |
| 73 // Don't show the bubble if it's already visible. |
| 74 if (save_card_bubble_view_) |
| 75 return; |
| 76 |
69 is_uploading_ = true; | 77 is_uploading_ = true; |
70 is_reshow_ = false; | 78 is_reshow_ = false; |
71 should_cvc_be_requested_ = should_cvc_be_requested; | 79 should_cvc_be_requested_ = should_cvc_be_requested; |
72 AutofillMetrics::LogSaveCardPromptMetric( | 80 AutofillMetrics::LogSaveCardPromptMetric( |
73 AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, is_uploading_, | 81 AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, is_uploading_, |
74 is_reshow_); | 82 is_reshow_); |
75 | 83 |
76 if (!LegalMessageLine::Parse(*legal_message, &legal_message_lines_)) { | 84 if (!LegalMessageLine::Parse(*legal_message, &legal_message_lines_)) { |
77 AutofillMetrics::LogSaveCardPromptMetric( | 85 AutofillMetrics::LogSaveCardPromptMetric( |
78 AutofillMetrics::SAVE_CARD_PROMPT_END_INVALID_LEGAL_MESSAGE, | 86 AutofillMetrics::SAVE_CARD_PROMPT_END_INVALID_LEGAL_MESSAGE, |
79 is_uploading_, is_reshow_); | 87 is_uploading_, is_reshow_); |
80 return; | 88 return; |
81 } | 89 } |
82 | 90 |
83 card_ = card; | 91 card_ = card; |
84 save_card_callback_ = save_card_callback; | 92 save_card_callback_ = save_card_callback; |
85 ShowBubble(); | 93 ShowBubble(); |
86 } | 94 } |
87 | 95 |
88 void SaveCardBubbleControllerImpl::HideBubble() { | 96 void SaveCardBubbleControllerImpl::HideBubble() { |
89 if (save_card_bubble_view_) { | 97 if (save_card_bubble_view_) { |
90 save_card_bubble_view_->Hide(); | 98 save_card_bubble_view_->Hide(); |
91 save_card_bubble_view_ = nullptr; | 99 save_card_bubble_view_ = nullptr; |
92 } | 100 } |
93 } | 101 } |
94 | 102 |
95 void SaveCardBubbleControllerImpl::ReshowBubble() { | 103 void SaveCardBubbleControllerImpl::ReshowBubble() { |
| 104 // Don't show the bubble if it's already visible. |
| 105 if (save_card_bubble_view_) |
| 106 return; |
| 107 |
96 is_reshow_ = true; | 108 is_reshow_ = true; |
97 AutofillMetrics::LogSaveCardPromptMetric( | 109 AutofillMetrics::LogSaveCardPromptMetric( |
98 AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, is_uploading_, | 110 AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, is_uploading_, |
99 is_reshow_); | 111 is_reshow_); |
100 | 112 |
101 ShowBubble(); | 113 ShowBubble(); |
102 } | 114 } |
103 | 115 |
104 bool SaveCardBubbleControllerImpl::IsIconVisible() const { | 116 bool SaveCardBubbleControllerImpl::IsIconVisible() const { |
105 return !save_card_callback_.is_null(); | 117 return !save_card_callback_.is_null(); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 location_bar->UpdateSaveCreditCardIcon(); | 273 location_bar->UpdateSaveCreditCardIcon(); |
262 } | 274 } |
263 | 275 |
264 void SaveCardBubbleControllerImpl::OpenUrl(const GURL& url) { | 276 void SaveCardBubbleControllerImpl::OpenUrl(const GURL& url) { |
265 web_contents()->OpenURL(content::OpenURLParams( | 277 web_contents()->OpenURL(content::OpenURLParams( |
266 url, content::Referrer(), WindowOpenDisposition::NEW_FOREGROUND_TAB, | 278 url, content::Referrer(), WindowOpenDisposition::NEW_FOREGROUND_TAB, |
267 ui::PAGE_TRANSITION_LINK, false)); | 279 ui::PAGE_TRANSITION_LINK, false)); |
268 } | 280 } |
269 | 281 |
270 } // namespace autofill | 282 } // namespace autofill |
OLD | NEW |