Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / xwalk / runtime / browser / devtools / xwalk_devtools_delegate.h
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.
4
5 #ifndef XWALK_RUNTIME_BROWSER_DEVTOOLS_XWALK_DEVTOOLS_DELEGATE_H_
6 #define XWALK_RUNTIME_BROWSER_DEVTOOLS_XWALK_DEVTOOLS_DELEGATE_H_
7
8 #include <map>
9 #include <string>
10 #include <vector>
11
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"
18 #include "url/gurl.h"
19 #include "xwalk/runtime/browser/runtime.h"
20
21 namespace content {
22 class DevToolsHttpHandler;
23 }
24
25 namespace xwalk {
26
27 class XWalkBrowserContext;
28
29 class XWalkDevToolsHttpHandlerDelegate :
30     public content::DevToolsHttpHandlerDelegate {
31  public:
32   XWalkDevToolsHttpHandlerDelegate();
33   virtual ~XWalkDevToolsHttpHandlerDelegate();
34
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;
42
43  private:
44   DISALLOW_COPY_AND_ASSIGN(XWalkDevToolsHttpHandlerDelegate);
45 };
46
47 class XWalkDevToolsDelegate : public content::DevToolsManagerDelegate,
48                               public Runtime::Observer {
49  public:
50   explicit XWalkDevToolsDelegate(XWalkBrowserContext* browser_context);
51   virtual ~XWalkDevToolsDelegate();
52
53   void Inspect(
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);
68
69  private:
70   // Runtime::Observer
71   virtual void OnNewRuntimeAdded(Runtime* runtime) override;
72   virtual void OnRuntimeClosed(Runtime* runtime) override;
73
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);
79 };
80
81 }  // namespace xwalk
82
83 #endif  // XWALK_RUNTIME_BROWSER_DEVTOOLS_XWALK_DEVTOOLS_DELEGATE_H_