diff --git a/atom.gyp b/atom.gyp index df92b76726a6..fff917131448 100644 --- a/atom.gyp +++ b/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', diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index 5a74b86bfdf0..1caf3cd3fecc 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -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) diff --git a/atom/browser/api/atom_api_window.h b/atom/browser/api/atom_api_window.h index 19d6dc55bee7..c9b2a5ff0056 100644 --- a/atom/browser/api/atom_api_window.h +++ b/atom/browser/api/atom_api_window.h @@ -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(); diff --git a/atom/browser/devtools_delegate.cc b/atom/browser/devtools_delegate.cc deleted file mode 100644 index 6981f7397d35..000000000000 --- a/atom/browser/devtools_delegate.cc +++ /dev/null @@ -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 - -#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 diff --git a/atom/browser/devtools_delegate.h b/atom/browser/devtools_delegate.h deleted file mode 100644 index 624bacbfa3de..000000000000 --- a/atom/browser/devtools_delegate.h +++ /dev/null @@ -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 - -#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 devtools_agent_host_; - scoped_ptr devtools_client_host_; - scoped_ptr embedder_message_dispatcher_; - - DISALLOW_COPY_AND_ASSIGN(DevToolsDelegate); -}; - -} // namespace atom - -#endif // ATOM_BROWSER_DEVTOOLS_DELEGATE_H_ diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index 6b1ccd6ce954..4f89038366a7 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -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 = diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index 667df9743f26..a211abdeabd3 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -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 weak_factory_; - base::WeakPtr devtools_window_; - scoped_ptr devtools_delegate_; - scoped_ptr dialog_manager_; // Notice that inspectable_web_contents_ must be placed after dialog_manager_,