OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/frame/browser_view.h" | 5 #include "chrome/browser/ui/views/frame/browser_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 force_location_bar_focus_(false), | 430 force_location_bar_focus_(false), |
431 immersive_mode_controller_(chrome::CreateImmersiveModeController()), | 431 immersive_mode_controller_(chrome::CreateImmersiveModeController()), |
432 #if defined(OS_CHROMEOS) | 432 #if defined(OS_CHROMEOS) |
433 scroll_end_effect_controller_(ScrollEndEffectController::Create()), | 433 scroll_end_effect_controller_(ScrollEndEffectController::Create()), |
434 #endif | 434 #endif |
435 color_change_listener_(this), | 435 color_change_listener_(this), |
436 activate_modal_dialog_factory_(this) { | 436 activate_modal_dialog_factory_(this) { |
437 } | 437 } |
438 | 438 |
439 BrowserView::~BrowserView() { | 439 BrowserView::~BrowserView() { |
| 440 // All the tabs should have been destroyed already. If we were closed by the |
| 441 // OS with some tabs than the NativeBrowserFrame should have destroyed them. |
| 442 DCHECK_EQ(0, browser_->tab_strip_model()->count()); |
| 443 |
440 // Immersive mode may need to reparent views before they are removed/deleted. | 444 // Immersive mode may need to reparent views before they are removed/deleted. |
441 immersive_mode_controller_.reset(); | 445 immersive_mode_controller_.reset(); |
442 | 446 |
443 browser_->tab_strip_model()->RemoveObserver(this); | 447 browser_->tab_strip_model()->RemoveObserver(this); |
444 | 448 |
445 #if defined(OS_WIN) | 449 #if defined(OS_WIN) |
446 // Stop hung plugin monitoring. | 450 // Stop hung plugin monitoring. |
447 ticker_.Stop(); | 451 ticker_.Stop(); |
448 ticker_.UnregisterTickHandler(&hung_window_detector_); | 452 ticker_.UnregisterTickHandler(&hung_window_detector_); |
449 | 453 |
(...skipping 20 matching lines...) Expand all Loading... |
470 if (browser_view_layout) | 474 if (browser_view_layout) |
471 browser_view_layout->set_tab_strip(NULL); | 475 browser_view_layout->set_tab_strip(NULL); |
472 delete tabstrip_; | 476 delete tabstrip_; |
473 tabstrip_ = NULL; | 477 tabstrip_ = NULL; |
474 } | 478 } |
475 // Child views maintain PrefMember attributes that point to | 479 // Child views maintain PrefMember attributes that point to |
476 // OffTheRecordProfile's PrefService which gets deleted by ~Browser. | 480 // OffTheRecordProfile's PrefService which gets deleted by ~Browser. |
477 RemoveAllChildViews(true); | 481 RemoveAllChildViews(true); |
478 toolbar_ = NULL; | 482 toolbar_ = NULL; |
479 | 483 |
480 // It is possible that we were forced-closed by the native view system and | |
481 // that tabs remain in the browser. Close any such remaining tabs. Detach | |
482 // before destroying in hopes of avoiding less callbacks trying to access | |
483 // members since destroyed. | |
484 { | |
485 ScopedVector<content::WebContents> contents; | |
486 while (browser_->tab_strip_model()->count()) | |
487 contents.push_back(browser_->tab_strip_model()->DetachWebContentsAt(0)); | |
488 } | |
489 | |
490 // Explicitly set browser_ to NULL. | 484 // Explicitly set browser_ to NULL. |
491 browser_.reset(); | 485 browser_.reset(); |
492 } | 486 } |
493 | 487 |
494 void BrowserView::Init(Browser* browser) { | 488 void BrowserView::Init(Browser* browser) { |
495 browser_.reset(browser); | 489 browser_.reset(browser); |
496 browser_->tab_strip_model()->AddObserver(this); | 490 browser_->tab_strip_model()->AddObserver(this); |
497 } | 491 } |
498 | 492 |
499 // static | 493 // static |
(...skipping 2052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2552 !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) { | 2546 !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) { |
2553 gfx::Point icon_bottom( | 2547 gfx::Point icon_bottom( |
2554 toolbar_->location_bar()->GetLocationBarAnchorPoint()); | 2548 toolbar_->location_bar()->GetLocationBarAnchorPoint()); |
2555 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom); | 2549 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom); |
2556 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL)); | 2550 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL)); |
2557 ConvertPointToTarget(infobar_container_, this, &infobar_top); | 2551 ConvertPointToTarget(infobar_container_, this, &infobar_top); |
2558 top_arrow_height = infobar_top.y() - icon_bottom.y(); | 2552 top_arrow_height = infobar_top.y() - icon_bottom.y(); |
2559 } | 2553 } |
2560 return top_arrow_height; | 2554 return top_arrow_height; |
2561 } | 2555 } |
OLD | NEW |