Add DebugDevTools API.
This commit is contained in:
Родитель
ed34aa6fb3
Коммит
618040efc1
1
atom.gyp
1
atom.gyp
|
@ -359,6 +359,7 @@
|
|||
'include_dirs': [
|
||||
'.',
|
||||
'vendor',
|
||||
'vendor/brightray',
|
||||
# Include directories for uv and node.
|
||||
'vendor/node/src',
|
||||
'vendor/node/deps/http_parser',
|
||||
|
|
|
@ -20,6 +20,9 @@
|
|||
#include "browser/browser.h"
|
||||
#include "browser/window_list.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/navigation_entry.h"
|
||||
#include "content/public/browser/notification_details.h"
|
||||
|
@ -37,6 +40,7 @@
|
|||
#include "ui/gfx/point.h"
|
||||
#include "ui/gfx/rect.h"
|
||||
#include "ui/gfx/size.h"
|
||||
#include "vendor/brightray/browser/inspectable_web_contents_impl.h"
|
||||
#include "webkit/common/user_agent/user_agent_util.h"
|
||||
|
||||
using content::NavigationEntry;
|
||||
|
@ -165,6 +169,8 @@ bool NativeWindow::HasModalDialog() {
|
|||
|
||||
void NativeWindow::OpenDevTools() {
|
||||
inspectable_web_contents()->ShowDevTools();
|
||||
|
||||
DebugDevTools();
|
||||
}
|
||||
|
||||
void NativeWindow::CloseDevTools() {
|
||||
|
@ -183,6 +189,36 @@ void NativeWindow::InspectElement(int x, int 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() {
|
||||
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,
|
||||
bool succeed,
|
||||
const SkBitmap& bitmap) {
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "base/memory/weak_ptr.h"
|
||||
#include "base/observer_list.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_observer.h"
|
||||
#include "content/public/browser/web_contents_observer.h"
|
||||
|
@ -49,7 +50,8 @@ struct DraggableRegion;
|
|||
|
||||
class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
||||
public content::WebContentsObserver,
|
||||
public content::NotificationObserver {
|
||||
public content::NotificationObserver,
|
||||
public content::DevToolsFrontendHostDelegate {
|
||||
public:
|
||||
typedef base::Callback<void(const std::vector<unsigned char>& buffer)>
|
||||
CapturePageCallback;
|
||||
|
@ -127,6 +129,7 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
|||
virtual void CloseDevTools();
|
||||
virtual bool IsDevToolsOpened();
|
||||
virtual void InspectElement(int x, int y);
|
||||
virtual void DebugDevTools();
|
||||
|
||||
virtual void FocusOnWebView();
|
||||
virtual void BlurWebView();
|
||||
|
@ -210,11 +213,15 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
|||
virtual void BeforeUnloadFired(const base::TimeTicks& proceed_time) OVERRIDE;
|
||||
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
|
||||
|
||||
// Implementations of content::NotificationObserver
|
||||
// Implementations of content::NotificationObserver.
|
||||
virtual void Observe(int type,
|
||||
const content::NotificationSource& source,
|
||||
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.
|
||||
bool has_frame_;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче