| 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> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/timer/elapsed_timer.h" | 11 #include "base/timer/elapsed_timer.h" |
| 12 #include "components/autofill/core/browser/credit_card.h" | 12 #include "components/autofill/core/browser/credit_card.h" |
| 13 #include "components/autofill/core/browser/ui/save_card_bubble_controller.h" | 13 #include "components/autofill/core/browser/ui/save_card_bubble_controller.h" |
| 14 #include "content/public/browser/web_contents_observer.h" | 14 #include "content/public/browser/web_contents_observer.h" |
| 15 #include "content/public/browser/web_contents_user_data.h" | 15 #include "content/public/browser/web_contents_user_data.h" |
| 16 | 16 |
| 17 class PrefService; |
| 18 |
| 17 namespace autofill { | 19 namespace autofill { |
| 18 | 20 |
| 19 // Implementation of per-tab class to control the save credit card bubble and | 21 // Implementation of per-tab class to control the save credit card bubble and |
| 20 // Omnibox icon. | 22 // Omnibox icon. |
| 21 class SaveCardBubbleControllerImpl | 23 class SaveCardBubbleControllerImpl |
| 22 : public SaveCardBubbleController, | 24 : public SaveCardBubbleController, |
| 23 public content::WebContentsObserver, | 25 public content::WebContentsObserver, |
| 24 public content::WebContentsUserData<SaveCardBubbleControllerImpl> { | 26 public content::WebContentsUserData<SaveCardBubbleControllerImpl> { |
| 25 public: | 27 public: |
| 26 // Sets up the controller for local save and shows the bubble. | 28 // Sets up the controller for local save and shows the bubble. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 void ShowBubble(); | 88 void ShowBubble(); |
| 87 | 89 |
| 88 // Update the visibility and toggled state of the Omnibox save card icon. | 90 // Update the visibility and toggled state of the Omnibox save card icon. |
| 89 void UpdateIcon(); | 91 void UpdateIcon(); |
| 90 | 92 |
| 91 void OpenUrl(const GURL& url); | 93 void OpenUrl(const GURL& url); |
| 92 | 94 |
| 93 // Weak reference. Will be nullptr if no bubble is currently shown. | 95 // Weak reference. Will be nullptr if no bubble is currently shown. |
| 94 SaveCardBubbleView* save_card_bubble_view_; | 96 SaveCardBubbleView* save_card_bubble_view_; |
| 95 | 97 |
| 98 // Weak reference to read & write |kAutofillAcceptSaveCreditCardPromptState|. |
| 99 PrefService* pref_service_; |
| 100 |
| 96 // Callback to run if user presses Save button in the bubble. | 101 // Callback to run if user presses Save button in the bubble. |
| 97 // If save_card_callback_.is_null() is true then no bubble is available to | 102 // If save_card_callback_.is_null() is true then no bubble is available to |
| 98 // show and the icon is not visible. | 103 // show and the icon is not visible. |
| 99 base::Closure save_card_callback_; | 104 base::Closure save_card_callback_; |
| 100 | 105 |
| 101 // Governs whether the upload or local save version of the UI should be shown. | 106 // Governs whether the upload or local save version of the UI should be shown. |
| 102 bool is_uploading_{false}; | 107 bool is_uploading_{false}; |
| 103 | 108 |
| 104 // Whether ReshowBubble() has been called since ShowBubbleFor*() was called. | 109 // Whether ReshowBubble() has been called since ShowBubbleFor*() was called. |
| 105 bool is_reshow_{false}; | 110 bool is_reshow_{false}; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 119 // Used to measure the amount of time on a page; if it's less than some | 124 // Used to measure the amount of time on a page; if it's less than some |
| 120 // reasonable limit, then don't close the bubble upon navigation. | 125 // reasonable limit, then don't close the bubble upon navigation. |
| 121 std::unique_ptr<base::ElapsedTimer> timer_; | 126 std::unique_ptr<base::ElapsedTimer> timer_; |
| 122 | 127 |
| 123 DISALLOW_COPY_AND_ASSIGN(SaveCardBubbleControllerImpl); | 128 DISALLOW_COPY_AND_ASSIGN(SaveCardBubbleControllerImpl); |
| 124 }; | 129 }; |
| 125 | 130 |
| 126 } // namespace autofill | 131 } // namespace autofill |
| 127 | 132 |
| 128 #endif // CHROME_BROWSER_UI_AUTOFILL_SAVE_CARD_BUBBLE_CONTROLLER_IMPL_H_ | 133 #endif // CHROME_BROWSER_UI_AUTOFILL_SAVE_CARD_BUBBLE_CONTROLLER_IMPL_H_ |
| OLD | NEW |