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