| 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 class HeadlessBrowserContext; | |
| 20 | 19 |
| 21 class HeadlessDevToolsManagerDelegate | 20 class HeadlessDevToolsManagerDelegate |
| 22 : public content::DevToolsManagerDelegate { | 21 : public content::DevToolsManagerDelegate { |
| 23 public: | 22 public: |
| 24 explicit HeadlessDevToolsManagerDelegate( | 23 explicit HeadlessDevToolsManagerDelegate( |
| 25 base::WeakPtr<HeadlessBrowserImpl> browser); | 24 base::WeakPtr<HeadlessBrowserImpl> browser); |
| 26 ~HeadlessDevToolsManagerDelegate() override; | 25 ~HeadlessDevToolsManagerDelegate() override; |
| 27 | 26 |
| 28 // DevToolsManagerDelegate implementation: | 27 // DevToolsManagerDelegate implementation: |
| 29 base::DictionaryValue* HandleCommand(content::DevToolsAgentHost* agent_host, | 28 base::DictionaryValue* HandleCommand(content::DevToolsAgentHost* agent_host, |
| 30 base::DictionaryValue* command) override; | 29 base::DictionaryValue* command) override; |
| 31 std::string GetDiscoveryPageHTML() override; | 30 std::string GetDiscoveryPageHTML() override; |
| 32 std::string GetFrontendResource(const std::string& path) override; | 31 std::string GetFrontendResource(const std::string& path) override; |
| 33 | 32 |
| 34 private: | 33 private: |
| 35 std::unique_ptr<base::Value> CreateTarget( | 34 std::unique_ptr<base::DictionaryValue> CreateTarget( |
| 35 int command_id, |
| 36 const base::DictionaryValue* params); | 36 const base::DictionaryValue* params); |
| 37 std::unique_ptr<base::Value> CloseTarget(const base::DictionaryValue* params); | 37 std::unique_ptr<base::DictionaryValue> CloseTarget( |
| 38 std::unique_ptr<base::Value> CreateBrowserContext( | 38 int command_id, |
| 39 const base::DictionaryValue* params); | 39 const base::DictionaryValue* params); |
| 40 std::unique_ptr<base::Value> DisposeBrowserContext( | 40 std::unique_ptr<base::DictionaryValue> CreateBrowserContext( |
| 41 int command_id, |
| 42 const base::DictionaryValue* params); |
| 43 std::unique_ptr<base::DictionaryValue> DisposeBrowserContext( |
| 44 int command_id, |
| 41 const base::DictionaryValue* params); | 45 const base::DictionaryValue* params); |
| 42 | 46 |
| 43 base::WeakPtr<HeadlessBrowserImpl> browser_; | 47 base::WeakPtr<HeadlessBrowserImpl> browser_; |
| 44 | 48 |
| 45 using CommandMemberFnPtr = std::unique_ptr<base::Value> ( | 49 using CommandMemberFnPtr = std::unique_ptr<base::DictionaryValue> ( |
| 46 HeadlessDevToolsManagerDelegate::*)(const base::DictionaryValue* params); | 50 HeadlessDevToolsManagerDelegate::*)(int command_id, |
| 51 const base::DictionaryValue* params); |
| 47 | 52 |
| 48 std::map<std::string, CommandMemberFnPtr> command_map_; | 53 std::map<std::string, CommandMemberFnPtr> command_map_; |
| 49 | |
| 50 HeadlessBrowserContext* default_browser_context_; | |
| 51 }; | 54 }; |
| 52 | 55 |
| 53 } // namespace headless | 56 } // namespace headless |
| 54 | 57 |
| 55 #endif // HEADLESS_LIB_BROWSER_HEADLESS_DEVTOOLS_MANAGER_DELEGATE_H_ | 58 #endif // HEADLESS_LIB_BROWSER_HEADLESS_DEVTOOLS_MANAGER_DELEGATE_H_ |
| OLD | NEW |