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/views/tabs/tab_drag_controller.h" | 5 #include "chrome/browser/ui/views/tabs/tab_drag_controller.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 #include "ui/aura/env.h" | 56 #include "ui/aura/env.h" |
| 57 #include "ui/aura/root_window.h" | 57 #include "ui/aura/root_window.h" |
| 58 #include "ui/events/gestures/gesture_recognizer.h" | 58 #include "ui/events/gestures/gesture_recognizer.h" |
| 59 #endif | 59 #endif |
| 60 | 60 |
| 61 #if defined(OS_WIN) && defined(USE_AURA) | 61 #if defined(OS_WIN) && defined(USE_AURA) |
| 62 #include "ui/aura/window.h" | 62 #include "ui/aura/window.h" |
| 63 #include "ui/events/gestures/gesture_recognizer.h" | 63 #include "ui/events/gestures/gesture_recognizer.h" |
| 64 #endif | 64 #endif |
| 65 | 65 |
| 66 #if defined(OS_CHROMEOS) | |
| 67 #include "chrome/browser/ui/ash/multi_user_window_manager.h" | |
| 68 #endif | |
| 69 | |
| 66 using content::OpenURLParams; | 70 using content::OpenURLParams; |
| 67 using content::UserMetricsAction; | 71 using content::UserMetricsAction; |
| 68 using content::WebContents; | 72 using content::WebContents; |
| 69 | 73 |
| 70 static const int kHorizontalMoveThreshold = 16; // Pixels. | 74 static const int kHorizontalMoveThreshold = 16; // Pixels. |
| 71 | 75 |
| 72 // Distance from the next/previous stacked before before we consider the tab | 76 // Distance from the next/previous stacked before before we consider the tab |
| 73 // close enough to trigger moving. | 77 // close enough to trigger moving. |
| 74 static const int kStackedDistance = 36; | 78 static const int kStackedDistance = 36; |
| 75 | 79 |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 // position managed' property during a show and we need the property set to | 248 // position managed' property during a show and we need the property set to |
| 245 // false before WorkspaceLayoutManager sees the visibility change. | 249 // false before WorkspaceLayoutManager sees the visibility change. |
| 246 class WindowPositionManagedUpdater : public views::WidgetObserver { | 250 class WindowPositionManagedUpdater : public views::WidgetObserver { |
| 247 public: | 251 public: |
| 248 virtual void OnWidgetVisibilityChanged(views::Widget* widget, | 252 virtual void OnWidgetVisibilityChanged(views::Widget* widget, |
| 249 bool visible) OVERRIDE { | 253 bool visible) OVERRIDE { |
| 250 SetWindowPositionManaged(widget->GetNativeView(), false); | 254 SetWindowPositionManaged(widget->GetNativeView(), false); |
| 251 } | 255 } |
| 252 }; | 256 }; |
| 253 | 257 |
| 254 } // namespace | 258 // Being in the separate desktop multi profile mode, a visiting window from one |
| 259 // user should show all dragged off tabs on the current user's desktop. This | |
| 260 // function transfers the visibility of a newly created browser accordingly. | |
| 261 void MoveBrowserToCurrentUser(Browser* browser) { | |
|
sky
2013/10/31 22:04:04
This feels wrong. Why do we have to special case e
| |
| 262 #if defined(OS_CHROMEOS) | |
| 263 if (chrome::MultiUserWindowManager::GetMultiProfileMode() == | |
| 264 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) { | |
| 265 chrome::MultiUserWindowManager* window_manager = | |
| 266 chrome::MultiUserWindowManager::GetInstance(); | |
| 267 window_manager->ShowWindowForUser(browser->window()->GetNativeWindow(), | |
| 268 window_manager->current_user_id()); | |
| 269 } | |
| 270 #endif | |
| 271 } | |
| 272 | |
| 273 } // namespace | |
| 255 | 274 |
| 256 /////////////////////////////////////////////////////////////////////////////// | 275 /////////////////////////////////////////////////////////////////////////////// |
| 257 // DockDisplayer | 276 // DockDisplayer |
| 258 | 277 |
| 259 // DockDisplayer is responsible for giving the user a visual indication of a | 278 // DockDisplayer is responsible for giving the user a visual indication of a |
| 260 // possible dock position (as represented by DockInfo). DockDisplayer shows | 279 // possible dock position (as represented by DockInfo). DockDisplayer shows |
| 261 // a window with a DockView in it. Two animations are used that correspond to | 280 // a window with a DockView in it. Two animations are used that correspond to |
| 262 // the state of DockInfo::in_enable_area. | 281 // the state of DockInfo::in_enable_area. |
| 263 class TabDragController::DockDisplayer : public gfx::AnimationDelegate { | 282 class TabDragController::DockDisplayer : public gfx::AnimationDelegate { |
| 264 public: | 283 public: |
| (...skipping 1729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1994 item.web_contents = drag_data_[i].contents; | 2013 item.web_contents = drag_data_[i].contents; |
| 1995 item.add_types = drag_data_[i].pinned ? TabStripModel::ADD_PINNED | 2014 item.add_types = drag_data_[i].pinned ? TabStripModel::ADD_PINNED |
| 1996 : TabStripModel::ADD_NONE; | 2015 : TabStripModel::ADD_NONE; |
| 1997 contentses.push_back(item); | 2016 contentses.push_back(item); |
| 1998 } | 2017 } |
| 1999 | 2018 |
| 2000 Browser* new_browser = | 2019 Browser* new_browser = |
| 2001 GetModel(source_tabstrip_)->delegate()->CreateNewStripWithContents( | 2020 GetModel(source_tabstrip_)->delegate()->CreateNewStripWithContents( |
| 2002 contentses, window_bounds, dock_info_, widget->IsMaximized()); | 2021 contentses, window_bounds, dock_info_, widget->IsMaximized()); |
| 2003 ResetSelection(new_browser->tab_strip_model()); | 2022 ResetSelection(new_browser->tab_strip_model()); |
| 2023 // Make sure that the window is shown on the correct users desktop. | |
| 2024 MoveBrowserToCurrentUser(new_browser); | |
| 2004 new_browser->window()->Show(); | 2025 new_browser->window()->Show(); |
| 2005 | 2026 |
| 2006 // Return the WebContents to normalcy. | 2027 // Return the WebContents to normalcy. |
| 2007 if (!detach_into_browser_) | 2028 if (!detach_into_browser_) |
| 2008 source_dragged_contents()->DecrementCapturerCount(); | 2029 source_dragged_contents()->DecrementCapturerCount(); |
| 2009 } | 2030 } |
| 2010 | 2031 |
| 2011 CleanUpHiddenFrame(); | 2032 CleanUpHiddenFrame(); |
| 2012 } | 2033 } |
| 2013 | 2034 |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2255 | 2276 |
| 2256 *drag_offset = point_in_screen - new_bounds.origin(); | 2277 *drag_offset = point_in_screen - new_bounds.origin(); |
| 2257 | 2278 |
| 2258 Profile* profile = | 2279 Profile* profile = |
| 2259 Profile::FromBrowserContext(drag_data_[0].contents->GetBrowserContext()); | 2280 Profile::FromBrowserContext(drag_data_[0].contents->GetBrowserContext()); |
| 2260 Browser::CreateParams create_params(Browser::TYPE_TABBED, | 2281 Browser::CreateParams create_params(Browser::TYPE_TABBED, |
| 2261 profile, | 2282 profile, |
| 2262 host_desktop_type_); | 2283 host_desktop_type_); |
| 2263 create_params.initial_bounds = new_bounds; | 2284 create_params.initial_bounds = new_bounds; |
| 2264 Browser* browser = new Browser(create_params); | 2285 Browser* browser = new Browser(create_params); |
| 2286 // Make sure that the window is shown on the correct users desktop. | |
| 2287 MoveBrowserToCurrentUser(browser); | |
| 2288 | |
| 2265 is_dragging_new_browser_ = true; | 2289 is_dragging_new_browser_ = true; |
| 2266 SetTrackedByWorkspace(browser->window()->GetNativeWindow(), false); | 2290 SetTrackedByWorkspace(browser->window()->GetNativeWindow(), false); |
| 2267 SetWindowPositionManaged(browser->window()->GetNativeWindow(), false); | 2291 SetWindowPositionManaged(browser->window()->GetNativeWindow(), false); |
| 2268 // If the window is created maximized then the bounds we supplied are ignored. | 2292 // If the window is created maximized then the bounds we supplied are ignored. |
| 2269 // We need to reset them again so they are honored. | 2293 // We need to reset them again so they are honored. |
| 2270 browser->window()->SetBounds(new_bounds); | 2294 browser->window()->SetBounds(new_bounds); |
| 2271 | 2295 |
| 2272 return browser; | 2296 return browser; |
| 2273 } | 2297 } |
| 2274 | 2298 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 2295 gfx::Vector2d TabDragController::GetWindowOffset( | 2319 gfx::Vector2d TabDragController::GetWindowOffset( |
| 2296 const gfx::Point& point_in_screen) { | 2320 const gfx::Point& point_in_screen) { |
| 2297 TabStrip* owning_tabstrip = (attached_tabstrip_ && detach_into_browser_) ? | 2321 TabStrip* owning_tabstrip = (attached_tabstrip_ && detach_into_browser_) ? |
| 2298 attached_tabstrip_ : source_tabstrip_; | 2322 attached_tabstrip_ : source_tabstrip_; |
| 2299 views::View* toplevel_view = owning_tabstrip->GetWidget()->GetContentsView(); | 2323 views::View* toplevel_view = owning_tabstrip->GetWidget()->GetContentsView(); |
| 2300 | 2324 |
| 2301 gfx::Point point = point_in_screen; | 2325 gfx::Point point = point_in_screen; |
| 2302 views::View::ConvertPointFromScreen(toplevel_view, &point); | 2326 views::View::ConvertPointFromScreen(toplevel_view, &point); |
| 2303 return point.OffsetFromOrigin(); | 2327 return point.OffsetFromOrigin(); |
| 2304 } | 2328 } |
| OLD | NEW |