2013-06-04 18:31:37 +00:00
|
|
|
#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"
|
2014-07-07 18:27:23 +00:00
|
|
|
#include "ui/views/layout/fill_layout.h"
|
|
|
|
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
|
|
|
|
#include "ui/views/widget/widget_delegate.h"
|
2013-06-04 18:31:37 +00:00
|
|
|
|
|
|
|
namespace brightray {
|
|
|
|
|
2014-07-07 18:27:23 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
class WidgetDelegateView : public views::WidgetDelegateView {
|
|
|
|
public:
|
|
|
|
WidgetDelegateView() {
|
|
|
|
SetLayoutManager(new views::FillLayout);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void DeleteDelegate() OVERRIDE { delete this; }
|
2014-07-07 18:42:30 +00:00
|
|
|
virtual views::View* GetContentsView() OVERRIDE { return this; }
|
2014-07-07 18:27:23 +00:00
|
|
|
virtual bool CanResize() const OVERRIDE { return true; }
|
|
|
|
virtual bool CanMaximize() const OVERRIDE { return true; }
|
|
|
|
virtual base::string16 GetWindowTitle() const OVERRIDE { return L"Developer Tools"; }
|
|
|
|
virtual gfx::Size GetPreferredSize() OVERRIDE { return gfx::Size(800, 600); }
|
|
|
|
virtual gfx::Size GetMinimumSize() OVERRIDE { return gfx::Size(100, 100); }
|
|
|
|
};
|
|
|
|
|
2014-07-07 18:42:30 +00:00
|
|
|
} // namespace
|
2014-07-07 18:27:23 +00:00
|
|
|
|
2013-11-18 00:05:21 +00:00
|
|
|
DevToolsWindow* DevToolsWindow::Create(
|
|
|
|
InspectableWebContentsViewWin* controller) {
|
2013-06-04 18:31:37 +00:00
|
|
|
return new DevToolsWindow(controller);
|
|
|
|
}
|
|
|
|
|
|
|
|
DevToolsWindow::DevToolsWindow(InspectableWebContentsViewWin* controller)
|
2014-07-07 18:27:23 +00:00
|
|
|
: controller_(controller),
|
|
|
|
widget_(new views::Widget) {
|
|
|
|
auto delegate_view = new WidgetDelegateView;
|
|
|
|
views::Widget::InitParams params;
|
|
|
|
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
|
|
|
|
params.top_level = true;
|
|
|
|
params.native_widget = new views::DesktopNativeWidgetAura(widget_.get());
|
|
|
|
params.delegate = delegate_view;
|
|
|
|
widget_->Init(params);
|
|
|
|
delegate_view->AddChildView(controller->GetView());
|
|
|
|
delegate_view->Layout();
|
2013-06-04 18:31:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DevToolsWindow::~DevToolsWindow() {
|
|
|
|
}
|
|
|
|
|
2014-07-07 18:27:23 +00:00
|
|
|
void DevToolsWindow::Show() {
|
|
|
|
widget_->Show();
|
2013-06-04 18:31:37 +00:00
|
|
|
}
|
|
|
|
|
2014-07-07 18:27:23 +00:00
|
|
|
void DevToolsWindow::Close() {
|
|
|
|
widget_->Hide();
|
2013-06-04 18:31:37 +00:00
|
|
|
}
|
|
|
|
|
2014-07-07 18:27:23 +00:00
|
|
|
void DevToolsWindow::Destroy() {
|
|
|
|
delete this;
|
2013-06-04 18:31:37 +00:00
|
|
|
}
|
|
|
|
|
2013-11-17 23:20:17 +00:00
|
|
|
} // namespace brightray
|