| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/default_tab_drag_controller.h" | 5 #include "chrome/browser/ui/views/tabs/default_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/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/i18n/rtl.h" | 11 #include "base/i18n/rtl.h" |
| 12 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 12 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
| 13 #include "chrome/browser/tabs/tab_strip_model.h" | 13 #include "chrome/browser/tabs/tab_strip_model.h" |
| 14 #include "chrome/browser/ui/app_modal_dialogs/message_box_handler.h" | 14 #include "chrome/browser/ui/app_modal_dialogs/message_box_handler.h" |
| 15 #include "chrome/browser/ui/browser_window.h" | 15 #include "chrome/browser/ui/browser_window.h" |
| 16 #include "chrome/browser/ui/views/frame/browser_view.h" | 16 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 17 #include "chrome/browser/ui/views/tabs/base_tab.h" | 17 #include "chrome/browser/ui/views/tabs/base_tab.h" |
| 18 #include "chrome/browser/ui/views/tabs/base_tab_strip.h" | 18 #include "chrome/browser/ui/views/tabs/base_tab_strip.h" |
| 19 #include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h" | 19 #include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h" |
| 20 #include "chrome/browser/ui/views/tabs/dragged_tab_view.h" | 20 #include "chrome/browser/ui/views/tabs/dragged_tab_view.h" |
| 21 #include "chrome/browser/ui/views/tabs/native_view_photobooth.h" | 21 #include "chrome/browser/ui/views/tabs/native_view_photobooth.h" |
| 22 #include "chrome/browser/ui/views/tabs/tab.h" | 22 #include "chrome/browser/ui/views/tabs/tab.h" |
| 23 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 23 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
| 24 #include "content/browser/tab_contents/tab_contents.h" | 24 #include "content/browser/tab_contents/tab_contents.h" |
| 25 #include "content/browser/user_metrics.h" | |
| 26 #include "content/public/browser/notification_details.h" | 25 #include "content/public/browser/notification_details.h" |
| 27 #include "content/public/browser/notification_service.h" | 26 #include "content/public/browser/notification_service.h" |
| 28 #include "content/public/browser/notification_source.h" | 27 #include "content/public/browser/notification_source.h" |
| 29 #include "content/public/browser/notification_types.h" | 28 #include "content/public/browser/notification_types.h" |
| 29 #include "content/public/browser/user_metrics.h" |
| 30 #include "grit/theme_resources.h" | 30 #include "grit/theme_resources.h" |
| 31 #include "third_party/skia/include/core/SkBitmap.h" | 31 #include "third_party/skia/include/core/SkBitmap.h" |
| 32 #include "ui/base/animation/animation.h" | 32 #include "ui/base/animation/animation.h" |
| 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/widget.h" | 40 #include "ui/views/widget/widget.h" |
| 41 | 41 |
| 42 #if defined(TOOLKIT_USES_GTK) | 42 #if defined(TOOLKIT_USES_GTK) |
| 43 #include <gdk/gdk.h> // NOLINT | 43 #include <gdk/gdk.h> // NOLINT |
| 44 #include <gdk/gdkkeysyms.h> // NOLINT | 44 #include <gdk/gdkkeysyms.h> // NOLINT |
| 45 #endif | 45 #endif |
| 46 | 46 |
| 47 using content::UserMetricsAction; |
| 48 |
| 47 static const int kHorizontalMoveThreshold = 16; // Pixels. | 49 static const int kHorizontalMoveThreshold = 16; // Pixels. |
| 48 | 50 |
| 49 // If non-null there is a drag underway. | 51 // If non-null there is a drag underway. |
| 50 static DefaultTabDragController* instance_ = NULL; | 52 static DefaultTabDragController* instance_ = NULL; |
| 51 | 53 |
| 52 namespace { | 54 namespace { |
| 53 | 55 |
| 54 // Delay, in ms, during dragging before we bring a window to front. | 56 // Delay, in ms, during dragging before we bring a window to front. |
| 55 const int kBringToFrontDelay = 750; | 57 const int kBringToFrontDelay = 750; |
| 56 | 58 |
| (...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1183 void DefaultTabDragController::CompleteDrag() { | 1185 void DefaultTabDragController::CompleteDrag() { |
| 1184 DCHECK(started_drag_); | 1186 DCHECK(started_drag_); |
| 1185 | 1187 |
| 1186 if (attached_tabstrip_) { | 1188 if (attached_tabstrip_) { |
| 1187 attached_tabstrip_->StoppedDraggingTabs( | 1189 attached_tabstrip_->StoppedDraggingTabs( |
| 1188 GetTabsMatchingDraggedContents(attached_tabstrip_)); | 1190 GetTabsMatchingDraggedContents(attached_tabstrip_)); |
| 1189 } else { | 1191 } else { |
| 1190 if (dock_info_.type() != DockInfo::NONE) { | 1192 if (dock_info_.type() != DockInfo::NONE) { |
| 1191 switch (dock_info_.type()) { | 1193 switch (dock_info_.type()) { |
| 1192 case DockInfo::LEFT_OF_WINDOW: | 1194 case DockInfo::LEFT_OF_WINDOW: |
| 1193 UserMetrics::RecordAction(UserMetricsAction("DockingWindow_Left")); | 1195 content::RecordAction(UserMetricsAction("DockingWindow_Left")); |
| 1194 break; | 1196 break; |
| 1195 | 1197 |
| 1196 case DockInfo::RIGHT_OF_WINDOW: | 1198 case DockInfo::RIGHT_OF_WINDOW: |
| 1197 UserMetrics::RecordAction(UserMetricsAction("DockingWindow_Right")); | 1199 content::RecordAction(UserMetricsAction("DockingWindow_Right")); |
| 1198 break; | 1200 break; |
| 1199 | 1201 |
| 1200 case DockInfo::BOTTOM_OF_WINDOW: | 1202 case DockInfo::BOTTOM_OF_WINDOW: |
| 1201 UserMetrics::RecordAction(UserMetricsAction("DockingWindow_Bottom")); | 1203 content::RecordAction(UserMetricsAction("DockingWindow_Bottom")); |
| 1202 break; | 1204 break; |
| 1203 | 1205 |
| 1204 case DockInfo::TOP_OF_WINDOW: | 1206 case DockInfo::TOP_OF_WINDOW: |
| 1205 UserMetrics::RecordAction(UserMetricsAction("DockingWindow_Top")); | 1207 content::RecordAction(UserMetricsAction("DockingWindow_Top")); |
| 1206 break; | 1208 break; |
| 1207 | 1209 |
| 1208 case DockInfo::MAXIMIZE: | 1210 case DockInfo::MAXIMIZE: |
| 1209 UserMetrics::RecordAction( | 1211 content::RecordAction( |
| 1210 UserMetricsAction("DockingWindow_Maximize")); | 1212 UserMetricsAction("DockingWindow_Maximize")); |
| 1211 break; | 1213 break; |
| 1212 | 1214 |
| 1213 case DockInfo::LEFT_HALF: | 1215 case DockInfo::LEFT_HALF: |
| 1214 UserMetrics::RecordAction( | 1216 content::RecordAction( |
| 1215 UserMetricsAction("DockingWindow_LeftHalf")); | 1217 UserMetricsAction("DockingWindow_LeftHalf")); |
| 1216 break; | 1218 break; |
| 1217 | 1219 |
| 1218 case DockInfo::RIGHT_HALF: | 1220 case DockInfo::RIGHT_HALF: |
| 1219 UserMetrics::RecordAction( | 1221 content::RecordAction( |
| 1220 UserMetricsAction("DockingWindow_RightHalf")); | 1222 UserMetricsAction("DockingWindow_RightHalf")); |
| 1221 break; | 1223 break; |
| 1222 | 1224 |
| 1223 case DockInfo::BOTTOM_HALF: | 1225 case DockInfo::BOTTOM_HALF: |
| 1224 UserMetrics::RecordAction( | 1226 content::RecordAction( |
| 1225 UserMetricsAction("DockingWindow_BottomHalf")); | 1227 UserMetricsAction("DockingWindow_BottomHalf")); |
| 1226 break; | 1228 break; |
| 1227 | 1229 |
| 1228 default: | 1230 default: |
| 1229 NOTREACHED(); | 1231 NOTREACHED(); |
| 1230 break; | 1232 break; |
| 1231 } | 1233 } |
| 1232 } | 1234 } |
| 1233 // Compel the model to construct a new window for the detached TabContents. | 1235 // Compel the model to construct a new window for the detached TabContents. |
| 1234 views::Widget* widget = source_tabstrip_->GetWidget(); | 1236 views::Widget* widget = source_tabstrip_->GetWidget(); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1423 controller->Init(source_tabstrip, source_tab, tabs, mouse_offset, | 1425 controller->Init(source_tabstrip, source_tab, tabs, mouse_offset, |
| 1424 source_tab_offset, initial_selection_model); | 1426 source_tab_offset, initial_selection_model); |
| 1425 return controller; | 1427 return controller; |
| 1426 } | 1428 } |
| 1427 | 1429 |
| 1428 // static | 1430 // static |
| 1429 bool TabDragController::IsAttachedTo(BaseTabStrip* tab_strip) { | 1431 bool TabDragController::IsAttachedTo(BaseTabStrip* tab_strip) { |
| 1430 return instance_ && instance_->active()&& | 1432 return instance_ && instance_->active()&& |
| 1431 instance_->attached_tabstrip() == tab_strip; | 1433 instance_->attached_tabstrip() == tab_strip; |
| 1432 } | 1434 } |
| OLD | NEW |