Also add closeDevTools and isDevToolsOpened for webview
This commit is contained in:
parent
accd08a2bf
commit
4ebe58df57
5 changed files with 31 additions and 10 deletions
|
@ -10,9 +10,8 @@
|
||||||
#include "atom/common/native_mate_converters/gurl_converter.h"
|
#include "atom/common/native_mate_converters/gurl_converter.h"
|
||||||
#include "atom/common/native_mate_converters/string16_converter.h"
|
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||||
#include "atom/common/native_mate_converters/value_converter.h"
|
#include "atom/common/native_mate_converters/value_converter.h"
|
||||||
#include "atom/browser/atom_javascript_dialog_manager.h"
|
|
||||||
#include "brightray/browser/inspectable_web_contents.h"
|
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
|
#include "brightray/browser/inspectable_web_contents.h"
|
||||||
#include "content/public/browser/render_frame_host.h"
|
#include "content/public/browser/render_frame_host.h"
|
||||||
#include "content/public/browser/render_process_host.h"
|
#include "content/public/browser/render_process_host.h"
|
||||||
#include "content/public/browser/render_view_host.h"
|
#include "content/public/browser/render_view_host.h"
|
||||||
|
@ -375,6 +374,14 @@ void WebContents::OpenDevTools() {
|
||||||
storage_->ShowDevTools();
|
storage_->ShowDevTools();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebContents::CloseDevTools() {
|
||||||
|
storage_->CloseDevTools();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WebContents::IsDevToolsOpened() {
|
||||||
|
return storage_->IsDevToolsViewShowing();
|
||||||
|
}
|
||||||
|
|
||||||
bool WebContents::SendIPCMessage(const base::string16& channel,
|
bool WebContents::SendIPCMessage(const base::string16& channel,
|
||||||
const base::ListValue& args) {
|
const base::ListValue& args) {
|
||||||
return Send(new AtomViewMsg_Message(routing_id(), channel, args));
|
return Send(new AtomViewMsg_Message(routing_id(), channel, args));
|
||||||
|
@ -450,6 +457,8 @@ mate::ObjectTemplateBuilder WebContents::GetObjectTemplateBuilder(
|
||||||
.SetMethod("setAllowTransparency", &WebContents::SetAllowTransparency)
|
.SetMethod("setAllowTransparency", &WebContents::SetAllowTransparency)
|
||||||
.SetMethod("isGuest", &WebContents::is_guest)
|
.SetMethod("isGuest", &WebContents::is_guest)
|
||||||
.SetMethod("openDevTools", &WebContents::OpenDevTools)
|
.SetMethod("openDevTools", &WebContents::OpenDevTools)
|
||||||
|
.SetMethod("closeDevTools", &WebContents::CloseDevTools)
|
||||||
|
.SetMethod("isDevToolsOpened", &WebContents::IsDevToolsOpened)
|
||||||
.Build());
|
.Build());
|
||||||
|
|
||||||
return mate::ObjectTemplateBuilder(
|
return mate::ObjectTemplateBuilder(
|
||||||
|
|
|
@ -8,20 +8,20 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "atom/browser/api/event_emitter.h"
|
#include "atom/browser/api/event_emitter.h"
|
||||||
|
#include "brightray/browser/default_web_contents_delegate.h"
|
||||||
#include "content/public/browser/browser_plugin_guest_delegate.h"
|
#include "content/public/browser/browser_plugin_guest_delegate.h"
|
||||||
#include "content/public/browser/web_contents_delegate.h"
|
#include "content/public/browser/web_contents_delegate.h"
|
||||||
#include "content/public/browser/web_contents_observer.h"
|
#include "content/public/browser/web_contents_observer.h"
|
||||||
#include "brightray/browser/default_web_contents_delegate.h"
|
|
||||||
#include "native_mate/handle.h"
|
#include "native_mate/handle.h"
|
||||||
|
|
||||||
namespace mate {
|
|
||||||
class Dictionary;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace brightray {
|
namespace brightray {
|
||||||
class InspectableWebContents;
|
class InspectableWebContents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace mate {
|
||||||
|
class Dictionary;
|
||||||
|
}
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
namespace api {
|
namespace api {
|
||||||
|
@ -63,6 +63,8 @@ class WebContents : public mate::EventEmitter,
|
||||||
void InsertCSS(const std::string& css);
|
void InsertCSS(const std::string& css);
|
||||||
void ExecuteJavaScript(const base::string16& code);
|
void ExecuteJavaScript(const base::string16& code);
|
||||||
void OpenDevTools();
|
void OpenDevTools();
|
||||||
|
void CloseDevTools();
|
||||||
|
bool IsDevToolsOpened();
|
||||||
bool SendIPCMessage(const base::string16& channel,
|
bool SendIPCMessage(const base::string16& channel,
|
||||||
const base::ListValue& args);
|
const base::ListValue& args);
|
||||||
|
|
||||||
|
|
|
@ -519,6 +519,8 @@ registerWebViewElement = ->
|
||||||
"executeJavaScript"
|
"executeJavaScript"
|
||||||
"insertCSS",
|
"insertCSS",
|
||||||
"openDevTools",
|
"openDevTools",
|
||||||
|
"closeDevTools",
|
||||||
|
"isDevToolsOpened",
|
||||||
"send"
|
"send"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -167,11 +167,19 @@ Injects CSS into guest page.
|
||||||
|
|
||||||
* `code` String
|
* `code` String
|
||||||
|
|
||||||
Evaluate `code` in guest page.
|
Evaluates `code` in guest page.
|
||||||
|
|
||||||
### `<webview>`.openDevTools()
|
### `<webview>`.openDevTools()
|
||||||
|
|
||||||
Open a devtools instance for the webview's contents.
|
Opens a devtools window for guest page.
|
||||||
|
|
||||||
|
### `<webview>`.closeDevTools()
|
||||||
|
|
||||||
|
Closes the devtools window of guest page.
|
||||||
|
|
||||||
|
### `<webview>`.isDevToolsOpened()
|
||||||
|
|
||||||
|
Returns whether guest page has a devtools window attached.
|
||||||
|
|
||||||
### `<webview>`.send(channel[, args...])
|
### `<webview>`.send(channel[, args...])
|
||||||
|
|
||||||
|
|
2
vendor/brightray
vendored
2
vendor/brightray
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit 90d2649bdd02ac544c79dc24802f7914370e833a
|
Subproject commit 52b2a6bfac3e5e1527c0dcfba6f5a5d2aa6ad9dd
|
Loading…
Reference in a new issue