Support docking the devtools on the right side of the window

This commit is contained in:
Adam Roben 2013-03-27 11:19:15 -04:00
parent 001d0197de
commit c22d1cca79
6 changed files with 28 additions and 0 deletions

View file

@ -9,11 +9,14 @@
#include "browser/browser_main_parts.h"
#include "browser/inspectable_web_contents_view.h"
#include "base/stringprintf.h"
#include "base/utf_string_conversions.h"
#include "content/public/browser/devtools_agent_host.h"
#include "content/public/browser/devtools_client_host.h"
#include "content/public/browser/devtools_http_handler.h"
#include "content/public/browser/devtools_manager.h"
#include "content/public/browser/web_contents_view.h"
#include "content/public/browser/render_view_host.h"
namespace brightray {
@ -70,6 +73,11 @@ void InspectableWebContentsImpl::MoveWindow(int x, int y) {
}
void InspectableWebContentsImpl::SetDockSide(const std::string& side) {
if (!view_->SetDockSide(side))
return;
auto javascript = base::StringPrintf("InspectorFrontendAPI.setDockSide(\"%s\")", side.c_str());
devtools_web_contents_->GetRenderViewHost()->ExecuteJavascriptInWebFrame(string16(), ASCIIToUTF16(javascript));
}
void InspectableWebContentsImpl::OpenInNewTab(const std::string& url) {

View file

@ -13,6 +13,7 @@ public:
virtual void ShowDevTools() = 0;
virtual void CloseDevTools() = 0;
virtual bool SetDockSide(const std::string& side) = 0;
};
}

View file

@ -18,6 +18,7 @@ public:
virtual gfx::NativeView GetNativeView() const OVERRIDE;
virtual void ShowDevTools() OVERRIDE;
virtual void CloseDevTools() OVERRIDE;
virtual bool SetDockSide(const std::string& side) OVERRIDE;
InspectableWebContentsImpl* inspectable_web_contents() { return inspectable_web_contents_; }

View file

@ -29,4 +29,8 @@ void InspectableWebContentsViewMac::CloseDevTools() {
[view_ setDevToolsVisible:NO];
}
bool InspectableWebContentsViewMac::SetDockSide(const std::string& side) {
return [view_ setDockSide:side];
}
}

View file

@ -72,6 +72,19 @@ using namespace brightray;
[_private->splitView adjustSubviews];
}
- (BOOL)setDockSide:(const std::string&)side {
if (side == "right") {
_private->splitView.vertical = YES;
} else if (side == "bottom") {
_private->splitView.vertical = NO;
} else {
return NO;
}
[_private->splitView adjustSubviews];
return YES;
}
@end
@implementation BRYInspectableWebContentsViewPrivate

View file

@ -8,5 +8,6 @@ class InspectableWebContentsViewMac;
- (instancetype)initWithInspectableWebContentsViewMac:(brightray::InspectableWebContentsViewMac *)inspectableWebContentsView;
- (void)setDevToolsVisible:(BOOL)visible;
- (BOOL)setDockSide:(const std::string&)side;
@end