remove string_util and its dependencies

This commit is contained in:
Corey Johnson
2012-08-13 09:25:40 -07:00
parent 91ee54fac7
commit 97d3edf706
6 changed files with 1 additions and 173 deletions

View File

@@ -58,8 +58,6 @@
'tests/cefclient/client_switches.cpp',
'tests/cefclient/client_switches.h',
'tests/cefclient/resource_util.h',
'tests/cefclient/string_util.cpp',
'tests/cefclient/string_util.h',
'tests/cefclient/util.h',
],
'mac_bundle_resources': [
@@ -286,8 +284,6 @@
'tests/cefclient/process_helper_mac.cpp',
'tests/cefclient/resource_util.h',
'tests/cefclient/resource_util_mac.mm',
'tests/cefclient/string_util.cpp',
'tests/cefclient/string_util.h',
'tests/cefclient/util.h',
],
# TODO(mark): Come up with a fancier way to do this. It should only

View File

@@ -192,41 +192,3 @@ void AppGetBrowserSettings(CefBrowserSettings& settings) {
settings.fullscreen_enabled =
g_command_line->HasSwitch(cefclient::kFullscreenEnabled);
}
void RunGetSourceTest(CefRefPtr<CefBrowser> browser) {
class Visitor : public CefStringVisitor {
public:
explicit Visitor(CefRefPtr<CefBrowser> browser) : browser_(browser) {}
virtual void Visit(const CefString& string) OVERRIDE {
std::string source = StringReplace(string, "<", "&lt;");
source = StringReplace(source, ">", "&gt;");
std::stringstream ss;
ss << "<html><body>Source:<pre>" << source << "</pre></body></html>";
browser_->GetMainFrame()->LoadString(ss.str(), "http://tests/getsource");
}
private:
CefRefPtr<CefBrowser> browser_;
IMPLEMENT_REFCOUNTING(Visitor);
};
browser->GetMainFrame()->GetSource(new Visitor(browser));
}
void RunGetTextTest(CefRefPtr<CefBrowser> browser) {
class Visitor : public CefStringVisitor {
public:
explicit Visitor(CefRefPtr<CefBrowser> browser) : browser_(browser) {}
virtual void Visit(const CefString& string) OVERRIDE {
std::string text = StringReplace(string, "<", "&lt;");
text = StringReplace(text, ">", "&gt;");
std::stringstream ss;
ss << "<html><body>Text:<pre>" << text << "</pre></body></html>";
browser_->GetMainFrame()->LoadString(ss.str(), "http://tests/gettext");
}
private:
CefRefPtr<CefBrowser> browser_;
IMPLEMENT_REFCOUNTING(Visitor);
};
browser->GetMainFrame()->GetText(new Visitor(browser));
}

View File

@@ -35,24 +35,4 @@ void AppGetSettings(CefSettings& settings, CefRefPtr<ClientApp> app);
// Returns the application browser settings based on command line arguments.
void AppGetBrowserSettings(CefBrowserSettings& settings);
// Implementations for various tests.
void RunGetSourceTest(CefRefPtr<CefBrowser> browser);
void RunGetTextTest(CefRefPtr<CefBrowser> browser);
void RunRequestTest(CefRefPtr<CefBrowser> browser);
void RunPopupTest(CefRefPtr<CefBrowser> browser);
void RunDialogTest(CefRefPtr<CefBrowser> browser);
void RunPluginInfoTest(CefRefPtr<CefBrowser> browser);
void RunLocalStorageTest(CefRefPtr<CefBrowser> browser);
void RunAccelerated2DCanvasTest(CefRefPtr<CefBrowser> browser);
void RunAcceleratedLayersTest(CefRefPtr<CefBrowser> browser);
void RunWebGLTest(CefRefPtr<CefBrowser> browser);
void RunHTML5VideoTest(CefRefPtr<CefBrowser> browser);
void RunXMLHTTPRequestTest(CefRefPtr<CefBrowser> browser);
void RunDragDropTest(CefRefPtr<CefBrowser> browser);
void RunGeolocationTest(CefRefPtr<CefBrowser> browser);
#if defined(OS_WIN)
void RunTransparentPopupTest(CefRefPtr<CefBrowser> browser);
#endif
#endif // CEF_TESTS_CEFCLIENT_CEFCLIENT_H_

