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 DesktopIOSPromotionView* promotion_view, | |
31 desktop_ios_promotion::PromotionEntryPoint entry_point); | |
20 ~DesktopIOSPromotionController(); | 32 ~DesktopIOSPromotionController(); |
21 | 33 |
34 // Returns the current promotion entry point. | |
35 desktop_ios_promotion::PromotionEntryPoint entry_point() const { | |
36 return entry_point_; | |
37 } | |
38 | |
22 // Called by the view code when "Send SMS" button is clicked by the user. | 39 // Called by the view code when "Send SMS" button is clicked by the user. |
23 void OnSendSMSClicked(); | 40 void OnSendSMSClicked(); |
24 | 41 |
42 // Called by the view code when the promotion is ready to show. | |
43 void OnPromotionShown(); | |
44 | |
25 // Called by the view code when "No Thanks" button is clicked by the user. | 45 // Called by the view code when "No Thanks" button is clicked by the user. |
26 void OnNoThanksClicked(); | 46 void OnNoThanksClicked(); |
27 | 47 |
28 // (TODO): If needed verify that functions that affect the UI are done | 48 // Returns the Recovery phone number, returns empy string if the number is not |
29 // on the same thread. | 49 // set. |
50 std::string GetUsersRecoveryPhoneNumber(); | |
51 | |
52 private: | |
53 // Updates the user's recovery phone number once the sms_service phone query | |
54 // returns a response. | |
55 void OnGotPhoneNumber(SMSService::Request* request, | |
56 bool success, | |
57 const std::string& number); | |
58 | |
59 // Callback that logs the result when sms_service send sms returns a response. | |
60 void OnSendSMS(SMSService::Request* request, | |
61 bool success, | |
62 const std::string& number); | |
63 | |
64 PrefService* profile_prefs_; | |
65 const desktop_ios_promotion::PromotionEntryPoint entry_point_; | |
66 // Service used to send SMS to the user recovery phone number. | |
67 SMSService* sms_service_; | |
68 // User's recovery phone number, this is updated by the sms_service. | |
69 std::string recovery_number_; | |
70 // A Weak pointer to the promotion view. | |
71 DesktopIOSPromotionView* promotion_view_ = nullptr; | |
sky
2017/02/18 18:03:51
Now that you set this in the initializer list it i
mrefaat
2017/02/18 19:12:00
Done.
| |
72 // Track the action that is responsible for the promotion Dismissal. | |
73 desktop_ios_promotion::PromotionDismissalReason dismissal_reason_; | |
74 | |
75 base::WeakPtrFactory<DesktopIOSPromotionController> weak_ptr_factory_; | |
30 | 76 |
31 DISALLOW_COPY_AND_ASSIGN(DesktopIOSPromotionController); | 77 DISALLOW_COPY_AND_ASSIGN(DesktopIOSPromotionController); |
32 }; | 78 }; |
33 | 79 |
34 #endif // CHROME_BROWSER_UI_DESKTOP_IOS_PROMOTION_DESKTOP_IOS_PROMOTION_CONTROL LER_H_ | 80 #endif // CHROME_BROWSER_UI_DESKTOP_IOS_PROMOTION_DESKTOP_IOS_PROMOTION_CONTROL LER_H_ |
OLD | NEW |