| 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_UI_APP_LIST_ARC_ARC_APP_LAUNCHER_H_ | 5 #ifndef CHROME_BROWSER_UI_APP_LIST_ARC_ARC_APP_LAUNCHER_H_ |
| 6 #define CHROME_BROWSER_UI_APP_LIST_ARC_ARC_APP_LAUNCHER_H_ | 6 #define CHROME_BROWSER_UI_APP_LIST_ARC_ARC_APP_LAUNCHER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 11 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
| 12 | 12 |
| 13 namespace content { | 13 namespace content { |
| 14 class BrowserContext; | 14 class BrowserContext; |
| 15 } | 15 } |
| 16 | 16 |
| 17 // Helper class for deferred ARC app launching in case app is not ready on the | 17 // Helper class for deferred ARC app launching in case app is not ready on the |
| 18 // moment of request. | 18 // moment of request. |
| 19 class ArcAppLauncher : public ArcAppListPrefs::Observer { | 19 class ArcAppLauncher : public ArcAppListPrefs::Observer { |
| 20 public: | 20 public: |
| 21 ArcAppLauncher(content::BrowserContext* context, | 21 ArcAppLauncher(content::BrowserContext* context, |
| 22 const std::string& app_id, | 22 const std::string& app_id, |
| 23 bool landscape_layout); | 23 bool landscape_layout, |
| 24 bool deferred_launch_allowed); |
| 24 ~ArcAppLauncher() override; | 25 ~ArcAppLauncher() override; |
| 25 | 26 |
| 26 bool app_launched() const { return app_launched_; } | 27 bool app_launched() const { return app_launched_; } |
| 27 | 28 |
| 28 // ArcAppListPrefs::Observer: | 29 // ArcAppListPrefs::Observer: |
| 29 void OnAppRegistered(const std::string& app_id, | 30 void OnAppRegistered(const std::string& app_id, |
| 30 const ArcAppListPrefs::AppInfo& app_info) override; | 31 const ArcAppListPrefs::AppInfo& app_info) override; |
| 31 void OnAppReadyChanged(const std::string& app_id, bool ready) override; | 32 void OnAppReadyChanged(const std::string& app_id, bool ready) override; |
| 32 | 33 |
| 33 private: | 34 private: |
| 34 void LaunchApp(); | 35 void LaunchApp(); |
| 35 | 36 |
| 36 // Unowned pointer. | 37 // Unowned pointer. |
| 37 content::BrowserContext* context_; | 38 content::BrowserContext* context_; |
| 38 // ARC app id and requested layout. | 39 // ARC app id and requested layout. |
| 39 const std::string app_id_; | 40 const std::string app_id_; |
| 40 const bool landscape_layout_; | 41 const bool landscape_layout_; |
| 41 // Flag idicating that ARC app was launched. | 42 // If it is set to true that means app is allowed to launch in deferred mode |
| 43 // once it is registered, regardless it is ready or not. Otherwise app is |
| 44 // launched when it becomes ready. |
| 45 const bool deferred_launch_allowed_; |
| 46 // Flag indicating that ARC app was launched. |
| 42 bool app_launched_ = false; | 47 bool app_launched_ = false; |
| 43 | 48 |
| 44 DISALLOW_COPY_AND_ASSIGN(ArcAppLauncher); | 49 DISALLOW_COPY_AND_ASSIGN(ArcAppLauncher); |
| 45 }; | 50 }; |
| 46 | 51 |
| 47 #endif // CHROME_BROWSER_UI_APP_LIST_ARC_ARC_APP_LAUNCHER_H_ | 52 #endif // CHROME_BROWSER_UI_APP_LIST_ARC_ARC_APP_LAUNCHER_H_ |
| OLD | NEW |