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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_DEVTOOLS_DEVTOOLS_TARGETS_UI_H_ 6 #define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_TARGETS_UI_H_ 7 8 #include <map> 9 #include <string> 10 11 #include "base/callback.h" 12 #include "base/memory/scoped_ptr.h" 13 14 namespace base { 15 class ListValue; 16 class DictionaryValue; 17 } 18 19 class DevToolsTargetImpl; 20 class Profile; 21 22 class DevToolsTargetsUIHandler { 23 public: 24 typedef base::Callback<void(const std::string&, 25 scoped_ptr<base::ListValue>)> Callback; 26 27 DevToolsTargetsUIHandler(const std::string& source_id, Callback callback); 28 virtual ~DevToolsTargetsUIHandler(); 29 30 std::string source_id() const { return source_id_; } 31 32 static scoped_ptr<DevToolsTargetsUIHandler> CreateForRenderers( 33 Callback callback); 34 35 static scoped_ptr<DevToolsTargetsUIHandler> CreateForWorkers( 36 Callback callback); 37 38 void Inspect(const std::string& target_id, Profile* profile); 39 void Activate(const std::string& target_id); 40 void Close(const std::string& target_id); 41 void Reload(const std::string& target_id); 42 43 protected: 44 base::DictionaryValue* Serialize(const DevToolsTargetImpl& target); 45 void SendSerializedTargets(scoped_ptr<base::ListValue> list); 46 47 typedef std::map<std::string, DevToolsTargetImpl*> TargetMap; 48 TargetMap targets_; 49 50 private: 51 const std::string source_id_; 52 Callback callback_; 53 54 DISALLOW_COPY_AND_ASSIGN(DevToolsTargetsUIHandler); 55 }; 56 57 class DevToolsRemoteTargetsUIHandler: public DevToolsTargetsUIHandler { 58 public: 59 DevToolsRemoteTargetsUIHandler(const std::string& source_id, 60 Callback callback); 61 62 static scoped_ptr<DevToolsRemoteTargetsUIHandler> CreateForAdb( 63 Callback callback, Profile* profile); 64 65 virtual void Open(const std::string& browser_id, const std::string& url) = 0; 66 67 private: 68 DISALLOW_COPY_AND_ASSIGN(DevToolsRemoteTargetsUIHandler); 69 }; 70 71 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_TARGETS_UI_H_ 72