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