cefclient: Simplify tests and related resource loading.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1173 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2013-04-03 23:31:49 +00:00
parent 758470dfca
commit 64b570a994
29 changed files with 722 additions and 862 deletions

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights
// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
@@ -7,9 +7,6 @@
#include "cefclient/client_handler.h"
#include "include/cef_browser.h"
#include "include/cef_frame.h"
#include "cefclient/performance_test.h"
#include "cefclient/resource_util.h"
#include "cefclient/string_util.h"
// ClientHandler::ClientLifeSpanHandler implementation
bool ClientHandler::OnBeforePopup(CefRefPtr<CefBrowser> parentBrowser,
@@ -23,59 +20,6 @@ bool ClientHandler::OnBeforePopup(CefRefPtr<CefBrowser> parentBrowser,
return false;
}
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("logo.png");
response->SetMimeType("image/png");
response->SetStatus(200);
} else if (url == "http://tests/localstorage") {
// Show the localstorage contents
resourceStream = GetBinaryResourceReader("localstorage.html");
response->SetMimeType("text/html");
response->SetStatus(200);
} else if (url == "http://tests/xmlhttprequest") {
// Show the xmlhttprequest HTML contents
resourceStream = GetBinaryResourceReader("xmlhttprequest.html");
response->SetMimeType("text/html");
response->SetStatus(200);
} else if (url == "http://tests/domaccess") {
// Show the domaccess HTML contents
resourceStream = GetBinaryResourceReader("domaccess.html");
response->SetMimeType("text/html");
response->SetStatus(200);
} else if (url == performance_test::kTestUrl) {
resourceStream = GetBinaryResourceReader("performance.html");
response->SetMimeType("text/html");
response->SetStatus(200);
} else if (url == "http://tests/dialogs") {
// Show the dialogs HTML contents
resourceStream = GetBinaryResourceReader("dialogs.html");
response->SetMimeType("text/html");
response->SetStatus(200);
}
return false;
}
void ClientHandler::OnAddressChange(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const CefString& url) {