| 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" | 8 #include "content/public/browser/devtools_manager_delegate.h" |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/values.h" | 15 #include "base/values.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 scoped_refptr<content::DevToolsAgentHost> CreateNewTarget( |
| 31 const GURL& url) override; |
| 30 std::string GetDiscoveryPageHTML() override; | 32 std::string GetDiscoveryPageHTML() override; |
| 31 std::string GetFrontendResource(const std::string& path) override; | 33 std::string GetFrontendResource(const std::string& path) override; |
| 32 | 34 |
| 33 private: | 35 private: |
| 34 std::unique_ptr<base::DictionaryValue> CreateTarget( | 36 std::unique_ptr<base::DictionaryValue> CreateTarget( |
| 35 int command_id, | 37 int command_id, |
| 36 const base::DictionaryValue* params); | 38 const base::DictionaryValue* params); |
| 37 std::unique_ptr<base::DictionaryValue> CloseTarget( | 39 std::unique_ptr<base::DictionaryValue> CloseTarget( |
| 38 int command_id, | 40 int command_id, |
| 39 const base::DictionaryValue* params); | 41 const base::DictionaryValue* params); |
| 40 std::unique_ptr<base::DictionaryValue> CreateBrowserContext( | 42 std::unique_ptr<base::DictionaryValue> CreateBrowserContext( |
| 41 int command_id, | 43 int command_id, |
| 42 const base::DictionaryValue* params); | 44 const base::DictionaryValue* params); |
| 43 std::unique_ptr<base::DictionaryValue> DisposeBrowserContext( | 45 std::unique_ptr<base::DictionaryValue> DisposeBrowserContext( |
| 44 int command_id, | 46 int command_id, |
| 45 const base::DictionaryValue* params); | 47 const base::DictionaryValue* params); |
| 46 | 48 |
| 47 base::WeakPtr<HeadlessBrowserImpl> browser_; | 49 base::WeakPtr<HeadlessBrowserImpl> browser_; |
| 48 | 50 |
| 49 using CommandMemberFnPtr = std::unique_ptr<base::DictionaryValue> ( | 51 using CommandMemberFnPtr = std::unique_ptr<base::DictionaryValue> ( |
| 50 HeadlessDevToolsManagerDelegate::*)(int command_id, | 52 HeadlessDevToolsManagerDelegate::*)(int command_id, |
| 51 const base::DictionaryValue* params); | 53 const base::DictionaryValue* params); |
| 52 | 54 |
| 53 std::map<std::string, CommandMemberFnPtr> command_map_; | 55 std::map<std::string, CommandMemberFnPtr> command_map_; |
| 54 }; | 56 }; |
| 55 | 57 |
| 56 } // namespace headless | 58 } // namespace headless |
| 57 | 59 |
| 58 #endif // HEADLESS_LIB_BROWSER_HEADLESS_DEVTOOLS_MANAGER_DELEGATE_H_ | 60 #endif // HEADLESS_LIB_BROWSER_HEADLESS_DEVTOOLS_MANAGER_DELEGATE_H_ |
| OLD | NEW |