View File

@@ -337,45 +337,8 @@ CefRefPtr<CefResourceHandler> ClientHandler::GetResourceHandler(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request) {
std::string url = request->GetURL();
if (url == "http://tests/request") {
// Show the request contents
std::string dump;
DumpRequestContents(request, dump);
CefRefPtr<CefStreamReader> stream =
CefStreamReader::CreateForData(
static_cast<void*>(const_cast<char*>(dump.c_str())),
dump.size());
ASSERT(stream.get());
return new CefStreamResourceHandler("text/plain", stream);
} else if (url == "http://tests/dialogs") {
// Show the dialogs contents
CefRefPtr<CefStreamReader> stream =
GetBinaryResourceReader("dialogs.html");
ASSERT(stream.get());
return new CefStreamResourceHandler("text/html", stream);
} else if (url == "http://tests/localstorage") {
// Show the localstorage contents
CefRefPtr<CefStreamReader> stream =
GetBinaryResourceReader("localstorage.html");
ASSERT(stream.get());
return new CefStreamResourceHandler("text/html", stream);
} else if (url == "http://tests/xmlhttprequest") {
// Show the xmlhttprequest contents
CefRefPtr<CefStreamReader> stream =
GetBinaryResourceReader("xmlhttprequest.html");
ASSERT(stream.get());
return new CefStreamResourceHandler("text/html", stream);
}
CefRefPtr<CefResourceHandler> handler;
// Execute delegate callbacks.
RequestDelegateSet::iterator it = request_delegates_.begin();
for (; it != request_delegates_.end() && !handler.get(); ++it)
handler = (*it)->GetResourceHandler(this, browser, frame, request);
return handler;
return NULL;
}
void ClientHandler::OnProtocolExecution(CefRefPtr<CefBrowser> browser,

View File

@@ -6,69 +6,3 @@
#include <sstream>
#include <string>
#include "include/cef_request.h"
void DumpRequestContents(CefRefPtr<CefRequest> request, std::string& str) {
std::stringstream ss;
ss << "URL: " << std::string(request->GetURL());
ss << "\nMethod: " << std::string(request->GetMethod());
CefRequest::HeaderMap headerMap;
request->GetHeaderMap(headerMap);
if (headerMap.size() > 0) {
ss << "\nHeaders:";
CefRequest::HeaderMap::const_iterator it = headerMap.begin();
for (; it != headerMap.end(); ++it) {
ss << "\n\t" << std::string((*it).first) << ": " <<
std::string((*it).second);
}
}
CefRefPtr<CefPostData> postData = request->GetPostData();
if (postData.get()) {
CefPostData::ElementVector elements;
postData->GetElements(elements);
if (elements.size() > 0) {
ss << "\nPost Data:";
CefRefPtr<CefPostDataElement> element;
CefPostData::ElementVector::const_iterator it = elements.begin();
for (; it != elements.end(); ++it) {
element = (*it);
if (element->GetType() == PDE_TYPE_BYTES) {
// the element is composed of bytes
ss << "\n\tBytes: ";
if (element->GetBytesCount() == 0) {
ss << "(empty)";
} else {
// retrieve the data.
size_t size = element->GetBytesCount();
char* bytes = new char[size];
element->GetBytes(size, bytes);
ss << std::string(bytes, size);
delete [] bytes;
}
} else if (element->GetType() == PDE_TYPE_FILE) {
ss << "\n\tFile: " << std::string(element->GetFile());
}
}
}
}
str = ss.str();
}
std::string StringReplace(const std::string& str, const std::string& from,
const std::string& to) {
std::string result = str;
std::string::size_type pos = 0;
std::string::size_type from_len = from.length();
std::string::size_type to_len = to.length();
do {
pos = result.find(from, pos);
if (pos != std::string::npos) {
result.replace(pos, from_len, to);
pos += to_len;
}
} while (pos != std::string::npos);
return result;
}

View File

@@ -11,11 +11,4 @@
class CefRequest;
// Dump the contents of the request into a string.
void DumpRequestContents(CefRefPtr<CefRequest> request, std::string& str);
// Replace all instances of |from| with |to| in |str|.
std::string StringReplace(const std::string& str, const std::string& from,
const std::string& to);
#endif // CEF_TESTS_CEFCLIENT_STRING_UTIL_H_