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

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

Issue 115453004: Moves management of transients out of Window (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove unneeded parens Created 6 years, 11 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/shell_window.h" 7 #include "apps/shell_window.h"
8 #include "apps/shell_window_registry.h" 8 #include "apps/shell_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 18 matching lines...) Expand all
29 #include "chrome/browser/ui/browser_list.h" 29 #include "chrome/browser/ui/browser_list.h"
30 #include "chrome/browser/ui/browser_window.h" 30 #include "chrome/browser/ui/browser_window.h"
31 #include "content/public/browser/notification_service.h" 31 #include "content/public/browser/notification_service.h"
32 #include "google_apis/gaia/gaia_auth_util.h" 32 #include "google_apis/gaia/gaia_auth_util.h"
33 #include "ui/aura/client/activation_client.h" 33 #include "ui/aura/client/activation_client.h"
34 #include "ui/aura/client/aura_constants.h" 34 #include "ui/aura/client/aura_constants.h"
35 #include "ui/aura/root_window.h" 35 #include "ui/aura/root_window.h"
36 #include "ui/aura/window.h" 36 #include "ui/aura/window.h"
37 #include "ui/base/ui_base_types.h" 37 #include "ui/base/ui_base_types.h"
38 #include "ui/events/event.h" 38 #include "ui/events/event.h"
39 #include "ui/views/corewm/window_util.h"
39 40
40 namespace { 41 namespace {
41 42
42 // Checks if a given event is a user event. 43 // Checks if a given event is a user event.
43 bool IsUserEvent(ui::Event* e) { 44 bool IsUserEvent(ui::Event* e) {
44 if (e) { 45 if (e) {
45 ui::EventType type = e->type(); 46 ui::EventType type = e->type();
46 if (type != ui::ET_CANCEL_MODE && 47 if (type != ui::ET_CANCEL_MODE &&
47 type != ui::ET_UMA_DATA && 48 type != ui::ET_UMA_DATA &&
48 type != ui::ET_UNKNOWN) 49 type != ui::ET_UNKNOWN)
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 } else { 556 } else {
556 if (window->HasFocus()) 557 if (window->HasFocus())
557 window->Blur(); 558 window->Blur();
558 window->Hide(); 559 window->Hide();
559 } 560 }
560 } 561 }
561 562
562 void MultiUserWindowManagerChromeOS::ShowWithTransientChildrenRecursive( 563 void MultiUserWindowManagerChromeOS::ShowWithTransientChildrenRecursive(
563 aura::Window* window) { 564 aura::Window* window) {
564 aura::Window::Windows::const_iterator it = 565 aura::Window::Windows::const_iterator it =
565 window->transient_children().begin(); 566 views::corewm::GetTransientChildren(window).begin();
566 for (; it != window->transient_children().end(); ++it) 567 for (; it != views::corewm::GetTransientChildren(window).end(); ++it)
567 ShowWithTransientChildrenRecursive(*it); 568 ShowWithTransientChildrenRecursive(*it);
568 569
569 // We show all children which were not explicitly hidden. 570 // We show all children which were not explicitly hidden.
570 TransientWindowToVisibility::iterator it2 = 571 TransientWindowToVisibility::iterator it2 =
571 transient_window_to_visibility_.find(window); 572 transient_window_to_visibility_.find(window);
572 if (it2 == transient_window_to_visibility_.end() || it2->second) 573 if (it2 == transient_window_to_visibility_.end() || it2->second)
573 window->Show(); 574 window->Show();
574 } 575 }
575 576
576 aura::Window* MultiUserWindowManagerChromeOS::GetOwningWindowInTransientChain( 577 aura::Window* MultiUserWindowManagerChromeOS::GetOwningWindowInTransientChain(
577 aura::Window* window) { 578 aura::Window* window) {
578 if (!GetWindowOwner(window).empty()) 579 if (!GetWindowOwner(window).empty())
579 return NULL; 580 return NULL;
580 aura::Window* parent = window->transient_parent(); 581 aura::Window* parent = views::corewm::GetTransientParent(window);
581 while (parent) { 582 while (parent) {
582 if (!GetWindowOwner(parent).empty()) 583 if (!GetWindowOwner(parent).empty())
583 return parent; 584 return parent;
584 parent = parent->transient_parent(); 585 parent = views::corewm::GetTransientParent(parent);
585 } 586 }
586 return NULL; 587 return NULL;
587 } 588 }
588 589
589 void MultiUserWindowManagerChromeOS::AddTransientOwnerRecursive( 590 void MultiUserWindowManagerChromeOS::AddTransientOwnerRecursive(
590 aura::Window* window, 591 aura::Window* window,
591 aura::Window* owned_parent) { 592 aura::Window* owned_parent) {
592 // First add all child windows. 593 // First add all child windows.
593 aura::Window::Windows::const_iterator it = 594 aura::Window::Windows::const_iterator it =
594 window->transient_children().begin(); 595 views::corewm::GetTransientChildren(window).begin();
595 for (; it != window->transient_children().end(); ++it) 596 for (; it != views::corewm::GetTransientChildren(window).end(); ++it)
596 AddTransientOwnerRecursive(*it, owned_parent); 597 AddTransientOwnerRecursive(*it, owned_parent);
597 598
598 // If this window is the owned window, we do not have to handle it again. 599 // If this window is the owned window, we do not have to handle it again.
599 if (window == owned_parent) 600 if (window == owned_parent)
600 return; 601 return;
601 602
602 // Remember the current visibility. 603 // Remember the current visibility.
603 DCHECK(transient_window_to_visibility_.find(window) == 604 DCHECK(transient_window_to_visibility_.find(window) ==
604 transient_window_to_visibility_.end()); 605 transient_window_to_visibility_.end());
605 transient_window_to_visibility_[window] = window->IsVisible(); 606 transient_window_to_visibility_[window] = window->IsVisible();
606 607
607 // Add a window observer to make sure that we catch status changes. 608 // Add a window observer to make sure that we catch status changes.
608 window->AddObserver(this); 609 window->AddObserver(this);
609 610
610 // Hide the window if it should not be shown. Note that this hide operation 611 // Hide the window if it should not be shown. Note that this hide operation
611 // will hide recursively this and all children - but we have already collected 612 // will hide recursively this and all children - but we have already collected
612 // their initial view state. 613 // their initial view state.
613 if (!IsWindowOnDesktopOfUser(owned_parent, current_user_id_)) 614 if (!IsWindowOnDesktopOfUser(owned_parent, current_user_id_))
614 SetWindowVisibility(window, false); 615 SetWindowVisibility(window, false);
615 } 616 }
616 617
617 void MultiUserWindowManagerChromeOS::RemoveTransientOwnerRecursive( 618 void MultiUserWindowManagerChromeOS::RemoveTransientOwnerRecursive(
618 aura::Window* window) { 619 aura::Window* window) {
619 // First remove all child windows. 620 // First remove all child windows.
620 aura::Window::Windows::const_iterator it = 621 aura::Window::Windows::const_iterator it =
621 window->transient_children().begin(); 622 views::corewm::GetTransientChildren(window).begin();
622 for (; it != window->transient_children().end(); ++it) 623 for (; it != views::corewm::GetTransientChildren(window).end(); ++it)
623 RemoveTransientOwnerRecursive(*it); 624 RemoveTransientOwnerRecursive(*it);
624 625
625 // Find from transient window storage the visibility for the given window, 626 // Find from transient window storage the visibility for the given window,
626 // set the visibility accordingly and delete the window from the map. 627 // set the visibility accordingly and delete the window from the map.
627 TransientWindowToVisibility::iterator visibility_item = 628 TransientWindowToVisibility::iterator visibility_item =
628 transient_window_to_visibility_.find(window); 629 transient_window_to_visibility_.find(window);
629 DCHECK(visibility_item != transient_window_to_visibility_.end()); 630 DCHECK(visibility_item != transient_window_to_visibility_.end());
630 631
631 // Remove the window observer. 632 // Remove the window observer.
632 window->RemoveObserver(this); 633 window->RemoveObserver(this);
633 634
634 bool unowned_view_state = visibility_item->second; 635 bool unowned_view_state = visibility_item->second;
635 transient_window_to_visibility_.erase(visibility_item); 636 transient_window_to_visibility_.erase(visibility_item);
636 if (unowned_view_state && !window->IsVisible()) { 637 if (unowned_view_state && !window->IsVisible()) {
637 // To prevent these commands from being recorded as any other commands, we 638 // To prevent these commands from being recorded as any other commands, we
638 // are suppressing any window entry changes while this is going on. 639 // are suppressing any window entry changes while this is going on.
639 // Instead of calling SetWindowVisible, only show gets called here since all 640 // Instead of calling SetWindowVisible, only show gets called here since all
640 // dependents have been shown previously already. 641 // dependents have been shown previously already.
641 base::AutoReset<bool> suppressor(&suppress_visibility_changes_, true); 642 base::AutoReset<bool> suppressor(&suppress_visibility_changes_, true);
642 window->Show(); 643 window->Show();
643 } 644 }
644 } 645 }
645 646
646 } // namespace chrome 647 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698