| 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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 // The amount of space we expect the window border to take up. | 169 // The amount of space we expect the window border to take up. |
| 170 const int kWindowBorderWidth = 5; | 170 const int kWindowBorderWidth = 5; |
| 171 | 171 |
| 172 // How round the 'new tab' style bookmarks bar is. | 172 // How round the 'new tab' style bookmarks bar is. |
| 173 const int kNewtabBarRoundness = 5; | 173 const int kNewtabBarRoundness = 5; |
| 174 | 174 |
| 175 } // namespace | 175 } // namespace |
| 176 | 176 |
| 177 // Returned from BrowserView::GetClassName. | 177 // Returned from BrowserView::GetClassName. |
| 178 const char BrowserView::kViewClassName[] = "browser/ui/views/BrowserView"; | 178 const char BrowserView::kViewClassName[] = "browser/ui/views/BrowserView"; |
| 179 // static |
| 180 const int BrowserView::kTabstripIndex = 0; |
| 181 const int BrowserView::kInfoBarIndex = 1; |
| 182 const int BrowserView::kToolbarIndex = 2; |
| 179 | 183 |
| 180 namespace { | 184 namespace { |
| 181 | 185 |
| 182 bool ShouldSaveOrRestoreWindowPos() { | 186 bool ShouldSaveOrRestoreWindowPos() { |
| 183 #if defined(OS_WIN) && !defined(USE_AURA) | 187 #if defined(OS_WIN) && !defined(USE_AURA) |
| 184 // In Windows 8 metro mode the window is always maximized (without the | 188 // In Windows 8 metro mode the window is always maximized (without the |
| 185 // WS_MAXIMIZE) style. | 189 // WS_MAXIMIZE) style. |
| 186 if (base::win::IsMetroProcess()) | 190 if (base::win::IsMetroProcess()) |
| 187 return false; | 191 return false; |
| 188 #endif | 192 #endif |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 browser_->tab_strip_model()->AddObserver(this); | 529 browser_->tab_strip_model()->AddObserver(this); |
| 526 } | 530 } |
| 527 | 531 |
| 528 BrowserView::~BrowserView() { | 532 BrowserView::~BrowserView() { |
| 529 #if defined(USE_ASH) | 533 #if defined(USE_ASH) |
| 530 // Destroy BrowserLauncherItemController early on as it listens to the | 534 // Destroy BrowserLauncherItemController early on as it listens to the |
| 531 // TabstripModel, which is destroyed by the browser. | 535 // TabstripModel, which is destroyed by the browser. |
| 532 launcher_item_controller_.reset(); | 536 launcher_item_controller_.reset(); |
| 533 #endif | 537 #endif |
| 534 | 538 |
| 539 // Immersive mode may need to reparent views before they are removed/deleted. |
| 540 immersive_mode_controller_.reset(); |
| 541 |
| 535 preview_controller_.reset(); | 542 preview_controller_.reset(); |
| 536 | 543 |
| 537 browser_->tab_strip_model()->RemoveObserver(this); | 544 browser_->tab_strip_model()->RemoveObserver(this); |
| 538 | 545 |
| 539 #if defined(OS_WIN) && !defined(USE_AURA) | 546 #if defined(OS_WIN) && !defined(USE_AURA) |
| 540 // Stop hung plugin monitoring. | 547 // Stop hung plugin monitoring. |
| 541 ticker_.Stop(); | 548 ticker_.Stop(); |
| 542 ticker_.UnregisterTickHandler(&hung_window_detector_); | 549 ticker_.UnregisterTickHandler(&hung_window_detector_); |
| 543 | 550 |
| 544 // Terminate the jumplist (must be called before browser_->profile() is | 551 // Terminate the jumplist (must be called before browser_->profile() is |
| (...skipping 1610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2155 InitHangMonitor(); | 2162 InitHangMonitor(); |
| 2156 } | 2163 } |
| 2157 | 2164 |
| 2158 LoadAccelerators(); | 2165 LoadAccelerators(); |
| 2159 | 2166 |
| 2160 // TabStrip takes ownership of the controller. | 2167 // TabStrip takes ownership of the controller. |
| 2161 BrowserTabStripController* tabstrip_controller = | 2168 BrowserTabStripController* tabstrip_controller = |
| 2162 new BrowserTabStripController(browser_.get(), | 2169 new BrowserTabStripController(browser_.get(), |
| 2163 browser_->tab_strip_model()); | 2170 browser_->tab_strip_model()); |
| 2164 tabstrip_ = new TabStrip(tabstrip_controller); | 2171 tabstrip_ = new TabStrip(tabstrip_controller); |
| 2165 AddChildView(tabstrip_); | 2172 AddChildViewAt(tabstrip_, kTabstripIndex); |
| 2166 tabstrip_controller->InitFromModel(tabstrip_); | 2173 tabstrip_controller->InitFromModel(tabstrip_); |
| 2167 | 2174 |
| 2168 infobar_container_ = new InfoBarContainerView(this, | 2175 infobar_container_ = new InfoBarContainerView(this, |
| 2169 browser()->search_model()); | 2176 browser()->search_model()); |
| 2170 AddChildView(infobar_container_); | 2177 AddChildViewAt(infobar_container_, kInfoBarIndex); |
| 2171 | 2178 |
| 2172 contents_container_ = new views::WebView(browser_->profile()); | 2179 contents_container_ = new views::WebView(browser_->profile()); |
| 2173 contents_container_->set_id(VIEW_ID_TAB_CONTAINER); | 2180 contents_container_->set_id(VIEW_ID_TAB_CONTAINER); |
| 2174 contents_ = new ContentsContainer(contents_container_); | 2181 contents_ = new ContentsContainer(contents_container_); |
| 2175 | 2182 |
| 2176 toolbar_ = new ToolbarView(browser_.get()); | 2183 toolbar_ = new ToolbarView(browser_.get()); |
| 2177 AddChildView(toolbar_); | 2184 AddChildViewAt(toolbar_, kToolbarIndex); |
| 2178 toolbar_->Init(); | 2185 toolbar_->Init(); |
| 2179 | 2186 |
| 2180 preview_controller_.reset( | 2187 preview_controller_.reset( |
| 2181 new InstantPreviewControllerViews(browser(), contents_)); | 2188 new InstantPreviewControllerViews(browser(), contents_)); |
| 2182 | 2189 |
| 2183 SkColor bg_color = GetWidget()->GetThemeProvider()-> | 2190 SkColor bg_color = GetWidget()->GetThemeProvider()-> |
| 2184 GetColor(ThemeService::COLOR_TOOLBAR); | 2191 GetColor(ThemeService::COLOR_TOOLBAR); |
| 2185 | 2192 |
| 2186 devtools_container_ = new views::WebView(browser_->profile()); | 2193 devtools_container_ = new views::WebView(browser_->profile()); |
| 2187 devtools_container_->set_id(VIEW_ID_DEV_TOOLS_DOCKED); | 2194 devtools_container_->set_id(VIEW_ID_DEV_TOOLS_DOCKED); |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2781 modal_browser->window()->Activate(); | 2788 modal_browser->window()->Activate(); |
| 2782 } | 2789 } |
| 2783 | 2790 |
| 2784 AppModalDialogQueue::GetInstance()->ActivateModalDialog(); | 2791 AppModalDialogQueue::GetInstance()->ActivateModalDialog(); |
| 2785 } | 2792 } |
| 2786 | 2793 |
| 2787 void BrowserView::MaybeStackBookmarkBarAtTop() { | 2794 void BrowserView::MaybeStackBookmarkBarAtTop() { |
| 2788 if (bookmark_bar_view_.get()) | 2795 if (bookmark_bar_view_.get()) |
| 2789 bookmark_bar_view_->MaybeStackAtTop(); | 2796 bookmark_bar_view_->MaybeStackAtTop(); |
| 2790 } | 2797 } |
| OLD | NEW |