Remove Windows's devtools implementation.
This commit is contained in:
parent
0a7b1fdd87
commit
81d31b1d49
6 changed files with 0 additions and 375 deletions
|
@ -77,10 +77,6 @@
|
|||
'browser/views/inspectable_web_contents_view_views.cc',
|
||||
'browser/views/views_delegate.cc',
|
||||
'browser/views/views_delegate.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',
|
||||
'browser/web_ui_controller_factory.cc',
|
||||
'browser/web_ui_controller_factory.h',
|
||||
'common/application_info.h',
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
#include "browser/browser_context.h"
|
||||
#include "browser/web_ui_controller_factory.h"
|
||||
#include "net/proxy/proxy_resolver_v8.h"
|
||||
#include "ui/gfx/screen.h"
|
||||
#include "ui/views/widget/desktop_aura/desktop_screen.h"
|
||||
|
||||
#if defined(USE_AURA)
|
||||
#include "ui/aura/env.h"
|
||||
|
@ -69,10 +67,6 @@ void BrowserMainParts::PreMainMessageLoopRun() {
|
|||
new WebUIControllerFactory(browser_context_.get()));
|
||||
content::WebUIControllerFactory::RegisterFactory(
|
||||
web_ui_controller_factory_.get());
|
||||
|
||||
#if defined(OS_WIN)
|
||||
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, views::CreateDesktopScreen());
|
||||
#endif
|
||||
}
|
||||
|
||||
void BrowserMainParts::PostMainMessageLoopRun() {
|
||||
|
|
|
@ -1,66 +0,0 @@
|
|||
#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/views/layout/fill_layout.h"
|
||||
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
|
||||
#include "ui/views/widget/widget_delegate.h"
|
||||
|
||||
namespace brightray {
|
||||
|
||||
namespace {
|
||||
|
||||
class WidgetDelegateView : public views::WidgetDelegateView {
|
||||
public:
|
||||
WidgetDelegateView() {
|
||||
SetLayoutManager(new views::FillLayout);
|
||||
}
|
||||
|
||||
virtual void DeleteDelegate() OVERRIDE { delete this; }
|
||||
virtual views::View* GetContentsView() OVERRIDE { return this; }
|
||||
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); }
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
DevToolsWindow* DevToolsWindow::Create(
|
||||
InspectableWebContentsViewWin* controller) {
|
||||
return new DevToolsWindow(controller);
|
||||
}
|
||||
|
||||
DevToolsWindow::DevToolsWindow(InspectableWebContentsViewWin* controller)
|
||||
: 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();
|
||||
}
|
||||
|
||||
DevToolsWindow::~DevToolsWindow() {
|
||||
}
|
||||
|
||||
void DevToolsWindow::Show() {
|
||||
widget_->Show();
|
||||
}
|
||||
|
||||
void DevToolsWindow::Close() {
|
||||
widget_->Hide();
|
||||
}
|
||||
|
||||
void DevToolsWindow::Destroy() {
|
||||
delete this;
|
||||
}
|
||||
|
||||
} // namespace brightray
|
|
@ -1,37 +0,0 @@
|
|||
#ifndef BRIGHTRAY_BROWSER_WIN_DEVTOOLS_WINDOW_H_
|
||||
#define BRIGHTRAY_BROWSER_WIN_DEVTOOLS_WINDOW_H_
|
||||
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
|
||||
namespace views {
|
||||
class Widget;
|
||||
}
|
||||
|
||||
namespace brightray {
|
||||
|
||||
class InspectableWebContentsViewWin;
|
||||
|
||||
class DevToolsWindow : public base::SupportsWeakPtr<DevToolsWindow> {
|
||||
public:
|
||||
static DevToolsWindow* Create(
|
||||
InspectableWebContentsViewWin* inspectable_web_contents_view_win);
|
||||
|
||||
void Show();
|
||||
void Close();
|
||||
void Destroy();
|
||||
|
||||
private:
|
||||
explicit DevToolsWindow(
|
||||
InspectableWebContentsViewWin* inspectable_web_contents_view_win);
|
||||
~DevToolsWindow();
|
||||
|
||||
InspectableWebContentsViewWin* controller_;
|
||||
scoped_ptr<views::Widget> widget_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(DevToolsWindow);
|
||||
};
|
||||
|
||||
} // namespace brightray
|
||||
|
||||
#endif
|
|
@ -1,201 +0,0 @@
|
|||
#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/gfx/win/hwnd_util.h"
|
||||
#include "ui/views/controls/single_split_view.h"
|
||||
#include "ui/views/controls/webview/webview.h"
|
||||
#include "ui/views/view.h"
|
||||
|
||||
namespace brightray {
|
||||
|
||||
namespace {
|
||||
|
||||
const int kWindowInset = 100;
|
||||
|
||||
}
|
||||
|
||||
class ContainerView : public views::View {
|
||||
public:
|
||||
explicit ContainerView(InspectableWebContentsViewWin* web_contents_view)
|
||||
: container_view_created_(false),
|
||||
dockside_("none"), // "none" is treated as "bottom".
|
||||
web_view_(new views::WebView(NULL)),
|
||||
web_contents_view_(web_contents_view) {
|
||||
set_owned_by_client();
|
||||
web_view_->set_owned_by_client();
|
||||
web_view_->SetWebContents(
|
||||
web_contents_view_->inspectable_web_contents()->GetWebContents());
|
||||
}
|
||||
|
||||
views::View* GetWebView() const {
|
||||
return web_view_.get();
|
||||
}
|
||||
|
||||
void ShowDevTools() {
|
||||
if (IsDevToolsViewShowing())
|
||||
return;
|
||||
|
||||
RemoveChildView(web_view_.get());
|
||||
devtools_view_ = new views::WebView(NULL);
|
||||
devtools_view_->SetWebContents(web_contents_view_->
|
||||
inspectable_web_contents()->devtools_web_contents());
|
||||
split_view_.reset(new views::SingleSplitView(
|
||||
web_view_.get(),
|
||||
devtools_view_,
|
||||
GetSplitViewOrientation(),
|
||||
NULL));
|
||||
split_view_->set_divider_offset(GetSplitVievDividerOffset());
|
||||
AddChildView(split_view_.get());
|
||||
Layout();
|
||||
|
||||
devtools_view_->RequestFocus();
|
||||
}
|
||||
|
||||
void CloseDevTools() {
|
||||
if (!IsDevToolsViewShowing())
|
||||
return;
|
||||
|
||||
RemoveChildView(split_view_.get());
|
||||
split_view_.reset();
|
||||
AddChildView(web_view_.get());
|
||||
Layout();
|
||||
}
|
||||
|
||||
bool IsDevToolsViewShowing() {
|
||||
return split_view_;
|
||||
}
|
||||
|
||||
void SetDockSide(const std::string& side) {
|
||||
if (dockside_ == side)
|
||||
return; // no change from current location
|
||||
|
||||
dockside_ = side;
|
||||
if (!IsDevToolsViewShowing())
|
||||
return;
|
||||
|
||||
split_view_->set_orientation(GetSplitViewOrientation());
|
||||
split_view_->set_divider_offset(GetSplitVievDividerOffset());
|
||||
split_view_->Layout();
|
||||
return;
|
||||
}
|
||||
|
||||
private:
|
||||
// views::View:
|
||||
virtual void Layout() OVERRIDE {
|
||||
if (split_view_)
|
||||
split_view_->SetBounds(0, 0, width(), height());
|
||||
else
|
||||
web_view_->SetBounds(0, 0, width(), height());
|
||||
}
|
||||
|
||||
virtual void ViewHierarchyChanged(
|
||||
const ViewHierarchyChangedDetails& details) OVERRIDE {
|
||||
View::ViewHierarchyChanged(details);
|
||||
// We're not using child == this because a Widget may not be
|
||||
// available when this is added to the hierarchy.
|
||||
if (details.is_add && GetWidget() && !container_view_created_) {
|
||||
container_view_created_ = true;
|
||||
AddChildView(web_view_.get());
|
||||
}
|
||||
}
|
||||
|
||||
views::SingleSplitView::Orientation GetSplitViewOrientation() const {
|
||||
if (dockside_ == "right")
|
||||
return views::SingleSplitView::HORIZONTAL_SPLIT;
|
||||
else
|
||||
return views::SingleSplitView::VERTICAL_SPLIT;
|
||||
}
|
||||
|
||||
int GetSplitVievDividerOffset() const {
|
||||
if (dockside_ == "right")
|
||||
return width() * 2 / 3;
|
||||
else
|
||||
return height() * 2 / 3;
|
||||
}
|
||||
|
||||
// True if the container view has already been created, or false otherwise.
|
||||
bool container_view_created_;
|
||||
|
||||
std::string dockside_;
|
||||
|
||||
scoped_ptr<views::WebView> web_view_;
|
||||
scoped_ptr<views::SingleSplitView> split_view_;
|
||||
views::WebView* devtools_view_; // Owned by split_view_.
|
||||
|
||||
InspectableWebContentsViewWin* web_contents_view_;
|
||||
};
|
||||
|
||||
InspectableWebContentsView* CreateInspectableContentsView(
|
||||
InspectableWebContentsImpl* inspectable_web_contents) {
|
||||
return new InspectableWebContentsViewWin(inspectable_web_contents);
|
||||
}
|
||||
|
||||
InspectableWebContentsViewWin::InspectableWebContentsViewWin(
|
||||
InspectableWebContentsImpl* inspectable_web_contents)
|
||||
: inspectable_web_contents_(inspectable_web_contents),
|
||||
undocked_(false),
|
||||
container_(new ContainerView(this)) {
|
||||
}
|
||||
|
||||
InspectableWebContentsViewWin::~InspectableWebContentsViewWin() {
|
||||
if (devtools_window_)
|
||||
devtools_window_->Destroy();
|
||||
}
|
||||
|
||||
views::View* InspectableWebContentsViewWin::GetView() const {
|
||||
return container_.get();
|
||||
}
|
||||
|
||||
views::View* InspectableWebContentsViewWin::GetWebView() const {
|
||||
return container_->GetWebView();
|
||||
}
|
||||
|
||||
gfx::NativeView InspectableWebContentsViewWin::GetNativeView() const {
|
||||
auto web_contents = inspectable_web_contents_->GetWebContents();
|
||||
return web_contents->GetView()->GetNativeView();
|
||||
}
|
||||
|
||||
void InspectableWebContentsViewWin::ShowDevTools() {
|
||||
if (undocked_) {
|
||||
if (!devtools_window_)
|
||||
devtools_window_ = DevToolsWindow::Create(this)->AsWeakPtr();
|
||||
|
||||
devtools_window_->Show();
|
||||
} else {
|
||||
container_->ShowDevTools();
|
||||
}
|
||||
}
|
||||
|
||||
void InspectableWebContentsViewWin::CloseDevTools() {
|
||||
if (undocked_)
|
||||
devtools_window_->Close();
|
||||
else
|
||||
container_->CloseDevTools();
|
||||
}
|
||||
|
||||
bool InspectableWebContentsViewWin::IsDevToolsViewShowing() {
|
||||
return container_->IsDevToolsViewShowing() || devtools_window_;
|
||||
}
|
||||
|
||||
bool InspectableWebContentsViewWin::SetDockSide(const std::string& side) {
|
||||
if (side == "undocked") {
|
||||
undocked_ = true;
|
||||
container_->CloseDevTools();
|
||||
} else if (side == "right" || side == "bottom") {
|
||||
undocked_ = false;
|
||||
if (devtools_window_)
|
||||
devtools_window_->Close();
|
||||
container_->SetDockSide(side);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
ShowDevTools();
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace brightray
|
|
@ -1,61 +0,0 @@
|
|||
#ifndef BRIGHTRAY_BROWSER_WIN_INSPECTABLE_WEB_CONTENTS_VIEW_WIN_H_
|
||||
#define BRIGHTRAY_BROWSER_WIN_INSPECTABLE_WEB_CONTENTS_VIEW_WIN_H_
|
||||
|
||||
#include "browser/inspectable_web_contents_view.h"
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
|
||||
namespace views {
|
||||
class View;
|
||||
}
|
||||
|
||||
namespace brightray {
|
||||
|
||||
class ContainerView;
|
||||
class DevToolsWindow;
|
||||
class InspectableWebContentsImpl;
|
||||
|
||||
class InspectableWebContentsViewWin : public InspectableWebContentsView {
|
||||
public:
|
||||
explicit InspectableWebContentsViewWin(
|
||||
InspectableWebContentsImpl* inspectable_web_contents_impl);
|
||||
~InspectableWebContentsViewWin();
|
||||
|
||||
// Returns the container control, which has devtools view attached. Unlike
|
||||
// GetNativeView(), this returns a views::View instead of HWND, and can only
|
||||
// be used by applications that use the views library, if you don't use the
|
||||
// views library, you probably want to set dock side to "undocked" before
|
||||
// showing the devtools, because devtools is showed attached by default and
|
||||
// attached devtools is currently only supported when using views library.
|
||||
views::View* GetView() const;
|
||||
|
||||
// Returns the web view control, which can be used by the
|
||||
// GetInitiallyFocusedView() to set initial focus to web view.
|
||||
views::View* GetWebView() const;
|
||||
|
||||
virtual gfx::NativeView GetNativeView() const OVERRIDE;
|
||||
virtual void ShowDevTools() OVERRIDE;
|
||||
virtual void CloseDevTools() OVERRIDE;
|
||||
virtual bool IsDevToolsViewShowing() OVERRIDE;
|
||||
virtual bool SetDockSide(const std::string& side) OVERRIDE;
|
||||
|
||||
InspectableWebContentsImpl* inspectable_web_contents() {
|
||||
return inspectable_web_contents_;
|
||||
}
|
||||
|
||||
private:
|
||||
// Owns us.
|
||||
InspectableWebContentsImpl* inspectable_web_contents_;
|
||||
|
||||
bool undocked_;
|
||||
scoped_ptr<ContainerView> container_;
|
||||
base::WeakPtr<DevToolsWindow> devtools_window_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(InspectableWebContentsViewWin);
|
||||
};
|
||||
|
||||
} // namespace brightray
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue