2012-04-03 03:34:16 +02:00
|
|
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef CEF_LIBCEF_BROWSER_DEVTOOLS_DELEGATE_H_
|
|
|
|
#define CEF_LIBCEF_BROWSER_DEVTOOLS_DELEGATE_H_
|
|
|
|
#pragma once
|
|
|
|
|
2013-01-15 20:12:28 +01:00
|
|
|
#include <map>
|
2012-04-03 03:34:16 +02:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "base/basictypes.h"
|
|
|
|
#include "base/compiler_specific.h"
|
2012-04-27 00:20:18 +02:00
|
|
|
#include "base/memory/scoped_ptr.h"
|
2013-01-15 20:12:28 +01:00
|
|
|
#include "content/public/browser/devtools_agent_host.h"
|
2012-04-27 00:20:18 +02:00
|
|
|
#include "content/public/browser/devtools_http_handler.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "content/public/browser/devtools_http_handler_delegate.h"
|
|
|
|
|
|
|
|
namespace content {
|
2012-04-27 00:20:18 +02:00
|
|
|
class RenderViewHost;
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
2013-01-15 20:12:28 +01:00
|
|
|
class CefDevToolsBindingHandler
|
|
|
|
: public content::DevToolsHttpHandler::DevToolsAgentHostBinding {
|
|
|
|
public:
|
|
|
|
CefDevToolsBindingHandler();
|
|
|
|
|
|
|
|
// DevToolsAgentHostBinding overrides.
|
|
|
|
virtual std::string GetIdentifier(
|
|
|
|
content::DevToolsAgentHost* agent_host) OVERRIDE;
|
|
|
|
virtual content::DevToolsAgentHost* ForIdentifier(
|
|
|
|
const std::string& identifier) OVERRIDE;
|
|
|
|
|
|
|
|
std::string GetIdentifier(content::RenderViewHost* rvh);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void GarbageCollect();
|
|
|
|
|
|
|
|
std::string random_seed_;
|
|
|
|
|
|
|
|
// Map of identifier to DevToolsAgentHost. Keeps the DevToolsAgentHost objects
|
|
|
|
// alive until the associated RVH is disconnected.
|
|
|
|
typedef std::map<std::string, scoped_refptr<content::DevToolsAgentHost> >
|
|
|
|
AgentsMap;
|
|
|
|
AgentsMap agents_map_;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(CefDevToolsBindingHandler);
|
|
|
|
};
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
class CefDevToolsDelegate : public content::DevToolsHttpHandlerDelegate {
|
|
|
|
public:
|
2012-10-04 21:17:13 +02:00
|
|
|
explicit CefDevToolsDelegate(int port);
|
2012-04-03 03:34:16 +02:00
|
|
|
virtual ~CefDevToolsDelegate();
|
|
|
|
|
|
|
|
// Stops http server.
|
|
|
|
void Stop();
|
|
|
|
|
|
|
|
// DevToolsHttpProtocolHandler::Delegate overrides.
|
|
|
|
virtual std::string GetDiscoveryPageHTML() OVERRIDE;
|
|
|
|
virtual bool BundlesFrontendResources() OVERRIDE;
|
2013-02-23 01:43:28 +01:00
|
|
|
virtual base::FilePath GetDebugFrontendDir() OVERRIDE;
|
2012-10-04 21:17:13 +02:00
|
|
|
virtual std::string GetPageThumbnailData(const GURL& url) OVERRIDE;
|
2012-11-05 21:18:20 +01:00
|
|
|
virtual content::RenderViewHost* CreateNewTarget() OVERRIDE;
|
2013-02-23 01:43:28 +01:00
|
|
|
virtual TargetType GetTargetType(content::RenderViewHost*) OVERRIDE;
|
2013-04-02 19:21:37 +02:00
|
|
|
virtual std::string GetViewDescription(content::RenderViewHost*) OVERRIDE;
|
2013-05-07 23:48:34 +02:00
|
|
|
virtual scoped_refptr<net::StreamListenSocket> CreateSocketForTethering(
|
|
|
|
net::StreamListenSocket::Delegate* delegate,
|
|
|
|
std::string* name) OVERRIDE;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2012-04-27 00:20:18 +02:00
|
|
|
// Returns the DevTools URL for the specified RenderViewHost.
|
2012-05-18 17:04:56 +02:00
|
|
|
std::string GetDevToolsURL(content::RenderViewHost* rvh, bool http_scheme);
|
2012-04-27 00:20:18 +02:00
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
private:
|
|
|
|
content::DevToolsHttpHandler* devtools_http_handler_;
|
2013-01-15 20:12:28 +01:00
|
|
|
scoped_ptr<CefDevToolsBindingHandler> binding_;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(CefDevToolsDelegate);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_BROWSER_DEVTOOLS_DELEGATE_H_
|