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_ASH_LAUNCHER_ARC_APP_DEFERRED_LAUNCHER_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_ASH_LAUNCHER_ARC_APP_DEFERRED_LAUNCHER_CONTROLLER_H_ |
6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_ARC_APP_DEFERRED_LAUNCHER_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_ARC_APP_DEFERRED_LAUNCHER_CONTROLLER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "chrome/browser/chromeos/arc/arc_auth_service.h" |
13 #include "chrome/browser/ui/app_list/arc/arc_app_icon_loader.h" | 14 #include "chrome/browser/ui/app_list/arc/arc_app_icon_loader.h" |
14 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 15 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
15 | 16 |
16 class ArcAppDeferredLauncherItemController; | 17 class ArcAppDeferredLauncherItemController; |
17 class ChromeLauncherControllerImpl; | 18 class ChromeLauncherControllerImpl; |
18 | 19 |
19 class ArcAppDeferredLauncherController : public ArcAppListPrefs::Observer { | 20 class ArcAppDeferredLauncherController : public ArcAppListPrefs::Observer, |
| 21 public arc::ArcAuthService::Observer { |
20 public: | 22 public: |
21 explicit ArcAppDeferredLauncherController( | 23 explicit ArcAppDeferredLauncherController( |
22 ChromeLauncherControllerImpl* owner); | 24 ChromeLauncherControllerImpl* owner); |
23 ~ArcAppDeferredLauncherController() override; | 25 ~ArcAppDeferredLauncherController() override; |
24 | 26 |
| 27 bool HasApp(const std::string& app_id) const; |
| 28 |
25 base::TimeDelta GetActiveTime(const std::string& app_id) const; | 29 base::TimeDelta GetActiveTime(const std::string& app_id) const; |
26 | 30 |
27 // Registers deferred Arc app launch. | 31 // Registers deferred Arc app launch. |
28 void RegisterDeferredLaunch(const std::string& app_id); | 32 void RegisterDeferredLaunch(const std::string& app_id); |
29 | 33 |
30 // Applies spinning effect if requested app is handled by deferred controller. | 34 // Applies spinning effect if requested app is handled by deferred controller. |
31 void MaybeApplySpinningEffect(const std::string& app_id, | 35 void MaybeApplySpinningEffect(const std::string& app_id, |
32 gfx::ImageSkia* image); | 36 gfx::ImageSkia* image); |
33 | 37 |
34 // ArcAppListPrefs::Observer: | 38 // ArcAppListPrefs::Observer: |
35 void OnAppReadyChanged(const std::string& app_id, bool ready) override; | 39 void OnAppReadyChanged(const std::string& app_id, bool ready) override; |
36 void OnAppRemoved(const std::string& app_id) override; | 40 void OnAppRemoved(const std::string& app_id) override; |
37 | 41 |
| 42 // arc::ArcAuthService::Observer: |
| 43 void OnOptInEnabled(bool enabled) override; |
| 44 |
38 // Removes entry from the list of tracking items. | 45 // Removes entry from the list of tracking items. |
39 void Remove(const std::string& app_id); | 46 void Remove(const std::string& app_id); |
40 | 47 |
41 // Closes Shelf item if it has ArcAppDeferredLauncherItemController controller | 48 // Closes Shelf item if it has ArcAppDeferredLauncherItemController controller |
42 // and removes entry from the list of tracking items. | 49 // and removes entry from the list of tracking items. |
43 void Close(const std::string& app_id); | 50 void Close(const std::string& app_id); |
44 | 51 |
45 private: | 52 private: |
46 // Defines mapping of a shelf app id to a corresponded controller. Shelf app | 53 // Defines mapping of a shelf app id to a corresponded controller. Shelf app |
47 // id is optional mapping (for example, Play Store to Arc Host Support). | 54 // id is optional mapping (for example, Play Store to Arc Host Support). |
48 using AppControllerMap = | 55 using AppControllerMap = |
49 std::map<std::string, ArcAppDeferredLauncherItemController*>; | 56 std::map<std::string, ArcAppDeferredLauncherItemController*>; |
50 | 57 |
51 void UpdateApps(); | 58 void UpdateApps(); |
52 void RegisterNextUpdate(); | 59 void RegisterNextUpdate(); |
53 | 60 |
54 // Unowned pointers. | 61 // Unowned pointers. |
55 ChromeLauncherControllerImpl* owner_; | 62 ChromeLauncherControllerImpl* owner_; |
56 Profile* observed_profile_ = nullptr; | 63 Profile* observed_profile_ = nullptr; |
57 | 64 |
58 AppControllerMap app_controller_map_; | 65 AppControllerMap app_controller_map_; |
59 | 66 |
60 // Always keep this the last member of this class. | 67 // Always keep this the last member of this class. |
61 base::WeakPtrFactory<ArcAppDeferredLauncherController> weak_ptr_factory_; | 68 base::WeakPtrFactory<ArcAppDeferredLauncherController> weak_ptr_factory_; |
62 | 69 |
63 DISALLOW_COPY_AND_ASSIGN(ArcAppDeferredLauncherController); | 70 DISALLOW_COPY_AND_ASSIGN(ArcAppDeferredLauncherController); |
64 }; | 71 }; |
65 | 72 |
66 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_ARC_APP_DEFERRED_LAUNCHER_CONTROLLER_H
_ | 73 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_ARC_APP_DEFERRED_LAUNCHER_CONTROLLER_H
_ |
OLD | NEW |