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 #include "chrome/browser/ui/ash/launcher/extension_app_window_launcher_item_cont
roller.h" | 5 #include "chrome/browser/ui/ash/launcher/extension_app_window_launcher_item_cont
roller.h" |
6 | 6 |
7 #include "ash/common/wm/window_state.h" | 7 #include "ash/common/wm/window_state.h" |
8 #include "ash/wm/window_state_aura.h" | 8 #include "ash/wm/window_state_aura.h" |
9 #include "ash/wm/window_util.h" | 9 #include "ash/wm/window_util.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 | 32 |
33 ExtensionAppWindowLauncherItemController:: | 33 ExtensionAppWindowLauncherItemController:: |
34 ~ExtensionAppWindowLauncherItemController() {} | 34 ~ExtensionAppWindowLauncherItemController() {} |
35 | 35 |
36 void ExtensionAppWindowLauncherItemController::AddAppWindow( | 36 void ExtensionAppWindowLauncherItemController::AddAppWindow( |
37 extensions::AppWindow* app_window) { | 37 extensions::AppWindow* app_window) { |
38 DCHECK(!app_window->window_type_is_panel()); | 38 DCHECK(!app_window->window_type_is_panel()); |
39 AddWindow(app_window->GetBaseWindow()); | 39 AddWindow(app_window->GetBaseWindow()); |
40 } | 40 } |
41 | 41 |
42 ash::ShelfAppMenuItemList | 42 ash::ShelfItemDelegate::MenuItemList |
43 ExtensionAppWindowLauncherItemController::GetAppMenuItems(int event_flags) { | 43 ExtensionAppWindowLauncherItemController::GetAppMenuItems(int event_flags) { |
44 ash::ShelfAppMenuItemList items; | 44 ash::ShelfItemDelegate::MenuItemList items; |
45 extensions::AppWindowRegistry* app_window_registry = | 45 extensions::AppWindowRegistry* app_window_registry = |
46 extensions::AppWindowRegistry::Get(launcher_controller()->profile()); | 46 extensions::AppWindowRegistry::Get(launcher_controller()->profile()); |
47 | 47 |
48 uint32_t window_index = 0; | 48 uint32_t window_index = 0; |
49 for (const ui::BaseWindow* window : windows()) { | 49 for (const ui::BaseWindow* window : windows()) { |
50 extensions::AppWindow* app_window = | 50 extensions::AppWindow* app_window = |
51 app_window_registry->GetAppWindowForNativeWindow( | 51 app_window_registry->GetAppWindowForNativeWindow( |
52 window->GetNativeWindow()); | 52 window->GetNativeWindow()); |
53 DCHECK(app_window); | 53 DCHECK(app_window); |
54 | 54 |
| 55 ash::mojom::MenuItemPtr item(ash::mojom::MenuItem::New()); |
| 56 item->command_id = window_index; |
| 57 item->label = app_window->GetTitle(); |
| 58 |
55 // Use the app's web contents favicon, or the app window's icon. | 59 // Use the app's web contents favicon, or the app window's icon. |
56 favicon::FaviconDriver* favicon_driver = | 60 favicon::FaviconDriver* favicon_driver = |
57 favicon::ContentFaviconDriver::FromWebContents( | 61 favicon::ContentFaviconDriver::FromWebContents( |
58 app_window->web_contents()); | 62 app_window->web_contents()); |
59 gfx::Image icon = favicon_driver->GetFavicon(); | 63 gfx::Image icon = favicon_driver->GetFavicon(); |
60 if (icon.IsEmpty()) | 64 if (icon.IsEmpty()) |
61 icon = app_window->app_icon(); | 65 icon = app_window->app_icon(); |
62 | 66 if (!icon.IsEmpty()) |
63 items.push_back(base::MakeUnique<ash::ShelfApplicationMenuItem>( | 67 item->image = *icon.ToSkBitmap(); |
64 window_index, app_window->GetTitle(), &icon)); | 68 items.push_back(std::move(item)); |
65 ++window_index; | 69 ++window_index; |
66 } | 70 } |
67 return items; | 71 return items; |
68 } | 72 } |
69 | 73 |
70 void ExtensionAppWindowLauncherItemController::ExecuteCommand( | 74 void ExtensionAppWindowLauncherItemController::ExecuteCommand( |
71 uint32_t command_id, | 75 uint32_t command_id, |
72 int event_flags) { | 76 int32_t event_flags) { |
73 launcher_controller()->ActivateShellApp(app_id(), command_id); | 77 launcher_controller()->ActivateShellApp(app_id(), command_id); |
74 } | 78 } |
OLD | NEW |