Implement undocked dev tools on Windows
DevToolsWindow represents a vanilla top-level window that shows the dev tools. It uses ui::WindowImpl to implement window functionality, which requires a newer libchromiumcontent which contains the necessary headers for using that class, and requires some modifications to brightray.gypi to make WTL's headers available. * vendor/libchromiumcontent 2f53a96...fc02d93 (4): > Export third_party/wtl/include headers > Export test_support_base.pdb and test_support_content.pdb > Fix linker errors with test_support_base on Windows > Fix linker errors with base_prefs_test_support on Windows
This commit is contained in:
parent
4c9870e753
commit
9ad77c4a38
7 changed files with 122 additions and 1 deletions
|
@ -50,6 +50,8 @@
|
||||||
'browser/notification_presenter_mac.mm',
|
'browser/notification_presenter_mac.mm',
|
||||||
'browser/url_request_context_getter.cc',
|
'browser/url_request_context_getter.cc',
|
||||||
'browser/url_request_context_getter.h',
|
'browser/url_request_context_getter.h',
|
||||||
|
'browser/win/devtools_window.cc',
|
||||||
|
'browser/win/devtools_window.h',
|
||||||
'browser/win/inspectable_web_contents_view_win.cc',
|
'browser/win/inspectable_web_contents_view_win.cc',
|
||||||
'browser/win/inspectable_web_contents_view_win.h',
|
'browser/win/inspectable_web_contents_view_win.h',
|
||||||
'common/application_info.h',
|
'common/application_info.h',
|
||||||
|
|
|
@ -171,6 +171,9 @@
|
||||||
'conditions': [
|
'conditions': [
|
||||||
['OS=="win"', {
|
['OS=="win"', {
|
||||||
'target_defaults': {
|
'target_defaults': {
|
||||||
|
'include_dirs': [
|
||||||
|
'<(libchromiumcontent_include_dir)/third_party/wtl/include',
|
||||||
|
],
|
||||||
'defines': [
|
'defines': [
|
||||||
'_WIN32_WINNT=0x0602',
|
'_WIN32_WINNT=0x0602',
|
||||||
'WINVER=0x0602',
|
'WINVER=0x0602',
|
||||||
|
@ -182,6 +185,10 @@
|
||||||
'CERT_CHAIN_PARA_HAS_EXTRA_FIELDS',
|
'CERT_CHAIN_PARA_HAS_EXTRA_FIELDS',
|
||||||
'WIN32_LEAN_AND_MEAN',
|
'WIN32_LEAN_AND_MEAN',
|
||||||
'_ATL_NO_OPENGL',
|
'_ATL_NO_OPENGL',
|
||||||
|
'_SECURE_ATL',
|
||||||
|
],
|
||||||
|
'msvs_system_include_dirs': [
|
||||||
|
'$(VSInstallDir)/VC/atlmfc/include',
|
||||||
],
|
],
|
||||||
'msvs_settings': {
|
'msvs_settings': {
|
||||||
'VCCLCompilerTool': {
|
'VCCLCompilerTool': {
|
||||||
|
|
47
brightray/browser/win/devtools_window.cc
Normal file
47
brightray/browser/win/devtools_window.cc
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
#include "browser/win/devtools_window.h"
|
||||||
|
|
||||||
|
#include "browser/inspectable_web_contents_impl.h"
|
||||||
|
#include "browser/win/inspectable_web_contents_view_win.h"
|
||||||
|
|
||||||
|
#include "content/public/browser/web_contents_view.h"
|
||||||
|
#include "ui/base/win/hidden_window.h"
|
||||||
|
|
||||||
|
namespace brightray {
|
||||||
|
|
||||||
|
DevToolsWindow* DevToolsWindow::Create(InspectableWebContentsViewWin* controller) {
|
||||||
|
return new DevToolsWindow(controller);
|
||||||
|
}
|
||||||
|
|
||||||
|
DevToolsWindow::DevToolsWindow(InspectableWebContentsViewWin* controller)
|
||||||
|
: controller_(controller) {
|
||||||
|
}
|
||||||
|
|
||||||
|
DevToolsWindow::~DevToolsWindow() {
|
||||||
|
}
|
||||||
|
|
||||||
|
LRESULT DevToolsWindow::OnCreate(UINT, WPARAM, LPARAM, BOOL&) {
|
||||||
|
SetParent(controller_->inspectable_web_contents()->devtools_web_contents()->GetView()->GetNativeView(), hwnd());
|
||||||
|
SetWindowText(hwnd(), L"Developer Tools");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
LRESULT DevToolsWindow::OnDestroy(UINT, WPARAM, LPARAM, BOOL&) {
|
||||||
|
SetParent(controller_->inspectable_web_contents()->devtools_web_contents()->GetView()->GetNativeView(), ui::GetHiddenWindow());
|
||||||
|
delete this;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
LRESULT DevToolsWindow::OnSize(UINT, WPARAM, LPARAM, BOOL&) {
|
||||||
|
RECT rect;
|
||||||
|
GetClientRect(hwnd(), &rect);
|
||||||
|
|
||||||
|
SetWindowPos(controller_->inspectable_web_contents()->devtools_web_contents()->GetView()->GetNativeView(),
|
||||||
|
nullptr,
|
||||||
|
rect.left, rect.top,
|
||||||
|
rect.right - rect.left, rect.bottom - rect.top,
|
||||||
|
SWP_NOZORDER | SWP_SHOWWINDOW);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
36
brightray/browser/win/devtools_window.h
Normal file
36
brightray/browser/win/devtools_window.h
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
#ifndef BRIGHTRAY_BROWSER_WIN_DEVTOOLS_WINDOW_H_
|
||||||
|
#define BRIGHTRAY_BROWSER_WIN_DEVTOOLS_WINDOW_H_
|
||||||
|
|
||||||
|
#include "base/memory/weak_ptr.h"
|
||||||
|
#include "ui/base/win/window_impl.h"
|
||||||
|
|
||||||
|
namespace brightray {
|
||||||
|
|
||||||
|
class InspectableWebContentsViewWin;
|
||||||
|
|
||||||
|
class DevToolsWindow : public ui::WindowImpl, public base::SupportsWeakPtr<DevToolsWindow> {
|
||||||
|
public:
|
||||||
|
static DevToolsWindow* Create(InspectableWebContentsViewWin*);
|
||||||
|
|
||||||
|
BEGIN_MSG_MAP_EX(DevToolsWindow)
|
||||||
|
MESSAGE_HANDLER(WM_CREATE, OnCreate)
|
||||||
|
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
|
||||||
|
MESSAGE_HANDLER(WM_SIZE, OnSize)
|
||||||
|
END_MSG_MAP()
|
||||||
|
|
||||||
|
private:
|
||||||
|
DevToolsWindow(InspectableWebContentsViewWin*);
|
||||||
|
~DevToolsWindow();
|
||||||
|
|
||||||
|
LRESULT OnCreate(UINT message, WPARAM, LPARAM, BOOL& handled);
|
||||||
|
LRESULT OnDestroy(UINT message, WPARAM, LPARAM, BOOL& handled);
|
||||||
|
LRESULT OnSize(UINT message, WPARAM, LPARAM, BOOL& handled);
|
||||||
|
|
||||||
|
InspectableWebContentsViewWin* controller_;
|
||||||
|
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(DevToolsWindow);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,11 +1,20 @@
|
||||||
#include "browser/win/inspectable_web_contents_view_win.h"
|
#include "browser/win/inspectable_web_contents_view_win.h"
|
||||||
|
|
||||||
|
#include "browser/browser_client.h"
|
||||||
#include "browser/inspectable_web_contents_impl.h"
|
#include "browser/inspectable_web_contents_impl.h"
|
||||||
|
#include "browser/win/devtools_window.h"
|
||||||
|
|
||||||
#include "content/public/browser/web_contents_view.h"
|
#include "content/public/browser/web_contents_view.h"
|
||||||
|
#include "ui/base/win/hwnd_util.h"
|
||||||
|
|
||||||
namespace brightray {
|
namespace brightray {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
const int kWindowInset = 100;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
InspectableWebContentsView* CreateInspectableContentsView(InspectableWebContentsImpl* inspectable_web_contents) {
|
InspectableWebContentsView* CreateInspectableContentsView(InspectableWebContentsImpl* inspectable_web_contents) {
|
||||||
return new InspectableWebContentsViewWin(inspectable_web_contents);
|
return new InspectableWebContentsViewWin(inspectable_web_contents);
|
||||||
}
|
}
|
||||||
|
@ -15,6 +24,8 @@ InspectableWebContentsViewWin::InspectableWebContentsViewWin(InspectableWebConte
|
||||||
}
|
}
|
||||||
|
|
||||||
InspectableWebContentsViewWin::~InspectableWebContentsViewWin() {
|
InspectableWebContentsViewWin::~InspectableWebContentsViewWin() {
|
||||||
|
if (devtools_window_)
|
||||||
|
DestroyWindow(devtools_window_->hwnd());
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::NativeView InspectableWebContentsViewWin::GetNativeView() const {
|
gfx::NativeView InspectableWebContentsViewWin::GetNativeView() const {
|
||||||
|
@ -22,9 +33,23 @@ gfx::NativeView InspectableWebContentsViewWin::GetNativeView() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsViewWin::ShowDevTools() {
|
void InspectableWebContentsViewWin::ShowDevTools() {
|
||||||
|
if (!devtools_window_) {
|
||||||
|
devtools_window_ = DevToolsWindow::Create(this)->AsWeakPtr();
|
||||||
|
devtools_window_->Init(HWND_DESKTOP, gfx::Rect());
|
||||||
|
}
|
||||||
|
|
||||||
|
auto contents_view = inspectable_web_contents_->GetWebContents()->GetView();
|
||||||
|
auto size = contents_view->GetContainerSize();
|
||||||
|
size.Enlarge(-kWindowInset, -kWindowInset);
|
||||||
|
ui::CenterAndSizeWindow(contents_view->GetNativeView(), devtools_window_->hwnd(), size);
|
||||||
|
|
||||||
|
ShowWindow(devtools_window_->hwnd(), SW_SHOWNORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsViewWin::CloseDevTools() {
|
void InspectableWebContentsViewWin::CloseDevTools() {
|
||||||
|
if (!devtools_window_)
|
||||||
|
return;
|
||||||
|
SendMessage(devtools_window_->hwnd(), WM_CLOSE, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InspectableWebContentsViewWin::SetDockSide(const std::string& side) {
|
bool InspectableWebContentsViewWin::SetDockSide(const std::string& side) {
|
||||||
|
|
|
@ -4,9 +4,11 @@
|
||||||
#include "browser/inspectable_web_contents_view.h"
|
#include "browser/inspectable_web_contents_view.h"
|
||||||
|
|
||||||
#include "base/compiler_specific.h"
|
#include "base/compiler_specific.h"
|
||||||
|
#include "base/memory/weak_ptr.h"
|
||||||
|
|
||||||
namespace brightray {
|
namespace brightray {
|
||||||
|
|
||||||
|
class DevToolsWindow;
|
||||||
class InspectableWebContentsImpl;
|
class InspectableWebContentsImpl;
|
||||||
|
|
||||||
class InspectableWebContentsViewWin : public InspectableWebContentsView {
|
class InspectableWebContentsViewWin : public InspectableWebContentsView {
|
||||||
|
@ -25,6 +27,8 @@ private:
|
||||||
// Owns us.
|
// Owns us.
|
||||||
InspectableWebContentsImpl* inspectable_web_contents_;
|
InspectableWebContentsImpl* inspectable_web_contents_;
|
||||||
|
|
||||||
|
base::WeakPtr<DevToolsWindow> devtools_window_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(InspectableWebContentsViewWin);
|
DISALLOW_COPY_AND_ASSIGN(InspectableWebContentsViewWin);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
2
brightray/vendor/libchromiumcontent
vendored
2
brightray/vendor/libchromiumcontent
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit 2f53a96fc665176d7e07b67bac6d861295587ce8
|
Subproject commit fc02d9380a52ed648196ea6a0d9053483f233658
|
Loading…
Reference in a new issue