void QtWebPagePolicyClient::decidePolicyForNavigationAction(WKPageRef, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef, const void* clientInfo)
{
    WKRetainPtr<WKURLRef> frameURL(AdoptWK, WKFrameCopyURL(frame));
    WKRetainPtr<WKURLRef> requestURL(AdoptWK, WKURLRequestCopyURL(request));
    QUrl qUrl = WKURLCopyQUrl(requestURL.get());
    toQtWebPagePolicyClient(clientInfo)->decidePolicyForNavigationAction(qUrl, toQtMouseButton(mouseButton), toQtKeyboardModifiers(modifiers), toQuickWebViewNavigationType(navigationType), listener);
}
Exemple #2
0
KURL DocumentLoader::documentURL() const
{
    KURL url = substituteData().responseURL();
    if (url.isEmpty())
        url = requestURL();
    if (url.isEmpty())
        url = m_response.url();
    return url;
}
static bool isMainInspectorPage(const WebInspectorProxy* webInspectorProxy, WKURLRequestRef requestRef)
{
    // Use URL so we can compare just the paths.
    URL inspectorURL(URL(), webInspectorProxy->inspectorPageURL());
    URL requestURL(URL(), toImpl(requestRef)->resourceRequest().url());

    ASSERT(WebCore::SchemeRegistry::shouldTreatURLSchemeAsLocal(inspectorURL.protocol()));

    return WebCore::SchemeRegistry::shouldTreatURLSchemeAsLocal(requestURL.protocol()) && decodeURLEscapeSequences(requestURL.path()) == decodeURLEscapeSequences(inspectorURL.path());
}
CachedResource* InspectorResource::cachedResource() const
{
    // Try hard to find a corresponding CachedResource. During preloading, DocLoader may not have the resource in document resources set yet,
    // but Inspector will already try to fetch data that is only available via CachedResource (and it won't update once the resource is added,
    // because m_changes will not have the appropriate bits set).
    const String& url = requestURL();
    CachedResource* cachedResource = m_frame->document()->docLoader()->cachedResource(url);
    if (!cachedResource)
        cachedResource = cache()->resourceForURL(url);
    return cachedResource;
}
Exemple #5
0
KURL DocumentLoader::documentURL() const
{
    KURL url = substituteData().responseURL();
#if ENABLE(WEB_ARCHIVE)
    if (url.isEmpty() && m_archive && m_archive->type() == Archive::WebArchive)
        url = m_archive->mainResource()->url();
#endif
    if (url.isEmpty())
        url = requestURL();
    if (url.isEmpty())
        url = responseURL();
    return url;
}
Exemple #6
0
void DocumentLoader::finishedLoading()
{
// <lab126>
	KINDLE_BEGIN(Kindle_Debug_Resources)
		KINDLE_PRINT("\033[35mFinished Loading %s...\033[0m\n", requestURL().string().latin1().data());
	KINDLE_END()
// </lab126>
    m_gotFirstByte = true;   
    commitIfReady();
    if (FrameLoader* loader = frameLoader()) {
        loader->finishedLoadingDocument(this);
        loader->end();
    }
}
static bool isMainOrTestInspectorPage(WKURLRequestRef requestRef)
{
    URL requestURL(URL(), toImpl(requestRef)->resourceRequest().url());
    if (!WebCore::SchemeRegistry::shouldTreatURLSchemeAsLocal(requestURL.protocol()))
        return false;

    // Use URL so we can compare just the paths.
    URL mainPageURL(URL(), WebInspectorProxy::inspectorPageURL());
    ASSERT(WebCore::SchemeRegistry::shouldTreatURLSchemeAsLocal(mainPageURL.protocol()));
    if (decodeURLEscapeSequences(requestURL.path()) == decodeURLEscapeSequences(mainPageURL.path()))
        return true;

    // We might not have a Test URL in Production builds.
    String testPageURLString = WebInspectorProxy::inspectorTestPageURL();
    if (testPageURLString.isNull())
        return false;

    URL testPageURL(URL(), testPageURLString);
    ASSERT(WebCore::SchemeRegistry::shouldTreatURLSchemeAsLocal(testPageURL.protocol()));
    return decodeURLEscapeSequences(requestURL.path()) == decodeURLEscapeSequences(testPageURL.path());
}
void InspectorResource::createScriptObject(InspectorFrontend* frontend)
{
    if (!m_scriptObjectCreated) {
        JSONObject jsonObject = frontend->newJSONObject();
        JSONObject requestHeaders = frontend->newJSONObject();
        populateHeadersObject(&requestHeaders, m_requestHeaderFields);
        jsonObject.set("requestHeaders", requestHeaders);
        jsonObject.set("requestURL", requestURL());
        jsonObject.set("host", m_requestURL.host());
        jsonObject.set("path", m_requestURL.path());
        jsonObject.set("lastPathComponent", m_requestURL.lastPathComponent());
        jsonObject.set("isMainResource", m_isMainResource);
        jsonObject.set("cached", m_cached);
        if (!frontend->addResource(m_identifier, jsonObject))
            return;

        m_scriptObjectCreated = true;
        m_changes.clear(RequestChange);
    }
    updateScriptObject(frontend);
}
Exemple #9
0
/*
 * The old favorite
 */
