| 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" |
| 11 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" | |
| 12 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_v2app.h" | 11 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_v2app.h" |
| 13 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 12 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 14 #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h" | 13 #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h" |
| 15 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" | 14 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" |
| 16 #include "components/favicon/content/content_favicon_driver.h" | 15 #include "components/favicon/content/content_favicon_driver.h" |
| 17 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
| 18 #include "extensions/browser/app_window/app_window.h" | 17 #include "extensions/browser/app_window/app_window.h" |
| 19 #include "extensions/browser/app_window/native_app_window.h" | 18 #include "extensions/browser/app_window/native_app_window.h" |
| 20 #include "skia/ext/image_operations.h" | 19 #include "skia/ext/image_operations.h" |
| 21 #include "ui/aura/client/aura_constants.h" | 20 #include "ui/aura/client/aura_constants.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 | 59 |
| 61 void ExtensionAppWindowLauncherItemController::AddAppWindow( | 60 void ExtensionAppWindowLauncherItemController::AddAppWindow( |
| 62 extensions::AppWindow* app_window) { | 61 extensions::AppWindow* app_window) { |
| 63 DCHECK(!app_window->window_type_is_panel()); | 62 DCHECK(!app_window->window_type_is_panel()); |
| 64 DCHECK(window_to_app_window_.find(app_window->GetBaseWindow()) == | 63 DCHECK(window_to_app_window_.find(app_window->GetBaseWindow()) == |
| 65 window_to_app_window_.end()); | 64 window_to_app_window_.end()); |
| 66 AddWindow(app_window->GetBaseWindow()); | 65 AddWindow(app_window->GetBaseWindow()); |
| 67 window_to_app_window_[app_window->GetBaseWindow()] = app_window; | 66 window_to_app_window_[app_window->GetBaseWindow()] = app_window; |
| 68 } | 67 } |
| 69 | 68 |
| 70 void ExtensionAppWindowLauncherItemController::OnWindowRemoved( | 69 ash::ShelfAppMenuItemList |
| 71 ui::BaseWindow* window) { | 70 ExtensionAppWindowLauncherItemController::GetAppMenuItems(int event_flags) { |
| 72 WindowToAppWindow::iterator it = window_to_app_window_.find(window); | 71 ash::ShelfAppMenuItemList items; |
| 73 if (it == window_to_app_window_.end()) { | |
| 74 NOTREACHED(); | |
| 75 return; | |
| 76 } | |
| 77 | |
| 78 window_to_app_window_.erase(it); | |
| 79 } | |
| 80 | |
| 81 ChromeLauncherAppMenuItems | |
| 82 ExtensionAppWindowLauncherItemController::GetApplicationList(int event_flags) { | |
| 83 ChromeLauncherAppMenuItems items = | |
| 84 AppWindowLauncherItemController::GetApplicationList(event_flags); | |
| 85 int index = 0; | 72 int index = 0; |
| 86 for (const auto* window : windows()) { | 73 for (const auto* window : windows()) { |
| 87 extensions::AppWindow* app_window = window_to_app_window_[window]; | 74 extensions::AppWindow* app_window = window_to_app_window_[window]; |
| 88 DCHECK(app_window); | 75 DCHECK(app_window); |
| 89 | 76 |
| 90 // If the app's web contents provides a favicon, use it. Otherwise, use a | 77 // If the app's web contents provides a favicon, use it. Otherwise, use a |
| 91 // scaled down app icon. | 78 // scaled down app icon. |
| 92 favicon::FaviconDriver* favicon_driver = | 79 favicon::FaviconDriver* favicon_driver = |
| 93 favicon::ContentFaviconDriver::FromWebContents( | 80 favicon::ContentFaviconDriver::FromWebContents( |
| 94 app_window->web_contents()); | 81 app_window->web_contents()); |
| 95 gfx::Image result = favicon_driver->GetFavicon(); | 82 gfx::Image result = favicon_driver->GetFavicon(); |
| 96 if (result.IsEmpty()) | 83 if (result.IsEmpty()) |
| 97 result = GetAppListIcon(app_window); | 84 result = GetAppListIcon(app_window); |
| 98 | 85 |
| 99 items.push_back(base::MakeUnique<ChromeLauncherAppMenuItemV2App>( | 86 items.push_back(base::MakeUnique<ChromeLauncherAppMenuItemV2App>( |
| 100 app_window->GetTitle(), | 87 app_window->GetTitle(), |
| 101 &result, // Will be copied | 88 &result, // Will be copied |
| 102 app_id(), launcher_controller(), index, | 89 app_id(), launcher_controller(), index)); |
| 103 index == 0 /* has_leading_separator */)); | |
| 104 ++index; | 90 ++index; |
| 105 } | 91 } |
| 106 return items; | 92 return items; |
| 107 } | 93 } |
| 94 |
| 95 void ExtensionAppWindowLauncherItemController::OnWindowRemoved( |
| 96 ui::BaseWindow* window) { |
| 97 WindowToAppWindow::iterator it = window_to_app_window_.find(window); |
| 98 if (it == window_to_app_window_.end()) { |
| 99 NOTREACHED(); |
| 100 return; |
| 101 } |
| 102 |
| 103 window_to_app_window_.erase(it); |
| 104 } |
| OLD | NEW |