2016-10-17 20:14:44 +02:00
|
|
|
// Copyright 2013 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
2013-11-08 17:06:06 +01:00
|
|
|
|
|
|
|
#ifndef CEF_LIBCEF_BROWSER_DEVTOOLS_FRONTEND_H_
|
|
|
|
#define CEF_LIBCEF_BROWSER_DEVTOOLS_FRONTEND_H_
|
|
|
|
|
2016-10-17 20:14:44 +02:00
|
|
|
#include <memory>
|
|
|
|
|
2013-11-08 17:06:06 +01:00
|
|
|
#include "libcef/browser/browser_host_impl.h"
|
|
|
|
|
|
|
|
#include "base/compiler_specific.h"
|
2016-10-17 20:14:44 +02:00
|
|
|
#include "base/macros.h"
|
2013-11-08 17:06:06 +01:00
|
|
|
#include "base/memory/ref_counted.h"
|
2015-03-04 02:00:13 +01:00
|
|
|
#include "base/memory/weak_ptr.h"
|
2015-04-23 12:03:42 +02:00
|
|
|
#include "base/values.h"
|
2013-11-08 17:06:06 +01:00
|
|
|
#include "content/public/browser/devtools_agent_host.h"
|
2014-09-04 19:53:40 +02:00
|
|
|
#include "content/public/browser/devtools_frontend_host.h"
|
2013-11-08 17:06:06 +01:00
|
|
|
#include "content/public/browser/web_contents_observer.h"
|
2015-03-04 02:00:13 +01:00
|
|
|
#include "net/url_request/url_fetcher_delegate.h"
|
|
|
|
|
|
|
|
namespace base {
|
|
|
|
class Value;
|
|
|
|
}
|
2013-11-08 17:06:06 +01:00
|
|
|
|
|
|
|
namespace content {
|
2017-07-27 01:19:27 +02:00
|
|
|
class NavigationHandle;
|
2013-11-08 17:06:06 +01:00
|
|
|
class RenderViewHost;
|
|
|
|
class WebContents;
|
2017-07-27 01:19:27 +02:00
|
|
|
} // namespace content
|
2013-11-08 17:06:06 +01:00
|
|
|
|
2017-02-28 23:40:28 +01:00
|
|
|
class PrefService;
|
|
|
|
|
2013-11-08 17:06:06 +01:00
|
|
|
class CefDevToolsFrontend : public content::WebContentsObserver,
|
2015-03-04 02:00:13 +01:00
|
|
|
public content::DevToolsAgentHostClient,
|
|
|
|
public net::URLFetcherDelegate {
|
2013-11-08 17:06:06 +01:00
|
|
|
public:
|
|
|
|
static CefDevToolsFrontend* Show(
|
|
|
|
CefRefPtr<CefBrowserHostImpl> inspected_browser,
|
|
|
|
const CefWindowInfo& windowInfo,
|
|
|
|
CefRefPtr<CefClient> client,
|
2014-10-11 02:12:01 +02:00
|
|
|
const CefBrowserSettings& settings,
|
|
|
|
const CefPoint& inspect_element_at);
|
2013-11-08 17:06:06 +01:00
|
|
|
|
2016-10-17 20:14:44 +02:00
|
|
|
void Activate();
|
2013-11-08 17:06:06 +01:00
|
|
|
void Focus();
|
2015-03-04 02:00:13 +01:00
|
|
|
void InspectElementAt(int x, int y);
|
2013-11-08 17:06:06 +01:00
|
|
|
void Close();
|
|
|
|
|
2015-03-04 02:00:13 +01:00
|
|
|
void DisconnectFromTarget();
|
|
|
|
|
|
|
|
void CallClientFunction(const std::string& function_name,
|
|
|
|
const base::Value* arg1,
|
|
|
|
const base::Value* arg2,
|
|
|
|
const base::Value* arg3);
|
|
|
|
|
2016-10-17 20:14:44 +02:00
|
|
|
CefRefPtr<CefBrowserHostImpl> frontend_browser() const {
|
|
|
|
return frontend_browser_;
|
|
|
|
}
|
|
|
|
|
2018-02-15 01:12:09 +01:00
|
|
|
private:
|
2013-11-08 17:06:06 +01:00
|
|
|
CefDevToolsFrontend(CefRefPtr<CefBrowserHostImpl> frontend_browser,
|
2016-06-10 18:43:53 +02:00
|
|
|
content::WebContents* inspected_contents,
|
|
|
|
const CefPoint& inspect_element_at);
|
2014-11-12 20:25:15 +01:00
|
|
|
~CefDevToolsFrontend() override;
|
2013-11-08 17:06:06 +01:00
|
|
|
|
2015-03-04 02:00:13 +01:00
|
|
|
// content::DevToolsAgentHostClient implementation.
|
2017-12-07 22:44:24 +01:00
|
|
|
void AgentHostClosed(content::DevToolsAgentHost* agent_host) override;
|
2015-03-04 02:00:13 +01:00
|
|
|
void DispatchProtocolMessage(content::DevToolsAgentHost* agent_host,
|
|
|
|
const std::string& message) override;
|
2018-02-15 01:12:09 +01:00
|
|
|
void HandleMessageFromDevToolsFrontend(const std::string& message);
|
2015-03-04 02:00:13 +01:00
|
|
|
|
2016-10-17 20:14:44 +02:00
|
|
|
private:
|
2015-03-04 02:00:13 +01:00
|
|
|
// WebContentsObserver overrides
|
2017-07-27 01:19:27 +02:00
|
|
|
void ReadyToCommitNavigation(
|
|
|
|
content::NavigationHandle* navigation_handle) override;
|
2015-03-19 23:06:16 +01:00
|
|
|
void DocumentAvailableInMainFrame() override;
|
2014-11-12 20:25:15 +01:00
|
|
|
void WebContentsDestroyed() override;
|
2013-11-08 17:06:06 +01:00
|
|
|
|
2015-03-04 02:00:13 +01:00
|
|
|
// net::URLFetcherDelegate overrides.
|
|
|
|
void OnURLFetchComplete(const net::URLFetcher* source) override;
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
void SendMessageAck(int request_id, const base::Value* arg1);
|
2013-11-08 17:06:06 +01:00
|
|
|
|
2017-02-28 23:40:28 +01:00
|
|
|
PrefService* GetPrefs() const;
|
|
|
|
|
2013-11-08 17:06:06 +01:00
|
|
|
CefRefPtr<CefBrowserHostImpl> frontend_browser_;
|
2015-03-19 23:06:16 +01:00
|
|
|
content::WebContents* inspected_contents_;
|
2013-11-08 17:06:06 +01:00
|
|
|
scoped_refptr<content::DevToolsAgentHost> agent_host_;
|
2016-10-17 20:14:44 +02:00
|
|
|
CefPoint inspect_element_at_;
|
2016-04-27 22:38:52 +02:00
|
|
|
std::unique_ptr<content::DevToolsFrontendHost> frontend_host_;
|
2015-03-04 02:00:13 +01:00
|
|
|
using PendingRequestsMap = std::map<const net::URLFetcher*, int>;
|
|
|
|
PendingRequestsMap pending_requests_;
|
2017-07-27 01:19:27 +02:00
|
|
|
using ExtensionsAPIs = std::map<std::string, std::string>;
|
|
|
|
ExtensionsAPIs extensions_api_;
|
2015-03-04 02:00:13 +01:00
|
|
|
base::WeakPtrFactory<CefDevToolsFrontend> weak_factory_;
|
2013-11-08 17:06:06 +01:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(CefDevToolsFrontend);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_BROWSER_DEVTOOLS_FRONTEND_H_
|