Chromium Code Reviews| 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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 452 if (tabstrip_) { | 452 if (tabstrip_) { |
| 453 tabstrip_->parent()->RemoveChildView(tabstrip_); | 453 tabstrip_->parent()->RemoveChildView(tabstrip_); |
| 454 if (browser_view_layout) | 454 if (browser_view_layout) |
| 455 browser_view_layout->set_tab_strip(NULL); | 455 browser_view_layout->set_tab_strip(NULL); |
| 456 delete tabstrip_; | 456 delete tabstrip_; |
| 457 tabstrip_ = NULL; | 457 tabstrip_ = NULL; |
| 458 } | 458 } |
| 459 // Child views maintain PrefMember attributes that point to | 459 // Child views maintain PrefMember attributes that point to |
| 460 // OffTheRecordProfile's PrefService which gets deleted by ~Browser. | 460 // OffTheRecordProfile's PrefService which gets deleted by ~Browser. |
| 461 RemoveAllChildViews(true); | 461 RemoveAllChildViews(true); |
| 462 toolbar_ = NULL; | |
| 462 | 463 |
| 463 // It is possible that we were forced-closed by the native view system and | 464 // It is possible that we were forced-closed by the native view system and |
| 464 // that tabs remain in the browser. Close any such remaining tabs. | 465 // that tabs remain in the browser. Close any such remaining tabs. Detach |
| 465 while (browser_->tab_strip_model()->count()) | 466 // before destroying in hopes of avoiding less callbacks trying to access |
| 466 delete browser_->tab_strip_model()->GetWebContentsAt(0); | 467 // members since destroyed. |
| 468 { | |
| 469 ScopedVector<content::WebContents> contents; | |
| 470 while (browser_->tab_strip_model()->count()) | |
| 471 contents.push_back(browser_->tab_strip_model()->DetachWebContentsAt(0)); | |
| 472 } | |
|
Avi (use Gerrit)
2013/09/04 21:10:45
Wow, this code is even sketchier than the code I w
| |
| 467 | 473 |
| 468 // Explicitly set browser_ to NULL. | 474 // Explicitly set browser_ to NULL. |
| 469 browser_.reset(); | 475 browser_.reset(); |
| 470 } | 476 } |
| 471 | 477 |
| 472 void BrowserView::Init(Browser* browser) { | 478 void BrowserView::Init(Browser* browser) { |
| 473 browser_.reset(browser); | 479 browser_.reset(browser); |
| 474 browser_->tab_strip_model()->AddObserver(this); | 480 browser_->tab_strip_model()->AddObserver(this); |
| 475 } | 481 } |
| 476 | 482 |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 956 focus_manager->ClearFocus(); | 962 focus_manager->ClearFocus(); |
| 957 } | 963 } |
| 958 } | 964 } |
| 959 | 965 |
| 960 void BrowserView::UpdateReloadStopState(bool is_loading, bool force) { | 966 void BrowserView::UpdateReloadStopState(bool is_loading, bool force) { |
| 961 toolbar_->reload_button()->ChangeMode( | 967 toolbar_->reload_button()->ChangeMode( |
| 962 is_loading ? ReloadButton::MODE_STOP : ReloadButton::MODE_RELOAD, force); | 968 is_loading ? ReloadButton::MODE_STOP : ReloadButton::MODE_RELOAD, force); |
| 963 } | 969 } |
| 964 | 970 |
| 965 void BrowserView::UpdateToolbar(content::WebContents* contents) { | 971 void BrowserView::UpdateToolbar(content::WebContents* contents) { |
| 966 toolbar_->Update(contents); | 972 // We may end up here during destruction. |
| 973 if (toolbar_) | |
| 974 toolbar_->Update(contents); | |
| 967 } | 975 } |
| 968 | 976 |
| 969 void BrowserView::FocusToolbar() { | 977 void BrowserView::FocusToolbar() { |
| 970 // Temporarily reveal the top-of-window views (if not already revealed) so | 978 // Temporarily reveal the top-of-window views (if not already revealed) so |
| 971 // that the toolbar is visible and is considered focusable. If the | 979 // that the toolbar is visible and is considered focusable. If the |
| 972 // toolbar gains focus, |immersive_mode_controller_| will keep the | 980 // toolbar gains focus, |immersive_mode_controller_| will keep the |
| 973 // top-of-window views revealed. | 981 // top-of-window views revealed. |
| 974 scoped_ptr<ImmersiveRevealedLock> focus_reveal_lock( | 982 scoped_ptr<ImmersiveRevealedLock> focus_reveal_lock( |
| 975 immersive_mode_controller_->GetRevealedLock( | 983 immersive_mode_controller_->GetRevealedLock( |
| 976 ImmersiveModeController::ANIMATE_REVEAL_YES)); | 984 ImmersiveModeController::ANIMATE_REVEAL_YES)); |
| (...skipping 1689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2666 // The +1 in the next line creates a 1-px gap between icon and arrow tip. | 2674 // The +1 in the next line creates a 1-px gap between icon and arrow tip. |
| 2667 gfx::Point icon_bottom(0, location_icon_view->GetImageBounds().bottom() - | 2675 gfx::Point icon_bottom(0, location_icon_view->GetImageBounds().bottom() - |
| 2668 LocationBarView::kIconInternalPadding + 1); | 2676 LocationBarView::kIconInternalPadding + 1); |
| 2669 ConvertPointToTarget(location_icon_view, this, &icon_bottom); | 2677 ConvertPointToTarget(location_icon_view, this, &icon_bottom); |
| 2670 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL)); | 2678 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL)); |
| 2671 ConvertPointToTarget(infobar_container_, this, &infobar_top); | 2679 ConvertPointToTarget(infobar_container_, this, &infobar_top); |
| 2672 top_arrow_height = infobar_top.y() - icon_bottom.y(); | 2680 top_arrow_height = infobar_top.y() - icon_bottom.y(); |
| 2673 } | 2681 } |
| 2674 return top_arrow_height; | 2682 return top_arrow_height; |
| 2675 } | 2683 } |
| OLD | NEW |