 Chromium Code Reviews
 Chromium Code Reviews Issue 6692001:
  Add in DOMBrowserView and Frame related classes  (Closed) 
  Base URL: http://git.chromium.org/git/chromium.git@trunk
    
  
    Issue 6692001:
  Add in DOMBrowserView and Frame related classes  (Closed) 
  Base URL: http://git.chromium.org/git/chromium.git@trunk| Index: chrome/browser/ui/views/frame/browser_view.cc | 
| diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc | 
| index ec2bf14c7ead7ccdd3d3bc3ddbe4cf06255c1187..9c85c4cd33735086db0b5d563f9e2d154c1e7bd8 100644 | 
| --- a/chrome/browser/ui/views/frame/browser_view.cc | 
| +++ b/chrome/browser/ui/views/frame/browser_view.cc | 
| @@ -472,10 +472,11 @@ BrowserView::~BrowserView() { | 
| // The TabStrip attaches a listener to the model. Make sure we shut down the | 
| // TabStrip first so that it can cleanly remove the listener. | 
| - tabstrip_->parent()->RemoveChildView(tabstrip_); | 
| - delete tabstrip_; | 
| - tabstrip_ = NULL; | 
| - | 
| + if (tabstrip_) { | 
| + tabstrip_->parent()->RemoveChildView(tabstrip_); | 
| + delete tabstrip_; | 
| + tabstrip_ = NULL; | 
| + } | 
| // Child views maintain PrefMember attributes that point to | 
| // OffTheRecordProfile's PrefService which gets deleted by ~Browser. | 
| RemoveAllChildViews(true); | 
| @@ -513,8 +514,9 @@ void BrowserView::WindowMoved() { | 
| browser::HideBookmarkBubbleView(); | 
| // Close the omnibox popup, if any. | 
| - if (toolbar_->location_bar()) | 
| - toolbar_->location_bar()->location_entry()->ClosePopup(); | 
| + if (toolbar_) | 
| + if (toolbar_->location_bar()) | 
| 
oshima
2011/03/14 20:09:22
if (toolbar_ && toolbar_->location_bar())
 
rharrison
2011/03/15 22:01:21
Done.
 | 
| + toolbar_->location_bar()->location_entry()->ClosePopup(); | 
| } | 
| void BrowserView::WindowMoveOrResizeStarted() { | 
| @@ -1661,8 +1663,9 @@ void BrowserView::OnWindowActivate(bool active) { | 
| bool BrowserView::CanClose() { | 
| // You cannot close a frame for which there is an active originating drag | 
| // session. | 
| - if (!tabstrip_->IsTabStripCloseable()) | 
| - return false; | 
| + if (tabstrip_) | 
| + if (!tabstrip_->IsTabStripCloseable()) | 
| 
oshima
2011/03/14 20:09:22
if (tabstrip_ && ...)
 
rharrison
2011/03/15 22:01:21
Done.
 | 
| + return false; | 
| // Give beforeunload handlers the chance to cancel the close before we hide | 
| // the window below. | 
| @@ -1820,8 +1823,9 @@ void BrowserView::InitTabStrip(TabStripModel* model) { | 
| AddChildView(tabstrip_); | 
| } | 
| -/////////////////////////////////////////////////////////////////////////////// | 
| -// BrowserView, private: | 
| +ToolbarView* BrowserView::CreateToolbar() const { | 
| + return new ToolbarView(browser_.get()); | 
| +} | 
| void BrowserView::Init() { | 
| SetLayoutManager(CreateLayoutManager()); | 
| @@ -1845,9 +1849,7 @@ void BrowserView::Init() { | 
| InitTabStrip(browser_->tabstrip_model()); | 
| - toolbar_ = new ToolbarView(browser_.get()); | 
| - AddChildView(toolbar_); | 
| - toolbar_->Init(browser_->profile()); | 
| + SetToolbar(CreateToolbar()); | 
| infobar_container_ = new InfoBarContainer(this); | 
| AddChildView(infobar_container_); | 
| @@ -1920,6 +1922,34 @@ void BrowserView::Init() { | 
| ignore_layout_ = false; | 
| } | 
| +void BrowserView::LoadingAnimationCallback() { | 
| + base::TimeTicks now = base::TimeTicks::Now(); | 
| + if (!last_animation_time_.is_null()) { | 
| + UMA_HISTOGRAM_TIMES( | 
| + "Tabs.LoadingAnimationTime", | 
| + now - last_animation_time_); | 
| + } | 
| + last_animation_time_ = now; | 
| + if (browser_->type() == Browser::TYPE_NORMAL) { | 
| + // Loading animations are shown in the tab for tabbed windows. We check the | 
| + // browser type instead of calling IsTabStripVisible() because the latter | 
| + // will return false for fullscreen windows, but we still need to update | 
| + // their animations (so that when they come out of fullscreen mode they'll | 
| + // be correct). | 
| + tabstrip_->UpdateLoadingAnimations(); | 
| + } else if (ShouldShowWindowIcon()) { | 
| + // ... or in the window icon area for popups and app windows. | 
| + TabContents* tab_contents = browser_->GetSelectedTabContents(); | 
| + // GetSelectedTabContents can return NULL for example under Purify when | 
| + // the animations are running slowly and this function is called on a timer | 
| + // through LoadingAnimationCallback. | 
| + frame_->UpdateThrobber(tab_contents && tab_contents->is_loading()); | 
| + } | 
| +} | 
| + | 
| +/////////////////////////////////////////////////////////////////////////////// | 
| +// BrowserView, private: | 
| + | 
| #if defined(OS_WIN) | 
| void BrowserView::InitSystemMenu() { | 
| system_menu_contents_.reset(new views::SystemMenuModel(this)); | 
| @@ -2371,31 +2401,6 @@ int BrowserView::GetCommandIDForAppCommandID(int app_command_id) const { | 
| #endif | 
| } | 
| -void BrowserView::LoadingAnimationCallback() { | 
| - base::TimeTicks now = base::TimeTicks::Now(); | 
| - if (!last_animation_time_.is_null()) { | 
| - UMA_HISTOGRAM_TIMES( | 
| - "Tabs.LoadingAnimationTime", | 
| - now - last_animation_time_); | 
| - } | 
| - last_animation_time_ = now; | 
| - if (browser_->type() == Browser::TYPE_NORMAL) { | 
| - // Loading animations are shown in the tab for tabbed windows. We check the | 
| - // browser type instead of calling IsTabStripVisible() because the latter | 
| - // will return false for fullscreen windows, but we still need to update | 
| - // their animations (so that when they come out of fullscreen mode they'll | 
| - // be correct). | 
| - tabstrip_->UpdateLoadingAnimations(); | 
| - } else if (ShouldShowWindowIcon()) { | 
| - // ... or in the window icon area for popups and app windows. | 
| - TabContents* tab_contents = browser_->GetSelectedTabContents(); | 
| - // GetSelectedTabContents can return NULL for example under Purify when | 
| - // the animations are running slowly and this function is called on a timer | 
| - // through LoadingAnimationCallback. | 
| - frame_->UpdateThrobber(tab_contents && tab_contents->is_loading()); | 
| - } | 
| -} | 
| - | 
| void BrowserView::InitHangMonitor() { | 
| #if defined(OS_WIN) | 
| PrefService* pref_service = g_browser_process->local_state(); | 
| @@ -2521,6 +2526,14 @@ gfx::Size BrowserView::GetResizeCornerSize() const { | 
| return ResizeCorner::GetSize(); | 
| } | 
| +void BrowserView::SetToolbar(ToolbarView* toolbar) { | 
| + if (!toolbar) | 
| + return; | 
| 
oshima
2011/03/14 20:09:22
Can this happen? If not, use CHECK/DCHECK. If yes,
 
rharrison
2011/03/15 22:01:21
Yes, since we override the function CreateToolbar
 | 
| + toolbar_ = toolbar; | 
| + AddChildView(toolbar_); | 
| + toolbar_->Init(browser_->profile()); | 
| +} | 
| + | 
| #if !defined(OS_CHROMEOS) | 
| // static | 
| BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { |