Support docking the devtools on the right side of the window
This commit is contained in:
parent
001d0197de
commit
c22d1cca79
6 changed files with 28 additions and 0 deletions
|
@ -9,11 +9,14 @@
|
||||||
#include "browser/browser_main_parts.h"
|
#include "browser/browser_main_parts.h"
|
||||||
#include "browser/inspectable_web_contents_view.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_agent_host.h"
|
||||||
#include "content/public/browser/devtools_client_host.h"
|
#include "content/public/browser/devtools_client_host.h"
|
||||||
#include "content/public/browser/devtools_http_handler.h"
|
#include "content/public/browser/devtools_http_handler.h"
|
||||||
#include "content/public/browser/devtools_manager.h"
|
#include "content/public/browser/devtools_manager.h"
|
||||||
#include "content/public/browser/web_contents_view.h"
|
#include "content/public/browser/web_contents_view.h"
|
||||||
|
#include "content/public/browser/render_view_host.h"
|
||||||
|
|
||||||
namespace brightray {
|
namespace brightray {
|
||||||
|
|
||||||
|
@ -70,6 +73,11 @@ void InspectableWebContentsImpl::MoveWindow(int x, int y) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::SetDockSide(const std::string& side) {
|
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) {
|
void InspectableWebContentsImpl::OpenInNewTab(const std::string& url) {
|
||||||
|
|
|
@ -13,6 +13,7 @@ public:
|
||||||
|
|
||||||
virtual void ShowDevTools() = 0;
|
virtual void ShowDevTools() = 0;
|
||||||
virtual void CloseDevTools() = 0;
|
virtual void CloseDevTools() = 0;
|
||||||
|
virtual bool SetDockSide(const std::string& side) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ public:
|
||||||
virtual gfx::NativeView GetNativeView() const OVERRIDE;
|
virtual gfx::NativeView GetNativeView() const OVERRIDE;
|
||||||
virtual void ShowDevTools() OVERRIDE;
|
virtual void ShowDevTools() OVERRIDE;
|
||||||
virtual void CloseDevTools() OVERRIDE;
|
virtual void CloseDevTools() OVERRIDE;
|
||||||
|
virtual bool SetDockSide(const std::string& side) OVERRIDE;
|
||||||
|
|
||||||
InspectableWebContentsImpl* inspectable_web_contents() { return inspectable_web_contents_; }
|
InspectableWebContentsImpl* inspectable_web_contents() { return inspectable_web_contents_; }
|
||||||
|
|
||||||
|
|
|
@ -29,4 +29,8 @@ void InspectableWebContentsViewMac::CloseDevTools() {
|
||||||
[view_ setDevToolsVisible:NO];
|
[view_ setDevToolsVisible:NO];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool InspectableWebContentsViewMac::SetDockSide(const std::string& side) {
|
||||||
|
return [view_ setDockSide:side];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,19 @@ using namespace brightray;
|
||||||
[_private->splitView adjustSubviews];
|
[_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
|
@end
|
||||||
|
|
||||||
@implementation BRYInspectableWebContentsViewPrivate
|
@implementation BRYInspectableWebContentsViewPrivate
|
||||||
|
|
|
@ -8,5 +8,6 @@ class InspectableWebContentsViewMac;
|
||||||
|
|
||||||
- (instancetype)initWithInspectableWebContentsViewMac:(brightray::InspectableWebContentsViewMac *)inspectableWebContentsView;
|
- (instancetype)initWithInspectableWebContentsViewMac:(brightray::InspectableWebContentsViewMac *)inspectableWebContentsView;
|
||||||
- (void)setDevToolsVisible:(BOOL)visible;
|
- (void)setDevToolsVisible:(BOOL)visible;
|
||||||
|
- (BOOL)setDockSide:(const std::string&)side;
|
||||||
|
|
||||||
@end
|
@end
|
Loading…
Add table
Add a link
Reference in a new issue