| 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..1cf00e10c6ecf68773894429b52dd079d4860b88 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,51 @@ 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. | 
| +      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) { | 
| +        if (multi_user_util::GetProfileFromUserID( | 
| +            multi_user_util::GetUserIDFromEmail((*it)->email()))->GetPrefs()-> | 
| +            GetBoolean(prefs::kMultiProfileWarningShowDismissed)) { | 
| +          bool active_user_show_option = | 
| +              ProfileManager::GetActiveUserProfile()-> | 
| +              GetPrefs()->GetBoolean(prefs::kMultiProfileWarningShowDismissed); | 
| +          on_accept.Run(active_user_show_option); | 
| +          return; | 
| +        } | 
| +      } | 
| +      chromeos::ShowMultiprofilesWarningDialog(on_accept); | 
| +      return; | 
| +    } | 
| +    default: | 
| +      NOTREACHED(); | 
| +  } | 
| +} | 
|  |