| 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_APP_MODE_ARC_ARC_KIOSK_APP_SERVICE_H_ |    5 #ifndef CHROME_BROWSER_CHROMEOS_APP_MODE_ARC_ARC_KIOSK_APP_SERVICE_H_ | 
|    6 #define CHROME_BROWSER_CHROMEOS_APP_MODE_ARC_ARC_KIOSK_APP_SERVICE_H_ |    6 #define CHROME_BROWSER_CHROMEOS_APP_MODE_ARC_ARC_KIOSK_APP_SERVICE_H_ | 
|    7  |    7  | 
|    8 #include "base/macros.h" |    8 #include "base/macros.h" | 
|    9 #include "chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_launcher.h" |    9 #include "chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_launcher.h" | 
|   10 #include "chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_manager.h" |   10 #include "chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_manager.h" | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
|   26 // Keeps track of ARC session state and auto-launches kiosk app when it's ready. |   26 // Keeps track of ARC session state and auto-launches kiosk app when it's ready. | 
|   27 // App is started when the following conditions are satisfied: |   27 // App is started when the following conditions are satisfied: | 
|   28 // 1. App id is registered in ArcAppListPrefs and set to "ready" state. |   28 // 1. App id is registered in ArcAppListPrefs and set to "ready" state. | 
|   29 // 2. Got empty policy compliance report from Android |   29 // 2. Got empty policy compliance report from Android | 
|   30 // 3. App is not yet started |   30 // 3. App is not yet started | 
|   31 // Also, the app is stopped when one of above conditions changes. |   31 // Also, the app is stopped when one of above conditions changes. | 
|   32 class ArcKioskAppService |   32 class ArcKioskAppService | 
|   33     : public KeyedService, |   33     : public KeyedService, | 
|   34       public ArcAppListPrefs::Observer, |   34       public ArcAppListPrefs::Observer, | 
|   35       public ArcKioskAppManager::ArcKioskAppManagerObserver, |   35       public ArcKioskAppManager::ArcKioskAppManagerObserver, | 
|   36       public arc::ArcKioskBridge::Delegate { |   36       public arc::ArcKioskBridge::Delegate, | 
 |   37       public ArcKioskAppLauncher::Delegate { | 
|   37  public: |   38  public: | 
 |   39   class Delegate { | 
 |   40    public: | 
 |   41     Delegate() = default; | 
 |   42     virtual void OnAppStarted() = 0; | 
 |   43     virtual void OnAppWindowLaunched() = 0; | 
 |   44  | 
 |   45    protected: | 
 |   46     virtual ~Delegate() = default; | 
 |   47  | 
 |   48    private: | 
 |   49     DISALLOW_COPY_AND_ASSIGN(Delegate); | 
 |   50   }; | 
 |   51  | 
|   38   static ArcKioskAppService* Create(Profile* profile); |   52   static ArcKioskAppService* Create(Profile* profile); | 
|   39   static ArcKioskAppService* Get(content::BrowserContext* context); |   53   static ArcKioskAppService* Get(content::BrowserContext* context); | 
|   40  |   54  | 
 |   55   void SetDelegate(Delegate* delegate); | 
 |   56  | 
|   41   // KeyedService overrides |   57   // KeyedService overrides | 
|   42   void Shutdown() override; |   58   void Shutdown() override; | 
|   43  |   59  | 
|   44   // ArcAppListPrefs::Observer overrides |   60   // ArcAppListPrefs::Observer overrides | 
|   45   void OnAppRegistered(const std::string& app_id, |   61   void OnAppRegistered(const std::string& app_id, | 
|   46                        const ArcAppListPrefs::AppInfo& app_info) override; |   62                        const ArcAppListPrefs::AppInfo& app_info) override; | 
|   47   void OnAppReadyChanged(const std::string& id, bool ready) override; |   63   void OnAppReadyChanged(const std::string& id, bool ready) override; | 
|   48   void OnTaskCreated(int32_t task_id, |   64   void OnTaskCreated(int32_t task_id, | 
|   49                      const std::string& package_name, |   65                      const std::string& package_name, | 
|   50                      const std::string& activity, |   66                      const std::string& activity, | 
|   51                      const std::string& intent) override; |   67                      const std::string& intent) override; | 
|   52   void OnTaskDestroyed(int32_t task_id) override; |   68   void OnTaskDestroyed(int32_t task_id) override; | 
|   53   void OnPackageListInitialRefreshed() override; |   69   void OnPackageListInitialRefreshed() override; | 
|   54  |   70  | 
|   55   // ArcKioskAppManager::Observer overrides |   71   // ArcKioskAppManager::Observer overrides | 
|   56   void OnArcKioskAppsChanged() override; |   72   void OnArcKioskAppsChanged() override; | 
|   57  |   73  | 
|   58   // ArcKioskBridge::Delegate overrides |   74   // ArcKioskBridge::Delegate overrides | 
|   59   void OnMaintenanceSessionCreated() override; |   75   void OnMaintenanceSessionCreated() override; | 
|   60   void OnMaintenanceSessionFinished() override; |   76   void OnMaintenanceSessionFinished() override; | 
|   61  |   77  | 
 |   78   // ArcKioskAppLauncher::Delegate overrides | 
 |   79   void OnAppWindowLaunched() override; | 
 |   80  | 
|   62  private: |   81  private: | 
|   63   explicit ArcKioskAppService(Profile* profile); |   82   explicit ArcKioskAppService(Profile* profile); | 
|   64   ~ArcKioskAppService() override; |   83   ~ArcKioskAppService() override; | 
|   65  |   84  | 
|   66   std::string GetAppId(); |   85   std::string GetAppId(); | 
|   67   // Called when app should be started or stopped. |   86   // Called when app should be started or stopped. | 
|   68   void PreconditionsChanged(); |   87   void PreconditionsChanged(); | 
|   69  |   88  | 
|   70   Profile* const profile_; |   89   Profile* const profile_; | 
|   71   bool maintenance_session_running_ = false; |   90   bool maintenance_session_running_ = false; | 
|   72   ArcKioskAppManager* app_manager_; |   91   ArcKioskAppManager* app_manager_; | 
|   73   std::string app_id_; |   92   std::string app_id_; | 
|   74   std::unique_ptr<ArcAppListPrefs::AppInfo> app_info_; |   93   std::unique_ptr<ArcAppListPrefs::AppInfo> app_info_; | 
|   75   int32_t task_id_ = -1; |   94   int32_t task_id_ = -1; | 
|   76   std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_; |   95   std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_; | 
|   77   // Keeps track whether the app is already launched |   96   // Keeps track whether the app is already launched | 
|   78   std::unique_ptr<ArcKioskAppLauncher> app_launcher_; |   97   std::unique_ptr<ArcKioskAppLauncher> app_launcher_; | 
|   79   std::unique_ptr<ArcKioskNotificationBlocker> notification_blocker_; |   98   std::unique_ptr<ArcKioskNotificationBlocker> notification_blocker_; | 
 |   99   // Not owning the delegate, delegate removes itself in destructor | 
 |  100   Delegate* delegate_ = nullptr; | 
|   80  |  101  | 
|   81   DISALLOW_COPY_AND_ASSIGN(ArcKioskAppService); |  102   DISALLOW_COPY_AND_ASSIGN(ArcKioskAppService); | 
|   82 }; |  103 }; | 
|   83  |  104  | 
|   84 }  // namespace chromeos |  105 }  // namespace chromeos | 
|   85  |  106  | 
|   86 #endif  // CHROME_BROWSER_CHROMEOS_APP_MODE_ARC_ARC_KIOSK_APP_SERVICE_H_ |  107 #endif  // CHROME_BROWSER_CHROMEOS_APP_MODE_ARC_ARC_KIOSK_APP_SERVICE_H_ | 
| OLD | NEW |