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