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_controller2.h" | 5 #include "chrome/browser/ui/views/tabs/tab_drag_controller2.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 #include "ui/base/animation/animation_delegate.h" | 33 #include "ui/base/animation/animation_delegate.h" |
34 #include "ui/base/animation/slide_animation.h" | 34 #include "ui/base/animation/slide_animation.h" |
35 #include "ui/base/events.h" | 35 #include "ui/base/events.h" |
36 #include "ui/base/resource/resource_bundle.h" | 36 #include "ui/base/resource/resource_bundle.h" |
37 #include "ui/gfx/canvas_skia.h" | 37 #include "ui/gfx/canvas_skia.h" |
38 #include "ui/gfx/screen.h" | 38 #include "ui/gfx/screen.h" |
39 #include "ui/views/events/event.h" | 39 #include "ui/views/events/event.h" |
40 #include "ui/views/widget/root_view.h" | 40 #include "ui/views/widget/root_view.h" |
41 #include "ui/views/widget/widget.h" | 41 #include "ui/views/widget/widget.h" |
42 | 42 |
| 43 #if defined(USE_AURA) |
| 44 #include "ash/wm/property_util.h" |
| 45 #endif |
| 46 |
43 using content::UserMetricsAction; | 47 using content::UserMetricsAction; |
44 using content::WebContents; | 48 using content::WebContents; |
45 | 49 |
46 static const int kHorizontalMoveThreshold = 16; // Pixels. | 50 static const int kHorizontalMoveThreshold = 16; // Pixels. |
47 | 51 |
48 // If non-null there is a drag underway. | 52 // If non-null there is a drag underway. |
49 static TabDragController2* instance_; | 53 static TabDragController2* instance_; |
50 | 54 |
51 namespace { | 55 namespace { |
52 | 56 |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 instance_ = this; | 319 instance_ = this; |
316 } | 320 } |
317 | 321 |
318 TabDragController2::~TabDragController2() { | 322 TabDragController2::~TabDragController2() { |
319 if (instance_ == this) | 323 if (instance_ == this) |
320 instance_ = NULL; | 324 instance_ = NULL; |
321 | 325 |
322 if (destroyed_) | 326 if (destroyed_) |
323 *destroyed_ = true; | 327 *destroyed_ = true; |
324 | 328 |
325 if (move_loop_browser_view_) | 329 if (move_loop_browser_view_) { |
326 move_loop_browser_view_->set_move_observer(NULL); | 330 move_loop_browser_view_->set_move_observer(NULL); |
| 331 SetTrackedByWorkspace( |
| 332 move_loop_browser_view_->GetWidget()->GetNativeView(), true); |
| 333 } |
327 | 334 |
328 if (source_tabstrip_) | 335 if (source_tabstrip_) |
329 GetModel(source_tabstrip_)->RemoveObserver(this); | 336 GetModel(source_tabstrip_)->RemoveObserver(this); |
330 | 337 |
331 MessageLoopForUI::current()->RemoveObserver(this); | 338 MessageLoopForUI::current()->RemoveObserver(this); |
332 } | 339 } |
333 | 340 |
334 void TabDragController2::Init( | 341 void TabDragController2::Init( |
335 TabStrip* source_tabstrip, | 342 TabStrip* source_tabstrip, |
336 BaseTab* source_tab, | 343 BaseTab* source_tab, |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1089 return tabs; | 1096 return tabs; |
1090 } | 1097 } |
1091 | 1098 |
1092 void TabDragController2::EndDragImpl(EndDragType type) { | 1099 void TabDragController2::EndDragImpl(EndDragType type) { |
1093 DCHECK(active_); | 1100 DCHECK(active_); |
1094 active_ = false; | 1101 active_ = false; |
1095 | 1102 |
1096 bring_to_front_timer_.Stop(); | 1103 bring_to_front_timer_.Stop(); |
1097 | 1104 |
1098 if (is_dragging_window_) { | 1105 if (is_dragging_window_) { |
| 1106 if (type == NORMAL || (type == TAB_DESTROYED && drag_data_.size() > 1)) { |
| 1107 SetTrackedByWorkspace( |
| 1108 GetAttachedBrowserView()->GetWidget()->GetNativeView(), true); |
| 1109 } |
| 1110 |
1099 // End the nested drag loop. | 1111 // End the nested drag loop. |
1100 GetAttachedBrowserView()->GetWidget()->EndMoveLoop(); | 1112 GetAttachedBrowserView()->GetWidget()->EndMoveLoop(); |
1101 waiting_for_run_loop_to_exit_ = true; | 1113 waiting_for_run_loop_to_exit_ = true; |
1102 } | 1114 } |
1103 | 1115 |
1104 // Hide the current dock controllers. | 1116 // Hide the current dock controllers. |
1105 for (size_t i = 0; i < dock_controllers_.size(); ++i) { | 1117 for (size_t i = 0; i < dock_controllers_.size(); ++i) { |
1106 // Be sure and clear the controller first, that way if Hide ends up | 1118 // Be sure and clear the controller first, that way if Hide ends up |
1107 // deleting the controller it won't call us back. | 1119 // deleting the controller it won't call us back. |
1108 dock_controllers_[i]->clear_controller(); | 1120 dock_controllers_[i]->clear_controller(); |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1384 int delta = (*drag_bounds)[0].x(); | 1396 int delta = (*drag_bounds)[0].x(); |
1385 for (size_t i = 0; i < drag_bounds->size(); ++i) | 1397 for (size_t i = 0; i < drag_bounds->size(); ++i) |
1386 (*drag_bounds)[i].Offset(-delta, 0); | 1398 (*drag_bounds)[i].Offset(-delta, 0); |
1387 break; | 1399 break; |
1388 } | 1400 } |
1389 | 1401 |
1390 default: | 1402 default: |
1391 break; // Nothing to do for DETACH_ABOVE_OR_BELOW. | 1403 break; // Nothing to do for DETACH_ABOVE_OR_BELOW. |
1392 } | 1404 } |
1393 | 1405 |
| 1406 SetTrackedByWorkspace(browser->window()->GetNativeHandle(), false); |
1394 browser->window()->SetBounds(new_bounds); | 1407 browser->window()->SetBounds(new_bounds); |
1395 return browser; | 1408 return browser; |
1396 } | 1409 } |
| 1410 |
| 1411 void TabDragController2::SetTrackedByWorkspace(gfx::NativeWindow window, |
| 1412 bool value) { |
| 1413 #if defined(USE_AURA) |
| 1414 ash::SetTrackedByWorkspace(window, value); |
| 1415 #endif |
| 1416 } |
OLD | NEW |