Merge pull request #20 from brightray/windows-dev-tools
Implement undocked dev tools on Windows
This commit is contained in:
commit
57066d414c
9 changed files with 128 additions and 2 deletions
|
@ -50,6 +50,8 @@
|
|||
'browser/notification_presenter_mac.mm',
|
||||
'browser/url_request_context_getter.cc',
|
||||
'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.h',
|
||||
'common/application_info.h',
|
||||
|
|
|
@ -171,6 +171,9 @@
|
|||
'conditions': [
|
||||
['OS=="win"', {
|
||||
'target_defaults': {
|
||||
'include_dirs': [
|
||||
'<(libchromiumcontent_include_dir)/third_party/wtl/include',
|
||||
],
|
||||
'defines': [
|
||||
'_WIN32_WINNT=0x0602',
|
||||
'WINVER=0x0602',
|
||||
|
@ -182,6 +185,10 @@
|
|||
'CERT_CHAIN_PARA_HAS_EXTRA_FIELDS',
|
||||
'WIN32_LEAN_AND_MEAN',
|
||||
'_ATL_NO_OPENGL',
|
||||
'_SECURE_ATL',
|
||||
],
|
||||
'msvs_system_include_dirs': [
|
||||
'$(VSInstallDir)/VC/atlmfc/include',
|
||||
],
|
||||
'msvs_settings': {
|
||||
'VCCLCompilerTool': {
|
||||
|
|
|
@ -72,9 +72,13 @@ net::URLRequestContextGetter* BrowserContext::CreateRequestContext(content::Prot
|
|||
}
|
||||
|
||||
base::FilePath BrowserContext::GetPath() {
|
||||
if (!path_.empty())
|
||||
return path_;
|
||||
|
||||
base::FilePath path;
|
||||
CHECK(PathService::Get(base::DIR_APP_DATA, &path));
|
||||
return path.Append(base::FilePath::FromUTF8Unsafe(GetApplicationName()));
|
||||
path_ = path.Append(base::FilePath::FromUTF8Unsafe(GetApplicationName()));
|
||||
return path_;
|
||||
}
|
||||
|
||||
bool BrowserContext::IsOffTheRecord() const {
|
||||
|
|
|
@ -46,6 +46,7 @@ private:
|
|||
virtual content::SpeechRecognitionPreferences* GetSpeechRecognitionPreferences() OVERRIDE;
|
||||
virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE;
|
||||
|
||||
base::FilePath path_;
|
||||
scoped_ptr<ResourceContext> resource_context_;
|
||||
scoped_refptr<URLRequestContextGetter> url_request_getter_;
|
||||
scoped_ptr<PrefService> prefs_;
|
||||
|
|
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/browser_client.h"
|
||||
#include "browser/inspectable_web_contents_impl.h"
|
||||
#include "browser/win/devtools_window.h"
|
||||
|
||||
#include "content/public/browser/web_contents_view.h"
|
||||
#include "ui/base/win/hwnd_util.h"
|
||||
|
||||
namespace brightray {
|
||||
|
||||
namespace {
|
||||
|
||||
const int kWindowInset = 100;
|
||||
|
||||
}
|
||||
|
||||
InspectableWebContentsView* CreateInspectableContentsView(InspectableWebContentsImpl* inspectable_web_contents) {
|
||||
return new InspectableWebContentsViewWin(inspectable_web_contents);
|
||||
}
|
||||
|
@ -15,6 +24,8 @@ InspectableWebContentsViewWin::InspectableWebContentsViewWin(InspectableWebConte
|
|||
}
|
||||
|
||||
InspectableWebContentsViewWin::~InspectableWebContentsViewWin() {
|
||||
if (devtools_window_)
|
||||
DestroyWindow(devtools_window_->hwnd());
|
||||
}
|
||||
|
||||
gfx::NativeView InspectableWebContentsViewWin::GetNativeView() const {
|
||||
|
@ -22,9 +33,23 @@ gfx::NativeView InspectableWebContentsViewWin::GetNativeView() const {
|
|||
}
|
||||
|
||||
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() {
|
||||
if (!devtools_window_)
|
||||
return;
|
||||
SendMessage(devtools_window_->hwnd(), WM_CLOSE, 0, 0);
|
||||
}
|
||||
|
||||
bool InspectableWebContentsViewWin::SetDockSide(const std::string& side) {
|
||||
|
|
|
@ -4,9 +4,11 @@
|
|||
#include "browser/inspectable_web_contents_view.h"
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
|
||||
namespace brightray {
|
||||
|
||||
class DevToolsWindow;
|
||||
class InspectableWebContentsImpl;
|
||||
|
||||
class InspectableWebContentsViewWin : public InspectableWebContentsView {
|
||||
|
@ -25,6 +27,8 @@ private:
|
|||
// Owns us.
|
||||
InspectableWebContentsImpl* inspectable_web_contents_;
|
||||
|
||||
base::WeakPtr<DevToolsWindow> devtools_window_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(InspectableWebContentsViewWin);
|
||||
};
|
||||
|
||||
|
|
2
brightray/vendor/libchromiumcontent
vendored
2
brightray/vendor/libchromiumcontent
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 2f53a96fc665176d7e07b67bac6d861295587ce8
|
||||
Subproject commit fc02d9380a52ed648196ea6a0d9053483f233658
|
Loading…
Add table
Reference in a new issue