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 "apps/app_window.h" | 7 #include "apps/app_window.h" |
8 #include "apps/app_window_registry.h" | 8 #include "apps/app_window_registry.h" |
9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
10 #include "ash/multi_profile_uma.h" | 10 #include "ash/multi_profile_uma.h" |
(...skipping 30 matching lines...) Expand all Loading... | |
41 #include "ui/wm/core/transient_window_manager.h" | 41 #include "ui/wm/core/transient_window_manager.h" |
42 #include "ui/wm/core/window_animations.h" | 42 #include "ui/wm/core/window_animations.h" |
43 #include "ui/wm/core/window_util.h" | 43 #include "ui/wm/core/window_util.h" |
44 | 44 |
45 namespace { | 45 namespace { |
46 | 46 |
47 // The animation time in milliseconds for a single window which is fading | 47 // The animation time in milliseconds for a single window which is fading |
48 // in / out. | 48 // in / out. |
49 const int kAnimationTimeMS = 100; | 49 const int kAnimationTimeMS = 100; |
50 | 50 |
51 // The animation time in milliseconds for the fade in and / or out when | |
52 // switching users. | |
53 const int kUserFadeTimeMS = 110; | |
54 | |
51 // The animation time in ms for a window which get teleported to another screen. | 55 // The animation time in ms for a window which get teleported to another screen. |
52 const int kTeleportAnimationTimeMS = 300; | 56 const int kTeleportAnimationTimeMS = 300; |
53 | 57 |
54 // Checks if a given event is a user event. | 58 // Checks if a given event is a user event. |
55 bool IsUserEvent(const ui::Event* e) { | 59 bool IsUserEvent(const ui::Event* e) { |
56 if (e) { | 60 if (e) { |
57 ui::EventType type = e->type(); | 61 ui::EventType type = e->type(); |
58 if (type != ui::ET_CANCEL_MODE && | 62 if (type != ui::ET_CANCEL_MODE && |
59 type != ui::ET_UMA_DATA && | 63 type != ui::ET_UMA_DATA && |
60 type != ui::ET_UNKNOWN) | 64 type != ui::ET_UNKNOWN) |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 | 205 |
202 DISALLOW_COPY_AND_ASSIGN(AppObserver); | 206 DISALLOW_COPY_AND_ASSIGN(AppObserver); |
203 }; | 207 }; |
204 | 208 |
205 MultiUserWindowManagerChromeOS::MultiUserWindowManagerChromeOS( | 209 MultiUserWindowManagerChromeOS::MultiUserWindowManagerChromeOS( |
206 const std::string& current_user_id) | 210 const std::string& current_user_id) |
207 : current_user_id_(current_user_id), | 211 : current_user_id_(current_user_id), |
208 notification_blocker_(new MultiUserNotificationBlockerChromeOS( | 212 notification_blocker_(new MultiUserNotificationBlockerChromeOS( |
209 message_center::MessageCenter::Get(), this, current_user_id)), | 213 message_center::MessageCenter::Get(), this, current_user_id)), |
210 suppress_visibility_changes_(false), | 214 suppress_visibility_changes_(false), |
211 animations_disabled_(false) { | 215 animation_speed_(ANIMATION_SPEED_NORMAL) { |
212 // Add a session state observer to be able to monitor session changes. | 216 // Add a session state observer to be able to monitor session changes. |
213 if (ash::Shell::HasInstance()) | 217 if (ash::Shell::HasInstance()) |
214 ash::Shell::GetInstance()->session_state_delegate()-> | 218 ash::Shell::GetInstance()->session_state_delegate()-> |
215 AddSessionStateObserver(this); | 219 AddSessionStateObserver(this); |
216 | 220 |
217 // The BrowserListObserver would have been better to use then the old | 221 // The BrowserListObserver would have been better to use then the old |
218 // notification system, but that observer fires before the window got created. | 222 // notification system, but that observer fires before the window got created. |
219 registrar_.Add(this, NOTIFICATION_BROWSER_WINDOW_READY, | 223 registrar_.Add(this, NOTIFICATION_BROWSER_WINDOW_READY, |
220 content::NotificationService::AllSources()); | 224 content::NotificationService::AllSources()); |
221 | 225 |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
386 observers_.RemoveObserver(observer); | 390 observers_.RemoveObserver(observer); |
387 } | 391 } |
388 | 392 |
389 void MultiUserWindowManagerChromeOS::ActiveUserChanged( | 393 void MultiUserWindowManagerChromeOS::ActiveUserChanged( |
390 const std::string& user_id) { | 394 const std::string& user_id) { |
391 DCHECK(user_id != current_user_id_); | 395 DCHECK(user_id != current_user_id_); |
392 // This needs to be set before the animation starts. | 396 // This needs to be set before the animation starts. |
393 current_user_id_ = user_id; | 397 current_user_id_ = user_id; |
394 | 398 |
395 animation_.reset( | 399 animation_.reset( |
396 new UserSwichAnimatorChromeOS(this, user_id, animations_disabled_)); | 400 new UserSwichAnimatorChromeOS(this, user_id, |
401 animation_speed_ == ANIMATION_SPEED_NORMAL ? kUserFadeTimeMS : | |
402 (animation_speed_ == ANIMATION_SPEED_FAST ? 10 : 0))); | |
397 } | 403 } |
398 | 404 |
399 void MultiUserWindowManagerChromeOS::OnWindowDestroyed(aura::Window* window) { | 405 void MultiUserWindowManagerChromeOS::OnWindowDestroyed(aura::Window* window) { |
400 if (GetWindowOwner(window).empty()) { | 406 if (GetWindowOwner(window).empty()) { |
401 // This must be a window in the transient chain - remove it and its | 407 // This must be a window in the transient chain - remove it and its |
402 // children from the owner. | 408 // children from the owner. |
403 RemoveTransientOwnerRecursive(window); | 409 RemoveTransientOwnerRecursive(window); |
404 return; | 410 return; |
405 } | 411 } |
406 wm::TransientWindowManager::Get(window)->RemoveObserver(this); | 412 wm::TransientWindowManager::Get(window)->RemoveObserver(this); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
478 } | 484 } |
479 | 485 |
480 void MultiUserWindowManagerChromeOS::Observe( | 486 void MultiUserWindowManagerChromeOS::Observe( |
481 int type, | 487 int type, |
482 const content::NotificationSource& source, | 488 const content::NotificationSource& source, |
483 const content::NotificationDetails& details) { | 489 const content::NotificationDetails& details) { |
484 if (type == NOTIFICATION_BROWSER_WINDOW_READY) | 490 if (type == NOTIFICATION_BROWSER_WINDOW_READY) |
485 AddBrowserWindow(content::Source<Browser>(source).ptr()); | 491 AddBrowserWindow(content::Source<Browser>(source).ptr()); |
486 } | 492 } |
487 | 493 |
488 void MultiUserWindowManagerChromeOS::SetAnimationsForTest(bool disable) { | 494 void MultiUserWindowManagerChromeOS::SetAnimationSpeedForTest( |
489 animations_disabled_ = disable; | 495 MultiUserWindowManagerChromeOS::AnimationSpeed speed) { |
496 animation_speed_ = speed; | |
490 } | 497 } |
491 | 498 |
492 bool MultiUserWindowManagerChromeOS::IsAnimationRunningForTest() { | 499 bool MultiUserWindowManagerChromeOS::IsAnimationRunningForTest() { |
493 return animation_.get() != NULL && !animation_->IsAnimationFinished(); | 500 return animation_.get() != NULL && !animation_->IsAnimationFinished(); |
494 } | 501 } |
495 | 502 |
496 const std::string& MultiUserWindowManagerChromeOS::GetCurrentUserForTest() { | 503 const std::string& MultiUserWindowManagerChromeOS::GetCurrentUserForTest() { |
497 return current_user_id_; | 504 return current_user_id_; |
498 } | 505 } |
499 | 506 |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
675 window->Show(); | 682 window->Show(); |
676 } | 683 } |
677 } | 684 } |
678 | 685 |
679 void MultiUserWindowManagerChromeOS::SetWindowVisible( | 686 void MultiUserWindowManagerChromeOS::SetWindowVisible( |
680 aura::Window* window, | 687 aura::Window* window, |
681 bool visible, | 688 bool visible, |
682 int animation_time_in_ms) { | 689 int animation_time_in_ms) { |
683 AnimationSetter animation_setter( | 690 AnimationSetter animation_setter( |
684 window, | 691 window, |
685 animations_disabled_ ? 0 : animation_time_in_ms); | 692 animation_speed_ == ANIMATION_SPEED_NORMAL ? animation_time_in_ms : |
693 (animation_speed_ == ANIMATION_SPEED_FAST ? 10 : 0)); | |
Dmitry Polukhin
2014/04/10 00:11:48
I would extract it to separate method that gets no
Mr4D (OOO till 08-26)
2014/04/10 17:10:17
Done.
| |
686 | 694 |
687 if (visible) | 695 if (visible) |
688 window->Show(); | 696 window->Show(); |
689 else | 697 else |
690 window->Hide(); | 698 window->Hide(); |
691 | 699 |
692 // Make sure that animations have no influence on the window state after the | 700 // Make sure that animations have no influence on the window state after the |
693 // call. | 701 // call. |
694 DCHECK_EQ(visible, window->IsVisible()); | 702 DCHECK_EQ(visible, window->IsVisible()); |
695 } | 703 } |
696 | 704 |
697 } // namespace chrome | 705 } // namespace chrome |
OLD | NEW |