| 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_controlle
     r.h" |    5 #include "chrome/browser/ui/ash/launcher/extension_app_window_launcher_controlle
     r.h" | 
|    6  |    6  | 
|    7 #include "ash/aura/wm_window_aura.h" |    7 #include "ash/aura/wm_window_aura.h" | 
|    8 #include "ash/common/shelf/shelf_delegate.h" |    8 #include "ash/common/shelf/shelf_delegate.h" | 
|    9 #include "ash/common/wm_shell.h" |    9 #include "ash/common/wm_shell.h" | 
|   10 #include "ash/common/wm_window_property.h" |   10 #include "ash/common/wm_window_property.h" | 
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  120     aura::Window* window) { |  120     aura::Window* window) { | 
|  121   UnregisterApp(window); |  121   UnregisterApp(window); | 
|  122 } |  122 } | 
|  123  |  123  | 
|  124 void ExtensionAppWindowLauncherController::RegisterApp(AppWindow* app_window) { |  124 void ExtensionAppWindowLauncherController::RegisterApp(AppWindow* app_window) { | 
|  125   // Windows created by IME extension should be treated the same way as the |  125   // Windows created by IME extension should be treated the same way as the | 
|  126   // virtual keyboard window, which does not register itself in launcher. |  126   // virtual keyboard window, which does not register itself in launcher. | 
|  127   if (app_window->is_ime_window()) |  127   if (app_window->is_ime_window()) | 
|  128     return; |  128     return; | 
|  129  |  129  | 
 |  130   // Ash's ShelfWindowWatcher handles app panel windows separately. | 
 |  131   if (app_window->window_type_is_panel()) { | 
 |  132     // Load panel app icons now. ShelfWindowWatcher cannot easily trigger this, | 
 |  133     // and ShelfModel::Set cannot be called in ShelfItemAdded, since ShelfView | 
 |  134     // may not have added a view for the new shelf item at that point. | 
 |  135     const std::string& app_id = app_window->extension_id(); | 
 |  136     AppIconLoader* app_icon_loader = owner()->GetAppIconLoaderForApp(app_id); | 
 |  137     if (app_icon_loader) { | 
 |  138       app_icon_loader->FetchImage(app_id); | 
 |  139       app_icon_loader->UpdateImage(app_id); | 
 |  140     } | 
 |  141     return; | 
 |  142   } | 
 |  143  | 
|  130   aura::Window* window = app_window->GetNativeWindow(); |  144   aura::Window* window = app_window->GetNativeWindow(); | 
|  131   // Get the app's shelf identifier and add an entry to the map. |  145   // Get the app's shelf identifier and add an entry to the map. | 
|  132   DCHECK(window_to_app_shelf_id_map_.find(window) == |  146   DCHECK(window_to_app_shelf_id_map_.find(window) == | 
|  133          window_to_app_shelf_id_map_.end()); |  147          window_to_app_shelf_id_map_.end()); | 
|  134   const std::string app_shelf_id = GetAppShelfId(app_window); |  148   const std::string app_shelf_id = GetAppShelfId(app_window); | 
|  135   window_to_app_shelf_id_map_[window] = app_shelf_id; |  149   window_to_app_shelf_id_map_[window] = app_shelf_id; | 
|  136   window->AddObserver(this); |  150   window->AddObserver(this); | 
|  137  |  151  | 
|  138   // Find or create an item controller and launcher item. |  152   // Find or create an item controller and launcher item. | 
|  139   std::string app_id = app_window->extension_id(); |  153   std::string app_id = app_window->extension_id(); | 
|  140   ash::ShelfItemStatus status = ash::wm::IsActiveWindow(window) |  154   ash::ShelfItemStatus status = ash::wm::IsActiveWindow(window) | 
|  141                                     ? ash::STATUS_ACTIVE |  155                                     ? ash::STATUS_ACTIVE | 
|  142                                     : ash::STATUS_RUNNING; |  156                                     : ash::STATUS_RUNNING; | 
|  143   AppControllerMap::iterator app_controller_iter = |  157   AppControllerMap::iterator app_controller_iter = | 
|  144       app_controller_map_.find(app_shelf_id); |  158       app_controller_map_.find(app_shelf_id); | 
|  145   ash::ShelfID shelf_id = 0; |  159   ash::ShelfID shelf_id = 0; | 
|  146  |  160  | 
|  147   if (app_controller_iter != app_controller_map_.end()) { |  161   if (app_controller_iter != app_controller_map_.end()) { | 
|  148     ExtensionAppWindowLauncherItemController* controller = |  162     ExtensionAppWindowLauncherItemController* controller = | 
|  149         app_controller_iter->second; |  163         app_controller_iter->second; | 
|  150     DCHECK(controller->app_id() == app_id); |  164     DCHECK(controller->app_id() == app_id); | 
|  151     shelf_id = controller->shelf_id(); |  165     shelf_id = controller->shelf_id(); | 
|  152     controller->AddAppWindow(app_window); |  166     controller->AddAppWindow(app_window); | 
|  153   } else { |  167   } else { | 
|  154     LauncherItemController::Type type = |  168     LauncherItemController::Type type = LauncherItemController::TYPE_APP; | 
|  155         app_window->window_type_is_panel() |  | 
|  156             ? LauncherItemController::TYPE_APP_PANEL |  | 
|  157             : LauncherItemController::TYPE_APP; |  | 
|  158     std::string launch_id = GetLaunchId(app_window); |  169     std::string launch_id = GetLaunchId(app_window); | 
|  159     ExtensionAppWindowLauncherItemController* controller = |  170     ExtensionAppWindowLauncherItemController* controller = | 
|  160         new ExtensionAppWindowLauncherItemController(type, app_id, launch_id, |  171         new ExtensionAppWindowLauncherItemController(type, app_id, launch_id, | 
|  161                                                      owner()); |  172                                                      owner()); | 
|  162     controller->AddAppWindow(app_window); |  173     controller->AddAppWindow(app_window); | 
|  163     // If there is already a shelf id mapped to this app_shelf_id (e.g. pinned), |  174     // If there is already a shelf id mapped to this app_shelf_id (e.g. pinned), | 
|  164     // use that shelf item. |  175     // use that shelf item. | 
|  165     shelf_id = |  176     shelf_id = | 
|  166         ash::WmShell::Get()->shelf_delegate()->GetShelfIDForAppIDAndLaunchID( |  177         ash::WmShell::Get()->shelf_delegate()->GetShelfIDForAppIDAndLaunchID( | 
|  167             app_id, launch_id); |  178             app_id, launch_id); | 
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  224   WindowToAppShelfIdMap::iterator window_iter = |  235   WindowToAppShelfIdMap::iterator window_iter = | 
|  225       window_to_app_shelf_id_map_.find(window); |  236       window_to_app_shelf_id_map_.find(window); | 
|  226   if (window_iter == window_to_app_shelf_id_map_.end()) |  237   if (window_iter == window_to_app_shelf_id_map_.end()) | 
|  227     return nullptr; |  238     return nullptr; | 
|  228   AppControllerMap::iterator app_controller_iter = |  239   AppControllerMap::iterator app_controller_iter = | 
|  229       app_controller_map_.find(window_iter->second); |  240       app_controller_map_.find(window_iter->second); | 
|  230   if (app_controller_iter == app_controller_map_.end()) |  241   if (app_controller_iter == app_controller_map_.end()) | 
|  231     return nullptr; |  242     return nullptr; | 
|  232   return app_controller_iter->second; |  243   return app_controller_iter->second; | 
|  233 } |  244 } | 
| OLD | NEW |