Merge pull request #778 from atom/project-infinium-webview-devtools
devtools for webview tags (continue work of #774)
This commit is contained in:
commit
a3a21b5b88
7 changed files with 57 additions and 13 deletions
|
@ -11,6 +11,7 @@
|
|||
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||
#include "atom/common/native_mate_converters/value_converter.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_process_host.h"
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
|
@ -55,9 +56,9 @@ WebContents::WebContents(const mate::Dictionary& options)
|
|||
if (options.Get("isGuest", &is_guest) && is_guest)
|
||||
params.guest_delegate = this;
|
||||
|
||||
storage_.reset(content::WebContents::Create(params));
|
||||
storage_->SetDelegate(this);
|
||||
Observe(storage_.get());
|
||||
storage_.reset(brightray::InspectableWebContents::Create(params));
|
||||
Observe(storage_->GetWebContents());
|
||||
web_contents()->SetDelegate(this);
|
||||
}
|
||||
|
||||
WebContents::~WebContents() {
|
||||
|
@ -368,6 +369,19 @@ void WebContents::ExecuteJavaScript(const base::string16& code) {
|
|||
web_contents()->GetMainFrame()->ExecuteJavaScript(code);
|
||||
}
|
||||
|
||||
void WebContents::OpenDevTools() {
|
||||
storage_->SetCanDock(false);
|
||||
storage_->ShowDevTools();
|
||||
}
|
||||
|
||||
void WebContents::CloseDevTools() {
|
||||
storage_->CloseDevTools();
|
||||
}
|
||||
|
||||
bool WebContents::IsDevToolsOpened() {
|
||||
return storage_->IsDevToolsViewShowing();
|
||||
}
|
||||
|
||||
bool WebContents::SendIPCMessage(const base::string16& channel,
|
||||
const base::ListValue& args) {
|
||||
return Send(new AtomViewMsg_Message(routing_id(), channel, args));
|
||||
|
@ -442,6 +456,9 @@ mate::ObjectTemplateBuilder WebContents::GetObjectTemplateBuilder(
|
|||
.SetMethod("setAutoSize", &WebContents::SetAutoSize)
|
||||
.SetMethod("setAllowTransparency", &WebContents::SetAllowTransparency)
|
||||
.SetMethod("isGuest", &WebContents::is_guest)
|
||||
.SetMethod("openDevTools", &WebContents::OpenDevTools)
|
||||
.SetMethod("closeDevTools", &WebContents::CloseDevTools)
|
||||
.SetMethod("isDevToolsOpened", &WebContents::IsDevToolsOpened)
|
||||
.Build());
|
||||
|
||||
return mate::ObjectTemplateBuilder(
|
||||
|
|
|
@ -8,11 +8,16 @@
|
|||
#include <string>
|
||||
|
||||
#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/web_contents_delegate.h"
|
||||
#include "content/public/browser/web_contents_observer.h"
|
||||
#include "native_mate/handle.h"
|
||||
|
||||
namespace brightray {
|
||||
class InspectableWebContents;
|
||||
}
|
||||
|
||||
namespace mate {
|
||||
class Dictionary;
|
||||
}
|
||||
|
@ -57,6 +62,9 @@ class WebContents : public mate::EventEmitter,
|
|||
void SetUserAgent(const std::string& user_agent);
|
||||
void InsertCSS(const std::string& css);
|
||||
void ExecuteJavaScript(const base::string16& code);
|
||||
void OpenDevTools();
|
||||
void CloseDevTools();
|
||||
bool IsDevToolsOpened();
|
||||
bool SendIPCMessage(const base::string16& channel,
|
||||
const base::ListValue& args);
|
||||
|
||||
|
@ -175,7 +183,7 @@ class WebContents : public mate::EventEmitter,
|
|||
scoped_ptr<base::DictionaryValue> extra_params_;
|
||||
|
||||
// Stores the WebContents that managed by this class.
|
||||
scoped_ptr<content::WebContents> storage_;
|
||||
scoped_ptr<brightray::InspectableWebContents> storage_;
|
||||
|
||||
// The WebContents that attaches this guest view.
|
||||
content::WebContents* embedder_web_contents_;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
path = require 'path'
|
||||
timers = require 'timers'
|
||||
Module = require 'module'
|
||||
process = global.process
|
||||
path = require 'path'
|
||||
timers = require 'timers'
|
||||
Module = require 'module'
|
||||
|
||||
process.atomBinding = (name) ->
|
||||
try
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
path = require 'path'
|
||||
url = require 'url'
|
||||
Module = require 'module'
|
||||
process = global.process
|
||||
path = require 'path'
|
||||
url = require 'url'
|
||||
Module = require 'module'
|
||||
|
||||
# Expose information of current process.
|
||||
process.type = 'renderer'
|
||||
|
@ -83,3 +84,5 @@ else
|
|||
# global reference after they are done.
|
||||
process.once 'BIND_DONE', ->
|
||||
delete global.process
|
||||
delete global.setImmediate
|
||||
delete global.clearImmediate
|
||||
|
|
|
@ -517,7 +517,10 @@ registerWebViewElement = ->
|
|||
"isCrashed"
|
||||
"setUserAgent"
|
||||
"executeJavaScript"
|
||||
"insertCSS"
|
||||
"insertCSS",
|
||||
"openDevTools",
|
||||
"closeDevTools",
|
||||
"isDevToolsOpened",
|
||||
"send"
|
||||
]
|
||||
|
||||
|
|
|
@ -167,7 +167,19 @@ Injects CSS into guest page.
|
|||
|
||||
* `code` String
|
||||
|
||||
Evaluate `code` in guest page.
|
||||
Evaluates `code` in guest page.
|
||||
|
||||
### `<webview>`.openDevTools()
|
||||
|
||||
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...])
|
||||
|
||||
|
|
2
vendor/brightray
vendored
2
vendor/brightray
vendored
|
@ -1 +1 @@
|
|||
Subproject commit b90f13be24a006c55b7e1c935be492101ac2736c
|
||||
Subproject commit 52b2a6bfac3e5e1527c0dcfba6f5a5d2aa6ad9dd
|
Loading…
Reference in a new issue