vector<PopWord> TopTensSearch::getResults(string word)
{
	string buffer;
	vector<PopWord> results;

	string url("http://share.thetoptens.com/mrsmith7.asp?s=" + word);
        //is user input plural?
        if (word[word.size()-1] !='s')
           url.append("s");
        else if (word[word.size()-2] != 's')
           word = word.substr(0, word.size()-1);

//	cout << "Retrieving " << url << endl;

	buffer = requestURL(url);

	if (buffer.length() != 0)
	{
		results=parsePage(buffer, word);
	}
	return results;
}
NS_IMETHODIMP
nsUrlClassifierHashCompleter::Run()
{
  LOG(("nsUrlClassifierHashCompleter::Run [%p]\n", this));

  if (mShuttingDown) {
    mRequest = nsnull;
    return NS_ERROR_NOT_INITIALIZED;
  }

  if (!mRequest)
    return NS_OK;

  NS_ASSERTION(!mGethashUrl.IsEmpty(),
               "Request dispatched without a gethash url specified.");

  nsCOMPtr<nsIURI> uri;
  nsresult rv;
  if (mClientKey.IsEmpty()) {
    rv = NS_NewURI(getter_AddRefs(uri), mGethashUrl);
    NS_ENSURE_SUCCESS(rv, rv);
  } else {
    mRequest->SetClientKey(mClientKey);

    nsCAutoString requestURL(mGethashUrl);
    requestURL.Append("&wrkey=");
    requestURL.Append(mWrappedKey);
    rv = NS_NewURI(getter_AddRefs(uri), requestURL);
    NS_ENSURE_SUCCESS(rv, rv);
  }

  mRequest->SetURI(uri);

  // Dispatch the http request.
  rv = mRequest->Begin();
  mRequest = nsnull;
  return rv;
}
void InspectorResource::updateScriptObject(InspectorFrontend* frontend)
{
    if (!m_scriptObjectCreated)
        return;

    if (m_changes.hasChange(NoChange))
        return;

    ScriptObject jsonObject = frontend->newScriptObject();
    if (m_changes.hasChange(RequestChange)) {
        jsonObject.set("url", requestURL());
        jsonObject.set("domain", m_requestURL.host());
        jsonObject.set("path", m_requestURL.path());
        jsonObject.set("lastPathComponent", m_requestURL.lastPathComponent());
        ScriptObject requestHeaders = frontend->newScriptObject();
        populateHeadersObject(&requestHeaders, m_requestHeaderFields);
        jsonObject.set("requestHeaders", requestHeaders);
        jsonObject.set("mainResource", m_isMainResource);
        jsonObject.set("requestMethod", m_requestMethod);
        jsonObject.set("requestFormData", m_requestFormData);
        jsonObject.set("didRequestChange", true);
    }

    if (m_changes.hasChange(ResponseChange)) {
        jsonObject.set("mimeType", m_mimeType);
        jsonObject.set("suggestedFilename", m_suggestedFilename);
        jsonObject.set("expectedContentLength", m_expectedContentLength);
        jsonObject.set("statusCode", m_responseStatusCode);
        jsonObject.set("suggestedFilename", m_suggestedFilename);
        ScriptObject responseHeaders = frontend->newScriptObject();
        populateHeadersObject(&responseHeaders, m_responseHeaderFields);
        jsonObject.set("responseHeaders", responseHeaders);
        jsonObject.set("didResponseChange", true);
    }

    if (m_changes.hasChange(TypeChange)) {
        jsonObject.set("type", static_cast<int>(type()));
        jsonObject.set("didTypeChange", true);
    }
    
    if (m_changes.hasChange(LengthChange)) {
        jsonObject.set("contentLength", m_length);
        jsonObject.set("didLengthChange", true);
    }

    if (m_changes.hasChange(CompletionChange)) {
        jsonObject.set("failed", m_failed);
        jsonObject.set("finished", m_finished);
        jsonObject.set("didCompletionChange", true);
    }

    if (m_changes.hasChange(TimingChange)) {
        if (m_startTime > 0)
            jsonObject.set("startTime", m_startTime);
        if (m_responseReceivedTime > 0)
            jsonObject.set("responseReceivedTime", m_responseReceivedTime);
        if (m_endTime > 0)
            jsonObject.set("endTime", m_endTime);
        if (m_loadEventTime > 0)
            jsonObject.set("loadEventTime", m_loadEventTime);
        if (m_domContentEventTime > 0)
            jsonObject.set("domContentEventTime", m_domContentEventTime);
        jsonObject.set("didTimingChange", true);
    }
    if (!frontend->updateResource(m_identifier, jsonObject))
        return;
    m_changes.clearAll();
}
String InspectorResource::sourceString() const
{
    if (!m_xmlHttpResponseText.isNull())
        return String(m_xmlHttpResponseText);

    RefPtr<SharedBuffer> buffer;
    String textEncodingName;

    if (m_requestURL == m_loader->requestURL()) {
        buffer = m_loader->mainResourceData();
        textEncodingName = m_frame->document()->inputEncoding();
    } else {
        CachedResource* cachedResource = m_frame->document()->docLoader()->cachedResource(requestURL());
        if (!cachedResource)
            return String();

        if (cachedResource->isPurgeable()) {
            // If the resource is purgeable then make it unpurgeable to get
            // get its data. This might fail, in which case we return an
            // empty String.
            // FIXME: should we do something else in the case of a purged
            // resource that informs the user why there is no data in the
            // inspector?
            if (!cachedResource->makePurgeable(false))
                return String();
        }

        buffer = cachedResource->data();
        textEncodingName = cachedResource->encoding();
    }

    if (!buffer)
        return String();

    TextEncoding encoding(textEncodingName);
    if (!encoding.isValid())
        encoding = WindowsLatin1Encoding();
    return encoding.decode(buffer->data(), buffer->size());
}
InspectorResource::Type InspectorResource::type() const
{
    if (!m_xmlHttpResponseText.isNull())
        return XHR;

    if (m_requestURL == m_loader->requestURL())
        return Doc;

    if (m_loader->frameLoader() && m_requestURL == m_loader->frameLoader()->iconURL())
        return Image;

    CachedResource* cachedResource = m_frame->document()->docLoader()->cachedResource(requestURL());
    if (!cachedResource)
        return Other;

    switch (cachedResource->type()) {
        case CachedResource::ImageResource:
            return Image;
        case CachedResource::FontResource:
            return Font;
        case CachedResource::CSSStyleSheet:
#if ENABLE(XSLT)
        case CachedResource::XSLStyleSheet:
#endif
            return Stylesheet;
        case CachedResource::Script:
            return Script;
        default:
            return Other;
    }
}
Exemple #14
0
vector<PopWord> TopTensSearch::parsePage(string buffer, string word)
{
   vector<PopWord> results;
   set<PopWord*, DereferenceLess> unique;
//   boost::smatch what;
//   boost::regex expr(regex);

   //parse the XML document
   rapidxml::xml_document<> doc;
   doc.parse<0>((char*)buffer.c_str());

   rapidxml::xml_node<> *node = doc.first_node();

   //Filter the titles
   string exp(".*st "+word+"s?( (?!(in|about|from)).*|$)|.(?!\\w+s)* "+word+"s( (?!.*(in|about|from)).*|$)|.* "+word+"s? ((?!color)|(\\w+))s( (?!.*(in|about|from)).*|$)");
   boost::regex e(exp, boost::regex::icase);
   wninit();

   for (rapidxml::xml_node<> *list = node->first_node(); list; list = list->next_sibling())
   {
      //The list has:
      // * title
      // * link
      // * items
//      printf("Title: %s\n", list->first_node("title")->value());
      
      const string test = list->first_node("title")->value();
      //Determine if the title is any good
      if(boost::regex_match(test, e))
      {

         int count = 0;
         for (rapidxml::xml_node<> *attr = list->first_node("items")->first_node(); attr && count < 5; attr = attr->next_sibling())
         {
            std::string item = (std::string) attr->value();
            boost::regex re(" (in |from |of |- |\\(|:)", boost::regbase::icase);
            boost::sregex_token_iterator i(item.begin(), item.end(), re, -1);
            boost::sregex_token_iterator j;
            std::string found = *i++;
            if (i!=j)
            {
               boost::replace_all(found, " ", "_");
               //PopWord* pop = new PopWord(found, test, *i);
               set<PopWord*>::iterator it = unique.insert(unique.begin(), new PopWord(found, test, *i));
//               if (it != unique.end())
//               {
//                  cout << (*it)->getCount();
                  (*it)->incrementCount();
//                  cout << "\t1 |" << (*it)->getStem() << "|\t" << *i << " " << (*it)->getCount() << endl;
//               }
//               else
//                  unique.insert(pop);
            }
            else
            {
               boost::replace_all(item, " ", "_");
               bool inWN = false;

               for (int j=1; j <= 4; j++)
               {
                  //If the word is defined for the POS
                  if (is_defined((char*)item.c_str(), j) != 0)
                  {
                     set<PopWord*>::iterator it = unique.insert(unique.begin(), new PopWord(item, test));
                     (*it)->incrementCount();
                     inWN=true;
//                     cout << "\t\t2 " << item << endl;
                     break;
                  }
                  else 
                  {
                     char* morph = morphstr((char*)item.c_str(),j);
                     if (morph != NULL)
                     {
                        set<PopWord*>::iterator it = unique.insert(unique.begin(), new PopWord(item, test));
                        (*it)->incrementCount();
                        inWN=true;
//                        cout << "\t\t3 " << item << endl;
                        break;
                     }
                  }
               }
//               if(!inWN)
//                  std::cout << "Not used\t\t4 "<<item << std::endl;
            }
         }
      }
   }

   //Iterate through the unique set. Check how apparent the concept is in wikipedia
   int maxCount = 0;
   set<PopWord*>::iterator it;
   for (it=unique.begin(); it !=unique.end(); it++)
   {
      PopWord ttr = *(*it);
//      cout << ttr.getWord() << endl;
      //int count = -1;
      if (false)
      {
      string buffer = requestURL("http://en.wikipedia.org/w/api.php?format=json&action=parse&page="+ttr.getStem()+"&prop=links&redirects");
      boost::regex re("[\"\\s(:]" + word + "s?[)\"\\s]", boost::regbase::icase);
      boost::sregex_token_iterator i(buffer.begin(), buffer.end(), re, -1);
      boost::sregex_token_iterator j;

	      
//      cout << "-->\t" << buffer << endl;
      while (i != j)
      {
//         cout << "\t" << *i++ << endl;
         ttr.incrementCount();
      }
//      cout << count << endl << endl;
      }
     // ttr.setCount(count);
     if (ttr.getCount() > maxCount)
        maxCount=ttr.getCount();
      results.push_back(ttr);
      
   }
   for (int i =0; i < results.size(); i++)
   {
      results[i].setCount(results[i].getCount()/maxCount);
   }
   return results;
}