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

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

Issue 196063002: Move wm/core to wm namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 9 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/desktop_background/user_wallpaper_delegate.h" 10 #include "ash/desktop_background/user_wallpaper_delegate.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } // namespace 148 } // namespace
149 149
150 namespace chrome { 150 namespace chrome {
151 151
152 // A class to temporarily change the animation properties for a window. 152 // A class to temporarily change the animation properties for a window.
153 class AnimationSetter { 153 class AnimationSetter {
154 public: 154 public:
155 AnimationSetter(aura::Window* window, int animation_time_in_ms) 155 AnimationSetter(aura::Window* window, int animation_time_in_ms)
156 : window_(window), 156 : window_(window),
157 previous_animation_type_( 157 previous_animation_type_(
158 views::corewm::GetWindowVisibilityAnimationType(window_)), 158 wm::GetWindowVisibilityAnimationType(window_)),
159 previous_animation_time_( 159 previous_animation_time_(
160 views::corewm::GetWindowVisibilityAnimationDuration(*window_)) { 160 wm::GetWindowVisibilityAnimationDuration(*window_)) {
161 views::corewm::SetWindowVisibilityAnimationType( 161 wm::SetWindowVisibilityAnimationType(
162 window_, 162 window_,
163 views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); 163 wm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE);
164 views::corewm::SetWindowVisibilityAnimationDuration( 164 wm::SetWindowVisibilityAnimationDuration(
165 window_, 165 window_,
166 base::TimeDelta::FromMilliseconds(animation_time_in_ms)); 166 base::TimeDelta::FromMilliseconds(animation_time_in_ms));
167 } 167 }
168 168
169 ~AnimationSetter() { 169 ~AnimationSetter() {
170 views::corewm::SetWindowVisibilityAnimationType(window_, 170 wm::SetWindowVisibilityAnimationType(window_,
171 previous_animation_type_); 171 previous_animation_type_);
172 views::corewm::SetWindowVisibilityAnimationDuration( 172 wm::SetWindowVisibilityAnimationDuration(
173 window_, 173 window_,
174 previous_animation_time_); 174 previous_animation_time_);
175 } 175 }
176 176
177 private: 177 private:
178 // The window which gets used. 178 // The window which gets used.
179 aura::Window* window_; 179 aura::Window* window_;
180 180
181 // Previous animation type. 181 // Previous animation type.
182 const int previous_animation_type_; 182 const int previous_animation_type_;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 if (GetWindowOwner(window) == user_id) 289 if (GetWindowOwner(window) == user_id)
290 return; 290 return;
291 DCHECK(GetWindowOwner(window).empty()); 291 DCHECK(GetWindowOwner(window).empty());
292 window_to_entry_[window] = new WindowEntry(user_id); 292 window_to_entry_[window] = new WindowEntry(user_id);
293 293
294 // Remember the initial visibility of the window. 294 // Remember the initial visibility of the window.
295 window_to_entry_[window]->set_show(window->IsVisible()); 295 window_to_entry_[window]->set_show(window->IsVisible());
296 296
297 // Add observers to track state changes. 297 // Add observers to track state changes.
298 window->AddObserver(this); 298 window->AddObserver(this);
299 views::corewm::TransientWindowManager::Get(window)->AddObserver(this); 299 wm::TransientWindowManager::Get(window)->AddObserver(this);
300 300
301 // Check if this window was created due to a user interaction. If it was, 301 // Check if this window was created due to a user interaction. If it was,
302 // transfer it to the current user. 302 // transfer it to the current user.
303 if (IsProcessingUserEvent()) 303 if (IsProcessingUserEvent())
304 window_to_entry_[window]->set_show_for_user(current_user_id_); 304 window_to_entry_[window]->set_show_for_user(current_user_id_);
305 305
306 // Add all transient children to our set of windows. Note that the function 306 // Add all transient children to our set of windows. Note that the function
307 // will add the children but not the owner to the transient children map. 307 // will add the children but not the owner to the transient children map.
308 AddTransientOwnerRecursive(window, window); 308 AddTransientOwnerRecursive(window, window);
309 309
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 } 437 }
438 } 438 }
439 439
440 void MultiUserWindowManagerChromeOS::OnWindowDestroyed(aura::Window* window) { 440 void MultiUserWindowManagerChromeOS::OnWindowDestroyed(aura::Window* window) {
441 if (GetWindowOwner(window).empty()) { 441 if (GetWindowOwner(window).empty()) {
442 // This must be a window in the transient chain - remove it and its 442 // This must be a window in the transient chain - remove it and its
443 // children from the owner. 443 // children from the owner.
444 RemoveTransientOwnerRecursive(window); 444 RemoveTransientOwnerRecursive(window);
445 return; 445 return;
446 } 446 }
447 views::corewm::TransientWindowManager::Get(window)->RemoveObserver(this); 447 wm::TransientWindowManager::Get(window)->RemoveObserver(this);
448 // Remove the window from the owners list. 448 // Remove the window from the owners list.
449 delete window_to_entry_[window]; 449 delete window_to_entry_[window];
450 window_to_entry_.erase(window); 450 window_to_entry_.erase(window);
451 451
452 // Notify entry change. 452 // Notify entry change.
453 FOR_EACH_OBSERVER(Observer, observers_, OnOwnerEntryRemoved(window)); 453 FOR_EACH_OBSERVER(Observer, observers_, OnOwnerEntryRemoved(window));
454 } 454 }
455 455
456 void MultiUserWindowManagerChromeOS::OnWindowVisibilityChanging( 456 void MultiUserWindowManagerChromeOS::OnWindowVisibilityChanging(
457 aura::Window* window, bool visible) { 457 aura::Window* window, bool visible) {
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 } else { 762 } else {
763 if (window->HasFocus()) 763 if (window->HasFocus())
764 window->Blur(); 764 window->Blur();
765 SetWindowVisible(window, false, animation_time_in_ms); 765 SetWindowVisible(window, false, animation_time_in_ms);
766 } 766 }
767 } 767 }
768 768
769 void MultiUserWindowManagerChromeOS::ShowWithTransientChildrenRecursive( 769 void MultiUserWindowManagerChromeOS::ShowWithTransientChildrenRecursive(
770 aura::Window* window, int animation_time_in_ms) { 770 aura::Window* window, int animation_time_in_ms) {
771 aura::Window::Windows::const_iterator it = 771 aura::Window::Windows::const_iterator it =
772 views::corewm::GetTransientChildren(window).begin(); 772 wm::GetTransientChildren(window).begin();
773 for (; it != views::corewm::GetTransientChildren(window).end(); ++it) 773 for (; it != wm::GetTransientChildren(window).end(); ++it)
774 ShowWithTransientChildrenRecursive(*it, animation_time_in_ms); 774 ShowWithTransientChildrenRecursive(*it, animation_time_in_ms);
775 775
776 // We show all children which were not explicitly hidden. 776 // We show all children which were not explicitly hidden.
777 TransientWindowToVisibility::iterator it2 = 777 TransientWindowToVisibility::iterator it2 =
778 transient_window_to_visibility_.find(window); 778 transient_window_to_visibility_.find(window);
779 if (it2 == transient_window_to_visibility_.end() || it2->second) 779 if (it2 == transient_window_to_visibility_.end() || it2->second)
780 SetWindowVisible(window, true, animation_time_in_ms); 780 SetWindowVisible(window, true, animation_time_in_ms);
781 } 781 }
782 782
783 aura::Window* MultiUserWindowManagerChromeOS::GetOwningWindowInTransientChain( 783 aura::Window* MultiUserWindowManagerChromeOS::GetOwningWindowInTransientChain(
784 aura::Window* window) { 784 aura::Window* window) {
785 if (!GetWindowOwner(window).empty()) 785 if (!GetWindowOwner(window).empty())
786 return NULL; 786 return NULL;
787 aura::Window* parent = views::corewm::GetTransientParent(window); 787 aura::Window* parent = wm::GetTransientParent(window);
788 while (parent) { 788 while (parent) {
789 if (!GetWindowOwner(parent).empty()) 789 if (!GetWindowOwner(parent).empty())
790 return parent; 790 return parent;
791 parent = views::corewm::GetTransientParent(parent); 791 parent = wm::GetTransientParent(parent);
792 } 792 }
793 return NULL; 793 return NULL;
794 } 794 }
795 795
796 void MultiUserWindowManagerChromeOS::AddTransientOwnerRecursive( 796 void MultiUserWindowManagerChromeOS::AddTransientOwnerRecursive(
797 aura::Window* window, 797 aura::Window* window,
798 aura::Window* owned_parent) { 798 aura::Window* owned_parent) {
799 // First add all child windows. 799 // First add all child windows.
800 aura::Window::Windows::const_iterator it = 800 aura::Window::Windows::const_iterator it =
801 views::corewm::GetTransientChildren(window).begin(); 801 wm::GetTransientChildren(window).begin();
802 for (; it != views::corewm::GetTransientChildren(window).end(); ++it) 802 for (; it != wm::GetTransientChildren(window).end(); ++it)
803 AddTransientOwnerRecursive(*it, owned_parent); 803 AddTransientOwnerRecursive(*it, owned_parent);
804 804
805 // If this window is the owned window, we do not have to handle it again. 805 // If this window is the owned window, we do not have to handle it again.
806 if (window == owned_parent) 806 if (window == owned_parent)
807 return; 807 return;
808 808
809 // Remember the current visibility. 809 // Remember the current visibility.
810 DCHECK(transient_window_to_visibility_.find(window) == 810 DCHECK(transient_window_to_visibility_.find(window) ==
811 transient_window_to_visibility_.end()); 811 transient_window_to_visibility_.end());
812 transient_window_to_visibility_[window] = window->IsVisible(); 812 transient_window_to_visibility_[window] = window->IsVisible();
813 813
814 // Add observers to track state changes. 814 // Add observers to track state changes.
815 window->AddObserver(this); 815 window->AddObserver(this);
816 views::corewm::TransientWindowManager::Get(window)->AddObserver(this); 816 wm::TransientWindowManager::Get(window)->AddObserver(this);
817 817
818 // Hide the window if it should not be shown. Note that this hide operation 818 // Hide the window if it should not be shown. Note that this hide operation
819 // will hide recursively this and all children - but we have already collected 819 // will hide recursively this and all children - but we have already collected
820 // their initial view state. 820 // their initial view state.
821 if (!IsWindowOnDesktopOfUser(owned_parent, current_user_id_)) 821 if (!IsWindowOnDesktopOfUser(owned_parent, current_user_id_))
822 SetWindowVisibility(window, false, kAnimationTimeMS); 822 SetWindowVisibility(window, false, kAnimationTimeMS);
823 } 823 }
824 824
825 void MultiUserWindowManagerChromeOS::RemoveTransientOwnerRecursive( 825 void MultiUserWindowManagerChromeOS::RemoveTransientOwnerRecursive(
826 aura::Window* window) { 826 aura::Window* window) {
827 // First remove all child windows. 827 // First remove all child windows.
828 aura::Window::Windows::const_iterator it = 828 aura::Window::Windows::const_iterator it =
829 views::corewm::GetTransientChildren(window).begin(); 829 wm::GetTransientChildren(window).begin();
830 for (; it != views::corewm::GetTransientChildren(window).end(); ++it) 830 for (; it != wm::GetTransientChildren(window).end(); ++it)
831 RemoveTransientOwnerRecursive(*it); 831 RemoveTransientOwnerRecursive(*it);
832 832
833 // Find from transient window storage the visibility for the given window, 833 // Find from transient window storage the visibility for the given window,
834 // set the visibility accordingly and delete the window from the map. 834 // set the visibility accordingly and delete the window from the map.
835 TransientWindowToVisibility::iterator visibility_item = 835 TransientWindowToVisibility::iterator visibility_item =
836 transient_window_to_visibility_.find(window); 836 transient_window_to_visibility_.find(window);
837 DCHECK(visibility_item != transient_window_to_visibility_.end()); 837 DCHECK(visibility_item != transient_window_to_visibility_.end());
838 838
839 window->RemoveObserver(this); 839 window->RemoveObserver(this);
840 views::corewm::TransientWindowManager::Get(window)->RemoveObserver(this); 840 wm::TransientWindowManager::Get(window)->RemoveObserver(this);
841 841
842 bool unowned_view_state = visibility_item->second; 842 bool unowned_view_state = visibility_item->second;
843 transient_window_to_visibility_.erase(visibility_item); 843 transient_window_to_visibility_.erase(visibility_item);
844 if (unowned_view_state && !window->IsVisible()) { 844 if (unowned_view_state && !window->IsVisible()) {
845 // To prevent these commands from being recorded as any other commands, we 845 // To prevent these commands from being recorded as any other commands, we
846 // are suppressing any window entry changes while this is going on. 846 // are suppressing any window entry changes while this is going on.
847 // Instead of calling SetWindowVisible, only show gets called here since all 847 // Instead of calling SetWindowVisible, only show gets called here since all
848 // dependents have been shown previously already. 848 // dependents have been shown previously already.
849 base::AutoReset<bool> suppressor(&suppress_visibility_changes_, true); 849 base::AutoReset<bool> suppressor(&suppress_visibility_changes_, true);
850 window->Show(); 850 window->Show();
(...skipping 12 matching lines...) Expand all
863 window->Show(); 863 window->Show();
864 else 864 else
865 window->Hide(); 865 window->Hide();
866 866
867 // Make sure that animations have no influence on the window state after the 867 // Make sure that animations have no influence on the window state after the
868 // call. 868 // call.
869 DCHECK_EQ(visible, window->IsVisible()); 869 DCHECK_EQ(visible, window->IsVisible());
870 } 870 }
871 871
872 } // namespace chrome 872 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698