Make DevToolsDelegate respond to messages.
This commit is contained in:
parent
5e05a3045c
commit
391468ece0
2 changed files with 82 additions and 3 deletions
|
@ -11,13 +11,16 @@
|
||||||
#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.h"
|
#include "content/public/browser/web_contents.h"
|
||||||
|
#include "ui/gfx/point.h"
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
DevToolsDelegate::DevToolsDelegate(NativeWindow* window,
|
DevToolsDelegate::DevToolsDelegate(NativeWindow* window,
|
||||||
content::WebContents* target_web_contents)
|
content::WebContents* target_web_contents)
|
||||||
: content::WebContentsObserver(window->GetWebContents()),
|
: content::WebContentsObserver(window->GetWebContents()),
|
||||||
owner_window_(window) {
|
owner_window_(window),
|
||||||
|
embedder_message_dispatcher_(
|
||||||
|
new DevToolsEmbedderMessageDispatcher(this)) {
|
||||||
content::WebContents* web_contents = window->GetWebContents();
|
content::WebContents* web_contents = window->GetWebContents();
|
||||||
|
|
||||||
// Setup devtools.
|
// Setup devtools.
|
||||||
|
@ -34,7 +37,7 @@ DevToolsDelegate::DevToolsDelegate(NativeWindow* window,
|
||||||
options.SetString("title", "DevTools Debugger");
|
options.SetString("title", "DevTools Debugger");
|
||||||
window->InitFromOptions(&options);
|
window->InitFromOptions(&options);
|
||||||
web_contents->GetController().LoadURL(
|
web_contents->GetController().LoadURL(
|
||||||
GURL("chrome-devtools://devtools/devtools.html"),
|
GURL("chrome-devtools://devtools/devtools.html?dockSide=undocked"),
|
||||||
content::Referrer(),
|
content::Referrer(),
|
||||||
content::PAGE_TRANSITION_AUTO_TOPLEVEL,
|
content::PAGE_TRANSITION_AUTO_TOPLEVEL,
|
||||||
std::string());
|
std::string());
|
||||||
|
@ -44,6 +47,7 @@ DevToolsDelegate::~DevToolsDelegate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DevToolsDelegate::DispatchOnEmbedder(const std::string& message) {
|
void DevToolsDelegate::DispatchOnEmbedder(const std::string& message) {
|
||||||
|
embedder_message_dispatcher_->Dispatch(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DevToolsDelegate::InspectedContentsClosing() {
|
void DevToolsDelegate::InspectedContentsClosing() {
|
||||||
|
@ -60,4 +64,53 @@ void DevToolsDelegate::OnWindowClosed() {
|
||||||
delete owner_window_;
|
delete owner_window_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DevToolsDelegate::ActivateWindow() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void DevToolsDelegate::CloseWindow() {
|
||||||
|
owner_window_->Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DevToolsDelegate::MoveWindow(int x, int y) {
|
||||||
|
owner_window_->SetPosition(gfx::Point(x, y));
|
||||||
|
}
|
||||||
|
|
||||||
|
void DevToolsDelegate::SetDockSide(const std::string& dock_side) {
|
||||||
|
if (dock_side != "undocked")
|
||||||
|
owner_window_->Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DevToolsDelegate::OpenInNewTab(const std::string& url) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void DevToolsDelegate::SaveToFile(
|
||||||
|
const std::string& url, const std::string& content, bool save_as) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void DevToolsDelegate::AppendToFile(
|
||||||
|
const std::string& url, const std::string& content) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void DevToolsDelegate::RequestFileSystems() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void DevToolsDelegate::AddFileSystem() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void DevToolsDelegate::RemoveFileSystem(const std::string& file_system_path) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void DevToolsDelegate::IndexPath(
|
||||||
|
int request_id, const std::string& file_system_path) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void DevToolsDelegate::StopIndexing(int request_id) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void DevToolsDelegate::SearchInPath(
|
||||||
|
int request_id,
|
||||||
|
const std::string& file_system_path,
|
||||||
|
const std::string& query) {
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
|
@ -9,19 +9,23 @@
|
||||||
#include "browser/native_window_observer.h"
|
#include "browser/native_window_observer.h"
|
||||||
#include "content/public/browser/devtools_frontend_host_delegate.h"
|
#include "content/public/browser/devtools_frontend_host_delegate.h"
|
||||||
#include "content/public/browser/web_contents_observer.h"
|
#include "content/public/browser/web_contents_observer.h"
|
||||||
|
#include "vendor/brightray/browser/devtools_embedder_message_dispatcher.h"
|
||||||
|
|
||||||
namespace content {
|
namespace content {
|
||||||
class DevToolsAgentHost;
|
class DevToolsAgentHost;
|
||||||
class DevToolsClientHost;
|
class DevToolsClientHost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using brightray::DevToolsEmbedderMessageDispatcher;
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
class NativeWindow;
|
class NativeWindow;
|
||||||
|
|
||||||
class DevToolsDelegate : public content::DevToolsFrontendHostDelegate,
|
class DevToolsDelegate : public content::DevToolsFrontendHostDelegate,
|
||||||
public content::WebContentsObserver,
|
public content::WebContentsObserver,
|
||||||
public NativeWindowObserver {
|
public NativeWindowObserver,
|
||||||
|
public DevToolsEmbedderMessageDispatcher::Delegate {
|
||||||
public:
|
public:
|
||||||
DevToolsDelegate(NativeWindow* window,
|
DevToolsDelegate(NativeWindow* window,
|
||||||
content::WebContents* target_web_contents);
|
content::WebContents* target_web_contents);
|
||||||
|
@ -39,11 +43,33 @@ class DevToolsDelegate : public content::DevToolsFrontendHostDelegate,
|
||||||
// Implementations of NativeWindowObserver.
|
// Implementations of NativeWindowObserver.
|
||||||
virtual void OnWindowClosed() OVERRIDE;
|
virtual void OnWindowClosed() OVERRIDE;
|
||||||
|
|
||||||
|
// Implementations of DevToolsEmbedderMessageDispatcher::Delegate.
|
||||||
|
virtual void ActivateWindow() OVERRIDE;
|
||||||
|
virtual void CloseWindow() OVERRIDE;
|
||||||
|
virtual void MoveWindow(int x, int y) OVERRIDE;
|
||||||
|
virtual void SetDockSide(const std::string& dock_side) OVERRIDE;
|
||||||
|
virtual void OpenInNewTab(const std::string& url) OVERRIDE;
|
||||||
|
virtual void SaveToFile(const std::string& url,
|
||||||
|
const std::string& content,
|
||||||
|
bool save_as) OVERRIDE;
|
||||||
|
virtual void AppendToFile(const std::string& url,
|
||||||
|
const std::string& content) OVERRIDE;
|
||||||
|
virtual void RequestFileSystems() OVERRIDE;
|
||||||
|
virtual void AddFileSystem() OVERRIDE;
|
||||||
|
virtual void RemoveFileSystem(const std::string& file_system_path) OVERRIDE;
|
||||||
|
virtual void IndexPath(int request_id,
|
||||||
|
const std::string& file_system_path) OVERRIDE;
|
||||||
|
virtual void StopIndexing(int request_id) OVERRIDE;
|
||||||
|
virtual void SearchInPath(int request_id,
|
||||||
|
const std::string& file_system_path,
|
||||||
|
const std::string& query) OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NativeWindow* owner_window_;
|
NativeWindow* owner_window_;
|
||||||
|
|
||||||
scoped_refptr<content::DevToolsAgentHost> devtools_agent_host_;
|
scoped_refptr<content::DevToolsAgentHost> devtools_agent_host_;
|
||||||
scoped_ptr<content::DevToolsClientHost> devtools_client_host_;
|
scoped_ptr<content::DevToolsClientHost> devtools_client_host_;
|
||||||
|
scoped_ptr<DevToolsEmbedderMessageDispatcher> embedder_message_dispatcher_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(DevToolsDelegate);
|
DISALLOW_COPY_AND_ASSIGN(DevToolsDelegate);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue