| 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 #ifndef CHROME_BROWSER_UI_AUTOFILL_SAVE_CARD_BUBBLE_CONTROLLER_IMPL_H_ | 5 #ifndef CHROME_BROWSER_UI_AUTOFILL_SAVE_CARD_BUBBLE_CONTROLLER_IMPL_H_ |
| 6 #define CHROME_BROWSER_UI_AUTOFILL_SAVE_CARD_BUBBLE_CONTROLLER_IMPL_H_ | 6 #define CHROME_BROWSER_UI_AUTOFILL_SAVE_CARD_BUBBLE_CONTROLLER_IMPL_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 9 |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/timer/elapsed_timer.h" | 11 #include "base/timer/elapsed_timer.h" |
| 11 #include "chrome/browser/ui/autofill/save_card_bubble_controller.h" | 12 #include "chrome/browser/ui/autofill/save_card_bubble_controller.h" |
| 12 #include "components/autofill/core/browser/credit_card.h" | 13 #include "components/autofill/core/browser/credit_card.h" |
| 13 #include "content/public/browser/web_contents_observer.h" | 14 #include "content/public/browser/web_contents_observer.h" |
| 14 #include "content/public/browser/web_contents_user_data.h" | 15 #include "content/public/browser/web_contents_user_data.h" |
| 15 | 16 |
| 16 namespace autofill { | 17 namespace autofill { |
| 17 | 18 |
| 18 // Implementation of per-tab class to control the save credit card bubble and | 19 // Implementation of per-tab class to control the save credit card bubble and |
| 19 // Omnibox icon. | 20 // Omnibox icon. |
| 20 class SaveCardBubbleControllerImpl | 21 class SaveCardBubbleControllerImpl |
| 21 : public SaveCardBubbleController, | 22 : public SaveCardBubbleController, |
| 22 public content::WebContentsObserver, | 23 public content::WebContentsObserver, |
| 23 public content::WebContentsUserData<SaveCardBubbleControllerImpl> { | 24 public content::WebContentsUserData<SaveCardBubbleControllerImpl> { |
| 24 public: | 25 public: |
| 25 // Sets up the controller for local save and shows the bubble. | 26 // Sets up the controller for local save and shows the bubble. |
| 26 // |save_card_callback| will be invoked if and when the Save button is | 27 // |save_card_callback| will be invoked if and when the Save button is |
| 27 // pressed. | 28 // pressed. |
| 28 void ShowBubbleForLocalSave(const CreditCard& card, | 29 void ShowBubbleForLocalSave(const CreditCard& card, |
| 29 const base::Closure& save_card_callback); | 30 const base::Closure& save_card_callback); |
| 30 | 31 |
| 31 // Sets up the controller for upload and shows the bubble. | 32 // Sets up the controller for upload and shows the bubble. |
| 32 // |save_card_callback| will be invoked if and when the Save button is | 33 // |save_card_callback| will be invoked if and when the Save button is |
| 33 // pressed. The contents of |legal_message| will be displayed in the bubble. | 34 // pressed. The contents of |legal_message| will be displayed in the bubble. |
| 34 void ShowBubbleForUpload(const CreditCard& card, | 35 void ShowBubbleForUpload(const CreditCard& card, |
| 35 scoped_ptr<base::DictionaryValue> legal_message, | 36 std::unique_ptr<base::DictionaryValue> legal_message, |
| 36 const base::Closure& save_card_callback); | 37 const base::Closure& save_card_callback); |
| 37 | 38 |
| 38 void HideBubble(); | 39 void HideBubble(); |
| 39 void ReshowBubble(); | 40 void ReshowBubble(); |
| 40 | 41 |
| 41 // Returns true if Omnibox save credit card icon should be visible. | 42 // Returns true if Omnibox save credit card icon should be visible. |
| 42 bool IsIconVisible() const; | 43 bool IsIconVisible() const; |
| 43 | 44 |
| 44 // Returns nullptr if no bubble is currently shown. | 45 // Returns nullptr if no bubble is currently shown. |
| 45 SaveCardBubbleView* save_card_bubble_view() const; | 46 SaveCardBubbleView* save_card_bubble_view() const; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 bool is_reshow_; | 95 bool is_reshow_; |
| 95 | 96 |
| 96 // Contains the details of the card that will be saved if the user accepts. | 97 // Contains the details of the card that will be saved if the user accepts. |
| 97 CreditCard card_; | 98 CreditCard card_; |
| 98 | 99 |
| 99 // If no legal message should be shown then this variable is an empty vector. | 100 // If no legal message should be shown then this variable is an empty vector. |
| 100 LegalMessageLines legal_message_lines_; | 101 LegalMessageLines legal_message_lines_; |
| 101 | 102 |
| 102 // Used to measure the amount of time on a page; if it's less than some | 103 // Used to measure the amount of time on a page; if it's less than some |
| 103 // reasonable limit, then don't close the bubble upon navigation. | 104 // reasonable limit, then don't close the bubble upon navigation. |
| 104 scoped_ptr<base::ElapsedTimer> timer_; | 105 std::unique_ptr<base::ElapsedTimer> timer_; |
| 105 | 106 |
| 106 DISALLOW_COPY_AND_ASSIGN(SaveCardBubbleControllerImpl); | 107 DISALLOW_COPY_AND_ASSIGN(SaveCardBubbleControllerImpl); |
| 107 }; | 108 }; |
| 108 | 109 |
| 109 } // namespace autofill | 110 } // namespace autofill |
| 110 | 111 |
| 111 #endif // CHROME_BROWSER_UI_AUTOFILL_SAVE_CARD_BUBBLE_CONTROLLER_IMPL_H_ | 112 #endif // CHROME_BROWSER_UI_AUTOFILL_SAVE_CARD_BUBBLE_CONTROLLER_IMPL_H_ |
| OLD | NEW |