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

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: Remove kStatusTrayShelfID. 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"
23 #include "ui/aura/client/aura_constants.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/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.
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) {
131 ime_menu_tray->SetWindowState(ash::wm::GetWindowState(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(aura::client::kShowIconOnTrayKey, true);
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
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) {
166 WindowToAppShelfIdMap::iterator iter1 = 194 WindowToAppShelfIdMap::iterator iter1 =
167 window_to_app_shelf_id_map_.find(window); 195 window_to_app_shelf_id_map_.find(window);
168 DCHECK(iter1 != window_to_app_shelf_id_map_.end()); 196 DCHECK(iter1 != window_to_app_shelf_id_map_.end());
sadrul 2016/06/27 15:08:05 Do you not need to update this too? Instead of ha
Azure Wei 2016/06/27 18:33:49 Thanks for the advise. Sets the window state nullp
169 std::string app_shelf_id = iter1->second; 197 std::string app_shelf_id = iter1->second;
170 window_to_app_shelf_id_map_.erase(iter1); 198 window_to_app_shelf_id_map_.erase(iter1);
171 window->RemoveObserver(this); 199 window->RemoveObserver(this);
172 200
173 AppControllerMap::iterator iter2 = app_controller_map_.find(app_shelf_id); 201 AppControllerMap::iterator iter2 = app_controller_map_.find(app_shelf_id);
174 DCHECK(iter2 != app_controller_map_.end()); 202 DCHECK(iter2 != app_controller_map_.end());
175 ExtensionAppWindowLauncherItemController* controller = iter2->second; 203 ExtensionAppWindowLauncherItemController* controller = iter2->second;
176 controller->RemoveWindow(controller->GetAppWindow(window)); 204 controller->RemoveWindow(controller->GetAppWindow(window));
177 if (controller->window_count() == 0) { 205 if (controller->window_count() == 0) {
178 // If this is the last window associated with the app shelf id, close the 206 // If this is the last window associated with the app shelf id, close the
(...skipping 18 matching lines...) Expand all
197 WindowToAppShelfIdMap::iterator iter1 = 225 WindowToAppShelfIdMap::iterator iter1 =
198 window_to_app_shelf_id_map_.find(window); 226 window_to_app_shelf_id_map_.find(window);
199 if (iter1 == window_to_app_shelf_id_map_.end()) 227 if (iter1 == window_to_app_shelf_id_map_.end())
200 return nullptr; 228 return nullptr;
201 std::string app_shelf_id = iter1->second; 229 std::string app_shelf_id = iter1->second;
202 AppControllerMap::iterator iter2 = app_controller_map_.find(app_shelf_id); 230 AppControllerMap::iterator iter2 = app_controller_map_.find(app_shelf_id);
203 if (iter2 == app_controller_map_.end()) 231 if (iter2 == app_controller_map_.end())
204 return nullptr; 232 return nullptr;
205 return iter2->second; 233 return iter2->second;
206 } 234 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698