| 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_LAUNCHER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_APP_MODE_ARC_ARC_KIOSK_APP_LAUNCHER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_APP_MODE_ARC_ARC_KIOSK_APP_LAUNCHER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_APP_MODE_ARC_ARC_KIOSK_APP_LAUNCHER_H_ |
| 7 | 7 |
| 8 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 8 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
| 9 #include "ui/aura/env_observer.h" | 9 #include "ui/aura/env_observer.h" |
| 10 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
| 11 #include "ui/aura/window_observer.h" | 11 #include "ui/aura/window_observer.h" |
| 12 | 12 |
| 13 namespace chromeos { | 13 namespace chromeos { |
| 14 | 14 |
| 15 // Starts Android app in kiosk mode. | 15 // Starts Android app in kiosk mode. |
| 16 // Keeps track of start progress and pins app window | 16 // Keeps track of start progress and pins app window |
| 17 // when it's finally opened. | 17 // when it's finally opened. |
| 18 class ArcKioskAppLauncher : public ArcAppListPrefs::Observer, | 18 class ArcKioskAppLauncher : public ArcAppListPrefs::Observer, |
| 19 public aura::EnvObserver, | 19 public aura::EnvObserver, |
| 20 public aura::WindowObserver { | 20 public aura::WindowObserver { |
| 21 public: | 21 public: |
| 22 class Delegate { |
| 23 public: |
| 24 Delegate() = default; |
| 25 virtual void OnAppWindowLaunched() = 0; |
| 26 |
| 27 protected: |
| 28 virtual ~Delegate() = default; |
| 29 |
| 30 private: |
| 31 DISALLOW_COPY_AND_ASSIGN(Delegate); |
| 32 }; |
| 33 |
| 22 ArcKioskAppLauncher(content::BrowserContext* context, | 34 ArcKioskAppLauncher(content::BrowserContext* context, |
| 23 ArcAppListPrefs* prefs, | 35 ArcAppListPrefs* prefs, |
| 24 const std::string& app_id); | 36 const std::string& app_id, |
| 37 Delegate* delegate); |
| 25 | 38 |
| 26 ~ArcKioskAppLauncher() override; | 39 ~ArcKioskAppLauncher() override; |
| 27 | 40 |
| 28 // ArcAppListPrefs::Observer overrides. | 41 // ArcAppListPrefs::Observer overrides. |
| 29 void OnTaskCreated(int32_t task_id, | 42 void OnTaskCreated(int32_t task_id, |
| 30 const std::string& package_name, | 43 const std::string& package_name, |
| 31 const std::string& activity, | 44 const std::string& activity, |
| 32 const std::string& intent) override; | 45 const std::string& intent) override; |
| 33 | 46 |
| 34 // aura::EnvObserver overrides. | 47 // aura::EnvObserver overrides. |
| 35 void OnWindowInitialized(aura::Window* window) override; | 48 void OnWindowInitialized(aura::Window* window) override; |
| 36 | 49 |
| 37 // aura::WindowObserver overrides. | 50 // aura::WindowObserver overrides. |
| 38 void OnWindowPropertyChanged(aura::Window* window, | 51 void OnWindowPropertyChanged(aura::Window* window, |
| 39 const void* key, | 52 const void* key, |
| 40 intptr_t old) override; | 53 intptr_t old) override; |
| 41 void OnWindowDestroying(aura::Window* window) override; | 54 void OnWindowDestroying(aura::Window* window) override; |
| 42 | 55 |
| 43 private: | 56 private: |
| 44 // Check whether it's the app's window and pins it. | 57 // Check whether it's the app's window and pins it. |
| 45 bool CheckAndPinWindow(aura::Window* const window); | 58 bool CheckAndPinWindow(aura::Window* const window); |
| 46 void StopObserving(); | 59 void StopObserving(); |
| 47 | 60 |
| 48 const std::string app_id_; | 61 const std::string app_id_; |
| 49 ArcAppListPrefs* const prefs_; | 62 ArcAppListPrefs* const prefs_; |
| 50 int task_id_ = -1; | 63 int task_id_ = -1; |
| 51 std::set<aura::Window*> windows_; | 64 std::set<aura::Window*> windows_; |
| 65 // Not owning the delegate, delegate owns this class. |
| 66 Delegate* const delegate_; |
| 52 | 67 |
| 53 DISALLOW_COPY_AND_ASSIGN(ArcKioskAppLauncher); | 68 DISALLOW_COPY_AND_ASSIGN(ArcKioskAppLauncher); |
| 54 }; | 69 }; |
| 55 | 70 |
| 56 } // namespace chromeos | 71 } // namespace chromeos |
| 57 | 72 |
| 58 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_ARC_ARC_KIOSK_APP_LAUNCHER_H_ | 73 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_ARC_ARC_KIOSK_APP_LAUNCHER_H_ |
| OLD | NEW |