Example #1
0
/*--cef()--*/
void ResourceHandler::GetResponseHeaders(CefRefPtr<CefResponse> response,
                              int64& response_length,
                              CefString& redirectUrl) {
    REQUIRE_IO_THREAD();
    ResourceHandler_GetResponseHeaders(resourceHandlerId_, response,
            response_length, redirectUrl);
}
Example #2
0
/*--cef()--*/
bool ResourceHandler::ReadResponse(void* data_out,
                        int bytes_to_read,
                        int& bytes_read,
                        CefRefPtr<CefCallback> callback) {
    REQUIRE_IO_THREAD();
    return ResourceHandler_ReadResponse(resourceHandlerId_, data_out,
            bytes_to_read, bytes_read, callback);
}
Example #3
0
bool CookieVisitor::Visit(
        const CefCookie& cookie,
        int count,
        int total,
        bool& deleteCookie
        ) {
    REQUIRE_IO_THREAD();
    return CookieVisitor_Visit(cookieVisitorId_, cookie, count, total, deleteCookie);
}
Example #4
0
bool ClientHandler::OnBeforeResourceLoad(CefRefPtr<CefBrowser> browser,
                                     CefRefPtr<CefRequest> request,
                                     CefString& redirectUrl,
                                     CefRefPtr<CefStreamReader>& resourceStream,
                                     CefRefPtr<CefResponse> response,
                                     int loadFlags)
{
  REQUIRE_IO_THREAD();

  std::string url = request->GetURL();
  if(url == "http://tests/request") {
    // Show the request contents
    std::string dump;
    DumpRequestContents(request, dump);
    resourceStream =
        CefStreamReader::CreateForData((void*)dump.c_str(), dump.size());
    response->SetMimeType("text/plain");
    response->SetStatus(200);
  } else if(strstr(url.c_str(), "/ps_logo2.png") != NULL) {
    // Any time we find "ps_logo2.png" in the URL substitute in our own image
    resourceStream = GetBinaryResourceReader(IDS_LOGO);
    response->SetMimeType("image/png");
    response->SetStatus(200);
  } else if(url == "http://tests/uiapp") {
    // Show the uiapp contents
    resourceStream = GetBinaryResourceReader(IDS_UIPLUGIN);
    response->SetMimeType("text/html");
    response->SetStatus(200);
  } else if(url == "http://tests/osrapp") {
    // Show the osrapp contents
    resourceStream = GetBinaryResourceReader(IDS_OSRPLUGIN);
    response->SetMimeType("text/html");
    response->SetStatus(200);
  } else if(url == "http://tests/localstorage") {
    // Show the localstorage contents
    resourceStream = GetBinaryResourceReader(IDS_LOCALSTORAGE);
    response->SetMimeType("text/html");
    response->SetStatus(200);
  } else if(url == "http://tests/xmlhttprequest") {
    // Show the xmlhttprequest HTML contents
    resourceStream = GetBinaryResourceReader(IDS_XMLHTTPREQUEST);
    response->SetMimeType("text/html");
    response->SetStatus(200);
  } else if(url == "http://tests/domaccess") {
    // Show the domaccess HTML contents
    resourceStream = GetBinaryResourceReader(IDS_DOMACCESS);
    response->SetMimeType("text/html");
    response->SetStatus(200);
  } else if(strstr(url.c_str(), "/logoball.png") != NULL) {
    // Load the "logoball.png" image resource.
    resourceStream = GetBinaryResourceReader(IDS_LOGOBALL);
    response->SetMimeType("image/png");
    response->SetStatus(200);
  } else if(url == "http://tests/modalmain") {
    resourceStream = GetBinaryResourceReader(IDS_MODALMAIN);
    response->SetMimeType("text/html");
    response->SetStatus(200);
  } else if(url == "http://tests/modaldialog") {
    resourceStream = GetBinaryResourceReader(IDS_MODALDIALOG);
    response->SetMimeType("text/html");
    response->SetStatus(200);
  }

  return false;
}
Example #5
0
/*--cef()--*/
void ResourceHandler::Cancel() {
    REQUIRE_IO_THREAD();
    return ResourceHandler_Cancel(resourceHandlerId_);
}
Example #6
0
/*--cef()--*/
bool ResourceHandler::CanSetCookie(const CefCookie& cookie) { 
    REQUIRE_IO_THREAD();
    return ResourceHandler_CanSetCookie(resourceHandlerId_, cookie);
}
Example #7
0
/*--cef()--*/
bool ResourceHandler::ProcessRequest(CefRefPtr<CefRequest> request,
                          CefRefPtr<CefCallback> callback) {
    REQUIRE_IO_THREAD();
    return ResourceHandler_ProcessRequest(resourceHandlerId_, request,
            callback);
}
Example #8
0
bool ClientHandler::OnBeforeResourceLoad(CefRefPtr<CefBrowser> browser,
                                     CefRefPtr<CefRequest> request,
                                     CefString& redirectUrl,
                                     CefRefPtr<CefStreamReader>& resourceStream,
                                     CefRefPtr<CefResponse> response,
                                     int loadFlags) {
  REQUIRE_IO_THREAD();

  std::string url = request->GetURL();
  if (url == "http://tests/request") {
    // Show the request contents
    std::string dump;
    DumpRequestContents(request, dump);
    resourceStream = CefStreamReader::CreateForData(
        static_cast<void*>(const_cast<char*>(dump.c_str())),
        dump.size());
    response->SetMimeType("text/plain");
    response->SetStatus(200);
  } else if (strstr(url.c_str(), "/ps_logo2.png") != NULL) {
    // Any time we find "ps_logo2.png" in the URL substitute in our own image
    resourceStream = GetBinaryResourceReader(IDS_LOGO);
    response->SetMimeType("image/png");
    response->SetStatus(200);
  } else if (url == "http://tests/uiapp") {
    // Show the uiapp contents
    resourceStream = GetBinaryResourceReader(IDS_UIPLUGIN);
    response->SetMimeType("text/html");
    response->SetStatus(200);
  } else if (url == "http://tests/osrapp") {
    // Show the osrapp contents
    resourceStream = GetBinaryResourceReader(IDS_OSRPLUGIN);
    response->SetMimeType("text/html");
    response->SetStatus(200);
  } else if (url == "http://tests/localstorage") {
    // Show the localstorage contents
    resourceStream = GetBinaryResourceReader(IDS_LOCALSTORAGE);
    response->SetMimeType("text/html");
    response->SetStatus(200);
  } else if (url == "http://tests/xmlhttprequest") {
    // Show the xmlhttprequest HTML contents
    resourceStream = GetBinaryResourceReader(IDS_XMLHTTPREQUEST);
    response->SetMimeType("text/html");
    response->SetStatus(200);
  } else if (url == "http://tests/domaccess") {
    // Show the domaccess HTML contents
    resourceStream = GetBinaryResourceReader(IDS_DOMACCESS);
    response->SetMimeType("text/html");
    response->SetStatus(200);
  } else if (strstr(url.c_str(), "/logoball.png") != NULL) {
    // Load the "logoball.png" image resource.
    resourceStream = GetBinaryResourceReader(IDS_LOGOBALL);
    response->SetMimeType("image/png");
    response->SetStatus(200);
  } else if (url == "http://tests/modalmain") {
    resourceStream = GetBinaryResourceReader(IDS_MODALMAIN);
    response->SetMimeType("text/html");
    response->SetStatus(200);
  } else if (url == "http://tests/modaldialog") {
    resourceStream = GetBinaryResourceReader(IDS_MODALDIALOG);
    response->SetMimeType("text/html");
    response->SetStatus(200);
  } else if (url == "http://tests/transparency") {
    resourceStream = GetBinaryResourceReader(IDS_TRANSPARENCY);
    response->SetMimeType("text/html");
    response->SetStatus(200);
  } else if (url == "http://tests/plugin") {
    std::string html =
        "<html><body>\n"
        "Client Plugin loaded by Mime Type:<br>\n"
        "<embed type=\"application/x-client-plugin\" width=600 height=40>\n"
        "<br><br>Client Plugin loaded by File Extension:<br>\n"
        "<embed src=\"test.xcp\" width=600 height=40>\n"
        // Add some extra space below the plugin to allow scrolling.
        "<div style=\"height:1000px;\">&nbsp;</div>\n"
        "</body></html>";

    resourceStream = CefStreamReader::CreateForData(
        static_cast<void*>(const_cast<char*>(html.c_str())),
        html.size());
    response->SetMimeType("text/html");
    response->SetStatus(200);
  }

  return false;
}