| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/shell/browser/shell_devtools_delegate.h" | 5 #include "content/shell/browser/shell_devtools_delegate.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 #else | 67 #else |
| 68 class TCPServerSocketFactory | 68 class TCPServerSocketFactory |
| 69 : public content::DevToolsHttpHandler::ServerSocketFactory { | 69 : public content::DevToolsHttpHandler::ServerSocketFactory { |
| 70 public: | 70 public: |
| 71 TCPServerSocketFactory(const std::string& address, int port, int backlog) | 71 TCPServerSocketFactory(const std::string& address, int port, int backlog) |
| 72 : content::DevToolsHttpHandler::ServerSocketFactory( | 72 : content::DevToolsHttpHandler::ServerSocketFactory( |
| 73 address, port, backlog) {} | 73 address, port, backlog) {} |
| 74 | 74 |
| 75 private: | 75 private: |
| 76 // content::DevToolsHttpHandler::ServerSocketFactory. | 76 // content::DevToolsHttpHandler::ServerSocketFactory. |
| 77 virtual scoped_ptr<net::ServerSocket> Create() const override { | 77 scoped_ptr<net::ServerSocket> Create() const override { |
| 78 return scoped_ptr<net::ServerSocket>( | 78 return scoped_ptr<net::ServerSocket>( |
| 79 new net::TCPServerSocket(NULL, net::NetLog::Source())); | 79 new net::TCPServerSocket(NULL, net::NetLog::Source())); |
| 80 } | 80 } |
| 81 | 81 |
| 82 DISALLOW_COPY_AND_ASSIGN(TCPServerSocketFactory); | 82 DISALLOW_COPY_AND_ASSIGN(TCPServerSocketFactory); |
| 83 }; | 83 }; |
| 84 #endif | 84 #endif |
| 85 | 85 |
| 86 scoped_ptr<content::DevToolsHttpHandler::ServerSocketFactory> | 86 scoped_ptr<content::DevToolsHttpHandler::ServerSocketFactory> |
| 87 CreateSocketFactory() { | 87 CreateSocketFactory() { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 111 } | 111 } |
| 112 return scoped_ptr<content::DevToolsHttpHandler::ServerSocketFactory>( | 112 return scoped_ptr<content::DevToolsHttpHandler::ServerSocketFactory>( |
| 113 new TCPServerSocketFactory("127.0.0.1", port, 1)); | 113 new TCPServerSocketFactory("127.0.0.1", port, 1)); |
| 114 #endif | 114 #endif |
| 115 } | 115 } |
| 116 | 116 |
| 117 class Target : public content::DevToolsTarget { | 117 class Target : public content::DevToolsTarget { |
| 118 public: | 118 public: |
| 119 explicit Target(scoped_refptr<DevToolsAgentHost> agent_host); | 119 explicit Target(scoped_refptr<DevToolsAgentHost> agent_host); |
| 120 | 120 |
| 121 virtual std::string GetId() const override { return agent_host_->GetId(); } | 121 std::string GetId() const override { return agent_host_->GetId(); } |
| 122 virtual std::string GetParentId() const override { return std::string(); } | 122 std::string GetParentId() const override { return std::string(); } |
| 123 virtual std::string GetType() const override { | 123 std::string GetType() const override { |
| 124 switch (agent_host_->GetType()) { | 124 switch (agent_host_->GetType()) { |
| 125 case DevToolsAgentHost::TYPE_WEB_CONTENTS: | 125 case DevToolsAgentHost::TYPE_WEB_CONTENTS: |
| 126 return kTargetTypePage; | 126 return kTargetTypePage; |
| 127 case DevToolsAgentHost::TYPE_SERVICE_WORKER: | 127 case DevToolsAgentHost::TYPE_SERVICE_WORKER: |
| 128 return kTargetTypeServiceWorker; | 128 return kTargetTypeServiceWorker; |
| 129 default: | 129 default: |
| 130 break; | 130 break; |
| 131 } | 131 } |
| 132 return kTargetTypeOther; | 132 return kTargetTypeOther; |
| 133 } | 133 } |
| 134 virtual std::string GetTitle() const override { | 134 std::string GetTitle() const override { return agent_host_->GetTitle(); } |
| 135 return agent_host_->GetTitle(); | 135 std::string GetDescription() const override { return std::string(); } |
| 136 } | 136 GURL GetURL() const override { return agent_host_->GetURL(); } |
| 137 virtual std::string GetDescription() const override { return std::string(); } | 137 GURL GetFaviconURL() const override { return favicon_url_; } |
| 138 virtual GURL GetURL() const override { return agent_host_->GetURL(); } | 138 base::TimeTicks GetLastActivityTime() const override { |
| 139 virtual GURL GetFaviconURL() const override { return favicon_url_; } | |
| 140 virtual base::TimeTicks GetLastActivityTime() const override { | |
| 141 return last_activity_time_; | 139 return last_activity_time_; |
| 142 } | 140 } |
| 143 virtual bool IsAttached() const override { | 141 bool IsAttached() const override { return agent_host_->IsAttached(); } |
| 144 return agent_host_->IsAttached(); | 142 scoped_refptr<DevToolsAgentHost> GetAgentHost() const override { |
| 145 } | |
| 146 virtual scoped_refptr<DevToolsAgentHost> GetAgentHost() const override { | |
| 147 return agent_host_; | 143 return agent_host_; |
| 148 } | 144 } |
| 149 virtual bool Activate() const override; | 145 bool Activate() const override; |
| 150 virtual bool Close() const override; | 146 bool Close() const override; |
| 151 | 147 |
| 152 private: | 148 private: |
| 153 scoped_refptr<DevToolsAgentHost> agent_host_; | 149 scoped_refptr<DevToolsAgentHost> agent_host_; |
| 154 GURL favicon_url_; | 150 GURL favicon_url_; |
| 155 base::TimeTicks last_activity_time_; | 151 base::TimeTicks last_activity_time_; |
| 156 }; | 152 }; |
| 157 | 153 |
| 158 Target::Target(scoped_refptr<DevToolsAgentHost> agent_host) | 154 Target::Target(scoped_refptr<DevToolsAgentHost> agent_host) |
| 159 : agent_host_(agent_host) { | 155 : agent_host_(agent_host) { |
| 160 if (WebContents* web_contents = agent_host_->GetWebContents()) { | 156 if (WebContents* web_contents = agent_host_->GetWebContents()) { |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 content::DevToolsAgentHost::List agents = | 260 content::DevToolsAgentHost::List agents = |
| 265 content::DevToolsAgentHost::GetOrCreateAll(); | 261 content::DevToolsAgentHost::GetOrCreateAll(); |
| 266 for (content::DevToolsAgentHost::List::iterator it = agents.begin(); | 262 for (content::DevToolsAgentHost::List::iterator it = agents.begin(); |
| 267 it != agents.end(); ++it) { | 263 it != agents.end(); ++it) { |
| 268 targets.push_back(new Target(*it)); | 264 targets.push_back(new Target(*it)); |
| 269 } | 265 } |
| 270 callback.Run(targets); | 266 callback.Run(targets); |
| 271 } | 267 } |
| 272 | 268 |
| 273 } // namespace content | 269 } // namespace content |
| OLD | NEW |