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

Side by Side Diff: chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc

Issue 232133003: Fixing too long running unit tests on valgrind (produced by user switch animation) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: self nit Created 6 years, 8 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 | Annotate | Revision Log
OLDNEW
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
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
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
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(
401 this, user_id, GetAdjustedAnimationTimeInMS(kUserFadeTimeMS)));
397 } 402 }
398 403
399 void MultiUserWindowManagerChromeOS::OnWindowDestroyed(aura::Window* window) { 404 void MultiUserWindowManagerChromeOS::OnWindowDestroyed(aura::Window* window) {
400 if (GetWindowOwner(window).empty()) { 405 if (GetWindowOwner(window).empty()) {
401 // This must be a window in the transient chain - remove it and its 406 // This must be a window in the transient chain - remove it and its
402 // children from the owner. 407 // children from the owner.
403 RemoveTransientOwnerRecursive(window); 408 RemoveTransientOwnerRecursive(window);
404 return; 409 return;
405 } 410 }
406 wm::TransientWindowManager::Get(window)->RemoveObserver(this); 411 wm::TransientWindowManager::Get(window)->RemoveObserver(this);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 } 483 }
479 484
480 void MultiUserWindowManagerChromeOS::Observe( 485 void MultiUserWindowManagerChromeOS::Observe(
481 int type, 486 int type,
482 const content::NotificationSource& source, 487 const content::NotificationSource& source,
483 const content::NotificationDetails& details) { 488 const content::NotificationDetails& details) {
484 if (type == NOTIFICATION_BROWSER_WINDOW_READY) 489 if (type == NOTIFICATION_BROWSER_WINDOW_READY)
485 AddBrowserWindow(content::Source<Browser>(source).ptr()); 490 AddBrowserWindow(content::Source<Browser>(source).ptr());
486 } 491 }
487 492
488 void MultiUserWindowManagerChromeOS::SetAnimationsForTest(bool disable) { 493 void MultiUserWindowManagerChromeOS::SetAnimationSpeedForTest(
489 animations_disabled_ = disable; 494 MultiUserWindowManagerChromeOS::AnimationSpeed speed) {
495 animation_speed_ = speed;
490 } 496 }
491 497
492 bool MultiUserWindowManagerChromeOS::IsAnimationRunningForTest() { 498 bool MultiUserWindowManagerChromeOS::IsAnimationRunningForTest() {
493 return animation_.get() != NULL && !animation_->IsAnimationFinished(); 499 return animation_.get() != NULL && !animation_->IsAnimationFinished();
494 } 500 }
495 501
496 const std::string& MultiUserWindowManagerChromeOS::GetCurrentUserForTest() { 502 const std::string& MultiUserWindowManagerChromeOS::GetCurrentUserForTest() {
497 return current_user_id_; 503 return current_user_id_;
498 } 504 }
499 505
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 window->Show(); 681 window->Show();
676 } 682 }
677 } 683 }
678 684
679 void MultiUserWindowManagerChromeOS::SetWindowVisible( 685 void MultiUserWindowManagerChromeOS::SetWindowVisible(
680 aura::Window* window, 686 aura::Window* window,
681 bool visible, 687 bool visible,
682 int animation_time_in_ms) { 688 int animation_time_in_ms) {
683 AnimationSetter animation_setter( 689 AnimationSetter animation_setter(
684 window, 690 window,
685 animations_disabled_ ? 0 : animation_time_in_ms); 691 GetAdjustedAnimationTimeInMS(animation_time_in_ms));
686 692
687 if (visible) 693 if (visible)
688 window->Show(); 694 window->Show();
689 else 695 else
690 window->Hide(); 696 window->Hide();
691 697
692 // Make sure that animations have no influence on the window state after the 698 // Make sure that animations have no influence on the window state after the
693 // call. 699 // call.
694 DCHECK_EQ(visible, window->IsVisible()); 700 DCHECK_EQ(visible, window->IsVisible());
695 } 701 }
696 702
703 int MultiUserWindowManagerChromeOS::GetAdjustedAnimationTimeInMS(
704 int default_time_in_ms) {
705 return animation_speed_ == ANIMATION_SPEED_NORMAL ? default_time_in_ms :
706 (animation_speed_ == ANIMATION_SPEED_FAST ? 10 : 0);
707 }
708
697 } // namespace chrome 709 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698