quint64 WebContentsAdapter::findText(const QString &subString, bool caseSensitively, bool findBackward) { Q_D(WebContentsAdapter); if (d->lastFindRequestId > d->webContentsDelegate->lastReceivedFindReply()) { // There are cases where the render process will overwrite a previous request // with the new search and we'll have a dangling callback, leaving the application // waiting for it forever. // Assume that any unfinished find has been unsuccessful when a new one is started // to cover that case. d->adapterClient->didFindText(d->lastFindRequestId, 0); } blink::WebFindOptions options; options.forward = !findBackward; options.matchCase = caseSensitively; options.findNext = subString == d->webContentsDelegate->lastSearchedString(); d->webContentsDelegate->setLastSearchedString(subString); // Find already allows a request ID as input, but only as an int. // Use the same counter but mod it to MAX_INT, this keeps the same likeliness of request ID clashing. int shrunkRequestId = d->nextRequestId++ & 0x7fffffff; d->webContents->Find(shrunkRequestId, toString16(subString), options); d->lastFindRequestId = shrunkRequestId; return shrunkRequestId; }
void WebContentsAdapter::runJavaScript(const QString &javaScript) { Q_D(WebContentsAdapter); content::RenderViewHost *rvh = d->webContents->GetRenderViewHost(); Q_ASSERT(rvh); rvh->GetMainFrame()->ExecuteJavaScript(toString16(javaScript)); }
quint64 WebContentsAdapter::runJavaScriptCallbackResult(const QString &javaScript) { Q_D(WebContentsAdapter); content::RenderViewHost *rvh = d->webContents->GetRenderViewHost(); Q_ASSERT(rvh); content::RenderFrameHost::JavaScriptResultCallback callback = base::Bind(&callbackOnEvaluateJS, d->adapterClient, d->nextRequestId); rvh->GetMainFrame()->ExecuteJavaScript(toString16(javaScript), callback); return d->nextRequestId++; }
void WebContentsAdapter::download(const QUrl &url, const QString &suggestedFileName) { content::BrowserContext *bctx = webContents()->GetBrowserContext(); content::DownloadManager *dlm = content::BrowserContext::GetDownloadManager(bctx); if (!dlm) return; scoped_ptr<content::DownloadUrlParameters> params( content::DownloadUrlParameters::FromWebContents(webContents(), toGurl(url))); params->set_suggested_name(toString16(suggestedFileName)); dlm->DownloadUrl(params.Pass()); }
void Clipboard::ReadHTML(ClipboardType type, base::string16* markup, std::string* src_url, uint32* fragment_start, uint32* fragment_end) const { markup->clear(); if (src_url) src_url->clear(); *fragment_start = 0; *fragment_end = 0; const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData(type == CLIPBOARD_TYPE_COPY_PASTE ? QClipboard::Clipboard : QClipboard::Selection); *markup = toString16(mimeData->html()); *fragment_end = static_cast<uint32>(markup->length()); }
void add( unsigned char a ){ char s[ 4 ]; int c = 0; if ( mIsHex ){ c = toString16( s, a ); }else{ c = toString10( s, a ); } ASSERT( c <= 4 ); for ( int i = 0; i < c; ++i ){ mBuffer.add( s[ i ] ); } }
void add( short a ){ char s[ 6 ]; int c = 0; if ( mIsHex ){ c = toString16( s, a ); }else{ c = toString10( s, a ); } ASSERT( c <= 6 ); for ( int i = 0; i < c; ++i ){ mBuffer.add( s[ i ] ); } }
void add( char a ){ if ( ( a == '\n' ) || ( a == '\t' ) ){ mBuffer.add( a ); //変換せず(空白文字) }else if ( a >= 0x20 && a <= 0x7e ){ mBuffer.add( a ); //変換せず }else{ mBuffer.add( '%' ); char s[ 2 ]; int c = toString16( s, a ); //16進で ASSERT( c <= 2 ); for ( int i = 0; i < c; ++i ){ mBuffer.add( s[ i ] ); } } }
void Clipboard::ReadAvailableTypes(ui::ClipboardType type, std::vector<base::string16>* types, bool* contains_filenames) const { if (!types || !contains_filenames) { NOTREACHED(); return; } types->clear(); const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData(type == CLIPBOARD_TYPE_COPY_PASTE ? QClipboard::Clipboard : QClipboard::Selection); Q_FOREACH (const QString &mimeType, mimeData->formats()) types->push_back(toString16(mimeType)); *contains_filenames = false; const QByteArray customData = mimeData->data(QString::fromLatin1(kMimeTypeWebCustomDataCopy)); ReadCustomDataTypes(customData.constData(), customData.size(), types); }
int toString16( char* out, char a ){ return toString16( out, a, 2 ); }
int toString16( char* out, short a ){ return toString16( out, a, 4 ); }
int toString16( char* out, unsigned short a ){ return toString16( out, a, 4 ); }
int toString16( char* out, int a ){ return toString16( out, a, 8 ); }
int toString16( char* out, unsigned a ){ return toString16( out, a, 8 ); }
static void deserializeNavigationHistory(QDataStream &input, int *currentIndex, ScopedVector<content::NavigationEntry> *entries, content::BrowserContext *browserContext) { int version; input >> version; if (version != kHistoryStreamVersion) { // We do not try to decode previous history stream versions. // Make sure that our history is cleared and mark the rest of the stream as invalid. input.setStatus(QDataStream::ReadCorruptData); *currentIndex = -1; return; } int count; input >> count >> *currentIndex; int pageId = 0; entries->reserve(count); // Logic taken from SerializedNavigationEntry::ReadFromPickle and ToNavigationEntries. for (int i = 0; i < count; ++i) { QUrl virtualUrl, referrerUrl, originalRequestUrl; QString title; QByteArray pageState; qint32 transitionType, referrerPolicy; bool hasPostData, isOverridingUserAgent; qint64 timestamp; int httpStatusCode; input >> virtualUrl; input >> title; input >> pageState; input >> transitionType; input >> hasPostData; input >> referrerUrl; input >> referrerPolicy; input >> originalRequestUrl; input >> isOverridingUserAgent; input >> timestamp; input >> httpStatusCode; // If we couldn't unpack the entry successfully, abort everything. if (input.status() != QDataStream::Ok) { *currentIndex = -1; for (content::NavigationEntry *entry : *entries) delete entry; entries->clear(); return; } scoped_ptr<content::NavigationEntry> entry = content::NavigationController::CreateNavigationEntry( toGurl(virtualUrl), content::Referrer(toGurl(referrerUrl), static_cast<blink::WebReferrerPolicy>(referrerPolicy)), // Use a transition type of reload so that we don't incorrectly // increase the typed count. ui::PAGE_TRANSITION_RELOAD, false, // The extra headers are not sync'ed across sessions. std::string(), browserContext); entry->SetTitle(toString16(title)); entry->SetPageState(content::PageState::CreateFromEncodedData(std::string(pageState.data(), pageState.size()))); entry->SetPageID(pageId++); entry->SetHasPostData(hasPostData); entry->SetOriginalRequestURL(toGurl(originalRequestUrl)); entry->SetIsOverridingUserAgent(isOverridingUserAgent); entry->SetTimestamp(base::Time::FromInternalValue(timestamp)); entry->SetHttpStatusCode(httpStatusCode); entries->push_back(entry.release()); } }
int toString16( char* out, unsigned char a ){ return toString16( out, a, 2 ); }
void Clipboard::ReadText(ClipboardType type, base::string16* result) const { const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData(type == CLIPBOARD_TYPE_COPY_PASTE ? QClipboard::Clipboard : QClipboard::Selection); *result = toString16(mimeData->text()); }