Index: chrome/browser/views/frame/browser_view.cc |
=================================================================== |
--- chrome/browser/views/frame/browser_view.cc (revision 19804) |
+++ chrome/browser/views/frame/browser_view.cc (working copy) |
@@ -22,6 +22,7 @@ |
#include "chrome/browser/browser.h" |
#include "chrome/browser/browser_list.h" |
#include "chrome/browser/browser_process.h" |
+#include "chrome/browser/debugger/devtools_window.h" |
#include "chrome/browser/download/download_manager.h" |
#include "chrome/browser/find_bar.h" |
#include "chrome/browser/find_bar_controller.h" |
@@ -59,6 +60,7 @@ |
#if defined(OS_WIN) |
#include "views/controls/scrollbar/native_scroll_bar.h" |
#endif |
+#include "views/controls/single_split_view.h" |
#include "views/fill_layout.h" |
#include "views/view.h" |
#include "views/widget/root_view.h" |
@@ -277,6 +279,8 @@ |
infobar_container_(NULL), |
find_bar_y_(0), |
contents_container_(NULL), |
+ devtools_container_(NULL), |
+ contents_split_(NULL), |
initialized_(false), |
ignore_layout_(false), |
#if defined(OS_WIN) |
@@ -534,6 +538,7 @@ |
kDefaultPluginMessageResponseTimeout); |
prefs->RegisterIntegerPref(prefs::kHungPluginDetectFrequency, |
kDefaultHungPluginDetectFrequency); |
+ prefs->RegisterIntegerPref(prefs::kDevToolsSplitLocation, -1); |
} |
void BrowserView::AttachBrowserBubble(BrowserBubble* bubble) { |
@@ -570,6 +575,19 @@ |
if (selected_tab_contents) |
selected_tab_contents->view()->RestoreFocus(); |
+ // Restore split offset. |
+ int split_offset = g_browser_process->local_state()->GetInteger( |
+ prefs::kDevToolsSplitLocation); |
+ if (split_offset == -1) { |
+ // Initial load, set to default value. |
+ split_offset = 2 * contents_split_->height() / 3; |
+ } |
+ // Make sure user can see both panes. |
+ int min_split_size = contents_split_->height() / 10; |
+ split_offset = std::min(contents_split_->height() - min_split_size, |
+ std::max(min_split_size, split_offset)); |
+ contents_split_->set_divider_offset(split_offset); |
+ |
frame_->GetWindow()->Show(); |
} |
@@ -584,6 +602,9 @@ |
for (; bubble != browser_bubbles_.end(); ++bubble) { |
(*bubble)->BrowserWindowClosed(); |
} |
+ |
+ g_browser_process->local_state()->SetInteger( |
+ prefs::kDevToolsSplitLocation, contents_split_->divider_offset()); |
} |
void BrowserView::Activate() { |
@@ -631,7 +652,7 @@ |
contents_container_->SetFastResize(false); |
} else { |
UpdateUIForContents(browser_->GetSelectedTabContents()); |
- contents_container_->Layout(); |
+ contents_split_->Layout(); |
} |
} |
@@ -642,7 +663,8 @@ |
} |
void BrowserView::UpdateDevTools() { |
- NOTIMPLEMENTED(); |
+ UpdateDevToolsForContents(GetSelectedTabContents()); |
+ Layout(); |
} |
void BrowserView::UpdateLoadingAnimations(bool should_animate) { |
@@ -800,7 +822,7 @@ |
return gfx::Rect(); |
} |
- gfx::Rect client_rect = contents_container_->bounds(); |
+ gfx::Rect client_rect = contents_split_->bounds(); |
gfx::Size resize_corner_size = ResizeCorner::GetSize(); |
int x = client_rect.width() - resize_corner_size.width(); |
if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) |
@@ -979,6 +1001,7 @@ |
// on the selected TabContents when it is removed. |
infobar_container_->ChangeTabContents(NULL); |
contents_container_->ChangeTabContents(NULL); |
+ UpdateDevToolsForContents(NULL); |
} |
} |
@@ -1000,6 +1023,7 @@ |
// TabContents. |
infobar_container_->ChangeTabContents(new_contents); |
contents_container_->ChangeTabContents(new_contents); |
+ UpdateDevToolsForContents(new_contents); |
// TODO(beng): This should be called automatically by ChangeTabContents, but I |
// am striving for parity now rather than cleanliness. This is |
// required to make features like Duplicate Tab, Undo Close Tab, |
@@ -1322,7 +1346,7 @@ |
bookmark_bar_size.Enlarge(0, |
-kSeparationLineHeight - bookmark_bar_view_->GetToolbarOverlap(true)); |
} |
- gfx::Size contents_size(contents_container_->GetMinimumSize()); |
+ gfx::Size contents_size(contents_split_->GetMinimumSize()); |
int min_height = tabstrip_size.height() + toolbar_size.height() + |
bookmark_bar_size.height() + contents_size.height(); |
@@ -1412,8 +1436,15 @@ |
contents_container_ = new TabContentsContainer; |
set_contents_view(contents_container_); |
- AddChildView(contents_container_); |
+ devtools_container_ = new TabContentsContainer; |
+ contents_split_ = new views::SingleSplitView( |
+ contents_container_, |
+ devtools_container_, |
+ views::SingleSplitView::VERTICAL_SPLIT); |
+ |
+ AddChildView(contents_split_); |
+ |
status_bubble_.reset(new StatusBubbleViews(GetWidget())); |
extension_shelf_ = new ExtensionShelf(browser_.get()); |
@@ -1507,7 +1538,7 @@ |
} |
void BrowserView::LayoutTabContents(int top, int bottom) { |
- contents_container_->SetBounds(0, top, width(), bottom - top); |
+ contents_split_->SetBounds(0, top, width(), bottom - top); |
} |
int BrowserView::LayoutDownloadShelf(int bottom) { |
@@ -1574,6 +1605,13 @@ |
return true; |
} |
+void BrowserView::UpdateDevToolsForContents(TabContents* tab_contents) { |
+ TabContents* devtools_contents = |
+ DevToolsWindow::GetDevToolsContents(tab_contents); |
+ devtools_container_->ChangeTabContents(devtools_contents); |
+ devtools_container_->SetVisible(devtools_contents != NULL); |
+} |
+ |
void BrowserView::UpdateUIForContents(TabContents* contents) { |
bool needs_layout = MaybeShowBookmarkBar(contents); |
needs_layout |= MaybeShowInfoBar(contents); |