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_ARC_SUPPORT_HOST_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_ARC_ARC_SUPPORT_HOST_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_ARC_ARC_SUPPORT_HOST_H_ | 6 #define CHROME_BROWSER_CHROMEOS_ARC_ARC_SUPPORT_HOST_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 NETWORK_UNAVAILABLE_ERROR, | 37 NETWORK_UNAVAILABLE_ERROR, |
| 38 SERVER_COMMUNICATION_ERROR, | 38 SERVER_COMMUNICATION_ERROR, |
| 39 SIGN_IN_BAD_AUTHENTICATION_ERROR, | 39 SIGN_IN_BAD_AUTHENTICATION_ERROR, |
| 40 SIGN_IN_CLOUD_PROVISION_FLOW_FAIL_ERROR, | 40 SIGN_IN_CLOUD_PROVISION_FLOW_FAIL_ERROR, |
| 41 SIGN_IN_GMS_NOT_AVAILABLE_ERROR, | 41 SIGN_IN_GMS_NOT_AVAILABLE_ERROR, |
| 42 SIGN_IN_NETWORK_ERROR, | 42 SIGN_IN_NETWORK_ERROR, |
| 43 SIGN_IN_SERVICE_UNAVAILABLE_ERROR, | 43 SIGN_IN_SERVICE_UNAVAILABLE_ERROR, |
| 44 SIGN_IN_UNKNOWN_ERROR, | 44 SIGN_IN_UNKNOWN_ERROR, |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 // Observer to notify UI event. | 47 // Delegate to handle manual authentication related events. |
| 48 class Observer { | 48 class AuthDelegate { |
| 49 public: | 49 public: |
| 50 virtual ~Observer() = default; | 50 // Called when LSO auth token fetch is successfully completed. |
| 51 virtual void OnAuthSucceeded(const std::string& auth_code) = 0; | |
| 51 | 52 |
| 52 // Called when the ARC support window is closed. | 53 // Called when LSO auth token fetch has failed. |
| 53 virtual void OnWindowClosed() {} | 54 virtual void OnAuthFailed() = 0; |
| 54 | 55 |
| 55 // Called when the user press AGREE button on ToS page. | 56 // Called when "RETRY" button on the error page is clicked during |
| 57 // authentication. | |
| 58 virtual void OnAuthRetryClicked() = 0; | |
| 59 | |
| 60 protected: | |
| 61 virtual ~AuthDelegate() = default; | |
| 62 }; | |
| 63 | |
| 64 // Delegate to handle manual authentication related events. | |
| 65 class TermsOfServiceDelegate { | |
| 66 public: | |
| 67 // Called when the user press AGREE button on terms of service page. | |
| 56 virtual void OnTermsAgreed(bool is_metrics_enabled, | 68 virtual void OnTermsAgreed(bool is_metrics_enabled, |
| 57 bool is_backup_and_restore_enabled, | 69 bool is_backup_and_restore_enabled, |
| 58 bool is_location_service_enabled) {} | 70 bool is_location_service_enabled) = 0; |
| 59 | 71 |
| 60 // Called when LSO auth token fetch is successfully completed. | 72 // Called when the user rejects the terms of service or close the page. |
|
khmel
2017/06/02 17:02:40
nit: closes
victorhsieh0
2017/06/06 18:27:09
Done.
| |
| 61 virtual void OnAuthSucceeded(const std::string& auth_code) {} | 73 virtual void OnTermsRejected() = 0; |
| 62 | 74 |
| 63 // Called when LSO auth token fetch has failed. | 75 // Called when "RETRY" button on the error page is clicked during terms of |
| 64 virtual void OnAuthFailed() {} | 76 // service negotiation. |
| 77 virtual void OnTermsRetryClicked() = 0; | |
| 65 | 78 |
| 66 // Called when "RETRY" button on the error page is clicked. | 79 protected: |
| 67 virtual void OnRetryClicked() {} | 80 virtual ~TermsOfServiceDelegate() = default; |
| 81 }; | |
| 82 | |
| 83 // Delegate to handle general error events. Note that some of the callback | |
|
khmel
2017/06/02 17:02:41
nit: extra space
victorhsieh0
2017/06/06 18:27:09
Done.
| |
| 84 // will only be called when more the specific callback in the other delegate | |
| 85 // is not appropriate. | |
| 86 class ErrorDelegate { | |
| 87 public: | |
| 88 // Called when the window is closed but only when terms of service | |
| 89 // negotiation is not ongoing, in which case OnTermsRejected will be called. | |
| 90 virtual void OnWindowClosed() = 0; | |
| 91 | |
| 92 // Called when "RETRY" button on the error page is clicked, except when | |
| 93 // terms of service negotiation or manual authentication is onging. In those | |
| 94 // cases, the more specific retry function in the other delegates is called. | |
| 95 virtual void OnRetryClicked() = 0; | |
| 68 | 96 |
| 69 // Called when send feedback button on error page is clicked. | 97 // Called when send feedback button on error page is clicked. |
| 70 virtual void OnSendFeedbackClicked() {} | 98 virtual void OnSendFeedbackClicked() = 0; |
| 99 | |
| 100 protected: | |
| 101 virtual ~ErrorDelegate() = default; | |
| 71 }; | 102 }; |
| 72 | 103 |
| 73 static const char kStorageId[]; | 104 static const char kStorageId[]; |
| 74 | 105 |
| 75 using RequestOpenAppCallback = base::Callback<void(Profile* profile)>; | 106 using RequestOpenAppCallback = base::Callback<void(Profile* profile)>; |
| 76 | 107 |
| 77 explicit ArcSupportHost(Profile* profile); | 108 explicit ArcSupportHost(Profile* profile); |
| 78 ~ArcSupportHost() override; | 109 ~ArcSupportHost() override; |
| 79 | 110 |
| 80 void AddObserver(Observer* observer); | 111 void AddObserver(Observer* observer); |
| 81 void RemoveObserver(Observer* observer); | 112 void RemoveObserver(Observer* observer); |
| 82 bool HasObserver(Observer* observer); | 113 bool HasObserver(Observer* observer); |
| 83 | 114 |
| 115 void SetAuthDelegate(AuthDelegate* delegate); | |
| 116 void SetTermsOfServiceDelegate(TermsOfServiceDelegate* delegate); | |
| 117 void SetErrorDelegate(ErrorDelegate* delegate); | |
| 118 | |
| 119 bool HasAuthDelegate() const { return auth_delegate_ != nullptr; } | |
| 120 | |
| 84 // Called when the communication to arc_support Chrome App is ready. | 121 // Called when the communication to arc_support Chrome App is ready. |
| 85 void SetMessageHost(arc::ArcSupportMessageHost* message_host); | 122 void SetMessageHost(arc::ArcSupportMessageHost* message_host); |
| 86 | 123 |
| 87 // Called when the communication to arc_support Chrome App is closed. | 124 // Called when the communication to arc_support Chrome App is closed. |
| 88 // The argument message_host is used to check if the given |message_host| | 125 // The argument message_host is used to check if the given |message_host| |
| 89 // is what this instance uses know, to avoid racy case. | 126 // is what this instance uses know, to avoid racy case. |
| 90 // If |message_host| is different from the one this instance knows, | 127 // If |message_host| is different from the one this instance knows, |
| 91 // this is no op. | 128 // this is no op. |
| 92 void UnsetMessageHost(arc::ArcSupportMessageHost* message_host); | 129 void UnsetMessageHost(arc::ArcSupportMessageHost* message_host); |
| 93 | 130 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 // } | 195 // } |
| 159 void SendPreferenceCheckboxUpdate(const std::string& action_name, | 196 void SendPreferenceCheckboxUpdate(const std::string& action_name, |
| 160 const PreferenceCheckboxData& data); | 197 const PreferenceCheckboxData& data); |
| 161 | 198 |
| 162 void DisconnectMessageHost(); | 199 void DisconnectMessageHost(); |
| 163 | 200 |
| 164 Profile* const profile_; | 201 Profile* const profile_; |
| 165 RequestOpenAppCallback request_open_app_callback_; | 202 RequestOpenAppCallback request_open_app_callback_; |
| 166 | 203 |
| 167 base::ObserverList<Observer> observer_list_; | 204 base::ObserverList<Observer> observer_list_; |
| 205 AuthDelegate* auth_delegate_ = nullptr; // not owned | |
| 206 TermsOfServiceDelegate* tos_delegate_ = nullptr; // not owned | |
| 207 ErrorDelegate* error_delegate_ = nullptr; // not owned | |
| 168 | 208 |
| 169 // True, if ARC support app is requested to start, but the connection is not | 209 // True, if ARC support app is requested to start, but the connection is not |
| 170 // yet established. Reset to false, when the app is started and the | 210 // yet established. Reset to false, when the app is started and the |
| 171 // connection to the app is established. | 211 // connection to the app is established. |
| 172 bool app_start_pending_ = false; | 212 bool app_start_pending_ = false; |
| 173 | 213 |
| 174 // The instance is created and managed by Chrome. | 214 // The instance is created and managed by Chrome. |
| 175 arc::ArcSupportMessageHost* message_host_ = nullptr; | 215 arc::ArcSupportMessageHost* message_host_ = nullptr; |
| 176 | 216 |
| 177 // The lifetime of the message_host_ is out of control from ARC. | 217 // The lifetime of the message_host_ is out of control from ARC. |
| 178 // Fields below are UI parameter cache in case the value is set before | 218 // Fields below are UI parameter cache in case the value is set before |
| 179 // connection to the ARC support Chrome app is established. | 219 // connection to the ARC support Chrome app is established. |
| 180 UIPage ui_page_ = UIPage::NO_PAGE; | 220 UIPage ui_page_ = UIPage::NO_PAGE; |
| 181 | 221 |
| 182 // These have valid values iff ui_page_ == ERROR. | 222 // These have valid values iff ui_page_ == ERROR. |
| 183 Error error_; | 223 Error error_; |
| 184 bool should_show_send_feedback_; | 224 bool should_show_send_feedback_; |
| 185 | 225 |
| 186 bool is_arc_managed_ = false; | 226 bool is_arc_managed_ = false; |
| 187 | 227 |
| 188 PreferenceCheckboxData metrics_checkbox_; | 228 PreferenceCheckboxData metrics_checkbox_; |
| 189 PreferenceCheckboxData backup_and_restore_checkbox_; | 229 PreferenceCheckboxData backup_and_restore_checkbox_; |
| 190 PreferenceCheckboxData location_services_checkbox_; | 230 PreferenceCheckboxData location_services_checkbox_; |
| 191 | 231 |
| 192 DISALLOW_COPY_AND_ASSIGN(ArcSupportHost); | 232 DISALLOW_COPY_AND_ASSIGN(ArcSupportHost); |
| 193 }; | 233 }; |
| 194 | 234 |
| 195 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_SUPPORT_HOST_H_ | 235 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_SUPPORT_HOST_H_ |
| OLD | NEW |