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 HEADLESS_LIB_BROWSER_HEADLESS_DEVTOOLS_MANAGER_DELEGATE_H_ | 5 #ifndef HEADLESS_LIB_BROWSER_HEADLESS_DEVTOOLS_MANAGER_DELEGATE_H_ |
6 #define HEADLESS_LIB_BROWSER_HEADLESS_DEVTOOLS_MANAGER_DELEGATE_H_ | 6 #define HEADLESS_LIB_BROWSER_HEADLESS_DEVTOOLS_MANAGER_DELEGATE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "content/public/browser/devtools_manager_delegate.h" | 15 #include "content/public/browser/devtools_manager_delegate.h" |
16 | 16 |
17 namespace headless { | 17 namespace headless { |
18 class HeadlessBrowserImpl; | 18 class HeadlessBrowserImpl; |
19 | 19 |
20 class HeadlessDevToolsManagerDelegate | 20 class HeadlessDevToolsManagerDelegate |
21 : public content::DevToolsManagerDelegate { | 21 : public content::DevToolsManagerDelegate { |
22 public: | 22 public: |
23 explicit HeadlessDevToolsManagerDelegate( | 23 explicit HeadlessDevToolsManagerDelegate( |
24 base::WeakPtr<HeadlessBrowserImpl> browser); | 24 base::WeakPtr<HeadlessBrowserImpl> browser); |
25 ~HeadlessDevToolsManagerDelegate() override; | 25 ~HeadlessDevToolsManagerDelegate() override; |
26 | 26 |
27 // DevToolsManagerDelegate implementation: | 27 // DevToolsManagerDelegate implementation: |
28 base::DictionaryValue* HandleCommand(content::DevToolsAgentHost* agent_host, | 28 base::DictionaryValue* HandleCommand(content::DevToolsAgentHost* agent_host, |
29 base::DictionaryValue* command) override; | 29 base::DictionaryValue* command) override; |
| 30 bool HandleAsyncCommand(content::DevToolsAgentHost* agent_host, |
| 31 base::DictionaryValue* command, |
| 32 const CommandCallback& callback) override; |
30 scoped_refptr<content::DevToolsAgentHost> CreateNewTarget( | 33 scoped_refptr<content::DevToolsAgentHost> CreateNewTarget( |
31 const GURL& url) override; | 34 const GURL& url) override; |
32 std::string GetDiscoveryPageHTML() override; | 35 std::string GetDiscoveryPageHTML() override; |
33 std::string GetFrontendResource(const std::string& path) override; | 36 std::string GetFrontendResource(const std::string& path) override; |
34 | 37 |
35 private: | 38 private: |
36 std::unique_ptr<base::DictionaryValue> CreateTarget( | 39 std::unique_ptr<base::DictionaryValue> CreateTarget( |
37 int command_id, | 40 int command_id, |
38 const base::DictionaryValue* params); | 41 const base::DictionaryValue* params); |
39 std::unique_ptr<base::DictionaryValue> CloseTarget( | 42 std::unique_ptr<base::DictionaryValue> CloseTarget( |
40 int command_id, | 43 int command_id, |
41 const base::DictionaryValue* params); | 44 const base::DictionaryValue* params); |
42 std::unique_ptr<base::DictionaryValue> CreateBrowserContext( | 45 std::unique_ptr<base::DictionaryValue> CreateBrowserContext( |
43 int command_id, | 46 int command_id, |
44 const base::DictionaryValue* params); | 47 const base::DictionaryValue* params); |
45 std::unique_ptr<base::DictionaryValue> DisposeBrowserContext( | 48 std::unique_ptr<base::DictionaryValue> DisposeBrowserContext( |
46 int command_id, | 49 int command_id, |
47 const base::DictionaryValue* params); | 50 const base::DictionaryValue* params); |
| 51 void PrintToPDF(content::DevToolsAgentHost* agent_host, |
| 52 int command_id, |
| 53 const base::DictionaryValue* params, |
| 54 const CommandCallback& callback); |
48 | 55 |
49 base::WeakPtr<HeadlessBrowserImpl> browser_; | 56 base::WeakPtr<HeadlessBrowserImpl> browser_; |
50 | 57 |
51 using CommandMemberCallback = | 58 using CommandMemberCallback = |
52 base::Callback<std::unique_ptr<base::DictionaryValue>( | 59 base::Callback<std::unique_ptr<base::DictionaryValue>( |
53 int command_id, | 60 int command_id, |
54 const base::DictionaryValue* params)>; | 61 const base::DictionaryValue* params)>; |
| 62 using AsyncCommandMemberCallback = |
| 63 base::Callback<void(content::DevToolsAgentHost* agent_host, |
| 64 int command_id, |
| 65 const base::DictionaryValue* params, |
| 66 const CommandCallback& callback)>; |
55 std::map<std::string, CommandMemberCallback> command_map_; | 67 std::map<std::string, CommandMemberCallback> command_map_; |
| 68 std::map<std::string, AsyncCommandMemberCallback> async_command_map_; |
56 }; | 69 }; |
57 | 70 |
58 } // namespace headless | 71 } // namespace headless |
59 | 72 |
60 #endif // HEADLESS_LIB_BROWSER_HEADLESS_DEVTOOLS_MANAGER_DELEGATE_H_ | 73 #endif // HEADLESS_LIB_BROWSER_HEADLESS_DEVTOOLS_MANAGER_DELEGATE_H_ |
OLD | NEW |