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

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

Issue 8921032: Adds some debugging code in hopes of identifying a crasher. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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
« no previous file with comments | « no previous file | content/browser/tab_contents/tab_contents_delegate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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" 25 #include "content/browser/user_metrics.h"
26 #include "content/public/browser/notification_details.h" 26 #include "content/public/browser/notification_details.h"
27 #include "content/public/browser/notification_service.h"
27 #include "content/public/browser/notification_source.h" 28 #include "content/public/browser/notification_source.h"
28 #include "content/public/browser/notification_types.h" 29 #include "content/public/browser/notification_types.h"
29 #include "grit/theme_resources.h" 30 #include "grit/theme_resources.h"
30 #include "third_party/skia/include/core/SkBitmap.h" 31 #include "third_party/skia/include/core/SkBitmap.h"
31 #include "ui/base/animation/animation.h" 32 #include "ui/base/animation/animation.h"
32 #include "ui/base/animation/animation_delegate.h" 33 #include "ui/base/animation/animation_delegate.h"
33 #include "ui/base/animation/slide_animation.h" 34 #include "ui/base/animation/slide_animation.h"
34 #include "ui/base/events.h" 35 #include "ui/base/events.h"
35 #include "ui/base/resource/resource_bundle.h" 36 #include "ui/base/resource/resource_bundle.h"
36 #include "ui/gfx/canvas_skia.h" 37 #include "ui/gfx/canvas_skia.h"
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 354
354 // Listen for Esc key presses. 355 // Listen for Esc key presses.
355 MessageLoopForUI::current()->AddObserver(this); 356 MessageLoopForUI::current()->AddObserver(this);
356 357
357 if (source_tab->width() > 0) { 358 if (source_tab->width() > 0) {
358 offset_to_width_ratio_ = static_cast<float>(source_tab_offset_) / 359 offset_to_width_ratio_ = static_cast<float>(source_tab_offset_) /
359 static_cast<float>(source_tab->width()); 360 static_cast<float>(source_tab->width());
360 } 361 }
361 InitWindowCreatePoint(); 362 InitWindowCreatePoint();
362 initial_selection_model_.Copy(initial_selection_model); 363 initial_selection_model_.Copy(initial_selection_model);
364
365 registrar_.Add(
366 this,
367 content::NOTIFICATION_TAB_CONTENTS_DELEGATE_DESTROYED,
368 content::NotificationService::AllSources());
363 } 369 }
364 370
365 void DefaultTabDragController::InitTabDragData(BaseTab* tab, 371 void DefaultTabDragController::InitTabDragData(BaseTab* tab,
366 TabDragData* drag_data) { 372 TabDragData* drag_data) {
367 drag_data->source_model_index = 373 drag_data->source_model_index =
368 source_tabstrip_->GetModelIndexOfBaseTab(tab); 374 source_tabstrip_->GetModelIndexOfBaseTab(tab);
369 drag_data->contents = GetModel(source_tabstrip_)->GetTabContentsAt( 375 drag_data->contents = GetModel(source_tabstrip_)->GetTabContentsAt(
370 drag_data->source_model_index); 376 drag_data->source_model_index);
371 drag_data->pinned = source_tabstrip_->IsTabPinned(tab); 377 drag_data->pinned = source_tabstrip_->IsTabPinned(tab);
372 registrar_.Add( 378 registrar_.Add(
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 return GetJavaScriptDialogCreatorInstance(); 470 return GetJavaScriptDialogCreatorInstance();
465 } 471 }
466 472
467 /////////////////////////////////////////////////////////////////////////////// 473 ///////////////////////////////////////////////////////////////////////////////
468 // DefaultTabDragController, content::NotificationObserver implementation: 474 // DefaultTabDragController, content::NotificationObserver implementation:
469 475
470 void DefaultTabDragController::Observe( 476 void DefaultTabDragController::Observe(
471 int type, 477 int type,
472 const content::NotificationSource& source, 478 const content::NotificationSource& source,
473 const content::NotificationDetails& details) { 479 const content::NotificationDetails& details) {
480 if (type == content::NOTIFICATION_TAB_CONTENTS_DELEGATE_DESTROYED) {
481 TabContentsDelegate* delegate =
482 content::Source<TabContentsDelegate>(source).ptr();
483 for (size_t i = 0; i < drag_data_.size(); ++i)
484 CHECK_NE(delegate, drag_data_[i].original_delegate);
485 return;
486 }
474 DCHECK_EQ(type, content::NOTIFICATION_TAB_CONTENTS_DESTROYED); 487 DCHECK_EQ(type, content::NOTIFICATION_TAB_CONTENTS_DESTROYED);
475 TabContents* destroyed_contents = content::Source<TabContents>(source).ptr(); 488 TabContents* destroyed_contents = content::Source<TabContents>(source).ptr();
476 for (size_t i = 0; i < drag_data_.size(); ++i) { 489 for (size_t i = 0; i < drag_data_.size(); ++i) {
477 if (drag_data_[i].contents->tab_contents() == destroyed_contents) { 490 if (drag_data_[i].contents->tab_contents() == destroyed_contents) {
478 // One of the tabs we're dragging has been destroyed. Cancel the drag. 491 // One of the tabs we're dragging has been destroyed. Cancel the drag.
479 if (destroyed_contents->delegate() == this) 492 if (destroyed_contents->delegate() == this)
480 destroyed_contents->set_delegate(NULL); 493 destroyed_contents->set_delegate(NULL);
481 drag_data_[i].contents = NULL; 494 drag_data_[i].contents = NULL;
482 drag_data_[i].original_delegate = NULL; 495 drag_data_[i].original_delegate = NULL;
483 EndDragImpl(TAB_DESTROYED); 496 EndDragImpl(TAB_DESTROYED);
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after
1410 controller->Init(source_tabstrip, source_tab, tabs, mouse_offset, 1423 controller->Init(source_tabstrip, source_tab, tabs, mouse_offset,
1411 source_tab_offset, initial_selection_model); 1424 source_tab_offset, initial_selection_model);
1412 return controller; 1425 return controller;
1413 } 1426 }
1414 1427
1415 // static 1428 // static
1416 bool TabDragController::IsAttachedTo(BaseTabStrip* tab_strip) { 1429 bool TabDragController::IsAttachedTo(BaseTabStrip* tab_strip) {
1417 return instance_ && instance_->active()&& 1430 return instance_ && instance_->active()&&
1418 instance_->attached_tabstrip() == tab_strip; 1431 instance_->attached_tabstrip() == tab_strip;
1419 } 1432 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/tab_contents/tab_contents_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698