Skip to content

Commit

Permalink
Merge branch 'feature/blpwtk2' into blpwtk2/devtools-integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Buildbot committed May 14, 2021
2 parents 6484f23 + 9d1ec16 commit 1df3fb0
Show file tree
Hide file tree
Showing 32 changed files with 321 additions and 7 deletions.
26 changes: 26 additions & 0 deletions src/blpwtk2/private/blpwtk2_devtoolsmanagerdelegateimpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,14 @@ void DevToolsManagerDelegateImpl::StopHttpHandler()
}

// CREATORS
DevToolsManagerDelegateImpl::DevToolsManagerDelegateImpl()
{
content::DevToolsAgentHost::AddObserver(this);
}

DevToolsManagerDelegateImpl::~DevToolsManagerDelegateImpl()
{
content::DevToolsAgentHost::RemoveObserver(this);
}

// DevToolsManagerDelegate overrides
Expand All @@ -178,5 +184,25 @@ bool DevToolsManagerDelegateImpl::HasBundledFrontendResources()
return true;
}

void DevToolsManagerDelegateImpl::DevToolsAgentHostAttached(content::DevToolsAgentHost* agent_host)
{
content::WebContents* web_contents = agent_host->GetWebContents();
if (!web_contents) {
return;
}

web_contents->DevToolsAgentHostAttached();
}

void DevToolsManagerDelegateImpl::DevToolsAgentHostDetached(content::DevToolsAgentHost* agent_host)
{
content::WebContents* web_contents = agent_host->GetWebContents();
if (!web_contents) {
return;
}

web_contents->DevToolsAgentHostDetached();
}

} // close namespace blpwtk2

10 changes: 8 additions & 2 deletions src/blpwtk2/private/blpwtk2_devtoolsmanagerdelegateimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ namespace blpwtk2 {
// class DevToolsManagerDelegateImpl
// =================================

class DevToolsManagerDelegateImpl final : public content::DevToolsManagerDelegate
class DevToolsManagerDelegateImpl final :
public content::DevToolsManagerDelegate,
public content::DevToolsAgentHostObserver
{
DISALLOW_COPY_AND_ASSIGN(DevToolsManagerDelegateImpl);

Expand All @@ -42,11 +44,15 @@ class DevToolsManagerDelegateImpl final : public content::DevToolsManagerDelegat
static int GetHttpHandlerPort();

// CREATORS
DevToolsManagerDelegateImpl() = default;
DevToolsManagerDelegateImpl();
~DevToolsManagerDelegateImpl() override;

// DevToolsManagerDelegate overrides
bool HasBundledFrontendResources() override;

// DevToolsAgentHostObserver overrides
void DevToolsAgentHostAttached(content::DevToolsAgentHost* agent_host) override;
void DevToolsAgentHostDetached(content::DevToolsAgentHost* agent_host) override;
};

} // close namespace blpwtk2
Expand Down
28 changes: 28 additions & 0 deletions src/blpwtk2/private/blpwtk2_mainmessagepump.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <base/threading/thread_local.h>
#include <base/win/wrapped_window_proc.h>
#include <base/time/time.h>
#include <gin/public/debug.h>
#include <third_party/blink/renderer/core/page/bb_window_hooks.h>
#include <v8.h>

Expand Down Expand Up @@ -359,6 +360,27 @@ MainMessagePump* MainMessagePump::current()
return pump;
}

// CLASS METHODS
void MainMessagePump::OnDebugBreak()
{
current()->modalLoop(true);

auto *delegate = Statics::toolkitDelegate;
if (delegate) {
delegate->onDebugBreak();
}
}

void MainMessagePump::OnDebugResume()
{
current()->modalLoop(false);

auto *delegate = Statics::toolkitDelegate;
if (delegate) {
delegate->onDebugResume();
}
}

// CREATORS
MainMessagePump::MainMessagePump()
: base::MessagePumpForUI()
Expand Down Expand Up @@ -413,6 +435,9 @@ MainMessagePump::MainMessagePump()
DCHECK(!g_lazy_tls.Pointer()->Get());
g_lazy_tls.Pointer()->Set(this);

gin::Debug::SetDebugBreakCallback(&MainMessagePump::OnDebugBreak);
gin::Debug::SetDebugResumeCallback(&MainMessagePump::OnDebugResume);

// Active a default pump scheduler
activateScheduler(0);

Expand All @@ -430,6 +455,9 @@ MainMessagePump::MainMessagePump()

