#include "browser/browser.h"
#include "browser/window_list.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/invalidate_type.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/notification_details.h"
#include "ui/gfx/point.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/size.h"
+#include "vendor/brightray/browser/inspectable_web_contents_impl.h"
#include "webkit/common/user_agent/user_agent_util.h"
using content::NavigationEntry;
void NativeWindow::OpenDevTools() {
inspectable_web_contents()->ShowDevTools();
+
+ DebugDevTools();
}
void NativeWindow::CloseDevTools() {
agent->InspectElement(x, y);
}
+void NativeWindow::DebugDevTools() {
+ if (!IsDevToolsOpened())
+ return;
+
+ base::DictionaryValue options;
+ NativeWindow* window = NativeWindow::Create(&options);
+
+ brightray::InspectableWebContentsImpl* inspectable_web_contents_impl =
+ static_cast<brightray::InspectableWebContentsImpl*>(
+ inspectable_web_contents());
+ content::WebContents* devtools_web_contents =
+ inspectable_web_contents_impl->devtools_web_contents();
+
+ content::DevToolsAgentHost* agent_host =
+ content::DevToolsAgentHost::GetOrCreateFor(
+ devtools_web_contents->GetRenderViewHost());
+ content::DevToolsClientHost* frontend_host =
+ content::DevToolsClientHost::CreateDevToolsFrontendHost(
+ devtools_web_contents, window);
+ content::DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor(
+ agent_host, frontend_host);
+
+ window->InitFromOptions(&options);
+ window->GetWebContents()->GetController().LoadURL(
+ GURL("chrome-devtools://devtools/devtools.html"),
+ content::Referrer(),
+ content::PAGE_TRANSITION_AUTO_TOPLEVEL,
+ std::string());
+}
+
void NativeWindow::FocusOnWebView() {
GetWebContents()->GetRenderViewHost()->Focus();
}
}
}
+void NativeWindow::DispatchOnEmbedder(const std::string& message) {
+}
+
+void NativeWindow::InspectedContentsClosing() {
+ // We are acting as devtools debugger, safe to delete here.
+ delete this;
+}
+
void NativeWindow::OnCapturePageDone(const CapturePageCallback& callback,
bool succeed,
const SkBitmap& bitmap) {
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "browser/native_window_observer.h"
+#include "content/public/browser/devtools_frontend_host_delegate.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/web_contents_observer.h"
class NativeWindow : public brightray::DefaultWebContentsDelegate,
public content::WebContentsObserver,
- public content::NotificationObserver {
+ public content::NotificationObserver,
+ public content::DevToolsFrontendHostDelegate {
public:
typedef base::Callback<void(const std::vector<unsigned char>& buffer)>
CapturePageCallback;
virtual void CloseDevTools();
virtual bool IsDevToolsOpened();
virtual void InspectElement(int x, int y);
+ virtual void DebugDevTools();
virtual void FocusOnWebView();
virtual void BlurWebView();
virtual void BeforeUnloadFired(const base::TimeTicks& proceed_time) OVERRIDE;
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
- // Implementations of content::NotificationObserver
+ // Implementations of content::NotificationObserver.
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
+ // Implementations of content::DevToolsFrontendHostDelegate.
+ virtual void DispatchOnEmbedder(const std::string& message) OVERRIDE;
+ virtual void InspectedContentsClosing() OVERRIDE;
+
// Whether window has standard frame.
bool has_frame_;