OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_DESKTOP_IOS_PROMOTION_DESKTOP_IOS_PROMOTION_CONTROLLER
_H_ | 5 #ifndef CHROME_BROWSER_UI_DESKTOP_IOS_PROMOTION_DESKTOP_IOS_PROMOTION_CONTROLLER
_H_ |
6 #define CHROME_BROWSER_UI_DESKTOP_IOS_PROMOTION_DESKTOP_IOS_PROMOTION_CONTROLLER
_H_ | 6 #define CHROME_BROWSER_UI_DESKTOP_IOS_PROMOTION_DESKTOP_IOS_PROMOTION_CONTROLLER
_H_ |
7 | 7 |
| 8 #include <memory> |
| 9 #include <string> |
| 10 |
8 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "chrome/browser/ui/desktop_ios_promotion/sms_service.h" |
9 | 13 |
10 namespace desktop_ios_promotion { | 14 namespace desktop_ios_promotion { |
11 enum class PromotionEntryPoint; | 15 enum class PromotionEntryPoint; |
| 16 enum class PromotionDismissalReason; |
12 } | 17 } |
13 | 18 |
| 19 class DesktopIOSPromotionView; |
| 20 class Profile; |
| 21 class PrefService; |
| 22 |
14 // This class provides data to the Desktop to mobile promotion and control the | 23 // This class provides data to the Desktop to mobile promotion and control the |
15 // promotion actions. | 24 // promotion actions. |
16 class DesktopIOSPromotionController { | 25 class DesktopIOSPromotionController { |
17 public: | 26 public: |
18 // Should be instantiated on the UI thread. | 27 // Must be instantiated on the UI thread. |
19 DesktopIOSPromotionController(); | 28 DesktopIOSPromotionController( |
| 29 Profile* profile, |
| 30 desktop_ios_promotion::PromotionEntryPoint entry_point); |
20 ~DesktopIOSPromotionController(); | 31 ~DesktopIOSPromotionController(); |
21 | 32 |
| 33 // Returns the current promotion entry point. |
| 34 desktop_ios_promotion::PromotionEntryPoint entry_point() const { |
| 35 return entry_point_; |
| 36 } |
| 37 |
| 38 // Called by the promotion view. |
| 39 void SetPromotionView(DesktopIOSPromotionView* promotion_view); |
| 40 |
22 // Called by the view code when "Send SMS" button is clicked by the user. | 41 // Called by the view code when "Send SMS" button is clicked by the user. |
23 void OnSendSMSClicked(); | 42 void OnSendSMSClicked(); |
24 | 43 |
| 44 // Called by the view code when the promotion is ready to show. |
| 45 void OnPromotionShown(); |
| 46 |
25 // Called by the view code when "No Thanks" button is clicked by the user. | 47 // Called by the view code when "No Thanks" button is clicked by the user. |
26 void OnNoThanksClicked(); | 48 void OnNoThanksClicked(); |
27 | 49 |
28 // (TODO): If needed verify that functions that affect the UI are done | 50 // Returns the Recovery phone number, returns empy string if the number is not |
29 // on the same thread. | 51 // set. |
| 52 std::string GetUsersRecoveryPhoneNumber(); |
| 53 |
| 54 private: |
| 55 // Updates the user's recovery phone number once the sms_service phone query |
| 56 // returns a response. |
| 57 void OnGotPhoneNumber(SMSService::Request* request, |
| 58 bool success, |
| 59 const std::string& number); |
| 60 |
| 61 // Callback that logs the result when sms_service send sms returns a response. |
| 62 void OnSendSMS(SMSService::Request* request, |
| 63 bool success, |
| 64 const std::string& number); |
| 65 |
| 66 PrefService* profile_prefs_; |
| 67 const desktop_ios_promotion::PromotionEntryPoint entry_point_; |
| 68 // Service used to send SMS to the user recovery phone number. |
| 69 SMSService* sms_service_; |
| 70 // User's recovery phone number, this is updated by the sms_service. |
| 71 std::string recovery_number_; |
| 72 // A Weak pointer to the promotion view. |
| 73 DesktopIOSPromotionView* promotion_view_ = nullptr; |
| 74 // Track the action that is responsible for the promotion Dismissal. |
| 75 desktop_ios_promotion::PromotionDismissalReason dismissal_reason_; |
| 76 |
| 77 base::WeakPtrFactory<DesktopIOSPromotionController> weak_ptr_factory_; |
30 | 78 |
31 DISALLOW_COPY_AND_ASSIGN(DesktopIOSPromotionController); | 79 DISALLOW_COPY_AND_ASSIGN(DesktopIOSPromotionController); |
32 }; | 80 }; |
33 | 81 |
34 #endif // CHROME_BROWSER_UI_DESKTOP_IOS_PROMOTION_DESKTOP_IOS_PROMOTION_CONTROL
LER_H_ | 82 #endif // CHROME_BROWSER_UI_DESKTOP_IOS_PROMOTION_DESKTOP_IOS_PROMOTION_CONTROL
LER_H_ |
OLD | NEW |