Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Unified Diff: tools/skiaserve/skiaserve.cpp

Issue 1676403002: Skia serve now supports favicon correctly (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/skiaserve/favicon.ico ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/skiaserve/skiaserve.cpp
diff --git a/tools/skiaserve/skiaserve.cpp b/tools/skiaserve/skiaserve.cpp
index a8ddcdf488f9d812e925ff8c2d8334908456450e..e2e5450fbdfd066ba7d502d94a17347c396a0180 100644
--- a/tools/skiaserve/skiaserve.cpp
+++ b/tools/skiaserve/skiaserve.cpp
@@ -29,6 +29,7 @@
__SK_FORCE_IMAGE_DECODER_LINKING;
DEFINE_string(source, "https://debugger.skia.org", "Where to load the web UI from.");
+DEFINE_string(faviconDir, "tools/skiaserve", "The directory of the favicon");
DEFINE_int32(port, 8888, "The port to listen on.");
// TODO probably want to make this configurable
@@ -443,6 +444,28 @@ public:
}
};
+class FaviconHandler : public UrlHandler {
+public:
+ bool canHandle(const char* method, const char* url) override {
+ return 0 == strcmp(method, MHD_HTTP_METHOD_GET) &&
+ 0 == strcmp(url, "/favicon.ico");
+ }
+
+ int handle(Request* request, MHD_Connection* connection,
+ const char* url, const char* method,
+ const char* upload_data, size_t* upload_data_size) override {
+ SkString dir(FLAGS_faviconDir[0]);
+ dir.append("/favicon.ico");
+ FILE* ico = fopen(dir.c_str(), "r");
+
+ SkAutoTUnref<SkData> data(SkData::NewFromFILE(ico));
+ int ret = SendData(connection, data, "image/vnd.microsoft.icon");
+ fclose(ico);
+ return ret;
+ }
+};
+
+
class RootHandler : public UrlHandler {
public:
bool canHandle(const char* method, const char* url) override {
@@ -468,6 +491,7 @@ public:
fHandlers.push_back(new InfoHandler);
fHandlers.push_back(new DownloadHandler);
fHandlers.push_back(new DataHandler);
+ fHandlers.push_back(new FaviconHandler);
}
~UrlManager() {
@@ -502,7 +526,7 @@ int answer_to_connection(void* cls, struct MHD_Connection* connection,
int result = kUrlManager.invoke(request, connection, url, method, upload_data,
upload_data_size);
if (MHD_NO == result) {
- fprintf(stderr, "Invalid method and / or url: %s %s)\n", method, url);
+ fprintf(stderr, "Invalid method and / or url: %s %s\n", method, url);
}
return result;
}
« no previous file with comments | « tools/skiaserve/favicon.ico ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698