electron/brightray/browser/win/inspectable_web_contents_view_win.cc
Adam Roben 9ad77c4a38 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
2013-06-04 14:33:29 -04:00

59 lines
1.7 KiB
C++

#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);
}
InspectableWebContentsViewWin::InspectableWebContentsViewWin(InspectableWebContentsImpl* inspectable_web_contents)
: inspectable_web_contents_(inspectable_web_contents) {
}
InspectableWebContentsViewWin::~InspectableWebContentsViewWin() {
if (devtools_window_)
DestroyWindow(devtools_window_->hwnd());
}
gfx::NativeView InspectableWebContentsViewWin::GetNativeView() const {
return inspectable_web_contents_->GetWebContents()->GetView()->GetNativeView();
}
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) {
return false;
}
}