Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: chrome/browser/ui/ash/launcher/launcher_item_controller.h

Issue 2718563008: mash: Use mojo for ShelfItemDelegate and [app] MenuItem. (Closed)
Patch Set: Address comments. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_LAUNCHER_ITEM_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_ITEM_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_ITEM_CONTROLLER_H_ 6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_ITEM_CONTROLLER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "ash/common/shelf/shelf_item_delegate.h"
11 #include "ash/common/shelf/shelf_item_types.h" 10 #include "ash/common/shelf/shelf_item_types.h"
11 #include "ash/public/interfaces/shelf.mojom.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "ui/events/event.h" 14 #include "ui/events/event.h"
15 15
16 class AppWindowLauncherItemController; 16 class AppWindowLauncherItemController;
17 class ChromeLauncherController; 17 class ChromeLauncherController;
18 18
19 using MenuItemList = std::vector<ash::mojom::MenuItemPtr>;
20
19 // LauncherItemController is used by ChromeLauncherController to track one 21 // LauncherItemController is used by ChromeLauncherController to track one
20 // or more windows associated with a shelf item. 22 // or more windows associated with a shelf item.
21 // TODO (khmel): Consider using ash::AppLauncherId instead of pair 23 // TODO (khmel): Consider using ash::AppLauncherId instead of pair
22 // |app_id| and |launch_id|. 24 // |app_id| and |launch_id|.
23 class LauncherItemController : public ash::ShelfItemDelegate { 25 class LauncherItemController : public ash::mojom::ShelfItemDelegate {
24 public: 26 public:
25 LauncherItemController(const std::string& app_id, 27 LauncherItemController(const std::string& app_id,
26 const std::string& launch_id, 28 const std::string& launch_id,
27 ChromeLauncherController* launcher_controller); 29 ChromeLauncherController* launcher_controller);
28 ~LauncherItemController() override; 30 ~LauncherItemController() override;
29 31
30 ash::ShelfID shelf_id() const { return shelf_id_; } 32 ash::ShelfID shelf_id() const { return shelf_id_; }
31 void set_shelf_id(ash::ShelfID id) { shelf_id_ = id; } 33 void set_shelf_id(ash::ShelfID id) { shelf_id_ = id; }
32 const std::string& app_id() const { return app_id_; } 34 const std::string& app_id() const { return app_id_; }
33 const std::string& launch_id() const { return launch_id_; } 35 const std::string& launch_id() const { return launch_id_; }
34 ChromeLauncherController* launcher_controller() const { 36 ChromeLauncherController* launcher_controller() const {
35 return launcher_controller_; 37 return launcher_controller_;
36 } 38 }
37 39
38 // Lock this item to the launcher without being pinned (windowed v1 apps). 40 // Lock this item to the launcher without being pinned (windowed v1 apps).
39 void lock() { locked_++; } 41 void lock() { locked_++; }
40 void unlock() { 42 void unlock() {
41 DCHECK(locked_); 43 DCHECK(locked_);
42 locked_--; 44 locked_--;
43 } 45 }
44 bool locked() const { return locked_ > 0; } 46 bool locked() const { return locked_ > 0; }
45 47
46 bool image_set_by_controller() const { return image_set_by_controller_; } 48 bool image_set_by_controller() const { return image_set_by_controller_; }
47 void set_image_set_by_controller(bool image_set_by_controller) { 49 void set_image_set_by_controller(bool image_set_by_controller) {
48 image_set_by_controller_ = image_set_by_controller; 50 image_set_by_controller_ = image_set_by_controller;
49 } 51 }
50 52
53 // Returns items for the application menu; used for convenience and testing.
54 virtual MenuItemList GetAppMenuItems(int event_flags);
55
51 // Returns nullptr if class is not AppWindowLauncherItemController. 56 // Returns nullptr if class is not AppWindowLauncherItemController.
52 virtual AppWindowLauncherItemController* AsAppWindowLauncherItemController(); 57 virtual AppWindowLauncherItemController* AsAppWindowLauncherItemController();
53 58
54 private: 59 private:
55 // The application id; empty if there is no app associated with the item. 60 // The application id; empty if there is no app associated with the item.
56 const std::string app_id_; 61 const std::string app_id_;
57 62
58 // An id that can be passed to an app when launched in order to support 63 // An id that can be passed to an app when launched in order to support
59 // multiple shelf items per app. This id is used together with the app_id to 64 // multiple shelf items per app. This id is used together with the app_id to
60 // uniquely identify each shelf item that has the same app_id. 65 // uniquely identify each shelf item that has the same app_id.
61 const std::string launch_id_; 66 const std::string launch_id_;
62 67
63 // A unique id assigned by the shelf model for the shelf item. 68 // A unique id assigned by the shelf model for the shelf item.
64 ash::ShelfID shelf_id_; 69 ash::ShelfID shelf_id_;
65 70
66 ChromeLauncherController* launcher_controller_; 71 ChromeLauncherController* launcher_controller_;
67 72
68 // The lock counter which tells the launcher if the item can be removed from 73 // The lock counter which tells the launcher if the item can be removed from
69 // the launcher (0) or not (>0). It is being used for windowed V1 74 // the launcher (0) or not (>0). It is being used for windowed V1
70 // applications. 75 // applications.
71 int locked_; 76 int locked_;
72 77
73 // Set to true if the launcher item image has been set by the controller. 78 // Set to true if the launcher item image has been set by the controller.
74 bool image_set_by_controller_; 79 bool image_set_by_controller_;
75 80
76 DISALLOW_COPY_AND_ASSIGN(LauncherItemController); 81 DISALLOW_COPY_AND_ASSIGN(LauncherItemController);
77 }; 82 };
78 83
79 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_ITEM_CONTROLLER_H_ 84 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_ITEM_CONTROLLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/launcher/launcher_context_menu.cc ('k') | chrome/browser/ui/ash/launcher/launcher_item_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698