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 72860cb33e5de5509fac0c3fa9f7645018068bf8..15702eddce6734e3ac3d9dffe21c54e353f7e974 100644 |
| --- a/chrome/browser/chromeos/arc/arc_support_host.h |
| +++ b/chrome/browser/chromeos/arc/arc_support_host.h |
| @@ -8,32 +8,58 @@ |
| #include <memory> |
| #include "base/macros.h" |
| -#include "chrome/browser/chromeos/arc/arc_auth_service.h" |
| #include "chrome/browser/chromeos/arc/extensions/arc_support_message_host.h" |
| -#include "chrome/browser/chromeos/arc/optin/arc_optin_preference_handler_observer.h" |
| #include "extensions/browser/api/messaging/native_message_host.h" |
| #include "ui/display/display_observer.h" |
| -namespace arc { |
| -class ArcOptInPreferenceHandler; |
| -} |
| - |
| // Native interface to control ARC support chrome App. |
| // TODO(hidehiko): Move more implementation for the UI control from |
| -// ArcAuthService to this class and remove |
| -// arc::ArcOptInPreferenceHandlerObserver inheritance. |
| +// ArcAuthService to this class. |
| // TODO(hidehiko,lhchavez): Move this into extensions/ directory, and put it |
| // into "arc" namespace. Add unittests at the time. |
| class ArcSupportHost : public arc::ArcSupportMessageHost::Observer, |
| - public arc::ArcOptInPreferenceHandlerObserver, |
| public display::DisplayObserver { |
| public: |
| + enum class UIPage { |
| + NO_PAGE, // Hide everything. |
| + TERMS, // Terms content page. |
| + LSO_PROGRESS, // LSO loading progress page. |
| + LSO, // LSO page to enter user's credentials. |
| + START_PROGRESS, // Arc starting progress page. |
| + ERROR, // Arc start error page. |
| + ERROR_WITH_FEEDBACK, // Arc start error page, plus feedback button. |
| + }; |
| + |
| + // Observer to notify UI event. |
| + class Observer { |
| + public: |
| + virtual ~Observer() = default; |
| + |
| + // Called when the ARC support window is closed. |
| + virtual void OnWindowClosed() = 0; |
| + |
| + // Called when the user press AGREE button on ToS page. |
| + // TODO(hidehiko): Currently, due to implementation reason, |
| + // this is also called when RETRY on error page is clicked. Fix this. |
| + virtual void OnTermsAgreed(bool is_metrics_enabled, |
| + bool is_backup_and_restore_enabled, |
| + bool is_location_service_enabled) = 0; |
| + |
| + // Called when LSO auth token fetch is successfully completed. |
| + virtual void OnAuthSucceeded(const std::string& auth_code) = 0; |
| + |
| + // Called when send feedback button on error page is clicked. |
| + virtual void OnSendFeedbackClicked() = 0; |
| + }; |
| + |
| static const char kHostAppId[]; |
| static const char kStorageId[]; |
| ArcSupportHost(); |
| ~ArcSupportHost() override; |
| + void set_observer(Observer* observer) { observer_ = observer; } |
|
Luis Héctor Chávez
2016/11/04 17:55:15
If the plan is to support multiple observers, I'd
hidehiko
2016/11/04 22:19:51
Done.
|
| + |
| // Called when the communication to arc_support Chrome App is ready. |
| void SetMessageHost(arc::ArcSupportMessageHost* message_host); |
| @@ -46,7 +72,11 @@ class ArcSupportHost : public arc::ArcSupportMessageHost::Observer, |
| // Requests to close the extension window. |
| void Close(); |
| - void ShowPage(arc::ArcAuthService::UIPage page, const base::string16& status); |
| + void ShowPage(UIPage page, const base::string16& status); |
| + |
| + void SetMetricsPreferenceCheckbox(bool is_enabled, bool is_managed); |
| + void SetBackupAndRestorePreferenceCheckbox(bool is_enabled, bool is_managed); |
| + void SetLocationServicesPreferenceCheckbox(bool is_enabled, bool is_managed); |
| // arc::ArcSupportMessageHost::Observer override: |
| void OnMessage(const base::DictionaryValue& message) override; |
| @@ -57,12 +87,16 @@ class ArcSupportHost : public arc::ArcSupportMessageHost::Observer, |
| void OnDisplayMetricsChanged(const display::Display& display, |
| uint32_t changed_metrics) override; |
| - // arc::ArcOptInPreferenceHandlerObserver: |
| - void OnMetricsModeChanged(bool enabled, bool managed) override; |
| - void OnBackupAndRestoreModeChanged(bool enabled, bool managed) override; |
| - void OnLocationServicesModeChanged(bool enabled, bool managed) override; |
| - |
| private: |
| + struct PreferenceCheckboxData { |
| + PreferenceCheckboxData() : PreferenceCheckboxData(false, false) {} |
| + PreferenceCheckboxData(bool is_enabled, bool is_managed) |
| + : is_enabled(is_enabled), is_managed(is_managed) {} |
| + |
| + bool is_enabled; |
| + bool is_managed; |
| + }; |
| + |
| bool Initialize(); |
| // Sends a preference update to the extension. |
| @@ -72,18 +106,22 @@ class ArcSupportHost : public arc::ArcSupportMessageHost::Observer, |
| // 'enabled': is_enabled, |
| // 'managed': is_managed |
| // } |
| - void SendPreferenceUpdate(const std::string& action_name, |
| - bool is_enabled, |
| - bool is_managed); |
| + void SendPreferenceCheckboxUpdate(const std::string& action_name, |
| + const PreferenceCheckboxData& data); |
| void DisconnectMessageHost(); |
| + // Currently Observer is only ArcAuthService, so it is unique. |
| + // Use ObserverList when more classes start to observe it. |
| + Observer* observer_ = nullptr; |
| + |
| + PreferenceCheckboxData metrics_checkbox_; |
| + PreferenceCheckboxData backup_and_restore_checkbox_; |
| + PreferenceCheckboxData location_services_checkbox_; |
| + |
| // The instance is created and managed by Chrome. |
| arc::ArcSupportMessageHost* message_host_ = nullptr; |
| - // Handles preferences and metrics mode. |
| - std::unique_ptr<arc::ArcOptInPreferenceHandler> preference_handler_; |
| - |
| DISALLOW_COPY_AND_ASSIGN(ArcSupportHost); |
| }; |