Chromium Code Reviews| 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 26 matching lines...) Expand all Loading... | |
| 37 | 37 |
| 38 SaveCardBubbleControllerImpl::SaveCardBubbleControllerImpl( | 38 SaveCardBubbleControllerImpl::SaveCardBubbleControllerImpl( |
| 39 content::WebContents* web_contents) | 39 content::WebContents* web_contents) |
| 40 : content::WebContentsObserver(web_contents), | 40 : content::WebContentsObserver(web_contents), |
| 41 save_card_bubble_view_(nullptr), | 41 save_card_bubble_view_(nullptr), |
| 42 pref_service_( | 42 pref_service_( |
| 43 user_prefs::UserPrefs::Get(web_contents->GetBrowserContext())) {} | 43 user_prefs::UserPrefs::Get(web_contents->GetBrowserContext())) {} |
| 44 | 44 |
| 45 SaveCardBubbleControllerImpl::~SaveCardBubbleControllerImpl() { | 45 SaveCardBubbleControllerImpl::~SaveCardBubbleControllerImpl() { |
| 46 if (save_card_bubble_view_) | 46 if (save_card_bubble_view_) |
| 47 save_card_bubble_view_->Hide(); | 47 save_card_bubble_view_->Hide(); |
|
Jared Saul
2017/05/04 20:51:12
Why did this line let the bug exist? If the contr
Roger McFarlane (Chromium)
2017/05/05 16:16:11
the problem is not in the cleanup, it's in the Sho
| |
| 48 } | 48 } |
| 49 | 49 |
| 50 void SaveCardBubbleControllerImpl::ShowBubbleForLocalSave( | 50 void SaveCardBubbleControllerImpl::ShowBubbleForLocalSave( |
| 51 const CreditCard& card, | 51 const CreditCard& card, |
| 52 const base::Closure& save_card_callback) { | 52 const base::Closure& save_card_callback) { |
| 53 // Don't show the bubble if it's already visible. | |
| 54 if (save_card_bubble_view_) | |
| 55 return; | |
| 56 | |
| 53 is_uploading_ = false; | 57 is_uploading_ = false; |
| 54 is_reshow_ = false; | 58 is_reshow_ = false; |
| 55 should_cvc_be_requested_ = false; | 59 should_cvc_be_requested_ = false; |
| 56 legal_message_lines_.clear(); | 60 legal_message_lines_.clear(); |
| 57 | 61 |
| 58 AutofillMetrics::LogSaveCardPromptMetric( | 62 AutofillMetrics::LogSaveCardPromptMetric( |
| 59 AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, is_uploading_, | 63 AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, is_uploading_, |
| 60 is_reshow_, | 64 is_reshow_, |
| 61 pref_service_->GetInteger( | 65 pref_service_->GetInteger( |
| 62 prefs::kAutofillAcceptSaveCreditCardPromptState)); | 66 prefs::kAutofillAcceptSaveCreditCardPromptState)); |
| 63 | 67 |
| 64 card_ = card; | 68 card_ = card; |
| 65 save_card_callback_ = save_card_callback; | 69 save_card_callback_ = save_card_callback; |
| 66 ShowBubble(); | 70 ShowBubble(); |
| 67 } | 71 } |
| 68 | 72 |
| 69 void SaveCardBubbleControllerImpl::ShowBubbleForUpload( | 73 void SaveCardBubbleControllerImpl::ShowBubbleForUpload( |
| 70 const CreditCard& card, | 74 const CreditCard& card, |
| 71 std::unique_ptr<base::DictionaryValue> legal_message, | 75 std::unique_ptr<base::DictionaryValue> legal_message, |
| 72 bool should_cvc_be_requested, | 76 bool should_cvc_be_requested, |
| 73 const base::Closure& save_card_callback) { | 77 const base::Closure& save_card_callback) { |
| 78 // Don't show the bubble if it's already visible. | |
| 79 if (save_card_bubble_view_) | |
| 80 return; | |
| 81 | |
| 74 is_uploading_ = true; | 82 is_uploading_ = true; |
| 75 is_reshow_ = false; | 83 is_reshow_ = false; |
| 76 should_cvc_be_requested_ = should_cvc_be_requested; | 84 should_cvc_be_requested_ = should_cvc_be_requested; |
| 77 AutofillMetrics::LogSaveCardPromptMetric( | 85 AutofillMetrics::LogSaveCardPromptMetric( |
| 78 AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, is_uploading_, | 86 AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, is_uploading_, |
| 79 is_reshow_, | 87 is_reshow_, |
| 80 pref_service_->GetInteger( | 88 pref_service_->GetInteger( |
| 81 prefs::kAutofillAcceptSaveCreditCardPromptState)); | 89 prefs::kAutofillAcceptSaveCreditCardPromptState)); |
| 82 | 90 |
| 83 if (!LegalMessageLine::Parse(*legal_message, &legal_message_lines_)) { | 91 if (!LegalMessageLine::Parse(*legal_message, &legal_message_lines_)) { |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 95 } | 103 } |
| 96 | 104 |
| 97 void SaveCardBubbleControllerImpl::HideBubble() { | 105 void SaveCardBubbleControllerImpl::HideBubble() { |
| 98 if (save_card_bubble_view_) { | 106 if (save_card_bubble_view_) { |
| 99 save_card_bubble_view_->Hide(); | 107 save_card_bubble_view_->Hide(); |
| 100 save_card_bubble_view_ = nullptr; | 108 save_card_bubble_view_ = nullptr; |
| 101 } | 109 } |
| 102 } | 110 } |
| 103 | 111 |
| 104 void SaveCardBubbleControllerImpl::ReshowBubble() { | 112 void SaveCardBubbleControllerImpl::ReshowBubble() { |
| 113 // Don't show the bubble if it's already visible. | |
| 114 if (save_card_bubble_view_) | |
|
Jared Saul
2017/05/04 20:51:12
If the icon in the Omnibox is clicked which hides
Roger McFarlane (Chromium)
2017/05/05 16:16:11
The bubble actually manages it's own lifetime. We'
| |
| 115 return; | |
| 116 | |
| 105 is_reshow_ = true; | 117 is_reshow_ = true; |
| 106 AutofillMetrics::LogSaveCardPromptMetric( | 118 AutofillMetrics::LogSaveCardPromptMetric( |
| 107 AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, is_uploading_, | 119 AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, is_uploading_, |
| 108 is_reshow_, | 120 is_reshow_, |
| 109 pref_service_->GetInteger( | 121 pref_service_->GetInteger( |
| 110 prefs::kAutofillAcceptSaveCreditCardPromptState)); | 122 prefs::kAutofillAcceptSaveCreditCardPromptState)); |
| 111 | 123 |
| 112 ShowBubble(); | 124 ShowBubble(); |
| 113 } | 125 } |
| 114 | 126 |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 291 location_bar->UpdateSaveCreditCardIcon(); | 303 location_bar->UpdateSaveCreditCardIcon(); |
| 292 } | 304 } |
| 293 | 305 |
| 294 void SaveCardBubbleControllerImpl::OpenUrl(const GURL& url) { | 306 void SaveCardBubbleControllerImpl::OpenUrl(const GURL& url) { |
| 295 web_contents()->OpenURL(content::OpenURLParams( | 307 web_contents()->OpenURL(content::OpenURLParams( |
| 296 url, content::Referrer(), WindowOpenDisposition::NEW_FOREGROUND_TAB, | 308 url, content::Referrer(), WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 297 ui::PAGE_TRANSITION_LINK, false)); | 309 ui::PAGE_TRANSITION_LINK, false)); |
| 298 } | 310 } |
| 299 | 311 |
| 300 } // namespace autofill | 312 } // namespace autofill |
| OLD | NEW |