Adding "teleport windows to user X" context menu

This adds the teleport items to the context menu. At the same time I was also adding a GetUserID function to the SessionStateController to avoid adding the sanitization of the user names all over the place.

BUG=306143
TEST=visual, a few things got handled by unit tests

Review URL: https://codereview.chromium.org/27217003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@229607 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/ui/browser_command_controller.cc b/chrome/browser/ui/browser_command_controller.cc
index 2afe9bec..c58e17a 100644
--- a/chrome/browser/ui/browser_command_controller.cc
+++ b/chrome/browser/ui/browser_command_controller.cc
@@ -55,6 +55,12 @@
 #include "chrome/browser/ui/ash/ash_util.h"
 #endif
 
+#if defined(OS_CHROMEOS)
+#include "ash/session_state_delegate.h"
+#include "ash/shell.h"
+#include "chrome/browser/ui/ash/multi_user_window_manager.h"
+#endif
+
 using content::NavigationEntry;
 using content::NavigationController;
 using content::WebContents;
@@ -452,6 +458,21 @@
     // mechanism to pass accelerators back into Ash. http://crbug.com/285308
 #endif
 
+#if defined(OS_CHROMEOS)
+    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 == id ? 1 : 2);
+        chrome::MultiUserWindowManager::GetInstance()->ShowWindowForUser(
+            browser_->window()->GetNativeWindow(),
+            user_id);
+        break;
+      }
+#endif
+
 #if defined(OS_WIN)
     // Windows 8 specific commands.
     case IDC_METRO_SNAP_ENABLE:
@@ -845,6 +866,10 @@
 #if defined(USE_ASH)
   command_updater_.UpdateCommandEnabled(IDC_MINIMIZE_WINDOW, true);
 #endif
+#if defined(OS_CHROMEOS)
+  command_updater_.UpdateCommandEnabled(IDC_VISIT_DESKTOP_OF_LRU_USER_2, true);
+  command_updater_.UpdateCommandEnabled(IDC_VISIT_DESKTOP_OF_LRU_USER_3, true);
+#endif
 
   // Page-related commands
   command_updater_.UpdateCommandEnabled(IDC_EMAIL_PAGE_LOCATION, true);