Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/multi_user/multi_user_window_manager_chromeos.h" | 5 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/multi_profile_uma.h" | 8 #include "ash/multi_profile_uma.h" |
| 9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
| 10 #include "ash/session/session_state_delegate.h" | 10 #include "ash/session/session_state_delegate.h" |
| 11 #include "ash/shelf/shelf.h" | 11 #include "ash/shelf/shelf.h" |
| 12 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 13 #include "ash/shell_delegate.h" | 13 #include "ash/shell_delegate.h" |
| 14 #include "ash/shell_window_ids.h" | 14 #include "ash/shell_window_ids.h" |
| 15 #include "ash/system/tray/system_tray_notifier.h" | 15 #include "ash/system/tray/system_tray_notifier.h" |
| 16 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 16 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
| 17 #include "ash/wm/window_state.h" | 17 #include "ash/wm/window_state.h" |
| 18 #include "base/auto_reset.h" | 18 #include "base/auto_reset.h" |
| 19 #include "base/message_loop/message_loop.h" | 19 #include "base/message_loop/message_loop.h" |
| 20 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
| 21 #include "base/strings/utf_string_conversions.h" | |
| 21 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
| 22 #include "chrome/browser/chrome_notification_types.h" | 23 #include "chrome/browser/chrome_notification_types.h" |
| 23 #include "chrome/browser/chromeos/login/session/user_session_manager.h" | 24 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
| 24 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
| 25 #include "chrome/browser/profiles/profile_manager.h" | 26 #include "chrome/browser/profiles/profile_manager.h" |
| 26 #include "chrome/browser/ui/ash/multi_user/multi_user_notification_blocker_chrom eos.h" | 27 #include "chrome/browser/ui/ash/multi_user/multi_user_notification_blocker_chrom eos.h" |
| 27 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | 28 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
| 28 #include "chrome/browser/ui/ash/multi_user/user_switch_animator_chromeos.h" | 29 #include "chrome/browser/ui/ash/multi_user/user_switch_animator_chromeos.h" |
| 29 #include "chrome/browser/ui/browser.h" | 30 #include "chrome/browser/ui/browser.h" |
| 30 #include "chrome/browser/ui/browser_finder.h" | 31 #include "chrome/browser/ui/browser_finder.h" |
| 31 #include "chrome/browser/ui/browser_list.h" | 32 #include "chrome/browser/ui/browser_list.h" |
| 32 #include "chrome/browser/ui/browser_window.h" | 33 #include "chrome/browser/ui/browser_window.h" |
| 34 #include "chrome/browser/ui/tabs/tab_strip_model.h" | |
| 35 #include "chrome/common/url_constants.h" | |
| 33 #include "content/public/browser/notification_service.h" | 36 #include "content/public/browser/notification_service.h" |
| 34 #include "extensions/browser/app_window/app_window.h" | 37 #include "extensions/browser/app_window/app_window.h" |
| 35 #include "extensions/browser/app_window/app_window_registry.h" | 38 #include "extensions/browser/app_window/app_window_registry.h" |
| 36 #include "google_apis/gaia/gaia_auth_util.h" | 39 #include "google_apis/gaia/gaia_auth_util.h" |
| 37 #include "ui/aura/client/aura_constants.h" | 40 #include "ui/aura/client/aura_constants.h" |
| 38 #include "ui/aura/window.h" | 41 #include "ui/aura/window.h" |
| 39 #include "ui/aura/window_event_dispatcher.h" | 42 #include "ui/aura/window_event_dispatcher.h" |
| 40 #include "ui/base/ui_base_types.h" | 43 #include "ui/base/ui_base_types.h" |
| 41 #include "ui/events/event.h" | 44 #include "ui/events/event.h" |
| 42 #include "ui/message_center/message_center.h" | 45 #include "ui/message_center/message_center.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 extensions::AppWindow::WINDOW_TYPE_V1_PANEL) { | 139 extensions::AppWindow::WINDOW_TYPE_V1_PANEL) { |
| 137 window_type = ash::MultiProfileUMA::TELEPORT_WINDOW_PANEL; | 140 window_type = ash::MultiProfileUMA::TELEPORT_WINDOW_PANEL; |
| 138 } else { | 141 } else { |
| 139 window_type = ash::MultiProfileUMA::TELEPORT_WINDOW_V2_APP; | 142 window_type = ash::MultiProfileUMA::TELEPORT_WINDOW_V2_APP; |
| 140 } | 143 } |
| 141 } | 144 } |
| 142 } | 145 } |
| 143 ash::MultiProfileUMA::RecordTeleportWindowType(window_type); | 146 ash::MultiProfileUMA::RecordTeleportWindowType(window_type); |
| 144 } | 147 } |
| 145 | 148 |
| 149 // Check if the current browser window contains chrome://settings page or | |
| 150 // subpages. | |
| 151 bool IsWindowContainsChromeSettingsPages(aura::Window* window) { | |
| 152 const base::string16 kChromeSetting = | |
| 153 base::ASCIIToUTF16(content::kChromeUIScheme) + | |
| 154 base::ASCIIToUTF16(url::kStandardSchemeSeparator) + | |
| 155 base::ASCIIToUTF16(chrome::kChromeUISettingsHost); | |
| 156 | |
| 157 Browser* browser = chrome::FindBrowserWithWindow(window); | |
| 158 if (browser) { | |
| 159 TabStripModel* tab_strip = browser->tab_strip_model(); | |
| 160 for (int i = 0; i < tab_strip->count(); i++) { | |
| 161 const base::string16 gurl_spec = base::UTF8ToUTF16( | |
| 162 browser->tab_strip_model()->GetWebContentsAt(i)->GetURL().spec()); | |
| 163 if (gurl_spec.find(kChromeSetting) != base::string16::npos) | |
| 164 return true; | |
| 165 } | |
| 166 } | |
| 167 return false; | |
| 168 } | |
| 169 | |
| 146 } // namespace | 170 } // namespace |
| 147 | 171 |
| 148 namespace chrome { | 172 namespace chrome { |
| 149 | 173 |
| 150 // A class to temporarily change the animation properties for a window. | 174 // A class to temporarily change the animation properties for a window. |
| 151 class AnimationSetter { | 175 class AnimationSetter { |
| 152 public: | 176 public: |
| 153 AnimationSetter(aura::Window* window, int animation_time_in_ms) | 177 AnimationSetter(aura::Window* window, int animation_time_in_ms) |
| 154 : window_(window), | 178 : window_(window), |
| 155 previous_animation_type_( | 179 previous_animation_type_( |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 310 const std::string& MultiUserWindowManagerChromeOS::GetWindowOwner( | 334 const std::string& MultiUserWindowManagerChromeOS::GetWindowOwner( |
| 311 aura::Window* window) const { | 335 aura::Window* window) const { |
| 312 WindowToEntryMap::const_iterator it = window_to_entry_.find(window); | 336 WindowToEntryMap::const_iterator it = window_to_entry_.find(window); |
| 313 return it != window_to_entry_.end() ? it->second->owner() | 337 return it != window_to_entry_.end() ? it->second->owner() |
| 314 : base::EmptyString(); | 338 : base::EmptyString(); |
| 315 } | 339 } |
| 316 | 340 |
| 317 void MultiUserWindowManagerChromeOS::ShowWindowForUser( | 341 void MultiUserWindowManagerChromeOS::ShowWindowForUser( |
| 318 aura::Window* window, | 342 aura::Window* window, |
| 319 const std::string& user_id) { | 343 const std::string& user_id) { |
| 344 // If the browser window contains ChromeSettings or ChromeSettingsSubpages | |
| 345 // child windows, we should not teleport this window to another user's | |
| 346 // desktop. | |
|
Mr4D (OOO till 08-26)
2015/04/30 21:51:45
Why? This does not make sense. I do not see why we
| |
| 347 if (IsWindowContainsChromeSettingsPages(window)) { | |
| 348 // I'm not sure what to do here. Give user some error information? | |
| 349 return; | |
| 350 } | |
| 351 | |
| 320 std::string previous_owner(GetUserPresentingWindow(window)); | 352 std::string previous_owner(GetUserPresentingWindow(window)); |
| 321 if (!ShowWindowForUserIntern(window, user_id)) | 353 if (!ShowWindowForUserIntern(window, user_id)) |
| 322 return; | 354 return; |
| 323 // The window switched to a new desktop and we have to switch to that desktop, | 355 // The window switched to a new desktop and we have to switch to that desktop, |
| 324 // but only when it was on the visible desktop and the the target is not the | 356 // but only when it was on the visible desktop and the the target is not the |
| 325 // visible desktop. | 357 // visible desktop. |
| 326 if (user_id == current_user_id_ || previous_owner != current_user_id_) | 358 if (user_id == current_user_id_ || previous_owner != current_user_id_) |
| 327 return; | 359 return; |
| 328 | 360 |
| 329 ash::Shell::GetInstance()->session_state_delegate()->SwitchActiveUser( | 361 ash::Shell::GetInstance()->session_state_delegate()->SwitchActiveUser( |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 738 DCHECK_EQ(visible, window->IsVisible()); | 770 DCHECK_EQ(visible, window->IsVisible()); |
| 739 } | 771 } |
| 740 | 772 |
| 741 int MultiUserWindowManagerChromeOS::GetAdjustedAnimationTimeInMS( | 773 int MultiUserWindowManagerChromeOS::GetAdjustedAnimationTimeInMS( |
| 742 int default_time_in_ms) const { | 774 int default_time_in_ms) const { |
| 743 return animation_speed_ == ANIMATION_SPEED_NORMAL ? default_time_in_ms : | 775 return animation_speed_ == ANIMATION_SPEED_NORMAL ? default_time_in_ms : |
| 744 (animation_speed_ == ANIMATION_SPEED_FAST ? 10 : 0); | 776 (animation_speed_ == ANIMATION_SPEED_FAST ? 10 : 0); |
| 745 } | 777 } |
| 746 | 778 |
| 747 } // namespace chrome | 779 } // namespace chrome |
| OLD | NEW |