| 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/dragged_tab_controller.h" | 5 #include "chrome/browser/ui/views/tabs/dragged_tab_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" |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 } | 390 } |
| 391 | 391 |
| 392 void DraggedTabController::InitTabDragData(BaseTab* tab, | 392 void DraggedTabController::InitTabDragData(BaseTab* tab, |
| 393 TabDragData* drag_data) { | 393 TabDragData* drag_data) { |
| 394 drag_data->source_model_index = | 394 drag_data->source_model_index = |
| 395 source_tabstrip_->GetModelIndexOfBaseTab(tab); | 395 source_tabstrip_->GetModelIndexOfBaseTab(tab); |
| 396 drag_data->contents = GetModel(source_tabstrip_)->GetTabContentsAt( | 396 drag_data->contents = GetModel(source_tabstrip_)->GetTabContentsAt( |
| 397 drag_data->source_model_index); | 397 drag_data->source_model_index); |
| 398 drag_data->pinned = source_tabstrip_->IsTabPinned(tab); | 398 drag_data->pinned = source_tabstrip_->IsTabPinned(tab); |
| 399 registrar_.Add(this, | 399 registrar_.Add(this, |
| 400 NotificationType::TAB_CONTENTS_DESTROYED, | 400 content::NOTIFICATION_TAB_CONTENTS_DESTROYED, |
| 401 Source<TabContents>(drag_data->contents->tab_contents())); | 401 Source<TabContents>(drag_data->contents->tab_contents())); |
| 402 | 402 |
| 403 // We need to be the delegate so we receive messages about stuff, otherwise | 403 // We need to be the delegate so we receive messages about stuff, otherwise |
| 404 // our dragged TabContents may be replaced and subsequently | 404 // our dragged TabContents may be replaced and subsequently |
| 405 // collected/destroyed while the drag is in process, leading to nasty crashes. | 405 // collected/destroyed while the drag is in process, leading to nasty crashes. |
| 406 drag_data->original_delegate = | 406 drag_data->original_delegate = |
| 407 drag_data->contents->tab_contents()->delegate(); | 407 drag_data->contents->tab_contents()->delegate(); |
| 408 drag_data->contents->tab_contents()->set_delegate(this); | 408 drag_data->contents->tab_contents()->set_delegate(this); |
| 409 } | 409 } |
| 410 | 410 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 } | 464 } |
| 465 | 465 |
| 466 content::JavaScriptDialogCreator* | 466 content::JavaScriptDialogCreator* |
| 467 DraggedTabController::GetJavaScriptDialogCreator() { | 467 DraggedTabController::GetJavaScriptDialogCreator() { |
| 468 return GetJavaScriptDialogCreatorInstance(); | 468 return GetJavaScriptDialogCreatorInstance(); |
| 469 } | 469 } |
| 470 | 470 |
| 471 /////////////////////////////////////////////////////////////////////////////// | 471 /////////////////////////////////////////////////////////////////////////////// |
| 472 // DraggedTabController, NotificationObserver implementation: | 472 // DraggedTabController, NotificationObserver implementation: |
| 473 | 473 |
| 474 void DraggedTabController::Observe(NotificationType type, | 474 void DraggedTabController::Observe(int type, |
| 475 const NotificationSource& source, | 475 const NotificationSource& source, |
| 476 const NotificationDetails& details) { | 476 const NotificationDetails& details) { |
| 477 DCHECK_EQ(type.value, NotificationType::TAB_CONTENTS_DESTROYED); | 477 DCHECK_EQ(type, content::NOTIFICATION_TAB_CONTENTS_DESTROYED); |
| 478 TabContents* destroyed_contents = Source<TabContents>(source).ptr(); | 478 TabContents* destroyed_contents = Source<TabContents>(source).ptr(); |
| 479 for (size_t i = 0; i < drag_data_.size(); ++i) { | 479 for (size_t i = 0; i < drag_data_.size(); ++i) { |
| 480 if (drag_data_[i].contents->tab_contents() == destroyed_contents) { | 480 if (drag_data_[i].contents->tab_contents() == destroyed_contents) { |
| 481 // One of the tabs we're dragging has been destroyed. Cancel the drag. | 481 // One of the tabs we're dragging has been destroyed. Cancel the drag. |
| 482 if (destroyed_contents->delegate() == this) | 482 if (destroyed_contents->delegate() == this) |
| 483 destroyed_contents->set_delegate(NULL); | 483 destroyed_contents->set_delegate(NULL); |
| 484 drag_data_[i].contents = NULL; | 484 drag_data_[i].contents = NULL; |
| 485 drag_data_[i].original_delegate = NULL; | 485 drag_data_[i].original_delegate = NULL; |
| 486 EndDragImpl(TAB_DESTROYED); | 486 EndDragImpl(TAB_DESTROYED); |
| 487 return; | 487 return; |
| (...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1420 | 1420 |
| 1421 bool DraggedTabController::AreTabsConsecutive() { | 1421 bool DraggedTabController::AreTabsConsecutive() { |
| 1422 for (size_t i = 1; i < drag_data_.size(); ++i) { | 1422 for (size_t i = 1; i < drag_data_.size(); ++i) { |
| 1423 if (drag_data_[i - 1].source_model_index + 1 != | 1423 if (drag_data_[i - 1].source_model_index + 1 != |
| 1424 drag_data_[i].source_model_index) { | 1424 drag_data_[i].source_model_index) { |
| 1425 return false; | 1425 return false; |
| 1426 } | 1426 } |
| 1427 } | 1427 } |
| 1428 return true; | 1428 return true; |
| 1429 } | 1429 } |
| OLD | NEW |