Commit 73863b5c authored by pfeldman@chromium.org's avatar pfeldman@chromium.org

Add split with devtools container into the browser view.

Review URL: http://codereview.chromium.org/151150

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19807 0039d316-1c4b-4281-b951-d872f2087c98
parent 40247a92
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "chrome/browser/browser.h" #include "chrome/browser/browser.h"
#include "chrome/browser/browser_list.h" #include "chrome/browser/browser_list.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/debugger/devtools_window.h"
#include "chrome/browser/download/download_manager.h" #include "chrome/browser/download/download_manager.h"
#include "chrome/browser/find_bar.h" #include "chrome/browser/find_bar.h"
#include "chrome/browser/find_bar_controller.h" #include "chrome/browser/find_bar_controller.h"
...@@ -59,6 +60,7 @@ ...@@ -59,6 +60,7 @@
#if defined(OS_WIN) #if defined(OS_WIN)
#include "views/controls/scrollbar/native_scroll_bar.h" #include "views/controls/scrollbar/native_scroll_bar.h"
#endif #endif
#include "views/controls/single_split_view.h"
#include "views/fill_layout.h" #include "views/fill_layout.h"
#include "views/view.h" #include "views/view.h"
#include "views/widget/root_view.h" #include "views/widget/root_view.h"
...@@ -277,6 +279,8 @@ BrowserView::BrowserView(Browser* browser) ...@@ -277,6 +279,8 @@ BrowserView::BrowserView(Browser* browser)
infobar_container_(NULL), infobar_container_(NULL),
find_bar_y_(0), find_bar_y_(0),
contents_container_(NULL), contents_container_(NULL),
devtools_container_(NULL),
contents_split_(NULL),
initialized_(false), initialized_(false),
ignore_layout_(false), ignore_layout_(false),
#if defined(OS_WIN) #if defined(OS_WIN)
...@@ -534,6 +538,7 @@ void BrowserView::RegisterBrowserViewPrefs(PrefService* prefs) { ...@@ -534,6 +538,7 @@ void BrowserView::RegisterBrowserViewPrefs(PrefService* prefs) {
kDefaultPluginMessageResponseTimeout); kDefaultPluginMessageResponseTimeout);
prefs->RegisterIntegerPref(prefs::kHungPluginDetectFrequency, prefs->RegisterIntegerPref(prefs::kHungPluginDetectFrequency,
kDefaultHungPluginDetectFrequency); kDefaultHungPluginDetectFrequency);
prefs->RegisterIntegerPref(prefs::kDevToolsSplitLocation, -1);
} }
void BrowserView::AttachBrowserBubble(BrowserBubble* bubble) { void BrowserView::AttachBrowserBubble(BrowserBubble* bubble) {
...@@ -570,6 +575,19 @@ void BrowserView::Show() { ...@@ -570,6 +575,19 @@ void BrowserView::Show() {
if (selected_tab_contents) if (selected_tab_contents)
selected_tab_contents->view()->RestoreFocus(); 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(); frame_->GetWindow()->Show();
} }
...@@ -584,6 +602,9 @@ void BrowserView::Close() { ...@@ -584,6 +602,9 @@ void BrowserView::Close() {
for (; bubble != browser_bubbles_.end(); ++bubble) { for (; bubble != browser_bubbles_.end(); ++bubble) {
(*bubble)->BrowserWindowClosed(); (*bubble)->BrowserWindowClosed();
} }
g_browser_process->local_state()->SetInteger(
prefs::kDevToolsSplitLocation, contents_split_->divider_offset());
} }
void BrowserView::Activate() { void BrowserView::Activate() {
...@@ -631,7 +652,7 @@ void BrowserView::SelectedTabToolbarSizeChanged(bool is_animating) { ...@@ -631,7 +652,7 @@ void BrowserView::SelectedTabToolbarSizeChanged(bool is_animating) {
contents_container_->SetFastResize(false); contents_container_->SetFastResize(false);
} else { } else {
UpdateUIForContents(browser_->GetSelectedTabContents()); UpdateUIForContents(browser_->GetSelectedTabContents());
contents_container_->Layout(); contents_split_->Layout();
} }
} }
...@@ -642,7 +663,8 @@ void BrowserView::UpdateTitleBar() { ...@@ -642,7 +663,8 @@ void BrowserView::UpdateTitleBar() {
} }
void BrowserView::UpdateDevTools() { void BrowserView::UpdateDevTools() {
NOTIMPLEMENTED(); UpdateDevToolsForContents(GetSelectedTabContents());
Layout();
} }
void BrowserView::UpdateLoadingAnimations(bool should_animate) { void BrowserView::UpdateLoadingAnimations(bool should_animate) {
...@@ -800,7 +822,7 @@ gfx::Rect BrowserView::GetRootWindowResizerRect() const { ...@@ -800,7 +822,7 @@ gfx::Rect BrowserView::GetRootWindowResizerRect() const {
return gfx::Rect(); return gfx::Rect();
} }
gfx::Rect client_rect = contents_container_->bounds(); gfx::Rect client_rect = contents_split_->bounds();
gfx::Size resize_corner_size = ResizeCorner::GetSize(); gfx::Size resize_corner_size = ResizeCorner::GetSize();
int x = client_rect.width() - resize_corner_size.width(); int x = client_rect.width() - resize_corner_size.width();
if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT)
...@@ -979,6 +1001,7 @@ void BrowserView::TabDetachedAt(TabContents* contents, int index) { ...@@ -979,6 +1001,7 @@ void BrowserView::TabDetachedAt(TabContents* contents, int index) {
// on the selected TabContents when it is removed. // on the selected TabContents when it is removed.
infobar_container_->ChangeTabContents(NULL); infobar_container_->ChangeTabContents(NULL);
contents_container_->ChangeTabContents(NULL); contents_container_->ChangeTabContents(NULL);
UpdateDevToolsForContents(NULL);
} }
} }
...@@ -1000,6 +1023,7 @@ void BrowserView::TabSelectedAt(TabContents* old_contents, ...@@ -1000,6 +1023,7 @@ void BrowserView::TabSelectedAt(TabContents* old_contents,
// TabContents. // TabContents.
infobar_container_->ChangeTabContents(new_contents); infobar_container_->ChangeTabContents(new_contents);
contents_container_->ChangeTabContents(new_contents); contents_container_->ChangeTabContents(new_contents);
UpdateDevToolsForContents(new_contents);
// TODO(beng): This should be called automatically by ChangeTabContents, but I // TODO(beng): This should be called automatically by ChangeTabContents, but I
// am striving for parity now rather than cleanliness. This is // am striving for parity now rather than cleanliness. This is
// required to make features like Duplicate Tab, Undo Close Tab, // required to make features like Duplicate Tab, Undo Close Tab,
...@@ -1322,7 +1346,7 @@ gfx::Size BrowserView::GetMinimumSize() { ...@@ -1322,7 +1346,7 @@ gfx::Size BrowserView::GetMinimumSize() {
bookmark_bar_size.Enlarge(0, bookmark_bar_size.Enlarge(0,
-kSeparationLineHeight - bookmark_bar_view_->GetToolbarOverlap(true)); -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() + int min_height = tabstrip_size.height() + toolbar_size.height() +
bookmark_bar_size.height() + contents_size.height(); bookmark_bar_size.height() + contents_size.height();
...@@ -1412,7 +1436,14 @@ void BrowserView::Init() { ...@@ -1412,7 +1436,14 @@ void BrowserView::Init() {
contents_container_ = new TabContentsContainer; contents_container_ = new TabContentsContainer;
set_contents_view(contents_container_); 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())); status_bubble_.reset(new StatusBubbleViews(GetWidget()));
...@@ -1507,7 +1538,7 @@ int BrowserView::LayoutInfoBar(int top) { ...@@ -1507,7 +1538,7 @@ int BrowserView::LayoutInfoBar(int top) {
} }
void BrowserView::LayoutTabContents(int top, int bottom) { 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) { int BrowserView::LayoutDownloadShelf(int bottom) {
...@@ -1574,6 +1605,14 @@ bool BrowserView::MaybeShowInfoBar(TabContents* contents) { ...@@ -1574,6 +1605,14 @@ bool BrowserView::MaybeShowInfoBar(TabContents* contents) {
return true; 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);
contents_split_->Layout();
}
void BrowserView::UpdateUIForContents(TabContents* contents) { void BrowserView::UpdateUIForContents(TabContents* contents) {
bool needs_layout = MaybeShowBookmarkBar(contents); bool needs_layout = MaybeShowBookmarkBar(contents);
needs_layout |= MaybeShowInfoBar(contents); needs_layout |= MaybeShowInfoBar(contents);
......
...@@ -46,6 +46,7 @@ class ZoomMenuModel; ...@@ -46,6 +46,7 @@ class ZoomMenuModel;
namespace views { namespace views {
class Menu; class Menu;
class SingleSplitView;
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
...@@ -339,6 +340,9 @@ class BrowserView : public BrowserWindow, ...@@ -339,6 +340,9 @@ class BrowserView : public BrowserWindow,
// |contents| can be NULL. // |contents| can be NULL.
bool MaybeShowInfoBar(TabContents* contents); bool MaybeShowInfoBar(TabContents* contents);
// Updated devtools window for given contents.
void UpdateDevToolsForContents(TabContents* tab_contents);
// Updates various optional child Views, e.g. Bookmarks Bar, Info Bar or the // Updates various optional child Views, e.g. Bookmarks Bar, Info Bar or the
// Download Shelf in response to a change notification from the specified // Download Shelf in response to a change notification from the specified
// |contents|. |contents| can be NULL. In this case, all optional UI will be // |contents|. |contents| can be NULL. In this case, all optional UI will be
...@@ -406,6 +410,12 @@ class BrowserView : public BrowserWindow, ...@@ -406,6 +410,12 @@ class BrowserView : public BrowserWindow,
// The view that contains the selected TabContents. // The view that contains the selected TabContents.
TabContentsContainer* contents_container_; TabContentsContainer* contents_container_;
// The view that contains devtools window for the selected TabContents.
TabContentsContainer* devtools_container_;
// Split view containing the contents container and devtools container.
views::SingleSplitView* contents_split_;
// The Status information bubble that appears at the bottom of the window. // The Status information bubble that appears at the bottom of the window.
scoped_ptr<StatusBubbleViews> status_bubble_; scoped_ptr<StatusBubbleViews> status_bubble_;
......
...@@ -2,10 +2,13 @@ ...@@ -2,10 +2,13 @@
color: rgb(70, 134, 240); color: rgb(70, 134, 240);
} }
#dock-status-bar-item {
display: none
}
.data-grid table { .data-grid table {
line-height: 120%; line-height: 120%;
} }
body.attached #toolbar {
height: 34px;
border-top: 1px solid rgb(100, 100, 100);
cursor: default; /* overriden */
padding-left: 0;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment