Add API to get whether the devtools is opened.

This commit is contained in:
Cheng Zhao 2013-11-05 10:29:53 +08:00
parent afc627aae1
commit de7892cd6e
10 changed files with 24 additions and 2 deletions

View file

@ -22,6 +22,7 @@ class InspectableWebContents {
virtual content::WebContents* GetWebContents() const = 0;
virtual void ShowDevTools() = 0;
virtual bool IsDevToolsOpened() = 0;
};
} // namespace brightray

View file

@ -96,6 +96,10 @@ void InspectableWebContentsImpl::ShowDevTools() {
view_->ShowDevTools();
}
bool InspectableWebContentsImpl::IsDevToolsOpened() {
return devtools_web_contents_ && view_->IsDevToolsOpened();
}
void InspectableWebContentsImpl::UpdateFrontendDockSide() {
auto javascript = base::StringPrintf(
"InspectorFrontendAPI.setDockSide(\"%s\")", dock_side_.c_str());

View file

@ -41,6 +41,7 @@ class InspectableWebContentsImpl :
virtual content::WebContents* GetWebContents() const OVERRIDE;
virtual void ShowDevTools() OVERRIDE;
virtual bool IsDevToolsOpened() OVERRIDE;
content::WebContents* devtools_web_contents() {
return devtools_web_contents_.get();

View file

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

View file

@ -19,6 +19,7 @@ class InspectableWebContentsViewMac : public InspectableWebContentsView {
virtual gfx::NativeView GetNativeView() const OVERRIDE;
virtual void ShowDevTools() OVERRIDE;
virtual void CloseDevTools() OVERRIDE;
virtual bool IsDevToolsOpened() OVERRIDE;
virtual bool SetDockSide(const std::string& side) OVERRIDE;
InspectableWebContentsImpl* inspectable_web_contents() {

View file

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

View file

@ -112,6 +112,10 @@ void SetActive(content::WebContents* web_contents, bool active) {
[_private->splitView adjustSubviews];
}
- (BOOL)isDevToolsVisible {
return _private->visible;
}
- (BOOL)setDockSide:(const std::string&)side {
if (side == "right") {
_private->splitView.vertical = YES;
@ -221,4 +225,4 @@ void SetActive(content::WebContents* web_contents, bool active) {
@end
@implementation BRYInspectableWebContentsViewPrivate
@end
@end

View file

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

View file

@ -57,6 +57,10 @@ void InspectableWebContentsViewWin::CloseDevTools() {
SendMessage(devtools_window_->hwnd(), WM_CLOSE, 0, 0);
}
bool InspectableWebContentsViewWin::IsDevToolsOpened() {
return devtools_window_;
}
bool InspectableWebContentsViewWin::SetDockSide(const std::string& side) {
return false;
}

View file

@ -20,6 +20,7 @@ class InspectableWebContentsViewWin : public InspectableWebContentsView {
virtual gfx::NativeView GetNativeView() const OVERRIDE;
virtual void ShowDevTools() OVERRIDE;
virtual void CloseDevTools() OVERRIDE;
virtual bool IsDevToolsOpened() OVERRIDE;
virtual bool SetDockSide(const std::string& side) OVERRIDE;
InspectableWebContentsImpl* inspectable_web_contents() {