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

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: Change SetWindowState() with SetImeWindow(). 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/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
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->SetImeWindow(window);
131 // Sets the property of the window to indicate that the icon should be
132 // shown on the status area tray.
133 window->SetProperty(ash::kShelfItemOnTrayForImeMenu, true);
134 ash::SetShelfIDForWindow(ash::kInvalidShelfID, window);
135 }
136 }
137 return;
138 }
139 #endif // defined(OS_CHROMEOS)
112 // Get the app's shelf identifier and add an entry to the map. 140 // Get the app's shelf identifier and add an entry to the map.
113 DCHECK(window_to_app_shelf_id_map_.find(window) == 141 DCHECK(window_to_app_shelf_id_map_.find(window) ==
114 window_to_app_shelf_id_map_.end()); 142 window_to_app_shelf_id_map_.end());
115 const std::string app_shelf_id = GetAppShelfId(app_window); 143 const std::string app_shelf_id = GetAppShelfId(app_window);
116 window_to_app_shelf_id_map_[window] = app_shelf_id; 144 window_to_app_shelf_id_map_[window] = app_shelf_id;
117 window->AddObserver(this); 145 window->AddObserver(this);
118 146
119 // Find or create an item controller and launcher item. 147 // Find or create an item controller and launcher item.
120 std::string app_id = app_window->extension_id(); 148 std::string app_id = app_window->extension_id();
121 ash::ShelfItemStatus status = ash::wm::IsActiveWindow(window) 149 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); 184 owner()->SetItemController(shelf_id, controller);
157 } 185 }
158 const std::string app_shelf_id = GetAppShelfId(app_window); 186 const std::string app_shelf_id = GetAppShelfId(app_window);
159 app_controller_map_[app_shelf_id] = controller; 187 app_controller_map_[app_shelf_id] = controller;
160 } 188 }
161 owner()->SetItemStatus(shelf_id, status); 189 owner()->SetItemStatus(shelf_id, status);
162 ash::SetShelfIDForWindow(shelf_id, window); 190 ash::SetShelfIDForWindow(shelf_id, window);
163 } 191 }
164 192
165 void ExtensionAppWindowLauncherController::UnregisterApp(aura::Window* window) { 193 void ExtensionAppWindowLauncherController::UnregisterApp(aura::Window* window) {
194 if (window->GetProperty(ash::kShelfItemOnTrayForImeMenu))
195 return;
196
166 WindowToAppShelfIdMap::iterator iter1 = 197 WindowToAppShelfIdMap::iterator iter1 =
167 window_to_app_shelf_id_map_.find(window); 198 window_to_app_shelf_id_map_.find(window);
168 DCHECK(iter1 != window_to_app_shelf_id_map_.end()); 199 DCHECK(iter1 != window_to_app_shelf_id_map_.end());
169 std::string app_shelf_id = iter1->second; 200 std::string app_shelf_id = iter1->second;
170 window_to_app_shelf_id_map_.erase(iter1); 201 window_to_app_shelf_id_map_.erase(iter1);
171 window->RemoveObserver(this); 202 window->RemoveObserver(this);
172 203
173 AppControllerMap::iterator iter2 = app_controller_map_.find(app_shelf_id); 204 AppControllerMap::iterator iter2 = app_controller_map_.find(app_shelf_id);
174 DCHECK(iter2 != app_controller_map_.end()); 205 DCHECK(iter2 != app_controller_map_.end());
175 ExtensionAppWindowLauncherItemController* controller = iter2->second; 206 ExtensionAppWindowLauncherItemController* controller = iter2->second;
(...skipping 21 matching lines...) Expand all
197 WindowToAppShelfIdMap::iterator iter1 = 228 WindowToAppShelfIdMap::iterator iter1 =
198 window_to_app_shelf_id_map_.find(window); 229 window_to_app_shelf_id_map_.find(window);
199 if (iter1 == window_to_app_shelf_id_map_.end()) 230 if (iter1 == window_to_app_shelf_id_map_.end())
200 return nullptr; 231 return nullptr;
201 std::string app_shelf_id = iter1->second; 232 std::string app_shelf_id = iter1->second;
202 AppControllerMap::iterator iter2 = app_controller_map_.find(app_shelf_id); 233 AppControllerMap::iterator iter2 = app_controller_map_.find(app_shelf_id);
203 if (iter2 == app_controller_map_.end()) 234 if (iter2 == app_controller_map_.end())
204 return nullptr; 235 return nullptr;
205 return iter2->second; 236 return iter2->second;
206 } 237 }
OLDNEW
« ash/system/chromeos/ime_menu/ime_menu_tray.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