| 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/gtk/tabs/dragged_tab_controller_gtk.h" | 5 #include "chrome/browser/ui/gtk/tabs/dragged_tab_controller_gtk.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/i18n/rtl.h" | 11 #include "base/i18n/rtl.h" |
| 12 #include "chrome/browser/platform_util.h" | 12 #include "chrome/browser/platform_util.h" |
| 13 #include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_creator.h" | 13 #include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_creator.h" |
| 14 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/gtk/browser_window_gtk.h" | 15 #include "chrome/browser/ui/gtk/browser_window_gtk.h" |
| 16 #include "chrome/browser/ui/gtk/gtk_util.h" | 16 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 17 #include "chrome/browser/ui/gtk/tabs/dragged_view_gtk.h" | 17 #include "chrome/browser/ui/gtk/tabs/dragged_view_gtk.h" |
| 18 #include "chrome/browser/ui/gtk/tabs/tab_strip_gtk.h" | 18 #include "chrome/browser/ui/gtk/tabs/tab_strip_gtk.h" |
| 19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 19 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 20 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 20 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 21 #include "chrome/common/chrome_notification_types.h" | 21 #include "chrome/common/chrome_notification_types.h" |
| 22 #include "content/public/browser/notification_source.h" | 22 #include "content/public/browser/notification_source.h" |
| 23 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
| 24 #include "ui/base/gtk/gtk_screen_util.h" | 24 #include "ui/base/gtk/gtk_screen_util.h" |
| 25 #include "ui/gfx/screen.h" | 25 #include "ui/gfx/screen.h" |
| 26 | 26 |
| 27 using content::OpenURLParams; | 27 using content::OpenURLParams; |
| 28 using content::WebContents; | 28 using content::WebContents; |
| 29 | 29 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 drag_data_.reset(); | 83 drag_data_.reset(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void DraggedTabControllerGtk::CaptureDragInfo(const gfx::Point& mouse_offset) { | 86 void DraggedTabControllerGtk::CaptureDragInfo(const gfx::Point& mouse_offset) { |
| 87 start_screen_point_ = gfx::Screen::GetCursorScreenPoint(); | 87 start_screen_point_ = gfx::Screen::GetCursorScreenPoint(); |
| 88 mouse_offset_ = mouse_offset; | 88 mouse_offset_ = mouse_offset; |
| 89 } | 89 } |
| 90 | 90 |
| 91 void DraggedTabControllerGtk::Drag() { | 91 void DraggedTabControllerGtk::Drag() { |
| 92 if (!drag_data_->GetSourceTabData()->tab_ || | 92 if (!drag_data_->GetSourceTabData()->tab_ || |
| 93 !drag_data_->GetSourceTabContentsWrapper() || | 93 !drag_data_->GetSourceTabContents() || |
| 94 !drag_data_->GetSourceWebContents()) { | 94 !drag_data_->GetSourceWebContents()) { |
| 95 return; | 95 return; |
| 96 } | 96 } |
| 97 | 97 |
| 98 bring_to_front_timer_.Stop(); | 98 bring_to_front_timer_.Stop(); |
| 99 | 99 |
| 100 EnsureDraggedView(); | 100 EnsureDraggedView(); |
| 101 | 101 |
| 102 // Before we get to dragging anywhere, ensure that we consider ourselves | 102 // Before we get to dragging anywhere, ensure that we consider ourselves |
| 103 // attached to the source tabstrip. | 103 // attached to the source tabstrip. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 128 | 128 |
| 129 bool DraggedTabControllerGtk::IsDraggingTab(const TabGtk* tab) { | 129 bool DraggedTabControllerGtk::IsDraggingTab(const TabGtk* tab) { |
| 130 for (size_t i = 0; i < drag_data_->size(); i++) { | 130 for (size_t i = 0; i < drag_data_->size(); i++) { |
| 131 if (tab == drag_data_->get(i)->tab_) | 131 if (tab == drag_data_->get(i)->tab_) |
| 132 return true; | 132 return true; |
| 133 } | 133 } |
| 134 return false; | 134 return false; |
| 135 } | 135 } |
| 136 | 136 |
| 137 bool DraggedTabControllerGtk::IsDraggingTabContents( | 137 bool DraggedTabControllerGtk::IsDraggingTabContents( |
| 138 const TabContentsWrapper* tab_contents) { | 138 const TabContents* tab_contents) { |
| 139 for (size_t i = 0; i < drag_data_->size(); i++) { | 139 for (size_t i = 0; i < drag_data_->size(); i++) { |
| 140 if (tab_contents == drag_data_->get(i)->contents_) | 140 if (tab_contents == drag_data_->get(i)->contents_) |
| 141 return true; | 141 return true; |
| 142 } | 142 } |
| 143 return false; | 143 return false; |
| 144 } | 144 } |
| 145 | 145 |
| 146 bool DraggedTabControllerGtk::IsTabDetached(const TabGtk* tab) { | 146 bool DraggedTabControllerGtk::IsTabDetached(const TabGtk* tab) { |
| 147 return IsDraggingTab(tab) && attached_tabstrip_ == NULL; | 147 return IsDraggingTab(tab) && attached_tabstrip_ == NULL; |
| 148 } | 148 } |
| 149 | 149 |
| 150 DraggedTabData DraggedTabControllerGtk::InitDraggedTabData(TabGtk* tab) { | 150 DraggedTabData DraggedTabControllerGtk::InitDraggedTabData(TabGtk* tab) { |
| 151 int source_model_index = source_tabstrip_->GetIndexOfTab(tab); | 151 int source_model_index = source_tabstrip_->GetIndexOfTab(tab); |
| 152 TabContentsWrapper* contents = | 152 TabContents* contents = |
| 153 source_tabstrip_->model()->GetTabContentsAt(source_model_index); | 153 source_tabstrip_->model()->GetTabContentsAt(source_model_index); |
| 154 bool pinned = source_tabstrip_->IsTabPinned(tab); | 154 bool pinned = source_tabstrip_->IsTabPinned(tab); |
| 155 bool mini = source_tabstrip_->model()->IsMiniTab(source_model_index); | 155 bool mini = source_tabstrip_->model()->IsMiniTab(source_model_index); |
| 156 // We need to be the delegate so we receive messages about stuff, | 156 // We need to be the delegate so we receive messages about stuff, |
| 157 // otherwise our dragged_contents() may be replaced and subsequently | 157 // otherwise our dragged_contents() may be replaced and subsequently |
| 158 // collected/destroyed while the drag is in process, leading to | 158 // collected/destroyed while the drag is in process, leading to |
| 159 // nasty crashes. | 159 // nasty crashes. |
| 160 content::WebContentsDelegate* original_delegate = | 160 content::WebContentsDelegate* original_delegate = |
| 161 contents->web_contents()->GetDelegate(); | 161 contents->web_contents()->GetDelegate(); |
| 162 contents->web_contents()->SetDelegate(this); | 162 contents->web_contents()->SetDelegate(this); |
| 163 | 163 |
| 164 DraggedTabData dragged_tab_data(tab, contents, original_delegate, | 164 DraggedTabData dragged_tab_data(tab, contents, original_delegate, |
| 165 source_model_index, pinned, mini); | 165 source_model_index, pinned, mini); |
| 166 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_DESTROYED, | 166 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_DESTROYED, |
| 167 content::Source<TabContentsWrapper>(dragged_tab_data.contents_)); | 167 content::Source<TabContents>(dragged_tab_data.contents_)); |
| 168 return dragged_tab_data; | 168 return dragged_tab_data; |
| 169 } | 169 } |
| 170 | 170 |
| 171 //////////////////////////////////////////////////////////////////////////////// | 171 //////////////////////////////////////////////////////////////////////////////// |
| 172 // DraggedTabControllerGtk, content::WebContentsDelegate implementation: | 172 // DraggedTabControllerGtk, content::WebContentsDelegate implementation: |
| 173 | 173 |
| 174 WebContents* DraggedTabControllerGtk::OpenURLFromTab( | 174 WebContents* DraggedTabControllerGtk::OpenURLFromTab( |
| 175 WebContents* source, | 175 WebContents* source, |
| 176 const OpenURLParams& params) { | 176 const OpenURLParams& params) { |
| 177 if (drag_data_->GetSourceTabData()->original_delegate_) { | 177 if (drag_data_->GetSourceTabData()->original_delegate_) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 } | 219 } |
| 220 | 220 |
| 221 //////////////////////////////////////////////////////////////////////////////// | 221 //////////////////////////////////////////////////////////////////////////////// |
| 222 // DraggedTabControllerGtk, content::NotificationObserver implementation: | 222 // DraggedTabControllerGtk, content::NotificationObserver implementation: |
| 223 | 223 |
| 224 void DraggedTabControllerGtk::Observe( | 224 void DraggedTabControllerGtk::Observe( |
| 225 int type, | 225 int type, |
| 226 const content::NotificationSource& source, | 226 const content::NotificationSource& source, |
| 227 const content::NotificationDetails& details) { | 227 const content::NotificationDetails& details) { |
| 228 DCHECK_EQ(chrome::NOTIFICATION_TAB_CONTENTS_DESTROYED, type); | 228 DCHECK_EQ(chrome::NOTIFICATION_TAB_CONTENTS_DESTROYED, type); |
| 229 TabContentsWrapper* destroyed_tab_contents = | 229 TabContents* destroyed_tab_contents = |
| 230 content::Source<TabContentsWrapper>(source).ptr(); | 230 content::Source<TabContents>(source).ptr(); |
| 231 WebContents* destroyed_web_contents = destroyed_tab_contents->web_contents(); | 231 WebContents* destroyed_web_contents = destroyed_tab_contents->web_contents(); |
| 232 for (size_t i = 0; i < drag_data_->size(); ++i) { | 232 for (size_t i = 0; i < drag_data_->size(); ++i) { |
| 233 if (drag_data_->get(i)->contents_ == destroyed_tab_contents) { | 233 if (drag_data_->get(i)->contents_ == destroyed_tab_contents) { |
| 234 // One of the tabs we're dragging has been destroyed. Cancel the drag. | 234 // One of the tabs we're dragging has been destroyed. Cancel the drag. |
| 235 if (destroyed_web_contents->GetDelegate() == this) | 235 if (destroyed_web_contents->GetDelegate() == this) |
| 236 destroyed_web_contents->SetDelegate(NULL); | 236 destroyed_web_contents->SetDelegate(NULL); |
| 237 drag_data_->get(i)->contents_ = NULL; | 237 drag_data_->get(i)->contents_ = NULL; |
| 238 drag_data_->get(i)->original_delegate_ = NULL; | 238 drag_data_->get(i)->original_delegate_ = NULL; |
| 239 EndDragImpl(TAB_DESTROYED); | 239 EndDragImpl(TAB_DESTROYED); |
| 240 return; | 240 return; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 } | 281 } |
| 282 | 282 |
| 283 if (attached_tabstrip_) | 283 if (attached_tabstrip_) |
| 284 MoveAttached(screen_point); | 284 MoveAttached(screen_point); |
| 285 else | 285 else |
| 286 MoveDetached(screen_point); | 286 MoveDetached(screen_point); |
| 287 } | 287 } |
| 288 | 288 |
| 289 void DraggedTabControllerGtk::RestoreSelection(TabStripModel* model) { | 289 void DraggedTabControllerGtk::RestoreSelection(TabStripModel* model) { |
| 290 for (size_t i = 0; i < drag_data_->size(); ++i) { | 290 for (size_t i = 0; i < drag_data_->size(); ++i) { |
| 291 TabContentsWrapper* contents = drag_data_->get(i)->contents_; | 291 TabContents* contents = drag_data_->get(i)->contents_; |
| 292 // If a tab is destroyed while dragging contents might be null. See | 292 // If a tab is destroyed while dragging contents might be null. See |
| 293 // http://crbug.com/115409. | 293 // http://crbug.com/115409. |
| 294 if (contents != NULL) { | 294 if (contents != NULL) { |
| 295 int index = model->GetIndexOfTabContents(contents); | 295 int index = model->GetIndexOfTabContents(contents); |
| 296 CHECK(index != TabStripModel::kNoTab); | 296 CHECK(index != TabStripModel::kNoTab); |
| 297 model->AddTabAtToSelection(index); | 297 model->AddTabAtToSelection(index); |
| 298 } | 298 } |
| 299 } | 299 } |
| 300 } | 300 } |
| 301 | 301 |
| 302 void DraggedTabControllerGtk::MoveAttached(const gfx::Point& screen_point) { | 302 void DraggedTabControllerGtk::MoveAttached(const gfx::Point& screen_point) { |
| 303 DCHECK(attached_tabstrip_); | 303 DCHECK(attached_tabstrip_); |
| 304 | 304 |
| 305 gfx::Point dragged_view_point = GetDraggedViewPoint(screen_point); | 305 gfx::Point dragged_view_point = GetDraggedViewPoint(screen_point); |
| 306 TabStripModel* attached_model = attached_tabstrip_->model(); | 306 TabStripModel* attached_model = attached_tabstrip_->model(); |
| 307 | 307 |
| 308 std::vector<TabGtk*> tabs(drag_data_->GetDraggedTabs()); | 308 std::vector<TabGtk*> tabs(drag_data_->GetDraggedTabs()); |
| 309 | 309 |
| 310 // Determine the horizontal move threshold. This is dependent on the width | 310 // Determine the horizontal move threshold. This is dependent on the width |
| 311 // of tabs. The smaller the tabs compared to the standard size, the smaller | 311 // of tabs. The smaller the tabs compared to the standard size, the smaller |
| 312 // the threshold. | 312 // the threshold. |
| 313 double unselected, selected; | 313 double unselected, selected; |
| 314 attached_tabstrip_->GetCurrentTabWidths(&unselected, &selected); | 314 attached_tabstrip_->GetCurrentTabWidths(&unselected, &selected); |
| 315 double ratio = unselected / TabGtk::GetStandardSize().width(); | 315 double ratio = unselected / TabGtk::GetStandardSize().width(); |
| 316 int threshold = static_cast<int>(ratio * kHorizontalMoveThreshold); | 316 int threshold = static_cast<int>(ratio * kHorizontalMoveThreshold); |
| 317 | 317 |
| 318 // Update the model, moving the TabContentsWrapper from one index to another. | 318 // Update the model, moving the TabContents from one index to another. |
| 319 // Do this only if we have moved a minimum distance since the last reorder (to | 319 // Do this only if we have moved a minimum distance since the last reorder (to |
| 320 // prevent jitter) or if this is the first move and the tabs are not | 320 // prevent jitter) or if this is the first move and the tabs are not |
| 321 // consecutive. | 321 // consecutive. |
| 322 if (abs(screen_point.x() - last_move_screen_x_) > threshold || | 322 if (abs(screen_point.x() - last_move_screen_x_) > threshold || |
| 323 (initial_move_ && !AreTabsConsecutive())) { | 323 (initial_move_ && !AreTabsConsecutive())) { |
| 324 if (initial_move_ && !AreTabsConsecutive()) { | 324 if (initial_move_ && !AreTabsConsecutive()) { |
| 325 // Making dragged tabs adjacent, this is done only once, if necessary. | 325 // Making dragged tabs adjacent, this is done only once, if necessary. |
| 326 attached_tabstrip_->model()->MoveSelectedTabsTo( | 326 attached_tabstrip_->model()->MoveSelectedTabsTo( |
| 327 drag_data_->GetSourceTabData()->source_model_index_ - | 327 drag_data_->GetSourceTabData()->source_model_index_ - |
| 328 drag_data_->source_tab_index()); | 328 drag_data_->source_tab_index()); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 &unselected_width, &selected_width); | 417 &unselected_width, &selected_width); |
| 418 | 418 |
| 419 GtkWidget* parent_window = gtk_widget_get_parent( | 419 GtkWidget* parent_window = gtk_widget_get_parent( |
| 420 gtk_widget_get_parent(attached_tabstrip_->tabstrip_.get())); | 420 gtk_widget_get_parent(attached_tabstrip_->tabstrip_.get())); |
| 421 gfx::Rect window_bounds = ui::GetWidgetScreenBounds(parent_window); | 421 gfx::Rect window_bounds = ui::GetWidgetScreenBounds(parent_window); |
| 422 dragged_view_->Attach(static_cast<int>(floor(selected_width + 0.5)), | 422 dragged_view_->Attach(static_cast<int>(floor(selected_width + 0.5)), |
| 423 TabGtk::GetMiniWidth(), window_bounds.width()); | 423 TabGtk::GetMiniWidth(), window_bounds.width()); |
| 424 | 424 |
| 425 if (attached_dragged_tabs.size() == 0) { | 425 if (attached_dragged_tabs.size() == 0) { |
| 426 // There is no tab in |attached_tabstrip| that corresponds to the dragged | 426 // There is no tab in |attached_tabstrip| that corresponds to the dragged |
| 427 // TabContentsWrapper. We must now create one. | 427 // TabContents. We must now create one. |
| 428 | 428 |
| 429 // Remove ourselves as the delegate now that the dragged TabContentsWrapper | 429 // Remove ourselves as the delegate now that the dragged TabContents |
| 430 // is being inserted back into a Browser. | 430 // is being inserted back into a Browser. |
| 431 for (size_t i = 0; i < drag_data_->size(); ++i) { | 431 for (size_t i = 0; i < drag_data_->size(); ++i) { |
| 432 drag_data_->get(i)->contents_->web_contents()->SetDelegate(NULL); | 432 drag_data_->get(i)->contents_->web_contents()->SetDelegate(NULL); |
| 433 drag_data_->get(i)->original_delegate_ = NULL; | 433 drag_data_->get(i)->original_delegate_ = NULL; |
| 434 } | 434 } |
| 435 | 435 |
| 436 // Return the TabContentsWrapper to normalcy. | 436 // Return the TabContents to normalcy. |
| 437 drag_data_->GetSourceWebContents()->SetCapturingContents(false); | 437 drag_data_->GetSourceWebContents()->SetCapturingContents(false); |
| 438 | 438 |
| 439 // We need to ask the tabstrip we're attached to ensure that the ideal | 439 // We need to ask the tabstrip we're attached to ensure that the ideal |
| 440 // bounds for all its tabs are correctly generated, because the calculation | 440 // bounds for all its tabs are correctly generated, because the calculation |
| 441 // in GetInsertionIndexForDraggedBounds needs them to be to figure out the | 441 // in GetInsertionIndexForDraggedBounds needs them to be to figure out the |
| 442 // appropriate insertion index. | 442 // appropriate insertion index. |
| 443 attached_tabstrip_->GenerateIdealBounds(); | 443 attached_tabstrip_->GenerateIdealBounds(); |
| 444 | 444 |
| 445 // Inserting counts as a move. We don't want the tabs to jitter when the | 445 // Inserting counts as a move. We don't want the tabs to jitter when the |
| 446 // user moves the tab immediately after attaching it. | 446 // user moves the tab immediately after attaching it. |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 } | 545 } |
| 546 | 546 |
| 547 if (index == -1) { | 547 if (index == -1) { |
| 548 if (dragged_bounds_end > right_tab_x) | 548 if (dragged_bounds_end > right_tab_x) |
| 549 index = attached_tabstrip_->GetTabCount(); | 549 index = attached_tabstrip_->GetTabCount(); |
| 550 else | 550 else |
| 551 index = 0; | 551 index = 0; |
| 552 } | 552 } |
| 553 | 553 |
| 554 TabGtk* tab = GetTabMatchingDraggedContents( | 554 TabGtk* tab = GetTabMatchingDraggedContents( |
| 555 attached_tabstrip_, drag_data_->GetSourceTabContentsWrapper()); | 555 attached_tabstrip_, drag_data_->GetSourceTabContents()); |
| 556 if (tab == NULL) { | 556 if (tab == NULL) { |
| 557 // If dragged tabs are not attached yet, we don't need to constrain the | 557 // If dragged tabs are not attached yet, we don't need to constrain the |
| 558 // index. | 558 // index. |
| 559 return index; | 559 return index; |
| 560 } | 560 } |
| 561 | 561 |
| 562 int max_index = | 562 int max_index = |
| 563 attached_tabstrip_-> GetTabCount() - static_cast<int>(drag_data_->size()); | 563 attached_tabstrip_-> GetTabCount() - static_cast<int>(drag_data_->size()); |
| 564 return std::max(0, std::min(max_index, index)); | 564 return std::max(0, std::min(max_index, index)); |
| 565 } | 565 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 | 606 |
| 607 int DraggedTabControllerGtk::NormalizeIndexToAttachedTabStrip(int index) const { | 607 int DraggedTabControllerGtk::NormalizeIndexToAttachedTabStrip(int index) const { |
| 608 if (index >= attached_tabstrip_->model_->count()) | 608 if (index >= attached_tabstrip_->model_->count()) |
| 609 return attached_tabstrip_->model_->count() - 1; | 609 return attached_tabstrip_->model_->count() - 1; |
| 610 if (index == TabStripModel::kNoTab) | 610 if (index == TabStripModel::kNoTab) |
| 611 return 0; | 611 return 0; |
| 612 return index; | 612 return index; |
| 613 } | 613 } |
| 614 | 614 |
| 615 TabGtk* DraggedTabControllerGtk::GetTabMatchingDraggedContents( | 615 TabGtk* DraggedTabControllerGtk::GetTabMatchingDraggedContents( |
| 616 TabStripGtk* tabstrip, TabContentsWrapper* tab_contents) { | 616 TabStripGtk* tabstrip, TabContents* tab_contents) { |
| 617 int index = tabstrip->model()->GetIndexOfTabContents(tab_contents); | 617 int index = tabstrip->model()->GetIndexOfTabContents(tab_contents); |
| 618 return index == TabStripModel::kNoTab ? NULL : tabstrip->GetTabAt(index); | 618 return index == TabStripModel::kNoTab ? NULL : tabstrip->GetTabAt(index); |
| 619 } | 619 } |
| 620 | 620 |
| 621 std::vector<TabGtk*> DraggedTabControllerGtk::GetTabsMatchingDraggedContents( | 621 std::vector<TabGtk*> DraggedTabControllerGtk::GetTabsMatchingDraggedContents( |
| 622 TabStripGtk* tabstrip) { | 622 TabStripGtk* tabstrip) { |
| 623 std::vector<TabGtk*> dragged_tabs; | 623 std::vector<TabGtk*> dragged_tabs; |
| 624 for (size_t i = 0; i < drag_data_->size(); ++i) { | 624 for (size_t i = 0; i < drag_data_->size(); ++i) { |
| 625 if (!drag_data_->get(i)->contents_) | 625 if (!drag_data_->get(i)->contents_) |
| 626 continue; | 626 continue; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 bool destroy_immediately = true; | 746 bool destroy_immediately = true; |
| 747 if (attached_tabstrip_) { | 747 if (attached_tabstrip_) { |
| 748 // We don't need to do anything other than make the tabs visible again, | 748 // We don't need to do anything other than make the tabs visible again, |
| 749 // since the dragged view is going away. | 749 // since the dragged view is going away. |
| 750 dragged_view_->AnimateToBounds(GetAnimateBounds(), | 750 dragged_view_->AnimateToBounds(GetAnimateBounds(), |
| 751 base::Bind(&DraggedTabControllerGtk::OnAnimateToBoundsComplete, | 751 base::Bind(&DraggedTabControllerGtk::OnAnimateToBoundsComplete, |
| 752 base::Unretained(this))); | 752 base::Unretained(this))); |
| 753 destroy_immediately = false; | 753 destroy_immediately = false; |
| 754 } else { | 754 } else { |
| 755 // Compel the model to construct a new window for the detached | 755 // Compel the model to construct a new window for the detached |
| 756 // TabContentsWrapper. | 756 // TabContents. |
| 757 BrowserWindowGtk* window = source_tabstrip_->window(); | 757 BrowserWindowGtk* window = source_tabstrip_->window(); |
| 758 gfx::Rect window_bounds = window->GetRestoredBounds(); | 758 gfx::Rect window_bounds = window->GetRestoredBounds(); |
| 759 window_bounds.set_origin(GetWindowCreatePoint()); | 759 window_bounds.set_origin(GetWindowCreatePoint()); |
| 760 Browser* new_browser = | 760 Browser* new_browser = |
| 761 source_tabstrip_->model()->delegate()->CreateNewStripWithContents( | 761 source_tabstrip_->model()->delegate()->CreateNewStripWithContents( |
| 762 drag_data_->get(0)->contents_, | 762 drag_data_->get(0)->contents_, |
| 763 window_bounds, | 763 window_bounds, |
| 764 dock_info_, | 764 dock_info_, |
| 765 window->IsMaximized()); | 765 window->IsMaximized()); |
| 766 TabStripModel* new_model = new_browser->tab_strip_model(); | 766 TabStripModel* new_model = new_browser->tab_strip_model(); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 } | 839 } |
| 840 | 840 |
| 841 void DraggedTabControllerGtk::CleanUpDraggedTabs() { | 841 void DraggedTabControllerGtk::CleanUpDraggedTabs() { |
| 842 // If we were attached to the source tabstrip, dragged tabs will be in use. If | 842 // If we were attached to the source tabstrip, dragged tabs will be in use. If |
| 843 // we were detached or attached to another tabstrip, we can safely remove | 843 // we were detached or attached to another tabstrip, we can safely remove |
| 844 // them and delete them now. | 844 // them and delete them now. |
| 845 if (attached_tabstrip_ != source_tabstrip_) { | 845 if (attached_tabstrip_ != source_tabstrip_) { |
| 846 for (size_t i = 0; i < drag_data_->size(); ++i) { | 846 for (size_t i = 0; i < drag_data_->size(); ++i) { |
| 847 if (drag_data_->get(i)->contents_) { | 847 if (drag_data_->get(i)->contents_) { |
| 848 registrar_.Remove(this, chrome::NOTIFICATION_TAB_CONTENTS_DESTROYED, | 848 registrar_.Remove(this, chrome::NOTIFICATION_TAB_CONTENTS_DESTROYED, |
| 849 content::Source<TabContentsWrapper>(drag_data_->get(i)->contents_)); | 849 content::Source<TabContents>(drag_data_->get(i)->contents_)); |
| 850 } | 850 } |
| 851 source_tabstrip_->DestroyDraggedTab(drag_data_->get(i)->tab_); | 851 source_tabstrip_->DestroyDraggedTab(drag_data_->get(i)->tab_); |
| 852 drag_data_->get(i)->tab_ = NULL; | 852 drag_data_->get(i)->tab_ = NULL; |
| 853 } | 853 } |
| 854 } | 854 } |
| 855 } | 855 } |
| 856 | 856 |
| 857 void DraggedTabControllerGtk::OnAnimateToBoundsComplete() { | 857 void DraggedTabControllerGtk::OnAnimateToBoundsComplete() { |
| 858 // Sometimes, for some reason, in automation we can be called back on a | 858 // Sometimes, for some reason, in automation we can be called back on a |
| 859 // detach even though we aren't attached to a tabstrip. Guard against that. | 859 // detach even though we aren't attached to a tabstrip. Guard against that. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 883 | 883 |
| 884 bool DraggedTabControllerGtk::AreTabsConsecutive() { | 884 bool DraggedTabControllerGtk::AreTabsConsecutive() { |
| 885 for (size_t i = 1; i < drag_data_->size(); ++i) { | 885 for (size_t i = 1; i < drag_data_->size(); ++i) { |
| 886 if (drag_data_->get(i - 1)->source_model_index_ + 1 != | 886 if (drag_data_->get(i - 1)->source_model_index_ + 1 != |
| 887 drag_data_->get(i)->source_model_index_) { | 887 drag_data_->get(i)->source_model_index_) { |
| 888 return false; | 888 return false; |
| 889 } | 889 } |
| 890 } | 890 } |
| 891 return true; | 891 return true; |
| 892 } | 892 } |
| OLD | NEW |