MainMessagePump::~MainMessagePump()
{
gin::Debug::SetDebugBreakCallback(nullptr);
gin::Debug::SetDebugResumeCallback(nullptr);

::DestroyWindow(d_window);
g_lazy_tls.Pointer()->Set(nullptr);
}
Expand Down
9 changes: 9 additions & 0 deletions src/blpwtk2/private/blpwtk2_mainmessagepump.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@ class MainMessagePump final : public base::MessagePumpForUI {
// STATIC CREATORS
static MainMessagePump* current();

// CLASS METHODS
static void OnDebugBreak();
// Notify this pump that we're entering a "modal" loop due to being
// paused at a JavaScript breakpoint.

static void OnDebugResume();
// Notify this pump that we're exiting a "modal" loop due to resuming
// from being paused at a JavaScript breakpoint.

// CREATORS
MainMessagePump();
~MainMessagePump() override;
Expand Down
8 changes: 8 additions & 0 deletions src/blpwtk2/private/blpwtk2_webview.mojom
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,14 @@ interface WebViewClient {

didFailLoadForFrame(int32 routingId, string url);
// Notify the client that loading a URL into an IFRAME failed.

devToolsAgentHostAttached();
// Notify the client that the devtools frontend is connected to the
// devtools agent associated with this webview.

devToolsAgentHostDetached();
// Notify the client that the devtools frontend is disconnected from
// the devtools agent associated with this webview.
};

// vim: ts=4 et
Expand Down
10 changes: 10 additions & 0 deletions src/blpwtk2/private/blpwtk2_webviewclientdelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,16 @@ class WebViewClientDelegate
// This method is called when the setParent call is done
// If successful, status 0 will be returned, otherwise error code from GetLassError()
// will be returned as status

virtual void devToolsAgentHostAttached() = 0;
// This method is called when the client receives a notification from
// the host that a DevTools frontend successfully connected to the
// DevTools agent associated with this webview.

virtual void devToolsAgentHostDetached() = 0;
// This method is called when the client receives a notification from
// the host that a DevTools frontend is disconnected from the
// DevTools agent associated with this webview.
};

} // close namespace blpwtk2
Expand Down
18 changes: 18 additions & 0 deletions src/blpwtk2/private/blpwtk2_webviewclientimpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,24 @@ void WebViewClientImpl::didFailLoadForFrame(int routingId,
}
}

void WebViewClientImpl::devToolsAgentHostAttached()
{
DCHECK(d_delegate);

if (d_delegate) {
d_delegate->devToolsAgentHostAttached();
}
}

void WebViewClientImpl::devToolsAgentHostDetached()
{
DCHECK(d_delegate);

if (d_delegate) {
d_delegate->devToolsAgentHostDetached();
}
}

// Mojo callbacks
void WebViewClientImpl::loadStatus(int status)
{
Expand Down
6 changes: 6 additions & 0 deletions src/blpwtk2/private/blpwtk2_webviewclientimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ class WebViewClientImpl final : public WebViewClient
void didFinishLoadForFrame(int routingId, const std::string& url) override;
void didFailLoadForFrame(int routingId, const std::string& url) override;

void devToolsAgentHostAttached() override;
// Notify the client that the devtools frontend is connected.

void devToolsAgentHostDetached() override;
// Notify the client that the devtools frontend is disconnected.

// Mojo callbacks
void loadStatus(int status);
void moveAck(int x, int y, int w, int h);
Expand Down
12 changes: 12 additions & 0 deletions src/blpwtk2/private/blpwtk2_webviewhostimpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,18 @@ void WebViewHostImpl::findState(WebView *source,
NOTREACHED() << "findState should come in via findStateWithReqId";
}

void WebViewHostImpl::devToolsAgentHostAttached(WebView *source)
{
DCHECK(source == d_impl);
d_clientPtr->devToolsAgentHostAttached();
}

void WebViewHostImpl::devToolsAgentHostDetached(WebView *source)
{
DCHECK(source == d_impl);
d_clientPtr->devToolsAgentHostDetached();
}

// Mojo callbacks
void WebViewHostImpl::onNCDragAck()
{
Expand Down
3 changes: 3 additions & 0 deletions src/blpwtk2/private/blpwtk2_webviewhostimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ class WebViewHostImpl final : private WebViewImplClient
int activeMatchOrdinal,
bool finalUpdate) override;

void devToolsAgentHostAttached(WebView *source) override;
void devToolsAgentHostDetached(WebView *source) override;

// Mojo callbacks
void onNCDragAck();

Expand Down
14 changes: 14 additions & 0 deletions src/blpwtk2/private/blpwtk2_webviewimpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,20 @@ void WebViewImpl::FindReply(content::WebContents *source_contents,
}
}

void WebViewImpl::DevToolsAgentHostAttached(content::WebContents* web_contents)
{
if (d_delegate) {
d_delegate->devToolsAgentHostAttached(this);
}
}

void WebViewImpl::DevToolsAgentHostDetached(content::WebContents* web_contents)
{
if (d_delegate) {
d_delegate->devToolsAgentHostDetached(this);
}
}

// WebContentsObserver overrides
void WebViewImpl::RenderViewHostChanged(content::RenderViewHost *old_host,
content::RenderViewHost *new_host)
Expand Down
8 changes: 8 additions & 0 deletions src/blpwtk2/private/blpwtk2_webviewimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,14 @@ class WebViewImpl final : public WebView,
bool final_update) override;
// Information about current find request

void DevToolsAgentHostAttached(content::WebContents* web_contents) override;
// Notify that a frontend is now connected to the devtools agent
// associated with this webview.

void DevToolsAgentHostDetached(content::WebContents* web_contents) override;
// Notify that a frontend is now disconnected from the devtools agent
// associated with this webview.

