Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: chrome/browser/ui/ash/launcher/extension_app_window_launcher_controller.cc

Issue 1996563002: Add ImeMenuTray element. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move to ash/common/ and use WmWindow. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
8 #include "ash/shelf/shelf.h"
7 #include "ash/shelf/shelf_delegate.h" 9 #include "ash/shelf/shelf_delegate.h"
8 #include "ash/shelf/shelf_util.h" 10 #include "ash/shelf/shelf_util.h"
9 #include "ash/shell.h" 11 #include "ash/shell.h"
12 #include "ash/system/status_area_widget.h"
13 #include "ash/wm/window_state_aura.h"
10 #include "ash/wm/window_util.h" 14 #include "ash/wm/window_util.h"
11 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
12 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" 17 #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" 18 #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" 19 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h"
20 #include "chrome/common/extensions/extension_constants.h"
16 #include "extensions/browser/app_window/app_window.h" 21 #include "extensions/browser/app_window/app_window.h"
17 #include "extensions/browser/app_window/native_app_window.h" 22 #include "extensions/browser/app_window/native_app_window.h"
18 #include "extensions/common/extension.h" 23 #include "extensions/common/extension.h"
19 #include "ui/aura/window_event_dispatcher.h" 24 #include "ui/aura/window_event_dispatcher.h"
20 25
26 #if defined(OS_CHROMEOS)
27 #include "ash/common/system/chromeos/ime_menu/ime_menu_tray.h"
28 #endif // defined(OS_CHROMEOS)
29
21 using extensions::AppWindow; 30 using extensions::AppWindow;
22 using extensions::AppWindowRegistry; 31 using extensions::AppWindowRegistry;
23 32
24 namespace { 33 namespace {
25 34
26 std::string GetAppShelfId(AppWindow* app_window) { 35 std::string GetAppShelfId(AppWindow* app_window) {
27 if (app_window->window_type_is_panel()) 36 if (app_window->window_type_is_panel())
28 return base::StringPrintf("panel:%d", app_window->session_id().id()); 37 return base::StringPrintf("panel:%d", app_window->session_id().id());
29 return app_window->extension_id(); 38 return app_window->extension_id();
30 } 39 }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 UnregisterApp(window); 111 UnregisterApp(window);
103 } 112 }
104 113
105 void ExtensionAppWindowLauncherController::RegisterApp(AppWindow* app_window) { 114 void ExtensionAppWindowLauncherController::RegisterApp(AppWindow* app_window) {
106 // Windows created by IME extension should be treated the same way as the 115 // Windows created by IME extension should be treated the same way as the
107 // virtual keyboard window, which does not register itself in launcher. 116 // virtual keyboard window, which does not register itself in launcher.
108 if (app_window->is_ime_window()) 117 if (app_window->is_ime_window())
109 return; 118 return;
110 119
111 aura::Window* window = app_window->GetNativeWindow(); 120 aura::Window* window = app_window->GetNativeWindow();
121
122 #if defined(OS_CHROMEOS)
123 // IME window created by IME extension should also not register itself in the
124 // lanucher. Instead, is should show ImeMenuTray in the status tray.
James Cook 2016/06/30 21:15:47 nit: lanucher -> launcher. Or did you mean shelf?
Azure Wei 2016/07/01 03:48:05 Done.
125 if (extension_misc::IsImeMenuExtensionId(app_window->extension_id())) {
126 ash::Shelf* shelf = ash::Shelf::ForWindow(app_window->GetNativeWindow());
127 if (shelf) {
128 ash::ImeMenuTray* ime_menu_tray =
129 shelf->shelf_widget()->status_area_widget()->ime_menu_tray();
130 if (ime_menu_tray) {
James Cook 2016/06/30 21:15:47 I think this pointer is never null when you have a
Azure Wei 2016/07/01 03:48:05 Done.
131 ime_menu_tray->SetImeWindow(ash::WmWindowAura::Get(window));
132 // Sets the property of the window to indicate that the icon should be
133 // shown on the status area tray.
134 window->SetProperty(ash::kShelfItemOnTrayForImeMenu, true);
135 ash::SetShelfIDForWindow(ash::kInvalidShelfID, window);
136 }
137 }
138 return;
139 }
140 #endif // defined(OS_CHROMEOS)
112 // Get the app's shelf identifier and add an entry to the map. 141 // Get the app's shelf identifier and add an entry to the map.
113 DCHECK(window_to_app_shelf_id_map_.find(window) == 142 DCHECK(window_to_app_shelf_id_map_.find(window) ==
114 window_to_app_shelf_id_map_.end()); 143 window_to_app_shelf_id_map_.end());
115 const std::string app_shelf_id = GetAppShelfId(app_window); 144 const std::string app_shelf_id = GetAppShelfId(app_window);
116 window_to_app_shelf_id_map_[window] = app_shelf_id; 145 window_to_app_shelf_id_map_[window] = app_shelf_id;
117 window->AddObserver(this); 146 window->AddObserver(this);
118 147
119 // Find or create an item controller and launcher item. 148 // Find or create an item controller and launcher item.
120 std::string app_id = app_window->extension_id(); 149 std::string app_id = app_window->extension_id();
121 ash::ShelfItemStatus status = ash::wm::IsActiveWindow(window) 150 ash::ShelfItemStatus status = ash::wm::IsActiveWindow(window)
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 owner()->SetItemController(shelf_id, controller); 185 owner()->SetItemController(shelf_id, controller);
157 } 186 }
158 const std::string app_shelf_id = GetAppShelfId(app_window); 187 const std::string app_shelf_id = GetAppShelfId(app_window);
159 app_controller_map_[app_shelf_id] = controller; 188 app_controller_map_[app_shelf_id] = controller;
160 } 189 }
161 owner()->SetItemStatus(shelf_id, status); 190 owner()->SetItemStatus(shelf_id, status);
162 ash::SetShelfIDForWindow(shelf_id, window); 191 ash::SetShelfIDForWindow(shelf_id, window);
163 } 192 }
164 193
165 void ExtensionAppWindowLauncherController::UnregisterApp(aura::Window* window) { 194 void ExtensionAppWindowLauncherController::UnregisterApp(aura::Window* window) {
195 if (window->GetProperty(ash::kShelfItemOnTrayForImeMenu))
196 return;
197
166 WindowToAppShelfIdMap::iterator iter1 = 198 WindowToAppShelfIdMap::iterator iter1 =
167 window_to_app_shelf_id_map_.find(window); 199 window_to_app_shelf_id_map_.find(window);
168 DCHECK(iter1 != window_to_app_shelf_id_map_.end()); 200 DCHECK(iter1 != window_to_app_shelf_id_map_.end());
169 std::string app_shelf_id = iter1->second; 201 std::string app_shelf_id = iter1->second;
170 window_to_app_shelf_id_map_.erase(iter1); 202 window_to_app_shelf_id_map_.erase(iter1);
171 window->RemoveObserver(this); 203 window->RemoveObserver(this);
172 204
173 AppControllerMap::iterator iter2 = app_controller_map_.find(app_shelf_id); 205 AppControllerMap::iterator iter2 = app_controller_map_.find(app_shelf_id);
174 DCHECK(iter2 != app_controller_map_.end()); 206 DCHECK(iter2 != app_controller_map_.end());
175 ExtensionAppWindowLauncherItemController* controller = iter2->second; 207 ExtensionAppWindowLauncherItemController* controller = iter2->second;
(...skipping 21 matching lines...) Expand all
197 WindowToAppShelfIdMap::iterator iter1 = 229 WindowToAppShelfIdMap::iterator iter1 =
198 window_to_app_shelf_id_map_.find(window); 230 window_to_app_shelf_id_map_.find(window);
199 if (iter1 == window_to_app_shelf_id_map_.end()) 231 if (iter1 == window_to_app_shelf_id_map_.end())
200 return nullptr; 232 return nullptr;
201 std::string app_shelf_id = iter1->second; 233 std::string app_shelf_id = iter1->second;
202 AppControllerMap::iterator iter2 = app_controller_map_.find(app_shelf_id); 234 AppControllerMap::iterator iter2 = app_controller_map_.find(app_shelf_id);
203 if (iter2 == app_controller_map_.end()) 235 if (iter2 == app_controller_map_.end())
204 return nullptr; 236 return nullptr;
205 return iter2->second; 237 return iter2->second;
206 } 238 }
OLDNEW
« ash/test/test_system_tray_delegate.cc ('K') | « ash/test/test_system_tray_delegate.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698