Add DebugDevTools API.
This commit is contained in:
parent
ed34aa6fb3
commit
618040efc1
3 changed files with 54 additions and 2 deletions
1
atom.gyp
1
atom.gyp
|
@ -359,6 +359,7 @@
|
||||||
'include_dirs': [
|
'include_dirs': [
|
||||||
'.',
|
'.',
|
||||||
'vendor',
|
'vendor',
|
||||||
|
'vendor/brightray',
|
||||||
# Include directories for uv and node.
|
# Include directories for uv and node.
|
||||||
'vendor/node/src',
|
'vendor/node/src',
|
||||||
'vendor/node/deps/http_parser',
|
'vendor/node/deps/http_parser',
|
||||||
|
|
|
@ -20,6 +20,9 @@
|
||||||
#include "browser/browser.h"
|
#include "browser/browser.h"
|
||||||
#include "browser/window_list.h"
|
#include "browser/window_list.h"
|
||||||
#include "content/public/browser/devtools_agent_host.h"
|
#include "content/public/browser/devtools_agent_host.h"
|
||||||
|
#include "content/public/browser/devtools_client_host.h"
|
||||||
|
#include "content/public/browser/devtools_http_handler.h"
|
||||||
|
#include "content/public/browser/devtools_manager.h"
|
||||||
#include "content/public/browser/invalidate_type.h"
|
#include "content/public/browser/invalidate_type.h"
|
||||||
#include "content/public/browser/navigation_entry.h"
|
#include "content/public/browser/navigation_entry.h"
|
||||||
#include "content/public/browser/notification_details.h"
|
#include "content/public/browser/notification_details.h"
|
||||||
|
@ -37,6 +40,7 @@
|
||||||
#include "ui/gfx/point.h"
|
#include "ui/gfx/point.h"
|
||||||
#include "ui/gfx/rect.h"
|
#include "ui/gfx/rect.h"
|
||||||
#include "ui/gfx/size.h"
|
#include "ui/gfx/size.h"
|
||||||
|
#include "vendor/brightray/browser/inspectable_web_contents_impl.h"
|
||||||
#include "webkit/common/user_agent/user_agent_util.h"
|
#include "webkit/common/user_agent/user_agent_util.h"
|
||||||
|
|
||||||
using content::NavigationEntry;
|
using content::NavigationEntry;
|
||||||
|
@ -165,6 +169,8 @@ bool NativeWindow::HasModalDialog() {
|
||||||
|
|
||||||
void NativeWindow::OpenDevTools() {
|
void NativeWindow::OpenDevTools() {
|
||||||
inspectable_web_contents()->ShowDevTools();
|
inspectable_web_contents()->ShowDevTools();
|
||||||
|
|
||||||
|
DebugDevTools();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindow::CloseDevTools() {
|
void NativeWindow::CloseDevTools() {
|
||||||
|
@ -183,6 +189,36 @@ void NativeWindow::InspectElement(int x, int y) {
|
||||||
agent->InspectElement(x, y);
|
agent->InspectElement(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NativeWindow::DebugDevTools() {
|
||||||
|
if (!IsDevToolsOpened())
|
||||||
|
return;
|
||||||
|
|
||||||
|
base::DictionaryValue options;
|
||||||
|
NativeWindow* window = NativeWindow::Create(&options);
|
||||||
|
|
||||||
|
brightray::InspectableWebContentsImpl* inspectable_web_contents_impl =
|
||||||
|
static_cast<brightray::InspectableWebContentsImpl*>(
|
||||||
|
inspectable_web_contents());
|
||||||
|
content::WebContents* devtools_web_contents =
|
||||||
|
inspectable_web_contents_impl->devtools_web_contents();
|
||||||
|
|
||||||
|
content::DevToolsAgentHost* agent_host =
|
||||||
|
content::DevToolsAgentHost::GetOrCreateFor(
|
||||||
|
devtools_web_contents->GetRenderViewHost());
|
||||||
|
content::DevToolsClientHost* frontend_host =
|
||||||
|
content::DevToolsClientHost::CreateDevToolsFrontendHost(
|
||||||
|
devtools_web_contents, window);
|
||||||
|
content::DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor(
|
||||||
|
agent_host, frontend_host);
|
||||||
|
|
||||||
|
window->InitFromOptions(&options);
|
||||||
|
window->GetWebContents()->GetController().LoadURL(
|
||||||
|
GURL("chrome-devtools://devtools/devtools.html"),
|
||||||
|
content::Referrer(),
|
||||||
|
content::PAGE_TRANSITION_AUTO_TOPLEVEL,
|
||||||
|
std::string());
|
||||||
|
}
|
||||||
|
|
||||||
void NativeWindow::FocusOnWebView() {
|
void NativeWindow::FocusOnWebView() {
|
||||||
GetWebContents()->GetRenderViewHost()->Focus();
|
GetWebContents()->GetRenderViewHost()->Focus();
|
||||||
}
|
}
|
||||||
|
@ -447,6 +483,14 @@ void NativeWindow::Observe(int type,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NativeWindow::DispatchOnEmbedder(const std::string& message) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void NativeWindow::InspectedContentsClosing() {
|
||||||
|
// We are acting as devtools debugger, safe to delete here.
|
||||||
|
delete this;
|
||||||
|
}
|
||||||
|
|
||||||
void NativeWindow::OnCapturePageDone(const CapturePageCallback& callback,
|
void NativeWindow::OnCapturePageDone(const CapturePageCallback& callback,
|
||||||
bool succeed,
|
bool succeed,
|
||||||
const SkBitmap& bitmap) {
|
const SkBitmap& bitmap) {
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "base/memory/weak_ptr.h"
|
#include "base/memory/weak_ptr.h"
|
||||||
#include "base/observer_list.h"
|
#include "base/observer_list.h"
|
||||||
#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/notification_registrar.h"
|
#include "content/public/browser/notification_registrar.h"
|
||||||
#include "content/public/browser/notification_observer.h"
|
#include "content/public/browser/notification_observer.h"
|
||||||
#include "content/public/browser/web_contents_observer.h"
|
#include "content/public/browser/web_contents_observer.h"
|
||||||
|
@ -49,7 +50,8 @@ struct DraggableRegion;
|
||||||
|
|
||||||
class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
||||||
public content::WebContentsObserver,
|
public content::WebContentsObserver,
|
||||||
public content::NotificationObserver {
|
public content::NotificationObserver,
|
||||||
|
public content::DevToolsFrontendHostDelegate {
|
||||||
public:
|
public:
|
||||||
typedef base::Callback<void(const std::vector<unsigned char>& buffer)>
|
typedef base::Callback<void(const std::vector<unsigned char>& buffer)>
|
||||||
CapturePageCallback;
|
CapturePageCallback;
|
||||||
|
@ -127,6 +129,7 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
||||||
virtual void CloseDevTools();
|
virtual void CloseDevTools();
|
||||||
virtual bool IsDevToolsOpened();
|
virtual bool IsDevToolsOpened();
|
||||||
virtual void InspectElement(int x, int y);
|
virtual void InspectElement(int x, int y);
|
||||||
|
virtual void DebugDevTools();
|
||||||
|
|
||||||
virtual void FocusOnWebView();
|
virtual void FocusOnWebView();
|
||||||
virtual void BlurWebView();
|
virtual void BlurWebView();
|
||||||
|
@ -210,11 +213,15 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
||||||
virtual void BeforeUnloadFired(const base::TimeTicks& proceed_time) OVERRIDE;
|
virtual void BeforeUnloadFired(const base::TimeTicks& proceed_time) OVERRIDE;
|
||||||
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
|
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
|
||||||
|
|
||||||
// Implementations of content::NotificationObserver
|
// Implementations of content::NotificationObserver.
|
||||||
virtual void Observe(int type,
|
virtual void Observe(int type,
|
||||||
const content::NotificationSource& source,
|
const content::NotificationSource& source,
|
||||||
const content::NotificationDetails& details) OVERRIDE;
|
const content::NotificationDetails& details) OVERRIDE;
|
||||||
|
|
||||||
|
// Implementations of content::DevToolsFrontendHostDelegate.
|
||||||
|
virtual void DispatchOnEmbedder(const std::string& message) OVERRIDE;
|
||||||
|
virtual void InspectedContentsClosing() OVERRIDE;
|
||||||
|
|
||||||
// Whether window has standard frame.
|
// Whether window has standard frame.
|
||||||
bool has_frame_;
|
bool has_frame_;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue