Remove native_window's dead code.
This commit is contained in:
parent
8ecc4061a8
commit
0440c59d18
7 changed files with 6 additions and 259 deletions
2
atom.gyp
2
atom.gyp
|
@ -95,8 +95,6 @@
|
|||
'atom/browser/browser_mac.mm',
|
||||
'atom/browser/browser_win.cc',
|
||||
'atom/browser/browser_observer.h',
|
||||
'atom/browser/devtools_delegate.cc',
|
||||
'atom/browser/devtools_delegate.h',
|
||||
'atom/browser/mac/atom_application.h',
|
||||
'atom/browser/mac/atom_application.mm',
|
||||
'atom/browser/mac/atom_application_delegate.h',
|
||||
|
|
|
@ -284,11 +284,6 @@ void Window::InspectElement(int x, int y) {
|
|||
window_->InspectElement(x, y);
|
||||
}
|
||||
|
||||
void Window::DebugDevTools() {
|
||||
if (window_->IsDevToolsOpened())
|
||||
NativeWindow::Debug(window_->GetDevToolsWebContents());
|
||||
}
|
||||
|
||||
void Window::FocusOnWebView() {
|
||||
window_->FocusOnWebView();
|
||||
}
|
||||
|
@ -376,7 +371,6 @@ void Window::BuildPrototype(v8::Isolate* isolate,
|
|||
.SetMethod("closeDevTools", &Window::CloseDevTools)
|
||||
.SetMethod("isDevToolsOpened", &Window::IsDevToolsOpened)
|
||||
.SetMethod("inspectElement", &Window::InspectElement)
|
||||
.SetMethod("debugDevTools", &Window::DebugDevTools)
|
||||
.SetMethod("focusOnWebView", &Window::FocusOnWebView)
|
||||
.SetMethod("blurWebView", &Window::BlurWebView)
|
||||
.SetMethod("isWebViewFocused", &Window::IsWebViewFocused)
|
||||
|
|
|
@ -92,7 +92,6 @@ class Window : public mate::EventEmitter,
|
|||
void CloseDevTools();
|
||||
bool IsDevToolsOpened();
|
||||
void InspectElement(int x, int y);
|
||||
void DebugDevTools();
|
||||
void FocusOnWebView();
|
||||
void BlurWebView();
|
||||
bool IsWebViewFocused();
|
||||
|
|
|
@ -1,124 +0,0 @@
|
|||
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/browser/devtools_delegate.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "atom/browser/native_window.h"
|
||||
#include "content/public/browser/devtools_agent_host.h"
|
||||
#include "content/public/browser/devtools_client_host.h"
|
||||
#include "content/public/browser/devtools_http_handler.h"
|
||||
#include "content/public/browser/devtools_manager.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "ui/gfx/point.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
DevToolsDelegate::DevToolsDelegate(NativeWindow* window,
|
||||
content::WebContents* target_web_contents)
|
||||
: content::WebContentsObserver(window->GetWebContents()),
|
||||
owner_window_(window),
|
||||
delegate_(NULL),
|
||||
embedder_message_dispatcher_(
|
||||
new DevToolsEmbedderMessageDispatcher(this)) {
|
||||
content::WebContents* web_contents = window->GetWebContents();
|
||||
|
||||
// Setup devtools.
|
||||
devtools_agent_host_ = content::DevToolsAgentHost::GetOrCreateFor(
|
||||
target_web_contents->GetRenderViewHost());
|
||||
devtools_client_host_.reset(
|
||||
content::DevToolsClientHost::CreateDevToolsFrontendHost(web_contents,
|
||||
this));
|
||||
content::DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor(
|
||||
devtools_agent_host_.get(), devtools_client_host_.get());
|
||||
|
||||
// Go!
|
||||
mate::Dictionary options;
|
||||
options.Set("title", "DevTools Debugger");
|
||||
window->InitFromOptions(options);
|
||||
window->AddObserver(this);
|
||||
web_contents->GetController().LoadURL(
|
||||
GURL("chrome-devtools://devtools/devtools.html?dockSide=undocked"),
|
||||
content::Referrer(),
|
||||
content::PAGE_TRANSITION_AUTO_TOPLEVEL,
|
||||
std::string());
|
||||
}
|
||||
|
||||
DevToolsDelegate::~DevToolsDelegate() {
|
||||
}
|
||||
|
||||
void DevToolsDelegate::DispatchOnEmbedder(const std::string& message) {
|
||||
embedder_message_dispatcher_->Dispatch(message);
|
||||
}
|
||||
|
||||
void DevToolsDelegate::InspectedContentsClosing() {
|
||||
owner_window_->Close();
|
||||
}
|
||||
|
||||
void DevToolsDelegate::AboutToNavigateRenderView(
|
||||
content::RenderViewHost* render_view_host) {
|
||||
content::DevToolsClientHost::SetupDevToolsFrontendClient(
|
||||
owner_window_->GetWebContents()->GetRenderViewHost());
|
||||
}
|
||||
|
||||
void DevToolsDelegate::OnWindowClosed() {
|
||||
base::MessageLoop::current()->DeleteSoon(FROM_HERE, owner_window_);
|
||||
}
|
||||
|
||||
void DevToolsDelegate::ActivateWindow() {
|
||||
}
|
||||
|
||||
void DevToolsDelegate::CloseWindow() {
|
||||
owner_window_->Close();
|
||||
}
|
||||
|
||||
void DevToolsDelegate::MoveWindow(int x, int y) {
|
||||
owner_window_->SetPosition(gfx::Point(x, y));
|
||||
}
|
||||
|
||||
void DevToolsDelegate::SetDockSide(const std::string& dock_side) {
|
||||
bool succeed = true;
|
||||
if (delegate_ &&
|
||||
delegate_->DevToolsSetDockSide("attach-back", &succeed) &&
|
||||
succeed)
|
||||
owner_window_->Close();
|
||||
}
|
||||
|
||||
void DevToolsDelegate::OpenInNewTab(const std::string& url) {
|
||||
}
|
||||
|
||||
void DevToolsDelegate::SaveToFile(
|
||||
const std::string& url, const std::string& content, bool save_as) {
|
||||
}
|
||||
|
||||
void DevToolsDelegate::AppendToFile(
|
||||
const std::string& url, const std::string& content) {
|
||||
}
|
||||
|
||||
void DevToolsDelegate::RequestFileSystems() {
|
||||
}
|
||||
|
||||
void DevToolsDelegate::AddFileSystem() {
|
||||
}
|
||||
|
||||
void DevToolsDelegate::RemoveFileSystem(const std::string& file_system_path) {
|
||||
}
|
||||
|
||||
void DevToolsDelegate::IndexPath(
|
||||
int request_id, const std::string& file_system_path) {
|
||||
}
|
||||
|
||||
void DevToolsDelegate::StopIndexing(int request_id) {
|
||||
}
|
||||
|
||||
void DevToolsDelegate::SearchInPath(
|
||||
int request_id,
|
||||
const std::string& file_system_path,
|
||||
const std::string& query) {
|
||||
}
|
||||
|
||||
} // namespace atom
|
|
@ -1,87 +0,0 @@
|
|||
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_BROWSER_DEVTOOLS_DELEGATE_H_
|
||||
#define ATOM_BROWSER_DEVTOOLS_DELEGATE_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "atom/browser/native_window_observer.h"
|
||||
#include "content/public/browser/devtools_frontend_host_delegate.h"
|
||||
#include "content/public/browser/web_contents_observer.h"
|
||||
#include "vendor/brightray/browser/devtools_embedder_message_dispatcher.h"
|
||||
#include "vendor/brightray/browser/inspectable_web_contents_delegate.h"
|
||||
|
||||
namespace content {
|
||||
class DevToolsAgentHost;
|
||||
class DevToolsClientHost;
|
||||
}
|
||||
|
||||
using brightray::DevToolsEmbedderMessageDispatcher;
|
||||
|
||||
namespace atom {
|
||||
|
||||
class NativeWindow;
|
||||
|
||||
class DevToolsDelegate : public content::DevToolsFrontendHostDelegate,
|
||||
public content::WebContentsObserver,
|
||||
public NativeWindowObserver,
|
||||
public DevToolsEmbedderMessageDispatcher::Delegate {
|
||||
public:
|
||||
DevToolsDelegate(NativeWindow* window,
|
||||
content::WebContents* target_web_contents);
|
||||
virtual ~DevToolsDelegate();
|
||||
|
||||
void SetDelegate(brightray::InspectableWebContentsDelegate* delegate) {
|
||||
delegate_ = delegate;
|
||||
}
|
||||
|
||||
protected:
|
||||
// Implementations of content::DevToolsFrontendHostDelegate.
|
||||
virtual void DispatchOnEmbedder(const std::string& message) OVERRIDE;
|
||||
virtual void InspectedContentsClosing() OVERRIDE;
|
||||
|
||||
// Implementations of content::WebContentsObserver.
|
||||
virtual void AboutToNavigateRenderView(
|
||||
content::RenderViewHost* render_view_host) OVERRIDE;
|
||||
|
||||
// Implementations of NativeWindowObserver.
|
||||
virtual void OnWindowClosed() OVERRIDE;
|
||||
|
||||
// Implementations of DevToolsEmbedderMessageDispatcher::Delegate.
|
||||
virtual void ActivateWindow() OVERRIDE;
|
||||
virtual void CloseWindow() OVERRIDE;
|
||||
virtual void MoveWindow(int x, int y) OVERRIDE;
|
||||
virtual void SetDockSide(const std::string& dock_side) OVERRIDE;
|
||||
virtual void OpenInNewTab(const std::string& url) OVERRIDE;
|
||||
virtual void SaveToFile(const std::string& url,
|
||||
const std::string& content,
|
||||
bool save_as) OVERRIDE;
|
||||
virtual void AppendToFile(const std::string& url,
|
||||
const std::string& content) OVERRIDE;
|
||||
virtual void RequestFileSystems() OVERRIDE;
|
||||
virtual void AddFileSystem() OVERRIDE;
|
||||
virtual void RemoveFileSystem(const std::string& file_system_path) OVERRIDE;
|
||||
virtual void IndexPath(int request_id,
|
||||
const std::string& file_system_path) OVERRIDE;
|
||||
virtual void StopIndexing(int request_id) OVERRIDE;
|
||||
virtual void SearchInPath(int request_id,
|
||||
const std::string& file_system_path,
|
||||
const std::string& query) OVERRIDE;
|
||||
|
||||
private:
|
||||
NativeWindow* owner_window_;
|
||||
brightray::InspectableWebContentsDelegate* delegate_;
|
||||
|
||||
scoped_refptr<content::DevToolsAgentHost> devtools_agent_host_;
|
||||
scoped_ptr<content::DevToolsClientHost> devtools_client_host_;
|
||||
scoped_ptr<DevToolsEmbedderMessageDispatcher> embedder_message_dispatcher_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(DevToolsDelegate);
|
||||
};
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_DEVTOOLS_DELEGATE_H_
|
|
@ -11,7 +11,6 @@
|
|||
#include "atom/browser/atom_browser_context.h"
|
||||
#include "atom/browser/atom_javascript_dialog_manager.h"
|
||||
#include "atom/browser/browser.h"
|
||||
#include "atom/browser/devtools_delegate.h"
|
||||
#include "atom/browser/ui/file_dialog.h"
|
||||
#include "atom/browser/window_list.h"
|
||||
#include "atom/common/api/api_messages.h"
|
||||
|
@ -128,14 +127,6 @@ NativeWindow* NativeWindow::Create(const mate::Dictionary& options) {
|
|||
return Create(content::WebContents::Create(create_params), options);
|
||||
}
|
||||
|
||||
// static
|
||||
NativeWindow* NativeWindow::Debug(content::WebContents* web_contents) {
|
||||
mate::Dictionary options;
|
||||
NativeWindow* window = NativeWindow::Create(options);
|
||||
window->devtools_delegate_.reset(new DevToolsDelegate(window, web_contents));
|
||||
return window;
|
||||
}
|
||||
|
||||
// static
|
||||
NativeWindow* NativeWindow::FromRenderView(int process_id, int routing_id) {
|
||||
// Stupid iterating.
|
||||
|
@ -216,28 +207,20 @@ bool NativeWindow::HasModalDialog() {
|
|||
}
|
||||
|
||||
void NativeWindow::OpenDevTools() {
|
||||
if (devtools_window_) {
|
||||
devtools_window_->Focus(true);
|
||||
} else {
|
||||
inspectable_web_contents()->ShowDevTools();
|
||||
inspectable_web_contents()->ShowDevTools();
|
||||
#if defined(OS_MACOSX)
|
||||
// Temporary fix for flashing devtools, try removing this after upgraded to
|
||||
// Chrome 32.
|
||||
GetDevToolsWebContents()->GetView()->SetAllowOverlappingViews(false);
|
||||
// Temporary fix for flashing devtools, try removing this after upgraded to
|
||||
// Chrome 32.
|
||||
GetDevToolsWebContents()->GetView()->SetAllowOverlappingViews(false);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void NativeWindow::CloseDevTools() {
|
||||
if (devtools_window_)
|
||||
devtools_window_->Close();
|
||||
else
|
||||
inspectable_web_contents()->CloseDevTools();
|
||||
inspectable_web_contents()->CloseDevTools();
|
||||
}
|
||||
|
||||
bool NativeWindow::IsDevToolsOpened() {
|
||||
return (devtools_window_ && devtools_window_->IsFocused()) ||
|
||||
inspectable_web_contents()->IsDevToolsViewShowing();
|
||||
return inspectable_web_contents()->IsDevToolsViewShowing();
|
||||
}
|
||||
|
||||
void NativeWindow::InspectElement(int x, int y) {
|
||||
|
@ -262,10 +245,6 @@ bool NativeWindow::IsWebViewFocused() {
|
|||
return host_view && host_view->HasFocus();
|
||||
}
|
||||
|
||||
base::ProcessHandle NativeWindow::GetRenderProcessHandle() {
|
||||
return GetWebContents()->GetRenderProcessHost()->GetHandle();
|
||||
}
|
||||
|
||||
void NativeWindow::CapturePage(const gfx::Rect& rect,
|
||||
const CapturePageCallback& callback) {
|
||||
content::RenderViewHost* render_view_host =
|
||||
|
|
|
@ -44,7 +44,6 @@ class Dictionary;
|
|||
namespace atom {
|
||||
|
||||
class AtomJavaScriptDialogManager;
|
||||
class DevToolsDelegate;
|
||||
struct DraggableRegion;
|
||||
|
||||
class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
||||
|
@ -85,10 +84,6 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
|||
// managing the window's live.
|
||||
static NativeWindow* Create(const mate::Dictionary& options);
|
||||
|
||||
// Creates a devtools window to debug the WebContents, the returned window
|
||||
// will manage its own life.
|
||||
static NativeWindow* Debug(content::WebContents* web_contents);
|
||||
|
||||
// Find a window from its process id and routing id.
|
||||
static NativeWindow* FromRenderView(int process_id, int routing_id);
|
||||
|
||||
|
@ -144,10 +139,6 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
|||
virtual void BlurWebView();
|
||||
virtual bool IsWebViewFocused();
|
||||
|
||||
// Returns the process handle of render process, useful for killing the
|
||||
// render process manually
|
||||
virtual base::ProcessHandle GetRenderProcessHandle();
|
||||
|
||||
// Captures the page with |rect|, |callback| would be called when capturing is
|
||||
// done.
|
||||
virtual void CapturePage(const gfx::Rect& rect,
|
||||
|
@ -296,9 +287,6 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
|||
|
||||
base::WeakPtrFactory<NativeWindow> weak_factory_;
|
||||
|
||||
base::WeakPtr<NativeWindow> devtools_window_;
|
||||
scoped_ptr<DevToolsDelegate> devtools_delegate_;
|
||||
|
||||
scoped_ptr<AtomJavaScriptDialogManager> dialog_manager_;
|
||||
|
||||
// Notice that inspectable_web_contents_ must be placed after dialog_manager_,
|
||||
|
|
Loading…
Reference in a new issue