| Index: content/shell/browser/shell_devtools_delegate.cc
|
| diff --git a/content/shell/browser/shell_devtools_delegate.cc b/content/shell/browser/shell_devtools_delegate.cc
|
| index c8d256f61256127e8668ef7e235ffff04d03eb6a..a69b1595827770920d10d6cb6189a60851d2576a 100644
|
| --- a/content/shell/browser/shell_devtools_delegate.cc
|
| +++ b/content/shell/browser/shell_devtools_delegate.cc
|
| @@ -9,7 +9,10 @@
|
| #include "base/bind.h"
|
| #include "base/command_line.h"
|
| #include "base/strings/string_number_conversions.h"
|
| +#include "content/public/browser/devtools_agent_host.h"
|
| #include "content/public/browser/devtools_http_handler.h"
|
| +#include "content/public/browser/devtools_target_descriptor.h"
|
| +#include "content/public/browser/render_view_host.h"
|
| #include "content/public/browser/web_contents.h"
|
| #include "content/public/common/content_switches.h"
|
| #include "content/public/common/url_constants.h"
|
| @@ -23,6 +26,10 @@
|
| #include "net/socket/unix_domain_socket_posix.h"
|
| #endif
|
|
|
| +using content::DevToolsAgentHost;
|
| +using content::RenderViewHost;
|
| +using content::WebContents;
|
| +
|
| namespace {
|
|
|
| net::StreamListenSocketFactory* CreateSocketFactory() {
|
| @@ -53,6 +60,17 @@ net::StreamListenSocketFactory* CreateSocketFactory() {
|
| return new net::TCPListenSocketFactory("127.0.0.1", port);
|
| #endif
|
| }
|
| +
|
| +RenderViewHost* GetRenderViewHost(const std::string& id) {
|
| + DevToolsAgentHost* agent_host = DevToolsAgentHost::GetForId(id);
|
| + return agent_host ? agent_host->GetRenderViewHost() : NULL;
|
| +}
|
| +
|
| +WebContents* GetWebContents(const std::string& id) {
|
| + RenderViewHost* rvh = GetRenderViewHost(id);
|
| + return rvh ? WebContents::FromRenderViewHost(rvh) : NULL;
|
| +}
|
| +
|
| } // namespace
|
|
|
| namespace content {
|
| @@ -86,27 +104,56 @@ base::FilePath ShellDevToolsDelegate::GetDebugFrontendDir() {
|
| return base::FilePath();
|
| }
|
|
|
| -std::string ShellDevToolsDelegate::GetPageThumbnailData(const GURL& url) {
|
| +bool ShellDevToolsDelegate::SupportsPageThumbnails() {
|
| + return false;
|
| +}
|
| +
|
| +std::string ShellDevToolsDelegate::GetPageThumbnailData(const std::string& id) {
|
| return std::string();
|
| }
|
|
|
| -RenderViewHost* ShellDevToolsDelegate::CreateNewTarget() {
|
| +DevToolsHttpHandlerDelegate::Target*
|
| +ShellDevToolsDelegate::CreateNewTarget() {
|
| Shell* shell = Shell::CreateNewWindow(browser_context_,
|
| GURL(kAboutBlankURL),
|
| NULL,
|
| MSG_ROUTING_NONE,
|
| gfx::Size());
|
| - return shell->web_contents()->GetRenderViewHost();
|
| + return Target::FromWebContents(shell->web_contents());
|
| }
|
|
|
| -DevToolsHttpHandlerDelegate::TargetType
|
| -ShellDevToolsDelegate::GetTargetType(RenderViewHost*) {
|
| - return kTargetTypeTab;
|
| +bool ShellDevToolsDelegate::ActivateTarget(const std::string& id) {
|
| + WebContents* web_contents = GetWebContents(id);
|
| + if (!web_contents)
|
| + return false;
|
| + web_contents->GetDelegate()->ActivateContents(web_contents);
|
| + return true;
|
| }
|
|
|
| -std::string ShellDevToolsDelegate::GetViewDescription(
|
| - content::RenderViewHost*) {
|
| - return std::string();
|
| +bool ShellDevToolsDelegate::CloseTarget(const std::string& id) {
|
| + RenderViewHost* rvh = GetRenderViewHost(id);
|
| + if (!rvh)
|
| + return false;
|
| + rvh->ClosePage();
|
| + return true;
|
| +}
|
| +
|
| +scoped_refptr<content::DevToolsAgentHost>
|
| +ShellDevToolsDelegate::GetAgentHost(const std::string& id) {
|
| + return content::DevToolsAgentHost::GetForId(id);
|
| +}
|
| +
|
| +void ShellDevToolsDelegate::RequestTargets(TargetCallback callback) {
|
| + TargetList targets;
|
| + std::vector<RenderViewHost*> rvh_list =
|
| + content::DevToolsAgentHost::GetValidRenderViewHosts();
|
| + for (std::vector<RenderViewHost*>::iterator it = rvh_list.begin();
|
| + it != rvh_list.end(); ++it) {
|
| + WebContents* web_contents = WebContents::FromRenderViewHost(*it);
|
| + if (web_contents)
|
| + targets.push_back(Target::FromWebContents(web_contents));
|
| + }
|
| + callback.Run(targets);
|
| }
|
|
|
| scoped_ptr<net::StreamListenSocket>
|
|
|