Chromium Code Reviews| 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 void SetPromotionView(DesktopIOSPromotion* promotion); | |
|
sky
2017/02/17 00:57:22
I find it confusing that this function is called S
sky
2017/02/17 00:57:23
Document ownership. Can you pass the view into the
mrefaat
2017/02/17 04:31:49
Acknowledged.
mrefaat
2017/02/17 04:31:49
It's not possible as the controller is created bef
mrefaat
2017/02/17 04:31:49
I added weak pointer comment on the header file, b
mrefaat
2017/02/17 04:31:49
Acknowledged.
| |
| 36 | |
| 22 // Called by the view code when "Send SMS" button is clicked by the user. | 37 // Called by the view code when "Send SMS" button is clicked by the user. |
| 23 void OnSendSMSClicked(); | 38 void OnSendSMSClicked(); |
| 24 | 39 |
| 40 // Called by the view code when the promotion is ready to show. | |
| 41 void OnPromotionShown(); | |
| 42 | |
| 25 // Called by the view code when "No Thanks" button is clicked by the user. | 43 // Called by the view code when "No Thanks" button is clicked by the user. |
| 26 void OnNoThanksClicked(); | 44 void OnNoThanksClicked(); |
| 27 | 45 |
| 28 // (TODO): If needed verify that functions that affect the UI are done | 46 // Returns the Recovery phone number, returns empy string if the number is not |
| 29 // on the same thread. | 47 // set. |
| 48 std::string GetUsersRecoveryPhoneNumber(); | |
| 49 | |
| 50 private: | |
| 51 // Updates the user's recovery phone number once the sms_service phone query | |
| 52 // returns a response. | |
| 53 void OnQueryPhoneNumber(SMSService::Request* request, | |
|
sky
2017/02/17 00:57:22
optional: name this OnGotPhoneNumber to indicate w
mrefaat
2017/02/17 04:31:49
Done.
| |
| 54 bool success, | |
| 55 const std::string& number); | |
| 56 | |
| 57 // Callback that logs the result when sms_service send sms returns a response. | |
| 58 void OnSendSMS(SMSService::Request* request, | |
| 59 bool success, | |
| 60 const std::string& number); | |
| 61 | |
| 62 PrefService* profile_prefs_; | |
| 63 const desktop_ios_promotion::PromotionEntryPoint entry_point_; | |
| 64 // Service used to send SMS to the user recovery phone number. | |
| 65 SMSService* sms_service_; | |
| 66 // User's recovery phone number, This is updated by the sms_service. | |
|
sky
2017/02/17 00:57:22
'This' -> 'this'
mrefaat
2017/02/17 04:31:49
Done.
| |
| 67 std::string recovery_number_; | |
| 68 base::WeakPtrFactory<DesktopIOSPromotionController> weak_ptr_factory_; | |
|
sky
2017/02/17 00:57:23
WeakPtrFactory should be your last member.
mrefaat
2017/02/17 04:31:49
Done.
| |
| 69 DesktopIOSPromotion* promotion_view_; | |
|
sky
2017/02/17 00:57:23
You don't initialize this in the initializer list.
mrefaat
2017/02/17 04:31:49
Acknowledged.
| |
| 30 | 70 |
| 31 DISALLOW_COPY_AND_ASSIGN(DesktopIOSPromotionController); | 71 DISALLOW_COPY_AND_ASSIGN(DesktopIOSPromotionController); |
| 32 }; | 72 }; |
| 33 | 73 |
| 34 #endif // CHROME_BROWSER_UI_DESKTOP_IOS_PROMOTION_DESKTOP_IOS_PROMOTION_CONTROL LER_H_ | 74 #endif // CHROME_BROWSER_UI_DESKTOP_IOS_PROMOTION_DESKTOP_IOS_PROMOTION_CONTROL LER_H_ |
| OLD | NEW |