static void Open(JNIEnv* env, jobject obj, jstring path) { WebCore::IconDatabaseBase& iconDb = WebCore::iconDatabase(); if (iconDb.isOpen()) return; iconDb.setEnabled(true); iconDb.setClient(gIconDatabaseClient); ALOG_ASSERT(path, "No path given to nativeOpen"); WTF::String pathStr = jstringToWtfString(env, path); WTF::CString fullPath = WebCore::pathByAppendingComponent(pathStr, WebCore::IconDatabase::defaultDatabaseFilename()).utf8(); mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP; bool didSetPermissions = false; if (access(fullPath.data(), F_OK) == 0) { if (chmod(fullPath.data(), mode) == 0) didSetPermissions = true; } else { int fd = open(fullPath.data(), O_CREAT, mode); if (fd >= 0) { close(fd); didSetPermissions = true; } } if (didSetPermissions) { ALOGV("Opening WebIconDatabase file '%s'", pathStr.latin1().data()); bool res = iconDb.open(pathStr, WebCore::IconDatabase::defaultDatabaseFilename()); if (!res) ALOGE("Open failed!"); } else ALOGE("Failed to set permissions on '%s'", fullPath.data()); }
G_CONST_RETURN gchar* webkit_web_history_item_get_target(WebKitWebHistoryItem* webHistoryItem) { g_return_val_if_fail(WEBKIT_IS_WEB_HISTORY_ITEM(webHistoryItem), NULL); WebCore::HistoryItem* item = core(webHistoryItem); g_return_val_if_fail(item, NULL); WTF::CString t = item->target().utf8(); return g_strdup(t.data()); }
// 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 }
bool DebuggerShell::backtrace(std::string& output) { if (!paused_frame_) { return false; } output.clear(); const char *header = "At"; int i; for (i = ((int)backtrace_.size() - 1); i >= 0; i--) { WTF::CString f = WTF::String::format("%s %s:%d", header, source_map_[backtrace_[i].sourceID].url.c_str(), backtrace_[i].lineNumber).ascii(); output.append(f.data()); output.append("\n"); // CString seems to eat my newlines if this is in the format. header = "Called from"; } return true; }
void DebuggerShell::exception(const DebuggerCallFrame& callFrame, intptr_t sourceID, int lineNumber, int column, bool hasHandler) { ExecState *execState = callFrame.dynamicGlobalObject()->globalExec(); WTF::CString exceptString = callFrame.exception().toString(execState)->getString(execState).ascii(); if (tracing_ || !hasHandler) { WTF::CString f = WTF::String::format("Exception (%shandled) at "WHEREAMI_FMT": %s", hasHandler ? "" : "un", WHEREAMI_DATA, exceptString.data()).ascii(); std::string& url = source_map_[sourceID].url; if (hasHandler) { dumpToTTY(f); } else { dumpToTTYPopup(f); pause_ASAP_ = true; } } maybeBlockExecution(callFrame); }
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()); }