OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CHROME_BROWSER_DEVTOOLS_DEVTOOLS_TARGETS_UI_H_ | 5 #ifndef CHROME_BROWSER_DEVTOOLS_DEVTOOLS_TARGETS_UI_H_ |
6 #define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_TARGETS_UI_H_ | 6 #define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_TARGETS_UI_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "chrome/browser/devtools/device/port_forwarding_controller.h" | 13 #include "chrome/browser/devtools/device/port_forwarding_controller.h" |
14 | 14 |
15 namespace base { | 15 namespace base { |
16 class ListValue; | 16 class ListValue; |
17 class DictionaryValue; | 17 class DictionaryValue; |
18 } | 18 } |
19 | 19 |
20 class DevToolsTargetImpl; | 20 class DevToolsTargetImpl; |
21 class Profile; | 21 class Profile; |
22 | 22 |
23 class DevToolsTargetsUIHandler { | 23 class DevToolsTargetsUIHandler { |
24 public: | 24 public: |
25 typedef base::Callback<void(const std::string&, | 25 typedef base::Callback<void(const std::string&, |
26 scoped_ptr<base::ListValue>)> Callback; | 26 const base::ListValue&)> Callback; |
27 typedef base::Callback<void(DevToolsTargetImpl*)> TargetCallback; | 27 typedef base::Callback<void(DevToolsTargetImpl*)> TargetCallback; |
28 | 28 |
29 DevToolsTargetsUIHandler(const std::string& source_id, Callback callback); | 29 DevToolsTargetsUIHandler(const std::string& source_id, |
| 30 const Callback& callback); |
30 virtual ~DevToolsTargetsUIHandler(); | 31 virtual ~DevToolsTargetsUIHandler(); |
31 | 32 |
32 std::string source_id() const { return source_id_; } | 33 std::string source_id() const { return source_id_; } |
33 | 34 |
34 static scoped_ptr<DevToolsTargetsUIHandler> CreateForRenderers( | 35 static scoped_ptr<DevToolsTargetsUIHandler> CreateForRenderers( |
35 Callback callback); | 36 const Callback& callback); |
36 | 37 |
37 static scoped_ptr<DevToolsTargetsUIHandler> CreateForWorkers( | 38 static scoped_ptr<DevToolsTargetsUIHandler> CreateForWorkers( |
38 Callback callback); | 39 const Callback& callback); |
39 | 40 |
40 static scoped_ptr<DevToolsTargetsUIHandler> CreateForAdb( | 41 static scoped_ptr<DevToolsTargetsUIHandler> CreateForAdb( |
41 Callback callback, Profile* profile); | 42 const Callback& callback, Profile* profile); |
42 | 43 |
43 DevToolsTargetImpl* GetTarget(const std::string& target_id); | 44 DevToolsTargetImpl* GetTarget(const std::string& target_id); |
44 | 45 |
45 virtual void Open(const std::string& browser_id, const std::string& url, | 46 virtual void Open(const std::string& browser_id, const std::string& url, |
46 const TargetCallback& callback); | 47 const TargetCallback& callback); |
47 | 48 |
48 virtual scoped_refptr<content::DevToolsAgentHost> GetBrowserAgentHost( | 49 virtual scoped_refptr<content::DevToolsAgentHost> GetBrowserAgentHost( |
49 const std::string& browser_id); | 50 const std::string& browser_id); |
50 | 51 |
51 protected: | 52 protected: |
52 base::DictionaryValue* Serialize(const DevToolsTargetImpl& target); | 53 base::DictionaryValue* Serialize(const DevToolsTargetImpl& target); |
53 void SendSerializedTargets(scoped_ptr<base::ListValue> list); | 54 void SendSerializedTargets(const base::ListValue& list); |
54 | 55 |
55 typedef std::map<std::string, DevToolsTargetImpl*> TargetMap; | 56 typedef std::map<std::string, DevToolsTargetImpl*> TargetMap; |
56 TargetMap targets_; | 57 TargetMap targets_; |
57 | 58 |
58 private: | 59 private: |
59 const std::string source_id_; | 60 const std::string source_id_; |
60 Callback callback_; | 61 Callback callback_; |
61 | 62 |
62 DISALLOW_COPY_AND_ASSIGN(DevToolsTargetsUIHandler); | 63 DISALLOW_COPY_AND_ASSIGN(DevToolsTargetsUIHandler); |
63 }; | 64 }; |
64 | 65 |
65 class PortForwardingStatusSerializer | 66 class PortForwardingStatusSerializer |
66 : private PortForwardingController::Listener { | 67 : private PortForwardingController::Listener { |
67 public: | 68 public: |
68 typedef base::Callback<void(const base::Value&)> Callback; | 69 typedef base::Callback<void(const base::Value&)> Callback; |
69 | 70 |
70 PortForwardingStatusSerializer(const Callback& callback, Profile* profile); | 71 PortForwardingStatusSerializer(const Callback& callback, Profile* profile); |
71 virtual ~PortForwardingStatusSerializer(); | 72 virtual ~PortForwardingStatusSerializer(); |
72 | 73 |
73 virtual void PortStatusChanged(const DevicesStatus&) OVERRIDE; | 74 virtual void PortStatusChanged(const DevicesStatus&) OVERRIDE; |
74 | 75 |
75 private: | 76 private: |
76 Callback callback_; | 77 Callback callback_; |
77 Profile* profile_; | 78 Profile* profile_; |
78 }; | 79 }; |
79 | 80 |
80 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_TARGETS_UI_H_ | 81 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_TARGETS_UI_H_ |
OLD | NEW |