 Chromium Code Reviews
 Chromium Code Reviews Issue 148093008:
  Create a dialog that warns about possible UI-oddities of the multi-profiles window teleport  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 148093008:
  Create a dialog that warns about possible UI-oddities of the multi-profiles window teleport  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| Index: chrome/browser/ui/ash/multi_user/multi_user_context_menu_chromeos.cc | 
| diff --git a/chrome/browser/ui/ash/multi_user/multi_user_context_menu_chromeos.cc b/chrome/browser/ui/ash/multi_user/multi_user_context_menu_chromeos.cc | 
| index 595f02e2c43531a8470d00741ffdaaf33e0a635d..5acc067ca23003853fcbe7d5690d0ebfcf0c1ee2 100644 | 
| --- a/chrome/browser/ui/ash/multi_user/multi_user_context_menu_chromeos.cc | 
| +++ b/chrome/browser/ui/ash/multi_user/multi_user_context_menu_chromeos.cc | 
| @@ -7,14 +7,25 @@ | 
| #include "ash/multi_profile_uma.h" | 
| #include "ash/session_state_delegate.h" | 
| #include "ash/shell.h" | 
| +#include "base/bind.h" | 
| +#include "base/callback.h" | 
| +#include "base/prefs/pref_service.h" | 
| #include "chrome/app/chrome_command_ids.h" | 
| +#include "chrome/browser/chromeos/login/user.h" | 
| +#include "chrome/browser/chromeos/login/user_manager.h" | 
| +#include "chrome/browser/profiles/profile.h" | 
| +#include "chrome/browser/profiles/profile_manager.h" | 
| #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | 
| +#include "chrome/browser/ui/ash/multi_user/multi_user_warning_dialog.h" | 
| #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" | 
| +#include "chrome/common/pref_names.h" | 
| #include "grit/generated_resources.h" | 
| #include "ui/aura/window.h" | 
| #include "ui/base/l10n/l10n_util.h" | 
| #include "ui/base/models/simple_menu_model.h" | 
| +namespace chromeos { | 
| + | 
| namespace { | 
| class MultiUserContextMenuChromeos : public ui::SimpleMenuModel, | 
| @@ -51,27 +62,11 @@ MultiUserContextMenuChromeos::MultiUserContextMenuChromeos(aura::Window* window) | 
| void MultiUserContextMenuChromeos::ExecuteCommand(int command_id, | 
| int event_flags) { | 
| - switch (command_id) { | 
| - case IDC_VISIT_DESKTOP_OF_LRU_USER_2: | 
| - case IDC_VISIT_DESKTOP_OF_LRU_USER_3: { | 
| - ash::MultiProfileUMA::RecordTeleportAction( | 
| - ash::MultiProfileUMA::TELEPORT_WINDOW_CAPTION_MENU); | 
| - // When running the multi user mode on Chrome OS, windows can "visit" | 
| - // another user's desktop. | 
| - const std::string& user_id = | 
| - ash::Shell::GetInstance()->session_state_delegate()->GetUserID( | 
| - IDC_VISIT_DESKTOP_OF_LRU_USER_2 == command_id ? 1 : 2); | 
| - chrome::MultiUserWindowManager::GetInstance()->ShowWindowForUser( | 
| - window_, | 
| - user_id); | 
| - return; | 
| - } | 
| - default: | 
| - NOTREACHED(); | 
| - } | 
| + ExecuteVisitDesktopCommand(command_id, window_); | 
| } | 
| } // namespace | 
| +} // namespace chromeos | 
| scoped_ptr<ui::MenuModel> CreateMultiUserContextMenu( | 
| aura::Window* window) { | 
| @@ -87,8 +82,8 @@ scoped_ptr<ui::MenuModel> CreateMultiUserContextMenu( | 
| if (user_id.empty() || !window || | 
| manager->GetWindowOwner(window).empty()) | 
| return model.Pass(); | 
| - MultiUserContextMenuChromeos* menu = | 
| - new MultiUserContextMenuChromeos(window); | 
| + chromeos::MultiUserContextMenuChromeos* menu = | 
| + new chromeos::MultiUserContextMenuChromeos(window); | 
| model.reset(menu); | 
| for (int user_index = 1; user_index < logged_in_users; ++user_index) { | 
| menu->AddItem( | 
| @@ -101,3 +96,54 @@ scoped_ptr<ui::MenuModel> CreateMultiUserContextMenu( | 
| } | 
| return model.Pass(); | 
| } | 
| + | 
| +void OnAcceptTeleportWarning( | 
| + const std::string user_id, aura::Window* window_, bool no_show_again) { | 
| + PrefService* pref = ProfileManager::GetActiveUserProfile()->GetPrefs(); | 
| + pref->SetBoolean(prefs::kMultiProfileWarningShowDismissed, no_show_again); | 
| + | 
| + ash::MultiProfileUMA::RecordTeleportAction( | 
| + ash::MultiProfileUMA::TELEPORT_WINDOW_CAPTION_MENU); | 
| + | 
| + chrome::MultiUserWindowManager::GetInstance()->ShowWindowForUser(window_, | 
| + user_id); | 
| +} | 
| + | 
| +void ExecuteVisitDesktopCommand(int command_id, aura::Window* window) { | 
| + switch (command_id) { | 
| + case IDC_VISIT_DESKTOP_OF_LRU_USER_2: | 
| + case IDC_VISIT_DESKTOP_OF_LRU_USER_3: { | 
| + // When running the multi user mode on Chrome OS, windows can "visit" | 
| + // another user's desktop. | 
| + const std::string& user_id = | 
| + ash::Shell::GetInstance()->session_state_delegate()->GetUserID( | 
| + IDC_VISIT_DESKTOP_OF_LRU_USER_2 == command_id ? 1 : 2); | 
| + base::Callback<void(bool)> on_accept = | 
| + base::Bind(&OnAcceptTeleportWarning, user_id, window); | 
| + | 
| + // Don't show warning dialog if any logged in user in multi-profiles | 
| + // session dismissed it. | 
| + bool show_warning = true; | 
| + const chromeos::UserList logged_in_users = | 
| + chromeos::UserManager::Get()->GetLoggedInUsers(); | 
| + for (chromeos::UserList::const_iterator it = logged_in_users.begin(); | 
| + it != logged_in_users.end(); ++it) { | 
| 
Mr4D (OOO till 08-26)
2014/01/28 17:33:02
optional nit:
Why not doing "it != logged_in_users
 
merkulova
2014/01/29 09:11:19
Done.
 | 
| + show_warning &= !multi_user_util::GetProfileFromUserID( | 
| + multi_user_util::GetUserIDFromEmail((*it)->email()))->GetPrefs()-> | 
| + GetBoolean(prefs::kMultiProfileWarningShowDismissed); | 
| + if (!show_warning) | 
| + break; | 
| + } | 
| + if (show_warning) { | 
| + chromeos::ShowMultiprofilesWarningDialog(on_accept); | 
| + } else { | 
| + bool active_user_show_option = ProfileManager::GetActiveUserProfile()-> | 
| + GetPrefs()->GetBoolean(prefs::kMultiProfileWarningShowDismissed); | 
| + on_accept.Run(active_user_show_option); | 
| + } | 
| + return; | 
| + } | 
| + default: | 
| + NOTREACHED(); | 
| + } | 
| +} |