Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_CHROMEOS_ARC_OPTIN_ARC_TERMS_OF_SERVICE_NEGOTIATOR_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_ARC_OPTIN_ARC_TERMS_OF_SERVICE_NEGOTIATOR_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_ARC_OPTIN_ARC_TERMS_OF_SERVICE_NEGOTIATOR_H_ | 6 #define CHROME_BROWSER_CHROMEOS_ARC_OPTIN_ARC_TERMS_OF_SERVICE_NEGOTIATOR_H_ |
| 7 | 7 |
| 8 #include <memory> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/callback.h" | 8 #include "base/callback.h" |
| 12 #include "base/macros.h" | 9 #include "base/macros.h" |
| 13 #include "chrome/browser/chromeos/arc/arc_support_host.h" | |
| 14 #include "chrome/browser/chromeos/arc/optin/arc_optin_preference_handler_observe r.h" | |
| 15 | |
| 16 class PrefService; | |
| 17 | 10 |
| 18 namespace arc { | 11 namespace arc { |
| 19 | 12 |
| 20 class ArcOptInPreferenceHandler; | 13 // Interface to handle the Terms-of-service acceptance user action. |
| 14 class ArcTermsOfServiceNegotiator { | |
| 15 public: | |
| 16 ArcTermsOfServiceNegotiator(); | |
| 17 virtual ~ArcTermsOfServiceNegotiator(); | |
| 21 | 18 |
| 22 // Handles the Terms-of-service agreement user action. | 19 // Invokes the|callback| asynchronously with "|agreed| = true" if user accepts |
|
hidehiko
2016/12/19 15:49:44
Also, as you're here, could you s/agreed/accepted/
khmel
2016/12/19 17:48:10
Done.
| |
| 23 class ArcTermsOfServiceNegotiator : public ArcSupportHost::Observer, | 20 // ToS. If user explicitly rejects terms of service, invokes |callback| with |
| 24 public ArcOptInPreferenceHandlerObserver { | 21 // |agreed| = false. Deleting this instance cancels the operation, so |
| 25 public: | 22 // |callback| will never be invoked then. |
| 26 ArcTermsOfServiceNegotiator(PrefService* pref_service, | |
| 27 ArcSupportHost* support_host); | |
| 28 ~ArcTermsOfServiceNegotiator() override; | |
| 29 | |
| 30 // Shows "Terms of service" page on ARC support Chrome App. Invokes the | |
| 31 // |callback| asynchronously with "|agreed| = true" if user agrees it. | |
| 32 // Otherwise (e.g., user clicks "Cancel" or closes the window), invokes | |
| 33 // |callback| with |agreed| = false. | |
| 34 // Deleting this instance cancels the operation, so |callback| will never | |
| 35 // be invoked then. | |
| 36 using NegotiationCallback = base::Callback<void(bool accepted)>; | 23 using NegotiationCallback = base::Callback<void(bool accepted)>; |
| 37 void StartNegotiation(const NegotiationCallback& callback); | 24 void StartNegotiation(const NegotiationCallback& callback); |
| 38 | 25 |
| 26 protected: | |
| 27 // Performs implementation specific action on starting negotiation. | |
| 28 virtual void StartNegotiationImpl() = 0; | |
| 29 | |
| 30 // Reports result of negotiation via callback and then resets it. If | |
| 31 // |accepted| is true then this means terms of service were accepted. | |
| 32 void ReportResult(bool accepted); | |
| 33 | |
| 39 private: | 34 private: |
| 40 // ArcSupportHost::Observer: | |
| 41 void OnWindowClosed() override; | |
| 42 void OnTermsAgreed(bool is_metrics_enabled, | |
| 43 bool is_backup_and_restore_enabled, | |
| 44 bool is_location_service_enabled) override; | |
| 45 void OnAuthSucceeded(const std::string& auth_code) override; | |
| 46 void OnRetryClicked() override; | |
| 47 void OnSendFeedbackClicked() override; | |
| 48 | |
| 49 // ArcOptInPreferenceHandlerObserver: | |
| 50 void OnMetricsModeChanged(bool enabled, bool managed) override; | |
| 51 void OnBackupAndRestoreModeChanged(bool enabled, bool managed) override; | |
| 52 void OnLocationServicesModeChanged(bool enabled, bool managed) override; | |
| 53 | |
| 54 PrefService* const pref_service_; | |
| 55 // Owned by ArcSessionManager. | |
| 56 ArcSupportHost* const support_host_; | |
| 57 | |
| 58 NegotiationCallback pending_callback_; | 35 NegotiationCallback pending_callback_; |
| 59 std::unique_ptr<ArcOptInPreferenceHandler> preference_handler_; | |
| 60 | 36 |
| 61 DISALLOW_COPY_AND_ASSIGN(ArcTermsOfServiceNegotiator); | 37 DISALLOW_COPY_AND_ASSIGN(ArcTermsOfServiceNegotiator); |
| 62 }; | 38 }; |
| 63 | 39 |
| 64 } // namespace arc | 40 } // namespace arc |
| 65 | 41 |
| 66 #endif // CHROME_BROWSER_CHROMEOS_ARC_OPTIN_ARC_TERMS_OF_SERVICE_NEGOTIATOR_H_ | 42 #endif // CHROME_BROWSER_CHROMEOS_ARC_OPTIN_ARC_TERMS_OF_SERVICE_NEGOTIATOR_H_ |
| OLD | NEW |