OLD | NEW |
| (Empty) |
1 // Copyright 2015 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 COMPONENTS_DEVTOOLS_DISCOVERY_DEVTOOLS_DISCOVERY_MANAGER_H_ | |
6 #define COMPONENTS_DEVTOOLS_DISCOVERY_DEVTOOLS_DISCOVERY_MANAGER_H_ | |
7 | |
8 #include <memory> | |
9 #include <string> | |
10 | |
11 #include "base/macros.h" | |
12 #include "base/memory/singleton.h" | |
13 #include "base/values.h" | |
14 #include "content/public/browser/devtools_agent_host.h" | |
15 | |
16 namespace devtools_discovery { | |
17 | |
18 class DevToolsDiscoveryManager { | |
19 public: | |
20 class Provider { | |
21 public: | |
22 virtual ~Provider() {} | |
23 | |
24 virtual content::DevToolsAgentHost::List GetDescriptors() = 0; | |
25 }; | |
26 | |
27 using CreateCallback = base::Callback< | |
28 scoped_refptr<content::DevToolsAgentHost>(const GURL& url)>; | |
29 | |
30 // Returns single instance of this class. The instance is destroyed on the | |
31 // browser main loop exit so this method MUST NOT be called after that point. | |
32 static DevToolsDiscoveryManager* GetInstance(); | |
33 | |
34 void AddProvider(std::unique_ptr<Provider> provider); | |
35 void SetCreateCallback(const CreateCallback& callback); | |
36 // Caller takes ownership of created descriptors. | |
37 content::DevToolsAgentHost::List GetDescriptors(); | |
38 scoped_refptr<content::DevToolsAgentHost> CreateNew(const GURL& url); | |
39 | |
40 // Handles Browser.createTarget only. | |
41 std::unique_ptr<base::DictionaryValue> HandleCreateTargetCommand( | |
42 base::DictionaryValue* command_dict); | |
43 | |
44 private: | |
45 friend struct base::DefaultSingletonTraits<DevToolsDiscoveryManager>; | |
46 | |
47 DevToolsDiscoveryManager(); | |
48 ~DevToolsDiscoveryManager(); | |
49 content::DevToolsAgentHost::List GetDescriptorsFromProviders(); | |
50 | |
51 std::vector<Provider*> providers_; | |
52 CreateCallback create_callback_; | |
53 | |
54 DISALLOW_COPY_AND_ASSIGN(DevToolsDiscoveryManager); | |
55 }; | |
56 | |
57 } // namespace devtools_discovery | |
58 | |
59 #endif // COMPONENTS_DEVTOOLS_DISCOVERY_DEVTOOLS_DISCOVERY_MANAGER_H_ | |
OLD | NEW |