From 89ebc7edb982ebf5f8b185aa6e3aae6904eed965 Mon Sep 17 00:00:00 2001 From: "mpcomplete@chromium.org" Date: Mon, 24 Aug 2009 22:11:07 +0000 Subject: Exposes a chrome.devtools object to extensions. This allows extensions to call chrome.devtools.connect() to open up a Port by which it can receive devtools messages to implement the proposed perf trace extensions API documented here: http://code.google.com/p/chromium/wiki/ExtensionsPerfTraceAPI Review URL: http://codereview.chromium.org/159882 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24158 0039d316-1c4b-4281-b951-d872f2087c98 --- .../browser/extensions/extension_devtools_bridge.h | 60 ++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 chrome/browser/extensions/extension_devtools_bridge.h (limited to 'chrome/browser/extensions/extension_devtools_bridge.h') diff --git a/chrome/browser/extensions/extension_devtools_bridge.h b/chrome/browser/extensions/extension_devtools_bridge.h new file mode 100644 index 0000000..b4cb98d --- /dev/null +++ b/chrome/browser/extensions/extension_devtools_bridge.h @@ -0,0 +1,60 @@ +// Copyright (c) 2009 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. + +#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_DEVTOOLS_BRIDGE_H_ +#define CHROME_BROWSER_EXTENSIONS_EXTENSION_DEVTOOLS_BRIDGE_H_ + +#include + +#include "base/ref_counted.h" +#include "chrome/browser/debugger/devtools_client_host.h" +#include "chrome/browser/extensions/extension_devtools_manager.h" +#include "chrome/browser/extensions/extension_message_service.h" + +class Profile; +class RenderViewHost; + +// This class is a DevToolsClientHost that fires extension events. +class ExtensionDevToolsBridge : public DevToolsClientHost { + public: + ExtensionDevToolsBridge(int tab_id, Profile* profile); + virtual ~ExtensionDevToolsBridge(); + + bool RegisterAsDevToolsClientHost(); + void UnregisterAsDevToolsClientHost(); + + // DevToolsClientHost, called when the tab inspected by this client is + // closing. + virtual void InspectedTabClosing(); + + // DevToolsClientHost, called to send a message to this host. + virtual void SendMessageToClient(const IPC::Message& msg); + + private: + void OnRpcMessage(const std::string& class_name, + const std::string& message_name, + const std::string& msg); + + // ID of the tab we are monitoring. + int tab_id_; + // Host of the tab we are monitoring, NULL if not monitoring anything. + RenderViewHost* inspected_rvh_; + + scoped_refptr extension_devtools_manager_; + scoped_refptr extension_message_service_; + + // Profile that owns our tab + Profile* profile_; + + // The names of the events fired at extensions depend on the tab id, + // so we store the various event names in each bridge. + const std::string on_page_event_name_; + const std::string on_tab_url_change_event_name_; + const std::string on_tab_close_event_name_; + + DISALLOW_COPY_AND_ASSIGN(ExtensionDevToolsBridge); +}; + +#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_DEVTOOLS_BRIDGE_H_ + -- cgit v1.1