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