Chromium Code Reviews| Index: chrome/browser/chromeos/arc/arc_support_host.h |
| diff --git a/chrome/browser/chromeos/arc/arc_support_host.h b/chrome/browser/chromeos/arc/arc_support_host.h |
| index c645e59073561f2a658f440d7f8590944b432354..870ad9187e5d4728309c5c41904c8503791a59ce 100644 |
| --- a/chrome/browser/chromeos/arc/arc_support_host.h |
| +++ b/chrome/browser/chromeos/arc/arc_support_host.h |
| @@ -44,26 +44,55 @@ class ArcSupportHost : public arc::ArcSupportMessageHost::Observer, |
| SIGN_IN_UNKNOWN_ERROR, |
| }; |
| - // Observer to notify UI event. |
| - class Observer { |
| + // Delegate to handle manual authentication related events. The life cycle of |
|
Luis Héctor Chávez
2017/05/12 15:41:30
All the "The life cycle of the instance..." commen
victorhsieh0
2017/05/12 18:31:55
Removed, but add extra comment in the relevant cod
|
| + // the instance is as short as the manual authentication process. |
| + class AuthDelegate { |
| public: |
| - virtual ~Observer() = default; |
| + virtual ~AuthDelegate() = default; |
| - // Called when the ARC support window is closed. |
| - virtual void OnWindowClosed() {} |
| + // Called when LSO auth token fetch is successfully completed. |
| + virtual void OnAuthSucceeded(const std::string& auth_code) = 0; |
| + |
| + // Called when LSO auth token fetch has failed. |
| + virtual void OnAuthFailed() = 0; |
| + |
| + // Called when "RETRY" button on the error page is clicked during |
| + // authentication. |
| + virtual void OnAuthRetry() = 0; |
| + }; |
| + |
| + // Delegate to handle manual authentication related events. The life cycle of |
| + // the instance is as short as the terms of service negotiation. |
| + class TermsOfServiceDelegate { |
| + public: |
| + virtual ~TermsOfServiceDelegate() = default; |
| - // Called when the user press AGREE button on ToS page. |
| + // Called when the user press AGREE button on terms of service page. |
| virtual void OnTermsAgreed(bool is_metrics_enabled, |
| bool is_backup_and_restore_enabled, |
| - bool is_location_service_enabled) {} |
| + bool is_location_service_enabled) = 0; |
| - // Called when LSO auth token fetch is successfully completed. |
| - virtual void OnAuthSucceeded(const std::string& auth_code) {} |
| + // Called when the user rejects the terms of service or close the page. |
| + virtual void OnTermsRejected() = 0; |
| - // Called when LSO auth token fetch has failed. |
| - virtual void OnAuthFailed() {} |
| + // Called when "RETRY" button on the error page is clicked during terms of |
| + // service negotiation. |
| + virtual void OnTermsRetry() = 0; |
|
Luis Héctor Chávez
2017/05/12 15:41:31
OnTermsRetried? OnTermsRetryClicked? to be consist
victorhsieh0
2017/05/12 18:31:55
Done.
|
| + }; |
| - // Called when "RETRY" button on the error page is clicked. |
| + class ErrorDelegate { |
|
Luis Héctor Chávez
2017/05/12 15:41:31
Comment? At least mention that this is the "fallba
victorhsieh0
2017/05/12 18:31:55
Done.
|
| + public: |
| + virtual ~ErrorDelegate() = default; |
| + |
| + // Called when the opt-in process is aborted. This currently happens when |
| + // the ARC support window is closed (except when when the terms of service |
| + // negotiation is ongoing, the most specific function in |
| + // TermsOfServiceDelegate is called). |
| + virtual void OnOptInAborted() {} |
|
Luis Héctor Chávez
2017/05/12 15:41:31
Any reason why this Delegate has implementations,
victorhsieh0
2017/05/12 18:31:55
Done.
|
| + |
| + // Called when "RETRY" button on the error page is clicked, except when |
| + // terms of service negotiation or manual authentication is onging. In those |
| + // cases, the more specific retry function in the other delegates is called. |
| virtual void OnRetryClicked() {} |
| // Called when send feedback button on error page is clicked. |
| @@ -82,6 +111,10 @@ class ArcSupportHost : public arc::ArcSupportMessageHost::Observer, |
| void RemoveObserver(Observer* observer); |
| bool HasObserver(Observer* observer); |
| + void SetAuthDelegate(AuthDelegate* delegate); |
| + void SetTermsOfServiceDelegate(TermsOfServiceDelegate* delegate); |
| + void SetErrorDelegate(ErrorDelegate* delegate); |
| + |
| // Called when the communication to arc_support Chrome App is ready. |
| void SetMessageHost(arc::ArcSupportMessageHost* message_host); |
| @@ -166,6 +199,9 @@ class ArcSupportHost : public arc::ArcSupportMessageHost::Observer, |
| RequestOpenAppCallback request_open_app_callback_; |
| base::ObserverList<Observer> observer_list_; |
| + AuthDelegate* auth_delegate_ = nullptr; // not owned |
| + TermsOfServiceDelegate* tos_delegate_ = nullptr; // not owned |
| + ErrorDelegate* error_delegate_ = nullptr; // not owned |
| // True, if ARC support app is requested to start, but the connection is not |
| // yet established. Reset to false, when the app is started and the |