// because the debugger can be attached at any time, and also because other // methods will be called on this debugger for sources that have already been // detached, we make fake entries for unknown source entries as they are // encountered, and we retain old sourceID entries until they are replaced // by new data. fake entries are handled by the Source constructor. void DebuggerShell::sourceParsed(ExecState* execState, SourceProvider* sourceProvider, int errorLineNumber, const WTF::String& errorMessage) { intptr_t sourceID = sourceProvider->asID(); Source source = Source(fromWTFString(sourceProvider->url())); source.parseID = nextParseID_++; source_map_[sourceID] = source; // The URL map is used in setting breakpoints. // Therefore, it's okay if we overwrite one entry with another. // This might happen if we parse both http://a.tld/foo.js and http://b.tld/foo.js , // both of which would clobber the spot occupied by the filename foo.js . // This means if you want to break on one or the other, you'll have to // specify the full URL. The convenient mapping for filename won't be useful. // But for the common case, filename is very very useful. url_map_[source.url] = sourceID; url_map_[source.filename] = sourceID; parse_id_map_[source.parseID] = sourceID; if (errorLineNumber >= 0) { WTF::CString error = errorMessage.ascii(); WTF::CString f = WTF::String::format("Parse failed in %s on line %d: %s", source.url.c_str(), errorLineNumber, error.data()).ascii(); dumpToTTY(f); } else { if (tracing_ || dumping_source_) { WTF::CString f = WTF::String::format("Parsed %s", source.url.c_str()).ascii(); dumpToTTY(f); } if (dumping_source_) { // NOTE: We only dump first 100 bytes of source. The point is to know // more or less what's in it, not to see all 2MB of JavaScript. // It's really most useful for seeing the source of evals full of JSON. WTF::CString code = sourceProvider->source().ascii(); WTF::CString code_clipped(code.data(), code.length() > 100 ? 100 : code.length()); WTF::CString f = WTF::String::format("Source of %s[%d]: %s", source.url.c_str(), source.parseID, code_clipped.data()).ascii(); dumpToTTY(f); } } }
bool InspectorClientQt::sendMessageToFrontend(const String& message) { #if ENABLE(INSPECTOR) if (m_remoteFrontEndChannel) { WTF::CString msg = message.utf8(); m_remoteFrontEndChannel->webSocketSend(msg.data(), msg.length()); return true; } if (!m_frontendWebPage) return false; Page* frontendPage = m_frontendWebPage->page; return doDispatchMessageOnFrontendPage(frontendPage, message); #else return false; #endif }
static inline std::string fromWTFString(const WTF::String& wtf_string) { if (wtf_string.isNull()) return std::string(); WTF::CString cstring = wtf_string.ascii(); return std::string(cstring.data(), cstring.length()); }
void WebPreferences::migrateWebKitPreferencesToCFPreferences() { CFStringRef didMigrateKey = CFSTR(WebKitDidMigrateWebKitPreferencesToCFPreferencesPreferenceKey); if (boolValueForKey(didMigrateKey)) return; bool oldValue = m_autoSaves; m_autoSaves = true; setBoolValue(didMigrateKey, TRUE); m_autoSaves = oldValue; WTF::CString path = oldPreferencesPath().utf8(); RetainPtr<CFURLRef> urlRef(AdoptCF, CFURLCreateFromFileSystemRepresentation(0, reinterpret_cast<const UInt8*>(path.data()), path.length(), false)); if (!urlRef) return; RetainPtr<CFReadStreamRef> stream(AdoptCF, CFReadStreamCreateWithFile(0, urlRef.get())); if (!stream) return; if (!CFReadStreamOpen(stream.get())) return; CFPropertyListFormat format = kCFPropertyListBinaryFormat_v1_0 | kCFPropertyListXMLFormat_v1_0; RetainPtr<CFPropertyListRef> plist(AdoptCF, CFPropertyListCreateFromStream(0, stream.get(), 0, kCFPropertyListMutableContainersAndLeaves, &format, 0)); CFReadStreamClose(stream.get()); if (!plist || CFGetTypeID(plist.get()) != CFDictionaryGetTypeID()) return; copyWebKitPreferencesToCFPreferences(static_cast<CFDictionaryRef>(plist.get())); deleteFile(oldPreferencesPath()); }