Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1331)

Unified Diff: chrome/browser/chromeos/arc/arc_support_host.h

Issue 2844383006: Turn ArcSupportHost from Observer model to Delegate (Closed)
Patch Set: git cl try Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 e3abd08eedcfb9c373c621dfd65156c953b0db3a..ba35b25f1733075a04f212f175e37f6ca988dc45 100644
--- a/chrome/browser/chromeos/arc/arc_support_host.h
+++ b/chrome/browser/chromeos/arc/arc_support_host.h
@@ -44,30 +44,58 @@ class ArcSupportHost : public arc::ArcSupportMessageHost::Observer,
SIGN_IN_UNKNOWN_ERROR,
};
- // Observer to notify UI event.
- class Observer {
+ // Delegate to handle manual authentication related events.
+ class AuthDelegate {
public:
- virtual ~Observer() = default;
+ virtual ~AuthDelegate() = default;
Luis Héctor Chávez 2017/05/30 16:06:27 nit: make the dtors protected (per the ARC chromiu
victorhsieh0 2017/05/30 19:52:42 Done.
- // 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 OnAuthRetryClicked() = 0;
+ };
+
+ // Delegate to handle manual authentication related events.
+ 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 OnTermsRetryClicked() = 0;
+ };
+
+ // Delegate to handle general error events. Note that some of the callback
+ // will only be called when more the specific callback in the other delegate
+ // is not appropriate.
+ class ErrorDelegate {
+ public:
+ virtual ~ErrorDelegate() = default;
- // Called when "RETRY" button on the error page is clicked.
- virtual void OnRetryClicked() {}
+ // Called when the window is closed but only after terms accepted. If the
+ // terms are rejected in the first place, OnTermsRejected will be called.
+ virtual void OnWindowClosedTermsAccepted() = 0;
+
+ // 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() = 0;
// Called when send feedback button on error page is clicked.
- virtual void OnSendFeedbackClicked() {}
+ virtual void OnSendFeedbackClicked() = 0;
};
static const char kStorageId[];
@@ -81,6 +109,12 @@ 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);
+
+ bool HasAuthDelegateForTest() { return auth_delegate_ != nullptr; }
Luis Héctor Chávez 2017/05/30 16:06:27 nit: you can make this const
victorhsieh0 2017/05/30 19:52:42 Done.
+
// Called when the communication to arc_support Chrome App is ready.
void SetMessageHost(arc::ArcSupportMessageHost* message_host);
@@ -165,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

Powered by Google App Engine
This is Rietveld 408576698