| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/multi_user/multi_user_window_manager_chromeos.h" | 5 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h" |
| 6 | 6 |
| 7 #include "ash/common/media_controller.h" | 7 #include "ash/common/media_controller.h" |
| 8 #include "ash/common/multi_profile_uma.h" | 8 #include "ash/common/multi_profile_uma.h" |
| 9 #include "ash/common/session/session_state_delegate.h" | 9 #include "ash/common/session/session_state_delegate.h" |
| 10 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 10 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 // in / out. | 49 // in / out. |
| 50 const int kAnimationTimeMS = 100; | 50 const int kAnimationTimeMS = 100; |
| 51 | 51 |
| 52 // The animation time in milliseconds for the fade in and / or out when | 52 // The animation time in milliseconds for the fade in and / or out when |
| 53 // switching users. | 53 // switching users. |
| 54 const int kUserFadeTimeMS = 110; | 54 const int kUserFadeTimeMS = 110; |
| 55 | 55 |
| 56 // The animation time in ms for a window which get teleported to another screen. | 56 // The animation time in ms for a window which get teleported to another screen. |
| 57 const int kTeleportAnimationTimeMS = 300; | 57 const int kTeleportAnimationTimeMS = 300; |
| 58 | 58 |
| 59 // Checks if a given event is a user event. | |
| 60 bool IsUserEvent(const ui::Event* e) { | |
| 61 if (e) { | |
| 62 ui::EventType type = e->type(); | |
| 63 if (type != ui::ET_CANCEL_MODE && | |
| 64 type != ui::ET_UMA_DATA && | |
| 65 type != ui::ET_UNKNOWN) | |
| 66 return true; | |
| 67 } | |
| 68 return false; | |
| 69 } | |
| 70 | |
| 71 // Test if we are currently processing a user event which might lead to a | |
| 72 // browser / app creation. | |
| 73 bool IsProcessingUserEvent() { | |
| 74 // When there is a nested message loop (e.g. active menu or drag and drop | |
| 75 // operation) - we are in a nested loop and can ignore this. | |
| 76 // Note: Unit tests might not have a message loop. | |
| 77 base::MessageLoop* message_loop = base::MessageLoop::current(); | |
| 78 if (message_loop && message_loop->is_running() && message_loop->IsNested()) | |
| 79 return false; | |
| 80 | |
| 81 // TODO(skuhne): "Open link in new window" will come here after the menu got | |
| 82 // closed, executing the command from the nested menu loop. However at that | |
| 83 // time there is no active event processed. A solution for that need to be | |
| 84 // found past M-32. A global event handler filter (pre and post) might fix | |
| 85 // that problem in conjunction with a depth counter - but - for the menu | |
| 86 // execution we come here after the loop was finished (so it's not nested | |
| 87 // anymore) and the root window should therefore still have the event which | |
| 88 // lead to the menu invocation, but it is not. By fixing that problem this | |
| 89 // would "magically work". | |
| 90 aura::Window::Windows root_window_list = ash::Shell::GetAllRootWindows(); | |
| 91 for (aura::Window::Windows::iterator it = root_window_list.begin(); | |
| 92 it != root_window_list.end(); | |
| 93 ++it) { | |
| 94 if (IsUserEvent((*it)->GetHost()->dispatcher()->current_event())) | |
| 95 return true; | |
| 96 } | |
| 97 return false; | |
| 98 } | |
| 99 | |
| 100 // Records the type of window which was transferred to another desktop. | 59 // Records the type of window which was transferred to another desktop. |
| 101 void RecordUMAForTransferredWindowType(aura::Window* window) { | 60 void RecordUMAForTransferredWindowType(aura::Window* window) { |
| 102 // We need to figure out what kind of window this is to record the transfer. | 61 // We need to figure out what kind of window this is to record the transfer. |
| 103 Browser* browser = chrome::FindBrowserWithWindow(window); | 62 Browser* browser = chrome::FindBrowserWithWindow(window); |
| 104 ash::MultiProfileUMA::TeleportWindowType window_type = | 63 ash::MultiProfileUMA::TeleportWindowType window_type = |
| 105 ash::MultiProfileUMA::TELEPORT_WINDOW_UNKNOWN; | 64 ash::MultiProfileUMA::TELEPORT_WINDOW_UNKNOWN; |
| 106 if (browser) { | 65 if (browser) { |
| 107 if (browser->profile()->IsOffTheRecord()) { | 66 if (browser->profile()->IsOffTheRecord()) { |
| 108 window_type = ash::MultiProfileUMA::TELEPORT_WINDOW_INCOGNITO_BROWSER; | 67 window_type = ash::MultiProfileUMA::TELEPORT_WINDOW_INCOGNITO_BROWSER; |
| 109 } else if (browser->is_app()) { | 68 } else if (browser->is_app()) { |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 | 269 |
| 311 // Remember the initial visibility of the window. | 270 // Remember the initial visibility of the window. |
| 312 window_to_entry_[window]->set_show(window->IsVisible()); | 271 window_to_entry_[window]->set_show(window->IsVisible()); |
| 313 | 272 |
| 314 // Add observers to track state changes. | 273 // Add observers to track state changes. |
| 315 window->AddObserver(this); | 274 window->AddObserver(this); |
| 316 wm::TransientWindowManager::Get(window)->AddObserver(this); | 275 wm::TransientWindowManager::Get(window)->AddObserver(this); |
| 317 | 276 |
| 318 // Check if this window was created due to a user interaction. If it was, | 277 // Check if this window was created due to a user interaction. If it was, |
| 319 // transfer it to the current user. | 278 // transfer it to the current user. |
| 320 if (IsProcessingUserEvent()) | 279 if (window->GetProperty(aura::client::kCreatedByUserGesture)) |
| 321 window_to_entry_[window]->set_show_for_user(current_account_id_); | 280 window_to_entry_[window]->set_show_for_user(current_account_id_); |
| 322 | 281 |
| 323 // Add all transient children to our set of windows. Note that the function | 282 // Add all transient children to our set of windows. Note that the function |
| 324 // will add the children but not the owner to the transient children map. | 283 // will add the children but not the owner to the transient children map. |
| 325 AddTransientOwnerRecursive(window, window); | 284 AddTransientOwnerRecursive(window, window); |
| 326 | 285 |
| 327 // Notify entry adding. | 286 // Notify entry adding. |
| 328 for (Observer& observer : observers_) | 287 for (Observer& observer : observers_) |
| 329 observer.OnOwnerEntryAdded(window); | 288 observer.OnOwnerEntryAdded(window); |
| 330 | 289 |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 window->Hide(); | 713 window->Hide(); |
| 755 } | 714 } |
| 756 | 715 |
| 757 int MultiUserWindowManagerChromeOS::GetAdjustedAnimationTimeInMS( | 716 int MultiUserWindowManagerChromeOS::GetAdjustedAnimationTimeInMS( |
| 758 int default_time_in_ms) const { | 717 int default_time_in_ms) const { |
| 759 return animation_speed_ == ANIMATION_SPEED_NORMAL ? default_time_in_ms : | 718 return animation_speed_ == ANIMATION_SPEED_NORMAL ? default_time_in_ms : |
| 760 (animation_speed_ == ANIMATION_SPEED_FAST ? 10 : 0); | 719 (animation_speed_ == ANIMATION_SPEED_FAST ? 10 : 0); |
| 761 } | 720 } |
| 762 | 721 |
| 763 } // namespace chrome | 722 } // namespace chrome |
| OLD | NEW |