| 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/public/cpp/shelf_item_delegate.h" | 7 #include "ash/public/cpp/shelf_item_delegate.h" |
| 8 #include "ash/wm/window_state.h" | 8 #include "ash/wm/window_state.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" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 12 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 13 #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h" | 13 #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h" |
| 14 #include "components/favicon/content/content_favicon_driver.h" | 14 #include "components/favicon/content/content_favicon_driver.h" |
| 15 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
| 16 #include "extensions/browser/app_window/app_window.h" | 16 #include "extensions/browser/app_window/app_window.h" |
| 17 #include "extensions/browser/app_window/app_window_registry.h" | 17 #include "extensions/browser/app_window/app_window_registry.h" |
| 18 #include "extensions/browser/app_window/native_app_window.h" | 18 #include "extensions/browser/app_window/native_app_window.h" |
| 19 #include "ui/aura/client/aura_constants.h" | 19 #include "ui/aura/client/aura_constants.h" |
| 20 #include "ui/aura/window.h" | 20 #include "ui/aura/window.h" |
| 21 #include "ui/events/event.h" | 21 #include "ui/events/event.h" |
| 22 #include "ui/gfx/image/image.h" | 22 #include "ui/gfx/image/image.h" |
| 23 #include "ui/wm/core/window_animations.h" | 23 #include "ui/wm/core/window_animations.h" |
| 24 | 24 |
| 25 ExtensionAppWindowLauncherItemController:: | 25 ExtensionAppWindowLauncherItemController:: |
| 26 ExtensionAppWindowLauncherItemController(const ash::ShelfID& shelf_id) | 26 ExtensionAppWindowLauncherItemController(const ash::ShelfID& shelf_id, |
| 27 : AppWindowLauncherItemController(shelf_id) {} | 27 ChromeLauncherController* owner) |
| 28 : AppWindowLauncherItemController(shelf_id, owner) {} |
| 28 | 29 |
| 29 ExtensionAppWindowLauncherItemController:: | 30 ExtensionAppWindowLauncherItemController:: |
| 30 ~ExtensionAppWindowLauncherItemController() {} | 31 ~ExtensionAppWindowLauncherItemController() {} |
| 31 | 32 |
| 32 void ExtensionAppWindowLauncherItemController::AddAppWindow( | 33 void ExtensionAppWindowLauncherItemController::AddAppWindow( |
| 33 extensions::AppWindow* app_window) { | 34 extensions::AppWindow* app_window) { |
| 34 DCHECK(!app_window->window_type_is_panel()); | 35 DCHECK(!app_window->window_type_is_panel()); |
| 35 AddWindow(app_window->GetBaseWindow()); | 36 AddWindow(app_window->GetBaseWindow()); |
| 36 } | 37 } |
| 37 | 38 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 51 | 52 |
| 52 ash::mojom::MenuItemPtr item(ash::mojom::MenuItem::New()); | 53 ash::mojom::MenuItemPtr item(ash::mojom::MenuItem::New()); |
| 53 item->command_id = window_index; | 54 item->command_id = window_index; |
| 54 item->label = app_window->GetTitle(); | 55 item->label = app_window->GetTitle(); |
| 55 | 56 |
| 56 // Use the app's web contents favicon, or the app window's icon. | 57 // Use the app's web contents favicon, or the app window's icon. |
| 57 favicon::FaviconDriver* favicon_driver = | 58 favicon::FaviconDriver* favicon_driver = |
| 58 favicon::ContentFaviconDriver::FromWebContents( | 59 favicon::ContentFaviconDriver::FromWebContents( |
| 59 app_window->web_contents()); | 60 app_window->web_contents()); |
| 60 gfx::Image icon = favicon_driver->GetFavicon(); | 61 gfx::Image icon = favicon_driver->GetFavicon(); |
| 61 if (icon.IsEmpty()) | 62 if (icon.IsEmpty()) { |
| 62 icon = app_window->app_icon(); | 63 const gfx::ImageSkia* app_icon = nullptr; |
| 64 if (app_window->GetNativeWindow()) { |
| 65 app_icon = app_window->GetNativeWindow()->GetProperty( |
| 66 aura::client::kAppIconKey); |
| 67 } |
| 68 if (app_icon && !app_icon->isNull()) |
| 69 icon = gfx::Image(*app_icon); |
| 70 } |
| 63 if (!icon.IsEmpty()) | 71 if (!icon.IsEmpty()) |
| 64 item->image = *icon.ToSkBitmap(); | 72 item->image = *icon.ToSkBitmap(); |
| 65 items.push_back(std::move(item)); | 73 items.push_back(std::move(item)); |
| 66 ++window_index; | 74 ++window_index; |
| 67 } | 75 } |
| 68 return items; | 76 return items; |
| 69 } | 77 } |
| 70 | 78 |
| 71 void ExtensionAppWindowLauncherItemController::ExecuteCommand( | 79 void ExtensionAppWindowLauncherItemController::ExecuteCommand( |
| 72 uint32_t command_id, | 80 uint32_t command_id, |
| 73 int32_t event_flags) { | 81 int32_t event_flags) { |
| 74 ChromeLauncherController::instance()->ActivateShellApp(app_id(), command_id); | 82 ChromeLauncherController::instance()->ActivateShellApp(app_id(), command_id); |
| 75 } | 83 } |
| OLD | NEW |