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