// content::WebContentsObserver overrides
void RenderViewHostChanged(content::RenderViewHost *old_host,
content::RenderViewHost *new_host) override;
Expand Down
13 changes: 13 additions & 0 deletions src/blpwtk2/private/blpwtk2_webviewproxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,19 @@ bool WebViewProxy::validateClient()


// patch section: devtools integration
void WebViewProxy::devToolsAgentHostAttached()
{
if (d_delegate) {
d_delegate->devToolsAgentHostAttached(this);
}
}

void WebViewProxy::devToolsAgentHostDetached()
{
if (d_delegate) {
d_delegate->devToolsAgentHostDetached(this);
}
}


// patch section: memory diagnostics
Expand Down
2 changes: 2 additions & 0 deletions src/blpwtk2/private/blpwtk2_webviewproxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ class WebViewProxy final : public WebView
void didFailLoadForFrame(int routingId,
const StringRef& url) override;
void didParentStatus(int status, NativeView parent) override;
void devToolsAgentHostAttached() override;
void devToolsAgentHostDetached() override;
};

} // close namespace blpwtk2
Expand Down
1 change: 1 addition & 0 deletions src/blpwtk2/public/blpwtk2_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
// feature 3
// feature 4
// feature 5
#define BLPWTK2_FEATURE_DEVTOOLSINTEGRATION
// feature 6
// feature 7
// feature 8
Expand Down
2 changes: 2 additions & 0 deletions src/blpwtk2/public/blpwtk2_toolkitcreateparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class BLPWTK2_EXPORT ToolkitDelegate {
ToolkitDelegate();

// patch section: devtools integration
virtual void onDebugBreak() = 0;
virtual void onDebugResume() = 0;


// patch section: msg interception
Expand Down
4 changes: 4 additions & 0 deletions src/blpwtk2/public/blpwtk2_webviewdelegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ void WebViewDelegate::didParentStatus(WebView *source, int status, NativeView pa

void WebViewDelegate::validateClientFailed(WebView* source) {}

void WebViewDelegate::devToolsAgentHostAttached(WebView* source) {}

void WebViewDelegate::devToolsAgentHostDetached(WebView* source) {}

} // close namespace blpwtk2

// vim: ts=4 et
Expand Down
7 changes: 7 additions & 0 deletions src/blpwtk2/public/blpwtk2_webviewdelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,13 @@ class BLPWTK2_EXPORT WebViewDelegate {


// patch section: devtools integration
virtual void devToolsAgentHostAttached(WebView *source);
// Notify the embedder that a devtools frontend is connected to this
// webview's devtools agent.

virtual void devToolsAgentHostDetached(WebView *source);
// Notify the embedder that a devtools frontend is disconnected from
// this webview's devtools agent.


// patch section: performance monitor
Expand Down
3 changes: 3 additions & 0 deletions src/blpwtk2/shell/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ class ToolkitDelegate : public blpwtk2::ToolkitDelegate {
ToolkitDelegate()
{
}

void onDebugBreak() override {}
void onDebugResume() override {}
};

class Shell : public blpwtk2::WebViewDelegate {
Expand Down
8 changes: 8 additions & 0 deletions src/content/browser/web_contents/web_contents_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6741,6 +6741,14 @@ void WebContentsImpl::SetShowingContextMenu(bool showing) {
}
}

void WebContentsImpl::DevToolsAgentHostAttached() {
delegate_->DevToolsAgentHostAttached(this);
}

void WebContentsImpl::DevToolsAgentHostDetached() {
delegate_->DevToolsAgentHostDetached(this);
}

void WebContentsImpl::ClearFocusedElement() {
OPTIONAL_TRACE_EVENT0("content", "WebContentsImpl::ClearFocusedElement");
if (auto* frame = GetFocusedFrame())
Expand Down
2 changes: 2 additions & 0 deletions src/content/browser/web_contents/web_contents_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,8 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents,
const std::vector<blink::mojom::FaviconURLPtr>& GetFaviconURLs() override;
void Resize(const gfx::Rect& new_bounds) override;
gfx::Size GetSize() override;
void DevToolsAgentHostAttached() override;
void DevToolsAgentHostDetached() override;

#if defined(OS_ANDROID)
base::android::ScopedJavaLocalRef<jobject> GetJavaWebContents() override;
Expand Down
9 changes: 9 additions & 0 deletions src/content/public/browser/web_contents.h
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,15 @@ class WebContents : public PageNavigator,
// Tells the WebContents whether the context menu is showing.
virtual void SetShowingContextMenu(bool showing) = 0;


// Tells the WebContents that a frontend is connected to the
// devtools agent.
virtual void DevToolsAgentHostAttached() {}

// Tells the WebContents that a frontend disconnected from the
// devtools agent.
virtual void DevToolsAgentHostDetached() {}

#if defined(OS_ANDROID)
CONTENT_EXPORT static WebContents* FromJavaWebContents(
const base::android::JavaRef<jobject>& jweb_contents_android);
Expand Down

0 comments on commit 1df3fb0

Please sign in to comment.