| 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_CHROME_MASH_SHELF_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_MASH_SHELF_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_MASH_SHELF_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_MASH_SHELF_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "chrome/browser/ui/app_icon_loader.h" | 13 #include "chrome/browser/ui/app_icon_loader.h" |
| 14 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" | 14 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" |
| 15 #include "mash/shelf/public/interfaces/shelf.mojom.h" | 15 #include "mash/shelf/public/interfaces/shelf.mojom.h" |
| 16 #include "mojo/public/cpp/bindings/associated_binding.h" | 16 #include "mojo/public/cpp/bindings/associated_binding.h" |
| 17 | 17 |
| 18 class ChromeShelfItemDelegate; | 18 class ChromeShelfItemDelegate; |
| 19 | 19 |
| 20 // ChromeMashShelfController manages chrome's interaction with the mash shelf. | 20 // ChromeMashShelfController manages chrome's interaction with the mash shelf. |
| 21 class ChromeMashShelfController : public mash::shelf::mojom::ShelfObserver, | 21 class ChromeMashShelfController : public mash::shelf::mojom::ShelfObserver, |
| 22 public AppIconLoaderDelegate { | 22 public AppIconLoaderDelegate { |
| 23 public: | 23 public: |
| 24 ChromeMashShelfController(); |
| 24 ~ChromeMashShelfController() override; | 25 ~ChromeMashShelfController() override; |
| 25 | 26 |
| 26 // Creates an instance. | |
| 27 static ChromeMashShelfController* CreateInstance(); | |
| 28 | |
| 29 // Returns the single ChromeMashShelfController instance. | |
| 30 static ChromeMashShelfController* instance() { return instance_; } | |
| 31 | |
| 32 void LaunchItem(const std::string& app_id); | 27 void LaunchItem(const std::string& app_id); |
| 33 | 28 |
| 34 private: | 29 private: |
| 35 ChromeMashShelfController(); | |
| 36 | |
| 37 void Init(); | 30 void Init(); |
| 38 | 31 |
| 39 void PinAppsFromPrefs(); | 32 void PinAppsFromPrefs(); |
| 40 | 33 |
| 41 AppIconLoader* GetAppIconLoaderForApp(const std::string& app_id); | 34 AppIconLoader* GetAppIconLoaderForApp(const std::string& app_id); |
| 42 | 35 |
| 43 // mash::shelf::mojom::ShelfObserver: | 36 // mash::shelf::mojom::ShelfObserver: |
| 44 void OnAlignmentChanged(mash::shelf::mojom::Alignment alignment) override; | 37 void OnAlignmentChanged(mash::shelf::mojom::Alignment alignment) override; |
| 45 void OnAutoHideBehaviorChanged( | 38 void OnAutoHideBehaviorChanged( |
| 46 mash::shelf::mojom::AutoHideBehavior auto_hide) override; | 39 mash::shelf::mojom::AutoHideBehavior auto_hide) override; |
| 47 | 40 |
| 48 // AppIconLoaderDelegate: | 41 // AppIconLoaderDelegate: |
| 49 void OnAppImageUpdated(const std::string& app_id, | 42 void OnAppImageUpdated(const std::string& app_id, |
| 50 const gfx::ImageSkia& image) override; | 43 const gfx::ImageSkia& image) override; |
| 51 | 44 |
| 52 static ChromeMashShelfController* instance_; | |
| 53 | |
| 54 LauncherControllerHelper helper_; | 45 LauncherControllerHelper helper_; |
| 55 mash::shelf::mojom::ShelfControllerPtr shelf_controller_; | 46 mash::shelf::mojom::ShelfControllerPtr shelf_controller_; |
| 56 mojo::AssociatedBinding<mash::shelf::mojom::ShelfObserver> observer_binding_; | 47 mojo::AssociatedBinding<mash::shelf::mojom::ShelfObserver> observer_binding_; |
| 57 std::map<std::string, std::unique_ptr<ChromeShelfItemDelegate>> | 48 std::map<std::string, std::unique_ptr<ChromeShelfItemDelegate>> |
| 58 app_id_to_item_delegate_; | 49 app_id_to_item_delegate_; |
| 59 | 50 |
| 60 // Used to load the images for app items. | 51 // Used to load the images for app items. |
| 61 std::vector<std::unique_ptr<AppIconLoader>> app_icon_loaders_; | 52 std::vector<std::unique_ptr<AppIconLoader>> app_icon_loaders_; |
| 62 | 53 |
| 63 DISALLOW_COPY_AND_ASSIGN(ChromeMashShelfController); | 54 DISALLOW_COPY_AND_ASSIGN(ChromeMashShelfController); |
| 64 }; | 55 }; |
| 65 | 56 |
| 66 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_MASH_SHELF_CONTROLLER_H_ | 57 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_MASH_SHELF_CONTROLLER_H_ |
| OLD | NEW |