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_controlle r.h" | 5 #include "chrome/browser/ui/ash/launcher/extension_app_window_launcher_controlle r.h" |
| 6 | 6 |
| 7 #include "ash/shelf/shelf.h" | |
| 7 #include "ash/shelf/shelf_delegate.h" | 8 #include "ash/shelf/shelf_delegate.h" |
| 8 #include "ash/shelf/shelf_util.h" | 9 #include "ash/shelf/shelf_util.h" |
| 9 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "ash/system/status_area_widget.h" | |
| 12 #include "ash/wm/window_state_aura.h" | |
| 10 #include "ash/wm/window_util.h" | 13 #include "ash/wm/window_util.h" |
| 11 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 16 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 14 #include "chrome/browser/ui/ash/launcher/extension_app_window_launcher_item_cont roller.h" | 17 #include "chrome/browser/ui/ash/launcher/extension_app_window_launcher_item_cont roller.h" |
| 15 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" | 18 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" |
| 19 #include "chrome/common/extensions/extension_constants.h" | |
| 16 #include "extensions/browser/app_window/app_window.h" | 20 #include "extensions/browser/app_window/app_window.h" |
| 17 #include "extensions/browser/app_window/native_app_window.h" | 21 #include "extensions/browser/app_window/native_app_window.h" |
| 18 #include "extensions/common/extension.h" | 22 #include "extensions/common/extension.h" |
| 19 #include "ui/aura/window_event_dispatcher.h" | 23 #include "ui/aura/window_event_dispatcher.h" |
| 20 | 24 |
| 25 #if defined(OS_CHROMEOS) | |
| 26 #include "ash/system/chromeos/ime_menu/ime_menu_tray.h" | |
| 27 #endif // defined(OS_CHROMEOS) | |
| 28 | |
| 21 using extensions::AppWindow; | 29 using extensions::AppWindow; |
| 22 using extensions::AppWindowRegistry; | 30 using extensions::AppWindowRegistry; |
| 23 | 31 |
| 24 namespace { | 32 namespace { |
| 25 | 33 |
| 26 std::string GetAppShelfId(AppWindow* app_window) { | 34 std::string GetAppShelfId(AppWindow* app_window) { |
| 27 if (app_window->window_type_is_panel()) | 35 if (app_window->window_type_is_panel()) |
| 28 return base::StringPrintf("panel:%d", app_window->session_id().id()); | 36 return base::StringPrintf("panel:%d", app_window->session_id().id()); |
| 29 return app_window->extension_id(); | 37 return app_window->extension_id(); |
| 30 } | 38 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 UnregisterApp(window); | 110 UnregisterApp(window); |
| 103 } | 111 } |
| 104 | 112 |
| 105 void ExtensionAppWindowLauncherController::RegisterApp(AppWindow* app_window) { | 113 void ExtensionAppWindowLauncherController::RegisterApp(AppWindow* app_window) { |
| 106 // Windows created by IME extension should be treated the same way as the | 114 // Windows created by IME extension should be treated the same way as the |
| 107 // virtual keyboard window, which does not register itself in launcher. | 115 // virtual keyboard window, which does not register itself in launcher. |
| 108 if (app_window->is_ime_window()) | 116 if (app_window->is_ime_window()) |
| 109 return; | 117 return; |
| 110 | 118 |
| 111 aura::Window* window = app_window->GetNativeWindow(); | 119 aura::Window* window = app_window->GetNativeWindow(); |
| 120 | |
| 121 #if defined(OS_CHROMEOS) | |
| 122 // IME window created by IME extension should also not register itself in the | |
| 123 // lanucher. Instead, is should show ImeMenuTray in the status tray. | |
| 124 if (extension_misc::IsImeMenuExtensionId(app_window->extension_id())) { | |
| 125 ash::Shelf* shelf = ash::Shelf::ForWindow(app_window->GetNativeWindow()); | |
| 126 if (shelf) { | |
| 127 ash::ImeMenuTray* ime_menu_tray = | |
| 128 shelf->shelf_widget()->status_area_widget()->ime_menu_tray(); | |
| 129 if (ime_menu_tray) { | |
| 130 ime_menu_tray->SetWindowState(ash::wm::GetWindowState(window)); | |
| 131 // Sets the shelf id as -1 for the window to indicate that the icon | |
| 132 // should be shown on the status area tray. | |
| 133 ash::SetShelfIDForWindow(-1, window); | |
|
sadrul
2016/06/20 16:18:12
I don't think setting special values for the Shelf
Azure Wei
2016/06/22 01:47:10
I added a property kShowIconOnTrayKey for window t
Azure Wei
2016/06/27 05:10:31
The window has not been shown was caused by wrong
| |
| 134 } | |
| 135 } | |
| 136 return; | |
| 137 } | |
| 138 #endif // defined(OS_CHROMEOS) | |
| 112 // Get the app's shelf identifier and add an entry to the map. | 139 // Get the app's shelf identifier and add an entry to the map. |
| 113 DCHECK(window_to_app_shelf_id_map_.find(window) == | 140 DCHECK(window_to_app_shelf_id_map_.find(window) == |
| 114 window_to_app_shelf_id_map_.end()); | 141 window_to_app_shelf_id_map_.end()); |
| 115 const std::string app_shelf_id = GetAppShelfId(app_window); | 142 const std::string app_shelf_id = GetAppShelfId(app_window); |
| 116 window_to_app_shelf_id_map_[window] = app_shelf_id; | 143 window_to_app_shelf_id_map_[window] = app_shelf_id; |
| 117 window->AddObserver(this); | 144 window->AddObserver(this); |
| 118 | 145 |
| 119 // Find or create an item controller and launcher item. | 146 // Find or create an item controller and launcher item. |
| 120 std::string app_id = app_window->extension_id(); | 147 std::string app_id = app_window->extension_id(); |
| 121 ash::ShelfItemStatus status = ash::wm::IsActiveWindow(window) | 148 ash::ShelfItemStatus status = ash::wm::IsActiveWindow(window) |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 197 WindowToAppShelfIdMap::iterator iter1 = | 224 WindowToAppShelfIdMap::iterator iter1 = |
| 198 window_to_app_shelf_id_map_.find(window); | 225 window_to_app_shelf_id_map_.find(window); |
| 199 if (iter1 == window_to_app_shelf_id_map_.end()) | 226 if (iter1 == window_to_app_shelf_id_map_.end()) |
| 200 return nullptr; | 227 return nullptr; |
| 201 std::string app_shelf_id = iter1->second; | 228 std::string app_shelf_id = iter1->second; |
| 202 AppControllerMap::iterator iter2 = app_controller_map_.find(app_shelf_id); | 229 AppControllerMap::iterator iter2 = app_controller_map_.find(app_shelf_id); |
| 203 if (iter2 == app_controller_map_.end()) | 230 if (iter2 == app_controller_map_.end()) |
| 204 return nullptr; | 231 return nullptr; |
| 205 return iter2->second; | 232 return iter2->second; |
| 206 } | 233 } |
| OLD | NEW |