 Chromium Code Reviews
 Chromium Code Reviews Issue 2671923002:
  mash: Cleanup ash shelf application menu code.  (Closed)
    
  
    Issue 2671923002:
  mash: Cleanup ash shelf application menu code.  (Closed) 
  | Index: chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.cc | 
| diff --git a/chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.cc b/chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.cc | 
| index 92a911c36e52c7dedfa2ab3f7b1d30dc3eb2bd61..bc526df8b3393bbda48c96a52f84c2bdf3661ce7 100644 | 
| --- a/chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.cc | 
| +++ b/chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.cc | 
| @@ -9,7 +9,6 @@ | 
| #include "ash/wm/window_util.h" | 
| #include "base/memory/ptr_util.h" | 
| #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 
| -#include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h" | 
| #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" | 
| #include "ui/aura/client/aura_constants.h" | 
| #include "ui/aura/window.h" | 
| @@ -84,37 +83,6 @@ AppWindowLauncherItemController::Activate(ash::LaunchSource source) { | 
| return kExistingWindowActivated; | 
| } | 
| -ui::SimpleMenuModel* AppWindowLauncherItemController::CreateApplicationMenu( | 
| - int event_flags) { | 
| - return new LauncherApplicationMenuItemModel(GetApplicationList(event_flags)); | 
| -} | 
| - | 
| -void AppWindowLauncherItemController::Close() { | 
| - // Note: Closing windows may affect the contents of app_windows_. | 
| - WindowList windows_to_close = windows_; | 
| - for (auto* window : windows_) | 
| - window->Close(); | 
| -} | 
| - | 
| -void AppWindowLauncherItemController::ActivateIndexedApp(size_t index) { | 
| - if (index >= windows_.size()) | 
| - return; | 
| - auto it = windows_.begin(); | 
| - std::advance(it, index); | 
| - ShowAndActivateOrMinimize(*it); | 
| -} | 
| - | 
| -ChromeLauncherAppMenuItems AppWindowLauncherItemController::GetApplicationList( | 
| - int event_flags) { | 
| - ChromeLauncherAppMenuItems items; | 
| - // Add the application name to the menu. | 
| - base::string16 app_title = LauncherControllerHelper::GetAppTitle( | 
| - launcher_controller()->profile(), app_id()); | 
| - items.push_back( | 
| - base::MakeUnique<ChromeLauncherAppMenuItem>(app_title, nullptr, false)); | 
| - return items; | 
| -} | 
| - | 
| AppWindowLauncherItemController* | 
| AppWindowLauncherItemController::AsAppWindowLauncherItemController() { | 
| return this; | 
| @@ -132,9 +100,29 @@ AppWindowLauncherItemController::ItemSelected(const ui::Event& event) { | 
| if (windows_.size() >= 1 && window_to_show->IsActive() && | 
| event.type() == ui::ET_KEY_RELEASED) { | 
| return ActivateOrAdvanceToNextAppWindow(window_to_show); | 
| - } else { | 
| - return ShowAndActivateOrMinimize(window_to_show); | 
| } | 
| + | 
| + return ShowAndActivateOrMinimize(window_to_show); | 
| +} | 
| + | 
| +ash::ShelfApplicationMenuItems AppWindowLauncherItemController::GetAppMenuItems( | 
| + int event_flags) { | 
| + return ash::ShelfApplicationMenuItems(); | 
| +} | 
| + | 
| +void AppWindowLauncherItemController::Close() { | 
| + // Note: Closing windows may affect the contents of app_windows_. | 
| + WindowList windows_to_close = windows_; | 
| 
James Cook
2017/02/06 17:30:21
optional thinking out loud: ShelfAppMenuItemList()
 
msw
2017/02/07 09:12:01
Done; I could also rename Application to App for a
 | 
| + for (auto* window : windows_) | 
| + window->Close(); | 
| +} | 
| + | 
| +void AppWindowLauncherItemController::ActivateIndexedApp(size_t index) { | 
| + if (index >= windows_.size()) | 
| + return; | 
| + auto it = windows_.begin(); | 
| + std::advance(it, index); | 
| + ShowAndActivateOrMinimize(*it); | 
| } | 
| 
James Cook
2017/02/06 17:30:21
btw, thanks for sorting the functions
 
msw
2017/02/07 09:12:01
Acknowledged.
 | 
| void AppWindowLauncherItemController::OnWindowPropertyChanged( | 
| @@ -159,7 +147,7 @@ AppWindowLauncherItemController::ShowAndActivateOrMinimize( | 
| ui::BaseWindow* app_window) { | 
| // Either show or minimize windows when shown from the launcher. | 
| return launcher_controller()->ActivateWindowOrMinimizeIfActive( | 
| - app_window, GetApplicationList(0).size() == 2); | 
| + app_window, GetAppMenuItems(0).size() == 1); | 
| } | 
| ash::ShelfItemDelegate::PerformedAction |