Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / content / shell / browser / shell_devtools_frontend.h
blob15a236e532d1fb411f00c0c21c7a55110d359c2b
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.
5 #ifndef CONTENT_SHELL_BROWSER_SHELL_DEVTOOLS_FRONTEND_H_
6 #define CONTENT_SHELL_BROWSER_SHELL_DEVTOOLS_FRONTEND_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/values.h"
14 #include "content/public/browser/devtools_agent_host.h"
15 #include "content/public/browser/devtools_frontend_host.h"
16 #include "content/public/browser/web_contents_observer.h"
17 #include "net/url_request/url_fetcher_delegate.h"
19 namespace base {
20 class Value;
23 namespace content {
25 class RenderViewHost;
26 class Shell;
27 class WebContents;
29 class ShellDevToolsFrontend : public WebContentsObserver,
30 public DevToolsFrontendHost::Delegate,
31 public DevToolsAgentHostClient,
32 public net::URLFetcherDelegate {
33 public:
34 static ShellDevToolsFrontend* Show(WebContents* inspected_contents);
36 void Activate();
37 void Focus();
38 void InspectElementAt(int x, int y);
39 void Close();
41 void DisconnectFromTarget();
43 Shell* frontend_shell() const { return frontend_shell_; }
45 void CallClientFunction(const std::string& function_name,
46 const base::Value* arg1,
47 const base::Value* arg2,
48 const base::Value* arg3);
50 protected:
51 ShellDevToolsFrontend(Shell* frontend_shell, WebContents* inspected_contents);
52 ~ShellDevToolsFrontend() override;
54 // content::DevToolsAgentHostClient implementation.
55 void AgentHostClosed(DevToolsAgentHost* agent_host, bool replaced) override;
56 void DispatchProtocolMessage(DevToolsAgentHost* agent_host,
57 const std::string& message) override;
58 base::DictionaryValue* preferences() { return &preferences_; }
60 private:
61 // WebContentsObserver overrides
62 void RenderViewCreated(RenderViewHost* render_view_host) override;
63 void DocumentAvailableInMainFrame() override;
64 void WebContentsDestroyed() override;
66 // content::DevToolsFrontendHost::Delegate implementation.
67 void HandleMessageFromDevToolsFrontend(const std::string& message) override;
68 void HandleMessageFromDevToolsFrontendToBackend(
69 const std::string& message) override;
71 // net::URLFetcherDelegate overrides.
72 void OnURLFetchComplete(const net::URLFetcher* source) override;
74 void SendMessageAck(int request_id,
75 const base::Value* arg1);
77 Shell* frontend_shell_;
78 WebContents* inspected_contents_;
79 scoped_refptr<DevToolsAgentHost> agent_host_;
80 scoped_ptr<DevToolsFrontendHost> frontend_host_;
81 using PendingRequestsMap = std::map<const net::URLFetcher*, int>;
82 PendingRequestsMap pending_requests_;
83 base::DictionaryValue preferences_;
84 base::WeakPtrFactory<ShellDevToolsFrontend> weak_factory_;
86 DISALLOW_COPY_AND_ASSIGN(ShellDevToolsFrontend);
89 } // namespace content
91 #endif // CONTENT_SHELL_BROWSER_SHELL_DEVTOOLS_FRONTEND_H_