1 // Copyright (c) 2012 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.
5 #ifndef XWALK_RUNTIME_BROWSER_DEVTOOLS_XWALK_DEVTOOLS_DELEGATE_H_
6 #define XWALK_RUNTIME_BROWSER_DEVTOOLS_XWALK_DEVTOOLS_DELEGATE_H_
12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h"
14 #include "base/memory/ref_counted_memory.h"
15 #include "base/memory/weak_ptr.h"
16 #include "content/public/browser/devtools_http_handler_delegate.h"
17 #include "content/public/browser/devtools_manager_delegate.h"
19 #include "xwalk/runtime/browser/runtime.h"
22 class DevToolsHttpHandler;
27 class XWalkBrowserContext;
29 class XWalkDevToolsHttpHandlerDelegate :
30 public content::DevToolsHttpHandlerDelegate {
32 XWalkDevToolsHttpHandlerDelegate();
33 virtual ~XWalkDevToolsHttpHandlerDelegate();
35 // DevToolsHttpHandlerDelegate implementation.
36 std::string GetDiscoveryPageHTML() override;
37 bool BundlesFrontendResources() override;
38 base::FilePath GetDebugFrontendDir() override;
39 scoped_ptr<net::StreamListenSocket> CreateSocketForTethering(
40 net::StreamListenSocket::Delegate* delegate,
41 std::string* name) override;
44 DISALLOW_COPY_AND_ASSIGN(XWalkDevToolsHttpHandlerDelegate);
47 class XWalkDevToolsDelegate : public content::DevToolsManagerDelegate,
48 public Runtime::Observer {
50 explicit XWalkDevToolsDelegate(XWalkBrowserContext* browser_context);
51 virtual ~XWalkDevToolsDelegate();
54 content::BrowserContext* browser_context,
55 content::DevToolsAgentHost* agent_host) override {}
56 void DevToolsAgentStateChanged(
57 content::DevToolsAgentHost* agent_host,
58 bool attached) override {}
59 base::DictionaryValue* HandleCommand(
60 content::DevToolsAgentHost* agent_host,
61 base::DictionaryValue* command_dict) override;
62 scoped_ptr<content::DevToolsTarget> CreateNewTarget(
63 const GURL& url) override;
64 void EnumerateTargets(TargetCallback callback) override;
65 std::string GetPageThumbnailData(const GURL& url) override;
66 void ProcessAndSaveThumbnail(const GURL& url,
67 scoped_refptr<base::RefCountedBytes> png);
71 virtual void OnNewRuntimeAdded(Runtime* runtime) override;
72 virtual void OnRuntimeClosed(Runtime* runtime) override;
74 using ThumbnailMap = std::map<GURL, std::string>;
75 ThumbnailMap thumbnail_map_;
76 XWalkBrowserContext* browser_context_;
77 base::WeakPtrFactory<XWalkDevToolsDelegate> weak_factory_;
78 DISALLOW_COPY_AND_ASSIGN(XWalkDevToolsDelegate);
83 #endif // XWALK_RUNTIME_BROWSER_DEVTOOLS_XWALK_DEVTOOLS_DELEGATE_H_