Index: chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc |
diff --git a/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc b/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc |
index e5ea8f5a1a792767a62bb9f87fa33a96aeb29f8b..6723f87c3c264bef52f085c9f4e3bb2d03256ddc 100644 |
--- a/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc |
+++ b/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc |
@@ -18,6 +18,7 @@ |
#include "base/auto_reset.h" |
#include "base/message_loop/message_loop.h" |
#include "base/strings/string_util.h" |
+#include "base/strings/utf_string_conversions.h" |
#include "chrome/browser/browser_process.h" |
#include "chrome/browser/chrome_notification_types.h" |
#include "chrome/browser/chromeos/login/session/user_session_manager.h" |
@@ -30,6 +31,8 @@ |
#include "chrome/browser/ui/browser_finder.h" |
#include "chrome/browser/ui/browser_list.h" |
#include "chrome/browser/ui/browser_window.h" |
+#include "chrome/browser/ui/tabs/tab_strip_model.h" |
+#include "chrome/common/url_constants.h" |
#include "content/public/browser/notification_service.h" |
#include "extensions/browser/app_window/app_window.h" |
#include "extensions/browser/app_window/app_window_registry.h" |
@@ -143,6 +146,27 @@ void RecordUMAForTransferredWindowType(aura::Window* window) { |
ash::MultiProfileUMA::RecordTeleportWindowType(window_type); |
} |
+// Check if the current browser window contains chrome://settings page or |
+// subpages. |
+bool IsWindowContainsChromeSettingsPages(aura::Window* window) { |
+ const base::string16 kChromeSetting = |
+ base::ASCIIToUTF16(content::kChromeUIScheme) + |
+ base::ASCIIToUTF16(url::kStandardSchemeSeparator) + |
+ base::ASCIIToUTF16(chrome::kChromeUISettingsHost); |
+ |
+ Browser* browser = chrome::FindBrowserWithWindow(window); |
+ if (browser) { |
+ TabStripModel* tab_strip = browser->tab_strip_model(); |
+ for (int i = 0; i < tab_strip->count(); i++) { |
+ const base::string16 gurl_spec = base::UTF8ToUTF16( |
+ browser->tab_strip_model()->GetWebContentsAt(i)->GetURL().spec()); |
+ if (gurl_spec.find(kChromeSetting) != base::string16::npos) |
+ return true; |
+ } |
+ } |
+ return false; |
+} |
+ |
} // namespace |
namespace chrome { |
@@ -317,6 +341,14 @@ const std::string& MultiUserWindowManagerChromeOS::GetWindowOwner( |
void MultiUserWindowManagerChromeOS::ShowWindowForUser( |
aura::Window* window, |
const std::string& user_id) { |
+ // If the browser window contains ChromeSettings or ChromeSettingsSubpages |
+ // child windows, we should not teleport this window to another user's |
+ // desktop. |
Mr4D (OOO till 08-26)
2015/04/30 21:51:45
Why? This does not make sense. I do not see why we
|
+ if (IsWindowContainsChromeSettingsPages(window)) { |
+ // I'm not sure what to do here. Give user some error information? |
+ return; |
+ } |
+ |
std::string previous_owner(GetUserPresentingWindow(window)); |
if (!ShowWindowForUserIntern(window, user_id)) |
return; |