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

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

Issue 2910773002: cros: CustomFrameViewAsh avatar icon from a window prop (Closed)
Patch Set: rebase Created 3 years, 6 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 <set>
8 #include <vector>
9
7 #include "ash/media_controller.h" 10 #include "ash/media_controller.h"
8 #include "ash/multi_profile_uma.h" 11 #include "ash/multi_profile_uma.h"
9 #include "ash/public/cpp/shell_window_ids.h" 12 #include "ash/public/cpp/shell_window_ids.h"
10 #include "ash/shell.h" 13 #include "ash/shell.h"
11 #include "ash/wm/maximize_mode/maximize_mode_controller.h" 14 #include "ash/wm/maximize_mode/maximize_mode_controller.h"
12 #include "ash/wm/window_state.h" 15 #include "ash/wm/window_state.h"
13 #include "ash/wm_window.h" 16 #include "ash/wm_window.h"
14 #include "base/auto_reset.h" 17 #include "base/auto_reset.h"
15 #include "base/macros.h" 18 #include "base/macros.h"
16 #include "base/message_loop/message_loop.h" 19 #include "base/message_loop/message_loop.h"
17 #include "base/strings/string_util.h" 20 #include "base/strings/string_util.h"
18 #include "chrome/browser/browser_process.h" 21 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/chrome_notification_types.h" 22 #include "chrome/browser/chrome_notification_types.h"
20 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/profiles/profile_manager.h" 24 #include "chrome/browser/profiles/profile_manager.h"
22 #include "chrome/browser/ui/ash/multi_user/multi_user_notification_blocker_chrom eos.h" 25 #include "chrome/browser/ui/ash/multi_user/multi_user_notification_blocker_chrom eos.h"
23 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" 26 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
24 #include "chrome/browser/ui/ash/multi_user/user_switch_animator_chromeos.h" 27 #include "chrome/browser/ui/ash/multi_user/user_switch_animator_chromeos.h"
25 #include "chrome/browser/ui/ash/session_controller_client.h" 28 #include "chrome/browser/ui/ash/session_controller_client.h"
29 #include "chrome/browser/ui/ash/session_util.h"
26 #include "chrome/browser/ui/browser.h" 30 #include "chrome/browser/ui/browser.h"
27 #include "chrome/browser/ui/browser_finder.h" 31 #include "chrome/browser/ui/browser_finder.h"
28 #include "chrome/browser/ui/browser_list.h" 32 #include "chrome/browser/ui/browser_list.h"
29 #include "chrome/browser/ui/browser_window.h" 33 #include "chrome/browser/ui/browser_window.h"
30 #include "content/public/browser/notification_service.h" 34 #include "content/public/browser/notification_service.h"
31 #include "extensions/browser/app_window/app_window.h" 35 #include "extensions/browser/app_window/app_window.h"
32 #include "extensions/browser/app_window/app_window_registry.h" 36 #include "extensions/browser/app_window/app_window_registry.h"
33 #include "ui/aura/client/aura_constants.h" 37 #include "ui/aura/client/aura_constants.h"
34 #include "ui/aura/window.h" 38 #include "ui/aura/window.h"
35 #include "ui/aura/window_event_dispatcher.h" 39 #include "ui/aura/window_event_dispatcher.h"
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 ash::MultiProfileUMA::TELEPORT_WINDOW_RETURN_BY_MINIMIZE); 523 ash::MultiProfileUMA::TELEPORT_WINDOW_RETURN_BY_MINIMIZE);
520 } else { 524 } else {
521 // If the window was transferred without getting minimized, we should record 525 // If the window was transferred without getting minimized, we should record
522 // the window type. 526 // the window type.
523 RecordUMAForTransferredWindowType(window); 527 RecordUMAForTransferredWindowType(window);
524 } 528 }
525 529
526 WindowToEntryMap::iterator it = window_to_entry_.find(window); 530 WindowToEntryMap::iterator it = window_to_entry_.find(window);
527 it->second->set_show_for_user(account_id); 531 it->second->set_show_for_user(account_id);
528 532
533 // Show avatar icon on the teleported window for separated mode.
534 if (GetMultiProfileMode() == MULTI_PROFILE_MODE_SEPARATED) {
535 // Tests could either not have a UserManager or the UserManager does not
536 // know the window owner.
537 const user_manager::User* const window_owner =
538 user_manager::UserManager::IsInitialized()
539 ? user_manager::UserManager::Get()->FindUser(owner)
540 : nullptr;
541
542 const bool teleported = !IsWindowOnDesktopOfUser(window, owner);
543 if (window_owner && teleported) {
544 window->SetProperty(
545 aura::client::kAvatarIconKey,
546 new gfx::ImageSkia(GetAvatarImageForUser(window_owner)));
547 } else {
548 window->ClearProperty(aura::client::kAvatarIconKey);
549 }
550 }
James Cook 2017/05/30 21:27:15 If it's not too hard, could you add test coverage
xiyuan 2017/05/30 22:44:14 Done.
551
529 // Show the window if the added user is the current one. 552 // Show the window if the added user is the current one.
530 if (account_id == current_account_id_) { 553 if (account_id == current_account_id_) {
531 // Only show the window if it should be shown according to its state. 554 // Only show the window if it should be shown according to its state.
532 if (it->second->show()) 555 if (it->second->show())
533 SetWindowVisibility(window, true, kTeleportAnimationTimeMS); 556 SetWindowVisibility(window, true, kTeleportAnimationTimeMS);
534 } else { 557 } else {
535 SetWindowVisibility(window, false, kTeleportAnimationTimeMS); 558 SetWindowVisibility(window, false, kTeleportAnimationTimeMS);
536 } 559 }
537 560
538 // Notify entry change. 561 // Notify entry change.
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 window->Hide(); 723 window->Hide();
701 } 724 }
702 725
703 int MultiUserWindowManagerChromeOS::GetAdjustedAnimationTimeInMS( 726 int MultiUserWindowManagerChromeOS::GetAdjustedAnimationTimeInMS(
704 int default_time_in_ms) const { 727 int default_time_in_ms) const {
705 return animation_speed_ == ANIMATION_SPEED_NORMAL ? default_time_in_ms : 728 return animation_speed_ == ANIMATION_SPEED_NORMAL ? default_time_in_ms :
706 (animation_speed_ == ANIMATION_SPEED_FAST ? 10 : 0); 729 (animation_speed_ == ANIMATION_SPEED_FAST ? 10 : 0);
707 } 730 }
708 731
709 } // namespace chrome 732 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698