Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(492)

Side by Side Diff: chrome/browser/ui/views/tabs/tab_drag_controller.cc

Issue 10540100: TabContentsWrapper -> TabContents, part 48. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_controller.h" 5 #include "chrome/browser/ui/views/tabs/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"
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 } 459 }
460 460
461 void TabDragController::InitTabDragData(BaseTab* tab, 461 void TabDragController::InitTabDragData(BaseTab* tab,
462 TabDragData* drag_data) { 462 TabDragData* drag_data) {
463 drag_data->source_model_index = 463 drag_data->source_model_index =
464 source_tabstrip_->GetModelIndexOfBaseTab(tab); 464 source_tabstrip_->GetModelIndexOfBaseTab(tab);
465 drag_data->contents = GetModel(source_tabstrip_)->GetTabContentsAt( 465 drag_data->contents = GetModel(source_tabstrip_)->GetTabContentsAt(
466 drag_data->source_model_index); 466 drag_data->source_model_index);
467 drag_data->pinned = source_tabstrip_->IsTabPinned(tab); 467 drag_data->pinned = source_tabstrip_->IsTabPinned(tab);
468 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_DESTROYED, 468 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_DESTROYED,
469 content::Source<TabContentsWrapper>(drag_data->contents)); 469 content::Source<TabContents>(drag_data->contents));
470 470
471 if (!detach_into_browser_) { 471 if (!detach_into_browser_) {
472 drag_data->original_delegate = 472 drag_data->original_delegate =
473 drag_data->contents->web_contents()->GetDelegate(); 473 drag_data->contents->web_contents()->GetDelegate();
474 drag_data->contents->web_contents()->SetDelegate(this); 474 drag_data->contents->web_contents()->SetDelegate(this);
475 } 475 }
476 } 476 }
477 477
478 /////////////////////////////////////////////////////////////////////////////// 478 ///////////////////////////////////////////////////////////////////////////////
479 // TabDragController, PageNavigator implementation: 479 // TabDragController, PageNavigator implementation:
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 } 548 }
549 549
550 /////////////////////////////////////////////////////////////////////////////// 550 ///////////////////////////////////////////////////////////////////////////////
551 // TabDragController, content::NotificationObserver implementation: 551 // TabDragController, content::NotificationObserver implementation:
552 552
553 void TabDragController::Observe( 553 void TabDragController::Observe(
554 int type, 554 int type,
555 const content::NotificationSource& source, 555 const content::NotificationSource& source,
556 const content::NotificationDetails& details) { 556 const content::NotificationDetails& details) {
557 DCHECK_EQ(chrome::NOTIFICATION_TAB_CONTENTS_DESTROYED, type); 557 DCHECK_EQ(chrome::NOTIFICATION_TAB_CONTENTS_DESTROYED, type);
558 TabContentsWrapper* destroyed_tab_contents = 558 TabContents* destroyed_tab_contents =
559 content::Source<TabContentsWrapper>(source).ptr(); 559 content::Source<TabContents>(source).ptr();
560 WebContents* destroyed_web_contents = destroyed_tab_contents->web_contents(); 560 WebContents* destroyed_web_contents = destroyed_tab_contents->web_contents();
561 for (size_t i = 0; i < drag_data_.size(); ++i) { 561 for (size_t i = 0; i < drag_data_.size(); ++i) {
562 if (drag_data_[i].contents == destroyed_tab_contents) { 562 if (drag_data_[i].contents == destroyed_tab_contents) {
563 // One of the tabs we're dragging has been destroyed. Cancel the drag. 563 // One of the tabs we're dragging has been destroyed. Cancel the drag.
564 if (destroyed_web_contents->GetDelegate() == this) 564 if (destroyed_web_contents->GetDelegate() == this)
565 destroyed_web_contents->SetDelegate(NULL); 565 destroyed_web_contents->SetDelegate(NULL);
566 drag_data_[i].contents = NULL; 566 drag_data_[i].contents = NULL;
567 drag_data_[i].original_delegate = NULL; 567 drag_data_[i].original_delegate = NULL;
568 EndDragImpl(TAB_DESTROYED); 568 EndDragImpl(TAB_DESTROYED);
569 return; 569 return;
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 864
865 bool did_layout = false; 865 bool did_layout = false;
866 // Update the model, moving the WebContents from one index to another. Do this 866 // Update the model, moving the WebContents from one index to another. Do this
867 // only if we have moved a minimum distance since the last reorder (to prevent 867 // only if we have moved a minimum distance since the last reorder (to prevent
868 // jitter) or if this the first move and the tabs are not consecutive. 868 // jitter) or if this the first move and the tabs are not consecutive.
869 if ((abs(screen_point.x() - last_move_screen_loc_) > threshold || 869 if ((abs(screen_point.x() - last_move_screen_loc_) > threshold ||
870 (initial_move_ && !AreTabsConsecutive()))) { 870 (initial_move_ && !AreTabsConsecutive()))) {
871 TabStripModel* attached_model = GetModel(attached_tabstrip_); 871 TabStripModel* attached_model = GetModel(attached_tabstrip_);
872 gfx::Rect bounds = GetDraggedViewTabStripBounds(dragged_view_point); 872 gfx::Rect bounds = GetDraggedViewTabStripBounds(dragged_view_point);
873 int to_index = GetInsertionIndexForDraggedBounds(bounds); 873 int to_index = GetInsertionIndexForDraggedBounds(bounds);
874 TabContentsWrapper* last_contents = 874 TabContents* last_contents = drag_data_[drag_data_.size() - 1].contents;
875 drag_data_[drag_data_.size() - 1].contents;
876 int index_of_last_item = 875 int index_of_last_item =
877 attached_model->GetIndexOfTabContents(last_contents); 876 attached_model->GetIndexOfTabContents(last_contents);
878 if (initial_move_) { 877 if (initial_move_) {
879 // TabStrip determines if the tabs needs to be animated based on model 878 // TabStrip determines if the tabs needs to be animated based on model
880 // position. This means we need to invoke LayoutDraggedTabsAt before 879 // position. This means we need to invoke LayoutDraggedTabsAt before
881 // changing the model. 880 // changing the model.
882 attached_tabstrip_->LayoutDraggedTabsAt( 881 attached_tabstrip_->LayoutDraggedTabsAt(
883 tabs, source_tab_drag_data()->attached_tab, dragged_view_point, 882 tabs, source_tab_drag_data()->attached_tab, dragged_view_point,
884 initial_move_); 883 initial_move_);
885 did_layout = true; 884 did_layout = true;
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after
1877 } 1876 }
1878 1877
1879 default: 1878 default:
1880 break; // Nothing to do for DETACH_ABOVE_OR_BELOW. 1879 break; // Nothing to do for DETACH_ABOVE_OR_BELOW.
1881 } 1880 }
1882 1881
1883 SetTrackedByWorkspace(browser->window()->GetNativeWindow(), false); 1882 SetTrackedByWorkspace(browser->window()->GetNativeWindow(), false);
1884 browser->window()->SetBounds(new_bounds); 1883 browser->window()->SetBounds(new_bounds);
1885 return browser; 1884 return browser;
1886 } 1885 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698