Also add closeDevTools and isDevToolsOpened for webview

This commit is contained in:
Cheng Zhao
2014-11-03 22:12:56 +08:00
parent accd08a2bf
commit 4ebe58df57
5 changed files with 31 additions and 10 deletions

View File

@@ -10,9 +10,8 @@
#include "atom/common/native_mate_converters/gurl_converter.h"
#include "atom/common/native_mate_converters/string16_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 "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"
@@ -375,6 +374,14 @@ void WebContents::OpenDevTools() {
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));
@@ -450,6 +457,8 @@ mate::ObjectTemplateBuilder WebContents::GetObjectTemplateBuilder(
.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(

View File

@@ -8,20 +8,20 @@
#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 "brightray/browser/default_web_contents_delegate.h"
#include "native_mate/handle.h"
namespace mate {
class Dictionary;
}
namespace brightray {
class InspectableWebContents;
}
namespace mate {
class Dictionary;
}
namespace atom {
namespace api {
@@ -63,6 +63,8 @@ class WebContents : public mate::EventEmitter,
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);

View File

@@ -519,6 +519,8 @@ registerWebViewElement = ->
"executeJavaScript"
"insertCSS",
"openDevTools",
"closeDevTools",
"isDevToolsOpened",
"send"
]