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/devtools_android_bridge.h" | 13 #include "chrome/browser/devtools/device/devtools_android_bridge.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 using Callback = |
26 const base::ListValue&)> Callback; | 26 base::Callback<void(const std::string&, const base::ListValue&)>; |
27 typedef base::Callback<void(DevToolsTargetImpl*)> TargetCallback; | 27 using TargetCallback = base::Callback<void(DevToolsTargetImpl*)>; |
| 28 using JsonCallback = base::Callback<void(int, const std::string&)>; |
28 | 29 |
29 DevToolsTargetsUIHandler(const std::string& source_id, | 30 DevToolsTargetsUIHandler(const std::string& source_id, |
30 const Callback& callback); | 31 const Callback& callback); |
31 virtual ~DevToolsTargetsUIHandler(); | 32 virtual ~DevToolsTargetsUIHandler(); |
32 | 33 |
33 std::string source_id() const { return source_id_; } | 34 std::string source_id() const { return source_id_; } |
34 | 35 |
35 static scoped_ptr<DevToolsTargetsUIHandler> CreateForLocal( | 36 static scoped_ptr<DevToolsTargetsUIHandler> CreateForLocal( |
36 const Callback& callback); | 37 const Callback& callback); |
37 | 38 |
38 static scoped_ptr<DevToolsTargetsUIHandler> CreateForAdb( | 39 static scoped_ptr<DevToolsTargetsUIHandler> CreateForAdb( |
39 const Callback& callback, Profile* profile); | 40 const Callback& callback, Profile* profile); |
40 | 41 |
41 DevToolsTargetImpl* GetTarget(const std::string& target_id); | 42 DevToolsTargetImpl* GetTarget(const std::string& target_id); |
42 | 43 |
43 virtual void Open(const std::string& browser_id, const std::string& url, | 44 virtual void Open(const std::string& browser_id, const std::string& url, |
44 const TargetCallback& callback); | 45 const TargetCallback& callback); |
45 | 46 |
46 virtual scoped_refptr<content::DevToolsAgentHost> GetBrowserAgentHost( | 47 virtual scoped_refptr<content::DevToolsAgentHost> GetBrowserAgentHost( |
47 const std::string& browser_id); | 48 const std::string& browser_id); |
48 | 49 |
| 50 virtual void SendJsonRequest(const std::string& browser_id, |
| 51 const std::string& url, |
| 52 const JsonCallback& callback); |
| 53 |
49 virtual void ForceUpdate(); | 54 virtual void ForceUpdate(); |
50 | 55 |
51 protected: | 56 protected: |
52 base::DictionaryValue* Serialize(const DevToolsTargetImpl& target); | 57 base::DictionaryValue* Serialize(const DevToolsTargetImpl& target); |
53 void SendSerializedTargets(const base::ListValue& list); | 58 void SendSerializedTargets(const base::ListValue& list); |
54 | 59 |
55 typedef std::map<std::string, DevToolsTargetImpl*> TargetMap; | 60 typedef std::map<std::string, DevToolsTargetImpl*> TargetMap; |
56 TargetMap targets_; | 61 TargetMap targets_; |
57 | 62 |
58 private: | 63 private: |
(...skipping 12 matching lines...) Expand all Loading... |
71 ~PortForwardingStatusSerializer() override; | 76 ~PortForwardingStatusSerializer() override; |
72 | 77 |
73 void PortStatusChanged(const ForwardingStatus& status) override; | 78 void PortStatusChanged(const ForwardingStatus& status) override; |
74 | 79 |
75 private: | 80 private: |
76 Callback callback_; | 81 Callback callback_; |
77 Profile* profile_; | 82 Profile* profile_; |
78 }; | 83 }; |
79 | 84 |
80 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_TARGETS_UI_H_ | 85 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_TARGETS_UI_H_ |
OLD | NEW |