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 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h" | 4 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h" |
5 | 5 |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "ash/common/shelf/shelf_delegate.h" | 8 #include "ash/common/shelf/shelf_delegate.h" |
9 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 9 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
10 #include "ash/common/wm/window_state.h" | 10 #include "ash/common/wm/window_state.h" |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 | 239 |
240 private: | 240 private: |
241 const int task_id_; | 241 const int task_id_; |
242 const arc::ArcAppShelfId app_shelf_id_; | 242 const arc::ArcAppShelfId app_shelf_id_; |
243 ash::ShelfID shelf_id_ = 0; | 243 ash::ShelfID shelf_id_ = 0; |
244 FullScreenMode fullscreen_mode_ = FullScreenMode::NOT_DEFINED; | 244 FullScreenMode fullscreen_mode_ = FullScreenMode::NOT_DEFINED; |
245 // Unowned pointers | 245 // Unowned pointers |
246 views::Widget* const widget_; | 246 views::Widget* const widget_; |
247 ArcAppWindowLauncherController* owner_; | 247 ArcAppWindowLauncherController* owner_; |
248 ArcAppWindowLauncherItemController* controller_ = nullptr; | 248 ArcAppWindowLauncherItemController* controller_ = nullptr; |
249 // Unowned pointer, represents host Arc window. | 249 // Unowned pointer, represents host ARC window. |
250 | 250 |
251 DISALLOW_COPY_AND_ASSIGN(AppWindow); | 251 DISALLOW_COPY_AND_ASSIGN(AppWindow); |
252 }; | 252 }; |
253 | 253 |
254 ArcAppWindowLauncherController::ArcAppWindowLauncherController( | 254 ArcAppWindowLauncherController::ArcAppWindowLauncherController( |
255 ChromeLauncherController* owner, | 255 ChromeLauncherController* owner, |
256 ash::ShelfDelegate* shelf_delegate) | 256 ash::ShelfDelegate* shelf_delegate) |
257 : AppWindowLauncherController(owner), shelf_delegate_(shelf_delegate) { | 257 : AppWindowLauncherController(owner), shelf_delegate_(shelf_delegate) { |
258 if (arc::IsArcAllowedForProfile(owner->profile())) { | 258 if (arc::IsArcAllowedForProfile(owner->profile())) { |
259 observed_profile_ = owner->profile(); | 259 observed_profile_ = owner->profile(); |
(...skipping 22 matching lines...) Expand all Loading... |
282 : shelf_app_id; | 282 : shelf_app_id; |
283 } | 283 } |
284 | 284 |
285 void ArcAppWindowLauncherController::ActiveUserChanged( | 285 void ArcAppWindowLauncherController::ActiveUserChanged( |
286 const std::string& user_email) { | 286 const std::string& user_email) { |
287 const std::string& primary_user_email = user_manager::UserManager::Get() | 287 const std::string& primary_user_email = user_manager::UserManager::Get() |
288 ->GetPrimaryUser() | 288 ->GetPrimaryUser() |
289 ->GetAccountId() | 289 ->GetAccountId() |
290 .GetUserEmail(); | 290 .GetUserEmail(); |
291 if (user_email == primary_user_email) { | 291 if (user_email == primary_user_email) { |
292 // Restore existing Arc window and create controllers for them. | 292 // Restore existing ARC window and create controllers for them. |
293 AttachControllerToWindowsIfNeeded(); | 293 AttachControllerToWindowsIfNeeded(); |
294 | 294 |
295 // Make sure that we created items for all apps, not only which have a | 295 // Make sure that we created items for all apps, not only which have a |
296 // window. | 296 // window. |
297 for (const auto& info : task_id_to_app_window_info_) | 297 for (const auto& info : task_id_to_app_window_info_) |
298 AttachControllerToTask(info.first, *info.second); | 298 AttachControllerToTask(info.first, *info.second); |
299 | 299 |
300 // Update active status. | 300 // Update active status. |
301 OnTaskSetActive(active_task_id_); | 301 OnTaskSetActive(active_task_id_); |
302 } else { | 302 } else { |
303 // Remove all Arc apps and destroy its controllers. There is no mapping | 303 // Remove all ARC apps and destroy its controllers. There is no mapping |
304 // task id to app window because it is not safe when controller is missing. | 304 // task id to app window because it is not safe when controller is missing. |
305 for (auto& it : task_id_to_app_window_info_) | 305 for (auto& it : task_id_to_app_window_info_) |
306 UnregisterApp(it.second.get()); | 306 UnregisterApp(it.second.get()); |
307 | 307 |
308 // Some controllers might have no windows attached, for example background | 308 // Some controllers might have no windows attached, for example background |
309 // task when foreground tasks is in full screen. | 309 // task when foreground tasks is in full screen. |
310 for (const auto& it : app_shelf_group_to_controller_map_) | 310 for (const auto& it : app_shelf_group_to_controller_map_) |
311 owner()->CloseLauncherItem(it.second->shelf_id()); | 311 owner()->CloseLauncherItem(it.second->shelf_id()); |
312 app_shelf_group_to_controller_map_.clear(); | 312 app_shelf_group_to_controller_map_.clear(); |
313 } | 313 } |
(...skipping 13 matching lines...) Expand all Loading... |
327 if (!widget || !widget->is_top_level()) | 327 if (!widget || !widget->is_top_level()) |
328 return; | 328 return; |
329 observed_windows_.push_back(window); | 329 observed_windows_.push_back(window); |
330 window->AddObserver(this); | 330 window->AddObserver(this); |
331 } | 331 } |
332 | 332 |
333 void ArcAppWindowLauncherController::OnWindowVisibilityChanged( | 333 void ArcAppWindowLauncherController::OnWindowVisibilityChanged( |
334 aura::Window* window, | 334 aura::Window* window, |
335 bool visible) { | 335 bool visible) { |
336 // Attach window to multi-user manager now to let it manage visibility state | 336 // Attach window to multi-user manager now to let it manage visibility state |
337 // of the Arc window correctly. | 337 // of the ARC window correctly. |
338 if (GetWindowTaskId(window) > 0) { | 338 if (GetWindowTaskId(window) > 0) { |
339 chrome::MultiUserWindowManager::GetInstance()->SetWindowOwner( | 339 chrome::MultiUserWindowManager::GetInstance()->SetWindowOwner( |
340 window, | 340 window, |
341 user_manager::UserManager::Get()->GetPrimaryUser()->GetAccountId()); | 341 user_manager::UserManager::Get()->GetPrimaryUser()->GetAccountId()); |
342 } | 342 } |
343 | 343 |
344 // The application id property should be set at this time. It is important to | 344 // The application id property should be set at this time. It is important to |
345 // have window->IsVisible set to true before attaching to a controller because | 345 // have window->IsVisible set to true before attaching to a controller because |
346 // the window is registered in multi-user manager and this manager may | 346 // the window is registered in multi-user manager and this manager may |
347 // consider this new window as hidden for current profile. Multi-user manager | 347 // consider this new window as hidden for current profile. Multi-user manager |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 const std::string arc_app_id = exo::ShellSurface::GetApplicationId(window); | 720 const std::string arc_app_id = exo::ShellSurface::GetApplicationId(window); |
721 if (arc_app_id.empty()) | 721 if (arc_app_id.empty()) |
722 return -1; | 722 return -1; |
723 | 723 |
724 int task_id = -1; | 724 int task_id = -1; |
725 if (sscanf(arc_app_id.c_str(), "org.chromium.arc.%d", &task_id) != 1) | 725 if (sscanf(arc_app_id.c_str(), "org.chromium.arc.%d", &task_id) != 1) |
726 return -1; | 726 return -1; |
727 | 727 |
728 return task_id; | 728 return task_id; |
729 } | 729 } |
OLD | NEW |