2013-05-22 20:57:32 +00:00
|
|
|
#include "browser/win/inspectable_web_contents_view_win.h"
|
|
|
|
|
2013-06-04 18:31:37 +00:00
|
|
|
#include "browser/browser_client.h"
|
2013-05-22 20:57:32 +00:00
|
|
|
#include "browser/inspectable_web_contents_impl.h"
|
2013-06-04 18:31:37 +00:00
|
|
|
#include "browser/win/devtools_window.h"
|
2013-05-22 20:57:32 +00:00
|
|
|
|
|
|
|
#include "content/public/browser/web_contents_view.h"
|
2013-12-02 16:47:58 +00:00
|
|
|
#include "ui/gfx/win/hwnd_util.h"
|
2013-05-22 20:57:32 +00:00
|
|
|
|
|
|
|
namespace brightray {
|
|
|
|
|
2013-06-04 18:31:37 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
const int kWindowInset = 100;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-11-18 00:02:49 +00:00
|
|
|
InspectableWebContentsView* CreateInspectableContentsView(
|
|
|
|
InspectableWebContentsImpl* inspectable_web_contents) {
|
2013-05-22 20:57:32 +00:00
|
|
|
return new InspectableWebContentsViewWin(inspectable_web_contents);
|
|
|
|
}
|
|
|
|
|
2013-11-18 00:02:49 +00:00
|
|
|
InspectableWebContentsViewWin::InspectableWebContentsViewWin(
|
|
|
|
InspectableWebContentsImpl* inspectable_web_contents)
|
2013-05-22 20:57:32 +00:00
|
|
|
: inspectable_web_contents_(inspectable_web_contents) {
|
|
|
|
}
|
|
|
|
|
|
|
|
InspectableWebContentsViewWin::~InspectableWebContentsViewWin() {
|
2013-06-04 18:31:37 +00:00
|
|
|
if (devtools_window_)
|
|
|
|
DestroyWindow(devtools_window_->hwnd());
|
2013-05-22 20:57:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gfx::NativeView InspectableWebContentsViewWin::GetNativeView() const {
|
2013-11-18 00:02:49 +00:00
|
|
|
auto web_contents = inspectable_web_contents_->GetWebContents();
|
|
|
|
return web_contents->GetView()->GetNativeView();
|
2013-05-22 20:57:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void InspectableWebContentsViewWin::ShowDevTools() {
|
2013-06-04 18:31:37 +00:00
|
|
|
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);
|
2013-12-02 16:47:58 +00:00
|
|
|
gfx::CenterAndSizeWindow(contents_view->GetNativeView(),
|
|
|
|
devtools_window_->hwnd(),
|
|
|
|
size);
|
2013-06-04 18:31:37 +00:00
|
|
|
|
|
|
|
ShowWindow(devtools_window_->hwnd(), SW_SHOWNORMAL);
|
2013-05-22 20:57:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void InspectableWebContentsViewWin::CloseDevTools() {
|
2013-06-04 18:31:37 +00:00
|
|
|
if (!devtools_window_)
|
|
|
|
return;
|
|
|
|
SendMessage(devtools_window_->hwnd(), WM_CLOSE, 0, 0);
|
2013-05-22 20:57:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool InspectableWebContentsViewWin::SetDockSide(const std::string& side) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-11-17 23:20:17 +00:00
|
|
|
} // namespace brightray
|