Update source files for bracket style

This commit is contained in:
Marshall Greenblatt
2023-01-02 17:59:03 -05:00
parent d84b07a5cb
commit 3af3eab3e4
366 changed files with 7275 additions and 3834 deletions

View File

@ -93,11 +93,13 @@ class ServerHandler : public CefServerHandler {
CefURLParts url_parts;
CefParseURL(request->GetURL(), url_parts);
std::string path = CefString(&url_parts.path);
if (!path.empty() && path[0] == '/')
if (!path.empty() && path[0] == '/') {
path = path.substr(1);
}
if (path.empty())
if (path.empty()) {
path = kDefaultPath;
}
std::string mime_type;
const size_t sep = path.find_last_of(".");
@ -108,8 +110,9 @@ class ServerHandler : public CefServerHandler {
// No extension. Assume html.
path += ".html";
}
if (mime_type.empty())
if (mime_type.empty()) {
mime_type = "text/html";
}
CefRefPtr<CefStreamReader> stream;
CefResponse::HeaderMap extra_headers;
@ -189,8 +192,9 @@ class ServerHandler : public CefServerHandler {
size_t read;
do {
read = stream->Read(buffer, 1, sizeof(buffer));
if (read > 0)
if (read > 0) {
server->SendRawData(connection_id, buffer, read);
}
} while (!stream->Eof() && read != 0);
// Close the connection.
@ -230,8 +234,9 @@ class Handler : public CefMessageRouterBrowserSide::Handler {
// Only handle messages from the test URL.
const std::string& url = frame->GetURL();
if (url.find(kTestUrl) != 0)
if (url.find(kTestUrl) != 0) {
return false;
}
// Parse |request| as a JSON dictionary.
CefRefPtr<CefDictionaryValue> request_dict = ParseJSON(request);
@ -240,8 +245,9 @@ class Handler : public CefMessageRouterBrowserSide::Handler {
return true;
}
if (!VerifyKey(request_dict, kActionKey, VTYPE_STRING, callback))
if (!VerifyKey(request_dict, kActionKey, VTYPE_STRING, callback)) {
return true;
}
const std::string& action = request_dict->GetString(kActionKey);
if (action == "query") {
@ -280,8 +286,9 @@ class Handler : public CefMessageRouterBrowserSide::Handler {
return;
}
if (!VerifyKey(request_dict, kPortKey, VTYPE_INT, callback))
if (!VerifyKey(request_dict, kPortKey, VTYPE_INT, callback)) {
return;
}
const int port = request_dict->GetInt(kPortKey);
if (port < 8000 || port > 65535) {
@ -350,8 +357,9 @@ class Handler : public CefMessageRouterBrowserSide::Handler {
// Convert a JSON string to a dictionary value.
static CefRefPtr<CefDictionaryValue> ParseJSON(const CefString& string) {
CefRefPtr<CefValue> value = CefParseJSON(string, JSON_PARSER_RFC);
if (value.get() && value->GetType() == VTYPE_DICTIONARY)
if (value.get() && value->GetType() == VTYPE_DICTIONARY) {
return value->GetDictionary();
}
return nullptr;
}