Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/launcher/chrome_launcher_app_menu_item_tab.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_tab.h" |
| 6 | 6 |
| 7 #include "ash/wm/window_util.h" | 7 #include "ash/wm/window_util.h" |
| 8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/browser/ui/browser_finder.h" | 9 #include "chrome/browser/ui/browser_finder.h" |
| 10 #include "chrome/browser/ui/browser_window.h" | 10 #include "chrome/browser/ui/browser_window.h" |
| 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 12 #include "ui/events/event_constants.h" | 12 #include "ui/events/event_constants.h" |
| 13 | 13 |
| 14 #if defined(OS_CHROMEOS) | |
| 15 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" | |
| 16 #include "components/user_manager/user_manager.h" | |
| 17 #endif | |
| 18 | |
| 14 ChromeLauncherAppMenuItemTab::ChromeLauncherAppMenuItemTab( | 19 ChromeLauncherAppMenuItemTab::ChromeLauncherAppMenuItemTab( |
| 15 const base::string16 title, | 20 const base::string16 title, |
| 16 const gfx::Image* icon, | 21 const gfx::Image* icon, |
| 17 content::WebContents* content, | 22 content::WebContents* content, |
| 18 bool has_leading_separator) | 23 bool has_leading_separator) |
| 19 : ChromeLauncherAppMenuItem(title, icon, has_leading_separator), | 24 : ChromeLauncherAppMenuItem(title, icon, has_leading_separator), |
| 20 content::WebContentsObserver(content) { | 25 content::WebContentsObserver(content) { |
| 21 } | 26 } |
| 22 | 27 |
| 23 bool ChromeLauncherAppMenuItemTab::IsActive() const { | 28 bool ChromeLauncherAppMenuItemTab::IsActive() const { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 36 return; | 41 return; |
| 37 Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); | 42 Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); |
| 38 if (!browser) | 43 if (!browser) |
| 39 return; | 44 return; |
| 40 TabStripModel* tab_strip = browser->tab_strip_model(); | 45 TabStripModel* tab_strip = browser->tab_strip_model(); |
| 41 int index = tab_strip->GetIndexOfWebContents(web_contents()); | 46 int index = tab_strip->GetIndexOfWebContents(web_contents()); |
| 42 DCHECK_NE(index, TabStripModel::kNoTab); | 47 DCHECK_NE(index, TabStripModel::kNoTab); |
| 43 if (event_flags & (ui::EF_SHIFT_DOWN | ui::EF_MIDDLE_MOUSE_BUTTON)) { | 48 if (event_flags & (ui::EF_SHIFT_DOWN | ui::EF_MIDDLE_MOUSE_BUTTON)) { |
| 44 tab_strip->CloseWebContentsAt(index, TabStripModel::CLOSE_USER_GESTURE); | 49 tab_strip->CloseWebContentsAt(index, TabStripModel::CLOSE_USER_GESTURE); |
| 45 } else { | 50 } else { |
| 51 #if defined(OS_CHROMEOS) | |
| 52 // In multiprofile scenario we might need to teleport the window back to | |
| 53 // the current user desktop. | |
| 54 if (chrome::MultiUserWindowManager::GetMultiProfileMode() == | |
| 55 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) { | |
| 56 aura::Window* window = browser->window()->GetNativeWindow(); | |
| 57 const user_manager::UserManager* user_manager = | |
| 58 user_manager::UserManager::Get(); | |
| 59 const std::string& current_user = | |
| 60 user_manager->GetActiveUser()->GetUserID(); | |
| 61 chrome::MultiUserWindowManager* window_manager = | |
| 62 chrome::MultiUserWindowManager::GetInstance(); | |
|
Mr4D (OOO till 08-26)
2015/04/30 21:51:44
You could avoid using the user manager by checking
xdai1
2015/05/01 18:28:23
Done.
| |
| 63 if (!window_manager->IsWindowOnDesktopOfUser(window, current_user)) | |
| 64 window_manager->ShowWindowForUser(window, current_user); | |
| 65 } | |
| 66 #endif | |
| 46 tab_strip->ActivateTabAt(index, false); | 67 tab_strip->ActivateTabAt(index, false); |
| 47 browser->window()->Show(); | 68 browser->window()->Show(); |
| 48 // Need this check to prevent unit tests from crashing. | 69 // Need this check to prevent unit tests from crashing. |
| 49 if (browser->window()->GetNativeWindow()) | 70 if (browser->window()->GetNativeWindow()) |
| 50 ash::wm::ActivateWindow(browser->window()->GetNativeWindow()); | 71 ash::wm::ActivateWindow(browser->window()->GetNativeWindow()); |
| 51 } | 72 } |
| 52 } | 73 } |
| OLD | NEW |