| 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..3852310d2f5ec77a07f8177e8dcd35fa3303241b 100644
|
| --- a/chrome/browser/chromeos/arc/arc_support_host.h
|
| +++ b/chrome/browser/chromeos/arc/arc_support_host.h
|
| @@ -8,12 +8,12 @@
|
| #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"
|
|
|
| +class Profile;
|
| +
|
| namespace arc {
|
| class ArcOptInPreferenceHandler;
|
| }
|
| @@ -25,15 +25,48 @@ class ArcOptInPreferenceHandler;
|
| // 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 evertying.
|
| + TERMS, // Terms of Service page.
|
| + LSO, // LSO page.
|
| + LOADING, // ARC loading page.
|
| + ERROR, // Error message page.
|
| + };
|
| +
|
| + enum class ErrorType {
|
| + SIGN_IN_NETWORK_ERROR,
|
| + SIGN_IN_SERVICE_UNAVAILABLE_ERROR,
|
| + SIGN_IN_BAD_AUTHENTICATION_ERROR,
|
| + SIGN_IN_GMS_NOT_AVAILABLE_ERROR,
|
| + SIGN_IN_CLOUD_PROVISION_FLOW_FAIL_ERROR,
|
| + SIGN_IN_UNKNOWN_ERROR,
|
| + SERVER_COMMUNICATION_ERROR,
|
| + ANDROID_MANAGEMENT_REQUIRED_ERROR,
|
| + };
|
| +
|
| + // TODO
|
| + class Observer {
|
| + public:
|
| + virtual ~Observer() = default;
|
| +
|
| + virtual void OnWindowClosed() = 0;
|
| + virtual void OnTermsAgreed(bool is_metrics_enabled,
|
| + bool is_backup_and_restore_enabled,
|
| + bool is_location_service_enabled) = 0;
|
| + virtual void OnAuthSucceeded(const std::string& auth_code) = 0;
|
| + virtual void OnSendFeedbackClicked() = 0;
|
| + };
|
| +
|
| static const char kHostAppId[];
|
| static const char kStorageId[];
|
|
|
| - ArcSupportHost();
|
| + explicit ArcSupportHost(Profile* profile);
|
| ~ArcSupportHost() override;
|
|
|
| + void set_observer(Observer* observer) { observer_ = observer; }
|
| +
|
| // Called when the communication to arc_support Chrome App is ready.
|
| void SetMessageHost(arc::ArcSupportMessageHost* message_host);
|
|
|
| @@ -46,7 +79,37 @@ class ArcSupportHost : public arc::ArcSupportMessageHost::Observer,
|
|
|
| // Requests to close the extension window.
|
| void Close();
|
| - void ShowPage(arc::ArcAuthService::UIPage page, const base::string16& status);
|
| +
|
| + // Requests to show the Terms Of Service page.
|
| + void ShowTermsOfServicePage();
|
| +
|
| + // Requests to show LSO sign in page.
|
| + void ShowLsoPage();
|
| +
|
| + // Requests to show ARC loading page.
|
| + void ShowLoadingPage();
|
| +
|
| + // Requests to show an error page.
|
| + void ShowErrorPage(ErrorType error_type, bool show_feedback_button);
|
| +
|
| + // Set preference related checkboxes.
|
| + void SetMetricsCheckbox(bool is_enabled, bool is_managed);
|
| + void SetBackupAndRestoreCheckbox(bool is_enabled, bool is_managed);
|
| + void SetLocationServiceCheckbox(bool is_enabled, bool is_managed);
|
| +
|
| + // Temporarily expose currently requested UIPage.
|
| + // Note this may represent different page from the actually shown one,
|
| + // because the ARC support app may change its page by itself, and this is
|
| + // out-of-sync in the case.
|
| + // TODO(hidehiko): Remove this.
|
| + UIPage ui_page() const { return ui_page_; }
|
| +
|
| + // Returns whether send_feedback_button should be shown. Can be called only
|
| + // when ui_page() returns UIPage::ERROR.
|
| + // TODO(hidehiko): Remove this.
|
| + bool error_page_has_send_feedback_button() const {
|
| + return show_feedback_button_;
|
| + }
|
|
|
| // arc::ArcSupportMessageHost::Observer override:
|
| void OnMessage(const base::DictionaryValue& message) override;
|
| @@ -56,15 +119,24 @@ class ArcSupportHost : public arc::ArcSupportMessageHost::Observer,
|
| void OnDisplayRemoved(const display::Display& old_display) override;
|
| void OnDisplayMetricsChanged(const display::Display& display,
|
| uint32_t changed_metrics) override;
|
| + private:
|
| + // TODO
|
| + struct PreferenceCheckboxData {
|
| + PreferenceCheckboxData() : PreferenceCheckboxData(false, false) {}
|
| + PreferenceCheckboxData(bool is_enabled, bool is_managed)
|
| + : is_enabled(is_enabled), is_managed(is_managed) {}
|
|
|
| - // arc::ArcOptInPreferenceHandlerObserver:
|
| - void OnMetricsModeChanged(bool enabled, bool managed) override;
|
| - void OnBackupAndRestoreModeChanged(bool enabled, bool managed) override;
|
| - void OnLocationServicesModeChanged(bool enabled, bool managed) override;
|
| + bool is_enabled = false;
|
| + bool is_managed = false;
|
| + };
|
| +
|
| + // TODO.
|
| + void RequestWindowOpen();
|
|
|
| - private:
|
| bool Initialize();
|
|
|
| + void ShowPageInternal(UIPage ui_page);
|
| +
|
| // Sends a preference update to the extension.
|
| // The message will be
|
| // {
|
| @@ -72,17 +144,34 @@ 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();
|
|
|
| + Profile* profile_;
|
| +
|
| + // At the moment, we only have one observer, but will be multiple.
|
| + // TODO(hidehiko): Use ObserverList then.
|
| + Observer* observer_ = nullptr;
|
| +
|
| + // TODO
|
| + bool window_open_requested_ = false;
|
| +
|
| // 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_;
|
| + // The lifetime of the message_host_ is out of control from ARC,
|
| + // unfortunately. Cache the latest requested page info here, and send them
|
| + // in Initialize() to encapsulate synchronization.
|
| + UIPage ui_page_ = UIPage::NO_PAGE;
|
| + ErrorType error_type_;
|
| + bool show_feedback_button_;
|
| +
|
| + // Similar to page info above, cache the preference checkbox data.
|
| + PreferenceCheckboxData metrics_checkbox_;
|
| + PreferenceCheckboxData backup_and_restore_checkbox_;
|
| + PreferenceCheckboxData location_service_checkbox_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(ArcSupportHost);
|
| };
|
|
|