Chromium Code Reviews| 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_state_aura.h" | 9 #include "ash/wm/window_state_aura.h" |
| 10 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 13 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 14 #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h" | 14 #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h" |
| 15 #include "components/favicon/content/content_favicon_driver.h" | 15 #include "components/favicon/content/content_favicon_driver.h" |
| 16 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
| 17 #include "extensions/browser/app_window/app_window.h" | 17 #include "extensions/browser/app_window/app_window.h" |
| 18 #include "extensions/browser/app_window/app_window_registry.h" | 18 #include "extensions/browser/app_window/app_window_registry.h" |
| 19 #include "extensions/browser/app_window/native_app_window.h" | 19 #include "extensions/browser/app_window/native_app_window.h" |
| 20 #include "ui/aura/client/aura_constants.h" | 20 #include "ui/aura/client/aura_constants.h" |
| 21 #include "ui/aura/window.h" | 21 #include "ui/aura/window.h" |
| 22 #include "ui/events/event.h" | 22 #include "ui/events/event.h" |
| 23 #include "ui/gfx/image/image.h" | 23 #include "ui/gfx/image/image.h" |
| 24 #include "ui/wm/core/window_animations.h" | 24 #include "ui/wm/core/window_animations.h" |
| 25 | 25 |
| 26 ExtensionAppWindowLauncherItemController:: | 26 ExtensionAppWindowLauncherItemController:: |
| 27 ExtensionAppWindowLauncherItemController(const ash::ShelfID& shelf_id) | 27 ExtensionAppWindowLauncherItemController(const ash::ShelfID& shelf_id, |
| 28 : AppWindowLauncherItemController(shelf_id) {} | 28 ChromeLauncherController* owner) |
| 29 : AppWindowLauncherItemController(shelf_id, owner) {} | |
| 29 | 30 |
| 30 ExtensionAppWindowLauncherItemController:: | 31 ExtensionAppWindowLauncherItemController:: |
| 31 ~ExtensionAppWindowLauncherItemController() {} | 32 ~ExtensionAppWindowLauncherItemController() {} |
| 32 | 33 |
| 33 void ExtensionAppWindowLauncherItemController::AddAppWindow( | 34 void ExtensionAppWindowLauncherItemController::AddAppWindow( |
| 34 extensions::AppWindow* app_window) { | 35 extensions::AppWindow* app_window) { |
| 35 DCHECK(!app_window->window_type_is_panel()); | 36 DCHECK(!app_window->window_type_is_panel()); |
| 36 AddWindow(app_window->GetBaseWindow()); | 37 AddWindow(app_window->GetBaseWindow()); |
| 37 } | 38 } |
| 38 | 39 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 52 | 53 |
| 53 ash::mojom::MenuItemPtr item(ash::mojom::MenuItem::New()); | 54 ash::mojom::MenuItemPtr item(ash::mojom::MenuItem::New()); |
| 54 item->command_id = window_index; | 55 item->command_id = window_index; |
| 55 item->label = app_window->GetTitle(); | 56 item->label = app_window->GetTitle(); |
| 56 | 57 |
| 57 // Use the app's web contents favicon, or the app window's icon. | 58 // Use the app's web contents favicon, or the app window's icon. |
| 58 favicon::FaviconDriver* favicon_driver = | 59 favicon::FaviconDriver* favicon_driver = |
| 59 favicon::ContentFaviconDriver::FromWebContents( | 60 favicon::ContentFaviconDriver::FromWebContents( |
| 60 app_window->web_contents()); | 61 app_window->web_contents()); |
| 61 gfx::Image icon = favicon_driver->GetFavicon(); | 62 gfx::Image icon = favicon_driver->GetFavicon(); |
| 62 if (icon.IsEmpty()) | 63 if (icon.IsEmpty()) { |
| 63 icon = app_window->app_icon(); | 64 const gfx::ImageSkia* app_icon = nullptr; |
| 65 if (app_window->GetNativeWindow()) { | |
| 66 app_icon = app_window->GetNativeWindow()->GetProperty( | |
| 67 aura::client::kAppIconKey); | |
| 68 } | |
| 69 if (app_icon && !app_icon->isNull()) | |
| 70 icon = gfx::Image(*app_icon); | |
|
stevenjb
2017/05/23 17:00:19
Maybe put the above in AppWindow as GetAppIcon() i
khmel
2017/05/23 17:35:00
I am not very sure. Actually ChromeNativeAppWindow
msw
2017/05/23 18:13:12
Hmm, it seems like this code should call ChromeNat
| |
| 71 } | |
| 64 if (!icon.IsEmpty()) | 72 if (!icon.IsEmpty()) |
| 65 item->image = *icon.ToSkBitmap(); | 73 item->image = *icon.ToSkBitmap(); |
| 66 items.push_back(std::move(item)); | 74 items.push_back(std::move(item)); |
| 67 ++window_index; | 75 ++window_index; |
| 68 } | 76 } |
| 69 return items; | 77 return items; |
| 70 } | 78 } |
| 71 | 79 |
| 72 void ExtensionAppWindowLauncherItemController::ExecuteCommand( | 80 void ExtensionAppWindowLauncherItemController::ExecuteCommand( |
| 73 uint32_t command_id, | 81 uint32_t command_id, |
| 74 int32_t event_flags) { | 82 int32_t event_flags) { |
| 75 ChromeLauncherController::instance()->ActivateShellApp(app_id(), command_id); | 83 ChromeLauncherController::instance()->ActivateShellApp(app_id(), command_id); |
| 76 } | 84 } |
| OLD | NEW |