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