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

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

Issue 2424853003: Remove FOR_EACH_OBSERVER macro usage in chrome/browser/ui (Closed)
Patch Set: explicit types Created 4 years, 2 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 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/aura/wm_window_aura.h" 7 #include "ash/aura/wm_window_aura.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/shell_window_ids.h" 10 #include "ash/common/shell_window_ids.h"
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 // Check if this window was created due to a user interaction. If it was, 320 // Check if this window was created due to a user interaction. If it was,
321 // transfer it to the current user. 321 // transfer it to the current user.
322 if (IsProcessingUserEvent()) 322 if (IsProcessingUserEvent())
323 window_to_entry_[window]->set_show_for_user(current_account_id_); 323 window_to_entry_[window]->set_show_for_user(current_account_id_);
324 324
325 // Add all transient children to our set of windows. Note that the function 325 // Add all transient children to our set of windows. Note that the function
326 // will add the children but not the owner to the transient children map. 326 // will add the children but not the owner to the transient children map.
327 AddTransientOwnerRecursive(window, window); 327 AddTransientOwnerRecursive(window, window);
328 328
329 // Notify entry adding. 329 // Notify entry adding.
330 FOR_EACH_OBSERVER(Observer, observers_, OnOwnerEntryAdded(window)); 330 for (Observer& observer : observers_)
331 observer.OnOwnerEntryAdded(window);
331 332
332 if (!IsWindowOnDesktopOfUser(window, current_account_id_)) 333 if (!IsWindowOnDesktopOfUser(window, current_account_id_))
333 SetWindowVisibility(window, false, 0); 334 SetWindowVisibility(window, false, 0);
334 } 335 }
335 336
336 const AccountId& MultiUserWindowManagerChromeOS::GetWindowOwner( 337 const AccountId& MultiUserWindowManagerChromeOS::GetWindowOwner(
337 aura::Window* window) const { 338 aura::Window* window) const {
338 WindowToEntryMap::const_iterator it = window_to_entry_.find(window); 339 WindowToEntryMap::const_iterator it = window_to_entry_.find(window);
339 return it != window_to_entry_.end() ? it->second->owner() : EmptyAccountId(); 340 return it != window_to_entry_.end() ? it->second->owner() : EmptyAccountId();
340 } 341 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 // children from the owner. 454 // children from the owner.
454 RemoveTransientOwnerRecursive(window); 455 RemoveTransientOwnerRecursive(window);
455 return; 456 return;
456 } 457 }
457 wm::TransientWindowManager::Get(window)->RemoveObserver(this); 458 wm::TransientWindowManager::Get(window)->RemoveObserver(this);
458 // Remove the window from the owners list. 459 // Remove the window from the owners list.
459 delete window_to_entry_[window]; 460 delete window_to_entry_[window];
460 window_to_entry_.erase(window); 461 window_to_entry_.erase(window);
461 462
462 // Notify entry change. 463 // Notify entry change.
463 FOR_EACH_OBSERVER(Observer, observers_, OnOwnerEntryRemoved(window)); 464 for (Observer& observer : observers_)
465 observer.OnOwnerEntryRemoved(window);
464 } 466 }
465 467
466 void MultiUserWindowManagerChromeOS::OnWindowVisibilityChanging( 468 void MultiUserWindowManagerChromeOS::OnWindowVisibilityChanging(
467 aura::Window* window, bool visible) { 469 aura::Window* window, bool visible) {
468 // This command gets called first and immediately when show or hide gets 470 // This command gets called first and immediately when show or hide gets
469 // called. We remember here the desired state for restoration IF we were 471 // called. We remember here the desired state for restoration IF we were
470 // not ourselves issuing the call. 472 // not ourselves issuing the call.
471 // Note also that using the OnWindowVisibilityChanged callback cannot be 473 // Note also that using the OnWindowVisibilityChanged callback cannot be
472 // used for this. 474 // used for this.
473 if (suppress_visibility_changes_) 475 if (suppress_visibility_changes_)
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 // Show the window if the added user is the current one. 582 // Show the window if the added user is the current one.
581 if (account_id == current_account_id_) { 583 if (account_id == current_account_id_) {
582 // Only show the window if it should be shown according to its state. 584 // Only show the window if it should be shown according to its state.
583 if (it->second->show()) 585 if (it->second->show())
584 SetWindowVisibility(window, true, kTeleportAnimationTimeMS); 586 SetWindowVisibility(window, true, kTeleportAnimationTimeMS);
585 } else { 587 } else {
586 SetWindowVisibility(window, false, kTeleportAnimationTimeMS); 588 SetWindowVisibility(window, false, kTeleportAnimationTimeMS);
587 } 589 }
588 590
589 // Notify entry change. 591 // Notify entry change.
590 FOR_EACH_OBSERVER(Observer, observers_, OnOwnerEntryChanged(window)); 592 for (Observer& observer : observers_)
593 observer.OnOwnerEntryChanged(window);
591 return true; 594 return true;
592 } 595 }
593 596
594 void MultiUserWindowManagerChromeOS::SetWindowVisibility( 597 void MultiUserWindowManagerChromeOS::SetWindowVisibility(
595 aura::Window* window, bool visible, int animation_time_in_ms) { 598 aura::Window* window, bool visible, int animation_time_in_ms) {
596 // For a panel window, it's possible that this panel window is in the middle 599 // For a panel window, it's possible that this panel window is in the middle
597 // of relayout animation because of hiding/reshowing shelf during profile 600 // of relayout animation because of hiding/reshowing shelf during profile
598 // switch. Thus the window's visibility might not be its real visibility. See 601 // switch. Thus the window's visibility might not be its real visibility. See
599 // crbug.com/564725 for more info. 602 // crbug.com/564725 for more info.
600 if (window->TargetVisibility() == visible) 603 if (window->TargetVisibility() == visible)
(...skipping 24 matching lines...) Expand all
625 // suppressing any window entry changes while this is going on. 628 // suppressing any window entry changes while this is going on.
626 base::AutoReset<bool> suppressor(&suppress_visibility_changes_, true); 629 base::AutoReset<bool> suppressor(&suppress_visibility_changes_, true);
627 630
628 if (visible) 631 if (visible)
629 ShowWithTransientChildrenRecursive(window, animation_time_in_ms); 632 ShowWithTransientChildrenRecursive(window, animation_time_in_ms);
630 else 633 else
631 SetWindowVisible(window, false, animation_time_in_ms); 634 SetWindowVisible(window, false, animation_time_in_ms);
632 } 635 }
633 636
634 void MultiUserWindowManagerChromeOS::NotifyAfterUserSwitchAnimationFinished() { 637 void MultiUserWindowManagerChromeOS::NotifyAfterUserSwitchAnimationFinished() {
635 FOR_EACH_OBSERVER(Observer, observers_, OnUserSwitchAnimationFinished()); 638 for (Observer& observer : observers_)
639 observer.OnUserSwitchAnimationFinished();
636 } 640 }
637 641
638 void MultiUserWindowManagerChromeOS::AddBrowserWindow(Browser* browser) { 642 void MultiUserWindowManagerChromeOS::AddBrowserWindow(Browser* browser) {
639 // A unit test (e.g. CrashRestoreComplexTest.RestoreSessionForThreeUsers) can 643 // A unit test (e.g. CrashRestoreComplexTest.RestoreSessionForThreeUsers) can
640 // come here with no valid window. 644 // come here with no valid window.
641 if (!browser->window() || !browser->window()->GetNativeWindow()) 645 if (!browser->window() || !browser->window()->GetNativeWindow())
642 return; 646 return;
643 SetWindowOwner(browser->window()->GetNativeWindow(), 647 SetWindowOwner(browser->window()->GetNativeWindow(),
644 multi_user_util::GetAccountIdFromProfile(browser->profile())); 648 multi_user_util::GetAccountIdFromProfile(browser->profile()));
645 } 649 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 window->Hide(); 756 window->Hide();
753 } 757 }
754 758
755 int MultiUserWindowManagerChromeOS::GetAdjustedAnimationTimeInMS( 759 int MultiUserWindowManagerChromeOS::GetAdjustedAnimationTimeInMS(
756 int default_time_in_ms) const { 760 int default_time_in_ms) const {
757 return animation_speed_ == ANIMATION_SPEED_NORMAL ? default_time_in_ms : 761 return animation_speed_ == ANIMATION_SPEED_NORMAL ? default_time_in_ms :
758 (animation_speed_ == ANIMATION_SPEED_FAST ? 10 : 0); 762 (animation_speed_ == ANIMATION_SPEED_FAST ? 10 : 0);
759 } 763 }
760 764
761 } // namespace chrome 765 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/cast_config_delegate_media_router.cc ('k') | chrome/browser/ui/ash/session_state_delegate_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698