summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/inspector/InjectedScriptHost.cpp
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2011-06-08 08:26:01 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-06-08 08:26:01 -0700
commit3742ac093d35d923c81693096ab6671e9b147700 (patch)
treec2add9100f789dad45ef1ec5328bddde02c47a4c /Source/WebCore/inspector/InjectedScriptHost.cpp
parent901401d90459bc22580842455d4588b9a697514d (diff)
parente5926f4a0d6adc9ad4a75824129f117181953560 (diff)
downloadexternal_webkit-3742ac093d35d923c81693096ab6671e9b147700.zip
external_webkit-3742ac093d35d923c81693096ab6671e9b147700.tar.gz
external_webkit-3742ac093d35d923c81693096ab6671e9b147700.tar.bz2
Merge changes I55c6d71a,Ifb3277d4,Ia1b847a2,I7ba9cf3f,Ida2b2a8a,I1280ec90,I72f818d5,I2e3b588b,I9a4e6289,Ia724c78b,Icd8612c8,Ie31b15d7,Ie125edae,I77941a88,I89dae78b,I3516e5ca,I1a4c17b5,I2c4ecc1a,I9c8e6537,Ifac13115,Ie1f80e09,Ia541ed77,I60ce9d78
* changes: Merge WebKit at r82507: Update ThirdPartyProject.prop Merge WebKit at r82507: Cherry-pick change r88166 to add INSPECTOR guards to ScriptProfiler Merge WebKit at r82507: Work around a V8 bug Merge WebKit at r82507: JNIType renamed to JavaType Merge WebKit at r82507: IconDatabaseClient interface expanded Merge WebKit at r82507: Don't use new loss-free code path in HTMLCanvasElement::toDataURL() Merge WebKit at r82507: IcondDatabaseBase::iconForPageURL() renamed Merge WebKit at r82507: IconDatabaseBase::Open() signature changed Merge WebKit at r82507: Node::isContentEditable() renamed Merge WebKit at r82507: Use icon database through IconDatabaseBase Merge WebKit at r82507: toInputElement() is now a member of Node Merge WebKit at r82507: FrameLoaderClient::objectContentType() signature changed Merge WebKit at r82507: StringImpl::computeHash() removed Merge WebKit at r82507: Stub out FontPlatformData::setOrientation() Merge WebKit at r82507: Path::strokeBoundingRect() is now const Merge WebKit at r82507: Add missing UnusedParam.h include in ApplicationCacheGroup.cpp Merge WebKit at r82507: Continue to use Android's version of FontPlatformData.h Merge WebKit at r82507: Update signature of FontCustomPlatformData::fontPlatformData() Merge WebKit at r82507: Fix conflicts due to JNI refactoring Merge WebKit at r82507: Fix conflicts due to new StorageTracker Merge WebKit at r82507: Fix conflicts Merge WebKit at r82507: Fix makefiles Merge WebKit at r82507: Initial merge by git
Diffstat (limited to 'Source/WebCore/inspector/InjectedScriptHost.cpp')
-rw-r--r--Source/WebCore/inspector/InjectedScriptHost.cpp128
1 files changed, 47 insertions, 81 deletions
diff --git a/Source/WebCore/inspector/InjectedScriptHost.cpp b/Source/WebCore/inspector/InjectedScriptHost.cpp
index ad4df45..a0bafdf 100644
--- a/Source/WebCore/inspector/InjectedScriptHost.cpp
+++ b/Source/WebCore/inspector/InjectedScriptHost.cpp
@@ -38,7 +38,6 @@
#include "FrameLoader.h"
#include "HTMLFrameOwnerElement.h"
#include "InjectedScript.h"
-#include "InjectedScriptSource.h"
#include "InspectorAgent.h"
#include "InspectorClient.h"
#include "InspectorConsoleAgent.h"
@@ -69,29 +68,40 @@ using namespace std;
namespace WebCore {
-InjectedScriptHost::InjectedScriptHost(InspectorAgent* inspectorAgent)
- : m_inspectorAgent(inspectorAgent)
- , m_nextInjectedScriptId(1)
- , m_lastWorkerId(1 << 31) // Distinguish ids of fake workers from real ones, to minimize the chances they overlap.
+PassRefPtr<InjectedScriptHost> InjectedScriptHost::create()
{
+ return adoptRef(new InjectedScriptHost());
}
-InjectedScriptHost::~InjectedScriptHost()
+InjectedScriptHost::InjectedScriptHost()
+ : m_inspectorAgent(0)
+ , m_consoleAgent(0)
+#if ENABLE(DATABASE)
+ , m_databaseAgent(0)
+#endif
+#if ENABLE(DOM_STORAGE)
+ , m_domStorageAgent(0)
+#endif
+ , m_frontend(0)
+ , m_lastWorkerId(1 << 31) // Distinguish ids of fake workers from real ones, to minimize the chances they overlap.
{
}
-void InjectedScriptHost::inspectImpl(PassRefPtr<InspectorValue> objectId, PassRefPtr<InspectorValue> hints)
+InjectedScriptHost::~InjectedScriptHost()
{
- if (InspectorFrontend* fe = frontend())
- fe->inspector()->inspect(objectId->asObject(), hints->asObject());
}
-void InjectedScriptHost::clearConsoleMessages()
+void InjectedScriptHost::disconnect()
{
- if (m_inspectorAgent) {
- ErrorString error;
- m_inspectorAgent->consoleAgent()->clearConsoleMessages(&error);
- }
+ m_inspectorAgent = 0;
+ m_consoleAgent = 0;
+#if ENABLE(DATABASE)
+ m_databaseAgent = 0;
+#endif
+#if ENABLE(DOM_STORAGE)
+ m_domStorageAgent = 0;
+#endif
+ m_frontend = 0;
}
void InjectedScriptHost::addInspectedNode(Node* node)
@@ -106,12 +116,26 @@ void InjectedScriptHost::clearInspectedNodes()
m_inspectedNodes.clear();
}
+void InjectedScriptHost::inspectImpl(PassRefPtr<InspectorValue> object, PassRefPtr<InspectorValue> hints)
+{
+ if (m_frontend)
+ m_frontend->inspector()->inspect(object->asObject(), hints->asObject());
+}
+
+void InjectedScriptHost::clearConsoleMessages()
+{
+ if (m_consoleAgent) {
+ ErrorString error;
+ m_consoleAgent->clearConsoleMessages(&error);
+ }
+}
+
void InjectedScriptHost::copyText(const String& text)
{
Pasteboard::generalPasteboard()->writePlainText(text);
}
-Node* InjectedScriptHost::inspectedNode(unsigned long num)
+Node* InjectedScriptHost::inspectedNode(unsigned int num)
{
if (num < m_inspectedNodes.size())
return m_inspectedNodes[num].get();
@@ -119,81 +143,23 @@ Node* InjectedScriptHost::inspectedNode(unsigned long num)
}
#if ENABLE(DATABASE)
-long InjectedScriptHost::databaseIdImpl(Database* database)
+int InjectedScriptHost::databaseIdImpl(Database* database)
{
- if (m_inspectorAgent && m_inspectorAgent->databaseAgent())
- return m_inspectorAgent->databaseAgent()->databaseId(database);
+ if (m_databaseAgent)
+ return m_databaseAgent->databaseId(database);
return 0;
}
#endif
#if ENABLE(DOM_STORAGE)
-long InjectedScriptHost::storageIdImpl(Storage* storage)
+int InjectedScriptHost::storageIdImpl(Storage* storage)
{
- if (m_inspectorAgent && m_inspectorAgent->domStorageAgent())
- return m_inspectorAgent->domStorageAgent()->storageId(storage);
+ if (m_domStorageAgent)
+ return m_domStorageAgent->storageId(storage);
return 0;
}
#endif
-InjectedScript InjectedScriptHost::injectedScriptForId(long id)
-{
- return m_idToInjectedScript.get(id);
-}
-
-InjectedScript InjectedScriptHost::injectedScriptForObjectId(InspectorObject* objectId)
-{
- long injectedScriptId = 0;
- bool success = objectId->getNumber("injectedScriptId", &injectedScriptId);
- if (success)
- return injectedScriptForId(injectedScriptId);
- return InjectedScript();
-}
-
-InjectedScript InjectedScriptHost::injectedScriptForMainFrame()
-{
- return injectedScriptFor(mainWorldScriptState(m_inspectorAgent->inspectedPage()->mainFrame()));
-}
-
-void InjectedScriptHost::discardInjectedScripts()
-{
- IdToInjectedScriptMap::iterator end = m_idToInjectedScript.end();
- for (IdToInjectedScriptMap::iterator it = m_idToInjectedScript.begin(); it != end; ++it)
- discardInjectedScript(it->second.scriptState());
- m_idToInjectedScript.clear();
-}
-
-void InjectedScriptHost::releaseObjectGroup(long injectedScriptId, const String& objectGroup)
-{
- if (injectedScriptId) {
- InjectedScript injectedScript = m_idToInjectedScript.get(injectedScriptId);
- if (!injectedScript.hasNoValue())
- injectedScript.releaseObjectGroup(objectGroup);
- } else {
- // Iterate over all injected scripts if injectedScriptId is not specified.
- for (IdToInjectedScriptMap::iterator it = m_idToInjectedScript.begin(); it != m_idToInjectedScript.end(); ++it)
- it->second.releaseObjectGroup(objectGroup);
- }
-}
-
-InspectorFrontend* InjectedScriptHost::frontend()
-{
- if (!m_inspectorAgent)
- return 0;
- return m_inspectorAgent->frontend();
-}
-
-String InjectedScriptHost::injectedScriptSource()
-{
- return String(reinterpret_cast<char*>(InjectedScriptSource_js), sizeof(InjectedScriptSource_js));
-}
-
-pair<long, ScriptObject> InjectedScriptHost::injectScript(const String& source, ScriptState* scriptState)
-{
- long id = m_nextInjectedScriptId++;
- return std::make_pair(id, createInjectedScript(source, scriptState, id));
-}
-
#if ENABLE(WORKERS)
long InjectedScriptHost::nextWorkerId()
{
@@ -203,13 +169,13 @@ long InjectedScriptHost::nextWorkerId()
void InjectedScriptHost::didCreateWorker(long id, const String& url, bool isSharedWorker)
{
if (m_inspectorAgent)
- m_inspectorAgent->didCreateWorker(id, url, isSharedWorker);
+ m_inspectorAgent->didCreateWorker(static_cast<int>(id), url, isSharedWorker);
}
void InjectedScriptHost::didDestroyWorker(long id)
{
if (m_inspectorAgent)
- m_inspectorAgent->didDestroyWorker(id);
+ m_inspectorAgent->didDestroyWorker(static_cast<int>(id));
}
#endif // ENABLE(WORKERS)