summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-02 10:49:57 +0000
committerpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-02 10:49:57 +0000
commit73863b5c31da1575ba6910a1aa3456e18ebce9ca (patch)
tree3942201b47b6be6399833fce5940ea39df402633
parent40247a925ac0e7f10051fe1789d0b99549966cc3 (diff)
downloadchromium_src-73863b5c31da1575ba6910a1aa3456e18ebce9ca.zip
chromium_src-73863b5c31da1575ba6910a1aa3456e18ebce9ca.tar.gz
chromium_src-73863b5c31da1575ba6910a1aa3456e18ebce9ca.tar.bz2
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
-rw-r--r--chrome/browser/views/frame/browser_view.cc51
-rw-r--r--chrome/browser/views/frame/browser_view.h10
-rw-r--r--webkit/glue/devtools/js/devtools.css11
3 files changed, 62 insertions, 10 deletions
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index ed4617f..420b308 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -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 @@ BrowserView::BrowserView(Browser* browser)
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 @@ void BrowserView::RegisterBrowserViewPrefs(PrefService* prefs) {
kDefaultPluginMessageResponseTimeout);
prefs->RegisterIntegerPref(prefs::kHungPluginDetectFrequency,
kDefaultHungPluginDetectFrequency);
+ prefs->RegisterIntegerPref(prefs::kDevToolsSplitLocation, -1);
}
void BrowserView::AttachBrowserBubble(BrowserBubble* bubble) {
@@ -570,6 +575,19 @@ void BrowserView::Show() {
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 @@ void BrowserView::Close() {
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 @@ void BrowserView::SelectedTabToolbarSizeChanged(bool is_animating) {
contents_container_->SetFastResize(false);
} else {
UpdateUIForContents(browser_->GetSelectedTabContents());
- contents_container_->Layout();
+ contents_split_->Layout();
}
}
@@ -642,7 +663,8 @@ void BrowserView::UpdateTitleBar() {
}
void BrowserView::UpdateDevTools() {
- NOTIMPLEMENTED();
+ UpdateDevToolsForContents(GetSelectedTabContents());
+ Layout();
}
void BrowserView::UpdateLoadingAnimations(bool should_animate) {
@@ -800,7 +822,7 @@ gfx::Rect BrowserView::GetRootWindowResizerRect() const {
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 @@ void BrowserView::TabDetachedAt(TabContents* contents, int index) {
// on the selected TabContents when it is removed.
infobar_container_->ChangeTabContents(NULL);
contents_container_->ChangeTabContents(NULL);
+ UpdateDevToolsForContents(NULL);
}
}
@@ -1000,6 +1023,7 @@ void BrowserView::TabSelectedAt(TabContents* old_contents,
// 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 @@ gfx::Size BrowserView::GetMinimumSize() {
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,7 +1436,14 @@ void BrowserView::Init() {
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()));
@@ -1507,7 +1538,7 @@ int BrowserView::LayoutInfoBar(int top) {
}
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,14 @@ bool BrowserView::MaybeShowInfoBar(TabContents* contents) {
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) {
bool needs_layout = MaybeShowBookmarkBar(contents);
needs_layout |= MaybeShowInfoBar(contents);
diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h
index 1eaf7c4..c21b2a2 100644
--- a/chrome/browser/views/frame/browser_view.h
+++ b/chrome/browser/views/frame/browser_view.h
@@ -46,6 +46,7 @@ class ZoomMenuModel;
namespace views {
class Menu;
+class SingleSplitView;
}
///////////////////////////////////////////////////////////////////////////////
@@ -339,6 +340,9 @@ class BrowserView : public BrowserWindow,
// |contents| can be NULL.
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
// Download Shelf in response to a change notification from the specified
// |contents|. |contents| can be NULL. In this case, all optional UI will be
@@ -406,6 +410,12 @@ class BrowserView : public BrowserWindow,
// The view that contains the selected TabContents.
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.
scoped_ptr<StatusBubbleViews> status_bubble_;
diff --git a/webkit/glue/devtools/js/devtools.css b/webkit/glue/devtools/js/devtools.css
index 97f3636..d4b3ff7 100644
--- a/webkit/glue/devtools/js/devtools.css
+++ b/webkit/glue/devtools/js/devtools.css
@@ -2,10 +2,13 @@
color: rgb(70, 134, 240);
}
-#dock-status-bar-item {
- display: none
-}
-
.data-grid table {
line-height: 120%;
}
+
+body.attached #toolbar {
+ height: 34px;
+ border-top: 1px solid rgb(100, 100, 100);
+ cursor: default; /* overriden */
+ padding-left: 0;
+}