| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef CONTENT_BROWSER_DEVTOOLS_PROTOCOL_BROWSER_HANDLER_H_ | 5 #ifndef CONTENT_BROWSER_DEVTOOLS_PROTOCOL_BROWSER_HANDLER_H_ |
| 6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_BROWSER_HANDLER_H_ | 6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_BROWSER_HANDLER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/memory/weak_ptr.h" |
| 10 #include "content/browser/devtools/protocol/devtools_protocol_dispatcher.h" | 11 #include "content/browser/devtools/protocol/devtools_protocol_dispatcher.h" |
| 11 #include "content/public/browser/devtools_agent_host.h" | 12 #include "content/public/browser/devtools_agent_host.h" |
| 12 | 13 |
| 13 namespace net { | 14 namespace net { |
| 14 class ServerSocket; | 15 class ServerSocket; |
| 15 } | 16 } |
| 16 | 17 |
| 17 // Windows headers will redefine SendMessage. | 18 // Windows headers will redefine SendMessage. |
| 18 #ifdef SendMessage | 19 #ifdef SendMessage |
| 19 #undef SendMessage | 20 #undef SendMessage |
| 20 #endif | 21 #endif |
| 21 | 22 |
| 22 namespace content { | 23 namespace content { |
| 23 namespace devtools { | 24 namespace devtools { |
| 24 namespace browser { | 25 namespace browser { |
| 25 | 26 |
| 26 class BrowserHandler : public DevToolsAgentHostClient { | 27 class BrowserHandler : public DevToolsAgentHostClient { |
| 27 public: | 28 public: |
| 28 using Response = DevToolsProtocolClient::Response; | 29 using Response = DevToolsProtocolClient::Response; |
| 29 | 30 |
| 30 BrowserHandler(); | 31 BrowserHandler(); |
| 31 ~BrowserHandler() override; | 32 ~BrowserHandler() override; |
| 32 | 33 |
| 33 void SetClient(std::unique_ptr<Client> client); | 34 void SetClient(std::unique_ptr<Client> client); |
| 34 | 35 |
| 35 using TargetInfos = std::vector<scoped_refptr<devtools::browser::TargetInfo>>; | |
| 36 | |
| 37 Response CreateBrowserContext(std::string* out_context_id); | 36 Response CreateBrowserContext(std::string* out_context_id); |
| 38 Response DisposeBrowserContext(const std::string& context_id, | 37 Response DisposeBrowserContext(const std::string& context_id, |
| 39 bool* out_success); | 38 bool* out_success); |
| 40 Response CreateTarget(const std::string& url, | 39 Response CreateTarget(const std::string& url, |
| 41 const int* width, | 40 const int* width, |
| 42 const int* height, | 41 const int* height, |
| 43 const std::string* context_id, | 42 const std::string* context_id, |
| 44 std::string* out_targetId); | 43 std::string* out_target_id); |
| 45 Response CloseTarget(const std::string& targetId, bool* out_success); | 44 Response CloseTarget(const std::string& target_id, bool* out_success); |
| 46 Response GetTargets(TargetInfos* infos); | 45 Response GetTargets(DevToolsCommandId command_id); |
| 47 Response Attach(const std::string& targetId); | 46 Response Attach(DevToolsCommandId command_id, |
| 48 Response Detach(const std::string& targetId); | 47 const std::string& target_id); |
| 49 Response SendMessage(const std::string& targetId, const std::string& message); | 48 Response Detach(const std::string& target_id, bool* out_success); |
| 49 Response SendMessage(const std::string& target_id, |
| 50 const std::string& message); |
| 50 | 51 |
| 51 private: | 52 private: |
| 52 void DispatchProtocolMessage(DevToolsAgentHost* agent_host, | 53 void DispatchProtocolMessage(DevToolsAgentHost* agent_host, |
| 53 const std::string& message) override; | 54 const std::string& message) override; |
| 54 | 55 |
| 55 void AgentHostClosed(DevToolsAgentHost* agent_host, | 56 void AgentHostClosed(DevToolsAgentHost* agent_host, |
| 56 bool replaced_with_another_client) override; | 57 bool replaced_with_another_client) override; |
| 57 | 58 |
| 59 void RespondToGetTargets(DevToolsCommandId command_id, |
| 60 DevToolsAgentHost::List list); |
| 61 void RespondToAttach(DevToolsCommandId command_id, |
| 62 const std::string& target_id, |
| 63 DevToolsAgentHost::List agents); |
| 64 |
| 58 std::unique_ptr<Client> client_; | 65 std::unique_ptr<Client> client_; |
| 66 DevToolsAgentHost::List attached_hosts_; |
| 67 base::WeakPtrFactory<BrowserHandler> weak_factory_; |
| 59 DISALLOW_COPY_AND_ASSIGN(BrowserHandler); | 68 DISALLOW_COPY_AND_ASSIGN(BrowserHandler); |
| 60 }; | 69 }; |
| 61 | 70 |
| 62 } // namespace browser | 71 } // namespace browser |
| 63 } // namespace devtools | 72 } // namespace devtools |
| 64 } // namespace content | 73 } // namespace content |
| 65 | 74 |
| 66 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_BROWSER_HANDLER_H_ | 75 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_BROWSER_HANDLER_H_ |
| OLD | NEW |