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