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

@@ -33,8 +33,9 @@ void ClientAppBrowser::PopulateSettings(CefRefPtr<CefCommandLine> command_line,
if (!cookieable_schemes.empty()) {
std::string list_str;
for (const auto& scheme : cookieable_schemes) {
if (!list_str.empty())
if (!list_str.empty()) {
list_str += ",";
}
list_str += scheme;
}
CefString(&settings.cookieable_schemes_list) = list_str;
@@ -82,8 +83,9 @@ void ClientAppBrowser::OnBeforeCommandLineProcessing(
#endif
DelegateSet::iterator it = delegates_.begin();
for (; it != delegates_.end(); ++it)
for (; it != delegates_.end(); ++it) {
(*it)->OnBeforeCommandLineProcessing(this, command_line);
}
}
}
@@ -91,29 +93,33 @@ void ClientAppBrowser::OnRegisterCustomPreferences(
cef_preferences_type_t type,
CefRawPtr<CefPreferenceRegistrar> registrar) {
DelegateSet::iterator it = delegates_.begin();
for (; it != delegates_.end(); ++it)
for (; it != delegates_.end(); ++it) {
(*it)->OnRegisterCustomPreferences(this, type, registrar);
}
}
void ClientAppBrowser::OnContextInitialized() {
DelegateSet::iterator it = delegates_.begin();
for (; it != delegates_.end(); ++it)
for (; it != delegates_.end(); ++it) {
(*it)->OnContextInitialized(this);
}
}
void ClientAppBrowser::OnBeforeChildProcessLaunch(
CefRefPtr<CefCommandLine> command_line) {
DelegateSet::iterator it = delegates_.begin();
for (; it != delegates_.end(); ++it)
for (; it != delegates_.end(); ++it) {
(*it)->OnBeforeChildProcessLaunch(this, command_line);
}
}
void ClientAppBrowser::OnScheduleMessagePumpWork(int64 delay) {
// Only used when `--external-message-pump` is passed via the command-line.
MainMessageLoopExternalPump* message_pump =
MainMessageLoopExternalPump::Get();
if (message_pump)
if (message_pump) {
message_pump->OnScheduleMessagePumpWork(delay);
}
}
} // namespace client

View File

@@ -94,8 +94,9 @@ void GetInternalManifest(const std::string& extension_path,
CefRefPtr<CefValue> value =
CefParseJSONAndReturnError(manifest_contents, JSON_PARSER_RFC, error_msg);
if (!value || value->GetType() != VTYPE_DICTIONARY) {
if (error_msg.empty())
if (error_msg.empty()) {
error_msg = "Incorrectly formatted dictionary contents.";
}
LOG(ERROR) << "Failed to parse manifest from " << manifest_path << "; "
<< error_msg.ToString();
RunManifestCallback(std::move(callback), nullptr);
@@ -143,10 +144,12 @@ std::string GetInternalExtensionResourcePath(
std::string GetExtensionResourcePath(const std::string& extension_path,
bool* internal) {
const bool is_internal = IsInternalExtension(extension_path);
if (internal)
if (internal) {
*internal = is_internal;
if (is_internal)
}
if (is_internal) {
return GetInternalExtensionResourcePath(extension_path);
}
return extension_path;
}
@@ -227,8 +230,9 @@ std::string GetExtensionURL(CefRefPtr<CefExtension> extension) {
if (browser_action) {
const std::string& default_popup =
browser_action->GetString("default_popup");
if (!default_popup.empty())
if (!default_popup.empty()) {
return GetExtensionOrigin(extension->GetIdentifier()) + default_popup;
}
}
return std::string();

View File

@@ -35,14 +35,17 @@ const char kPathSep = '/';
bool ReadFileToString(const std::string& path,
std::string* contents,
size_t max_size) {
if (!AllowFileIO())
if (!AllowFileIO()) {
return false;
}
if (contents)
if (contents) {
contents->clear();
}
FILE* file = fopen(path.c_str(), "rb");
if (!file)
if (!file) {
return false;
}
const size_t kBufferSize = 1 << 16;
std::unique_ptr<char[]> buf(new char[kBufferSize]);
@@ -53,8 +56,9 @@ bool ReadFileToString(const std::string& path,
// Many files supplied in |path| have incorrect size (proc files etc).
// Hence, the file is read sequentially as opposed to a one-shot read.
while ((len = fread(buf.get(), 1, kBufferSize, file)) > 0) {
if (contents)
if (contents) {
contents->append(buf.get(), std::min(len, max_size - size));
}
if ((max_size - size) < len) {
read_status = false;
@@ -70,19 +74,22 @@ bool ReadFileToString(const std::string& path,
}
int WriteFile(const std::string& path, const char* data, int size) {
if (!AllowFileIO())
if (!AllowFileIO()) {
return -1;
}
FILE* file = fopen(path.c_str(), "wb");
if (!file)
if (!file) {
return -1;
}
int written = 0;
do {
size_t write = fwrite(data + written, 1, size - written, file);
if (write == 0)
if (write == 0) {
break;
}
written += static_cast<int>(write);
} while (written < size);
@@ -92,27 +99,33 @@ int WriteFile(const std::string& path, const char* data, int size) {
}
std::string JoinPath(const std::string& path1, const std::string& path2) {
if (path1.empty() && path2.empty())
if (path1.empty() && path2.empty()) {
return std::string();
if (path1.empty())
}
if (path1.empty()) {
return path2;
if (path2.empty())
}
if (path2.empty()) {
return path1;
}
std::string result = path1;
if (result[result.size() - 1] != kPathSep)
if (result[result.size() - 1] != kPathSep) {
result += kPathSep;
if (path2[0] == kPathSep)
}
if (path2[0] == kPathSep) {
result += path2.substr(1);
else
} else {
result += path2;
}
return result;
}
std::string GetFileExtension(const std::string& path) {
size_t sep = path.find_last_of(".");
if (sep != std::string::npos)
if (sep != std::string::npos) {
return path.substr(sep + 1);
}
return std::string();
}

View File

@@ -56,8 +56,9 @@ void MainMessageLoopExternalPump::OnScheduleWork(int64 delay_ms) {
DoWork();
} else {
// Never wait longer than the maximum allowed time.
if (delay_ms > kMaxTimerDelay)
if (delay_ms > kMaxTimerDelay) {
delay_ms = kMaxTimerDelay;
}
// Results in call to OnTimerTimeout() after the specified delay.
SetTimer(delay_ms);

View File

@@ -109,8 +109,9 @@ class MainMessageLoopExternalPumpLinux : public MainMessageLoopExternalPump {
// Return a timeout suitable for the glib loop, -1 to block forever,
// 0 to return right away, or a timeout in milliseconds from now.
int GetTimeIntervalMilliseconds(const CefTime& from) {
if (from.GetDoubleT() == 0.0)
if (from.GetDoubleT() == 0.0) {
return -1;
}
CefTime now;
now.Now();
@@ -206,8 +207,9 @@ int MainMessageLoopExternalPumpLinux::Run() {
bool block = !more_work_is_plausible;
more_work_is_plausible = g_main_context_iteration(context_, block);
if (should_quit_)
if (should_quit_) {
break;
}
}
// We need to run the message pump until it is idle. However we don't have
@@ -254,10 +256,12 @@ bool MainMessageLoopExternalPumpLinux::HandleCheck() {
if (num_bytes < sizeof(int64)) {
NOTREACHED() << "Error reading from the wakeup pipe.";
}
if (num_bytes == sizeof(int64))
if (num_bytes == sizeof(int64)) {
OnScheduleWork(delay_ms[0]);
if (num_bytes == sizeof(int64) * 2)
}
if (num_bytes == sizeof(int64) * 2) {
OnScheduleWork(delay_ms[1]);
}
}
if (GetTimeIntervalMilliseconds(delayed_work_time_) == 0) {

View File

@@ -72,8 +72,9 @@ MainMessageLoopExternalPumpWin::MainMessageLoopExternalPumpWin()
MainMessageLoopExternalPumpWin::~MainMessageLoopExternalPumpWin() {
KillTimer();
if (main_thread_target_)
if (main_thread_target_) {
DestroyWindow(main_thread_target_);
}
}
void MainMessageLoopExternalPumpWin::Quit() {

View File

@@ -16,15 +16,17 @@ bool GetResourceDir(std::string& dir) {
// Retrieve the executable path.
ssize_t len = readlink("/proc/self/exe", buff, sizeof(buff) - 1);
if (len == -1)
if (len == -1) {
return false;
}
buff[len] = 0;
// Remove the executable name from the path.
char* pos = strrchr(buff, '/');
if (!pos)
if (!pos) {
return false;
}
// Add "files" to the path.
strcpy(pos + 1, "files");

View File

@@ -22,13 +22,15 @@ bool FileExists(const char* path) {
bool ReadFileToString(const char* path, std::string& data) {
// Implementation adapted from base/file_util.cc
FILE* file = fopen(path, "rb");
if (!file)
if (!file) {
return false;
}
char buf[1 << 16];
size_t len;
while ((len = fread(buf, 1, sizeof(buf), file)) > 0)
while ((len = fread(buf, 1, sizeof(buf), file)) > 0) {
data.append(buf, len);
}
fclose(file);
return true;
@@ -38,8 +40,9 @@ bool ReadFileToString(const char* path, std::string& data) {
bool LoadBinaryResource(const char* resource_name, std::string& resource_data) {
std::string path;
if (!GetResourceDir(path))
if (!GetResourceDir(path)) {
return false;
}
path.append("/");
path.append(resource_name);
@@ -49,14 +52,16 @@ bool LoadBinaryResource(const char* resource_name, std::string& resource_data) {
CefRefPtr<CefStreamReader> GetBinaryResourceReader(const char* resource_name) {
std::string path;
if (!GetResourceDir(path))
if (!GetResourceDir(path)) {
return nullptr;
}
path.append("/");
path.append(resource_name);
if (!FileExists(path.c_str()))
if (!FileExists(path.c_str())) {
return nullptr;
}
return CefStreamReader::CreateForFile(path);
}

View File

@@ -22,8 +22,9 @@ bool LoadBinaryResource(int binaryId, DWORD& dwSize, LPBYTE& pBytes) {
if (hGlob) {
dwSize = SizeofResource(hInst, hRes);
pBytes = (LPBYTE)LockResource(hGlob);
if (dwSize > 0 && pBytes)
if (dwSize > 0 && pBytes) {
return true;
}
}
}
@@ -56,8 +57,9 @@ class BinaryResourceProvider : public CefResourceManager::Provider {
std::string relative_path = url.substr(url_path_.length());
if (!relative_path.empty()) {
if (!resource_path_prefix_.empty())
if (!resource_path_prefix_.empty()) {
relative_path = resource_path_prefix_ + relative_path;
}
CefRefPtr<CefStreamReader> stream =
GetBinaryResourceReader(relative_path.data());
@@ -85,8 +87,9 @@ extern int GetResourceId(const char* resource_name);
bool LoadBinaryResource(const char* resource_name, std::string& resource_data) {
int resource_id = GetResourceId(resource_name);
if (resource_id == 0)
if (resource_id == 0) {
return false;
}
DWORD dwSize;
LPBYTE pBytes;
@@ -102,8 +105,9 @@ bool LoadBinaryResource(const char* resource_name, std::string& resource_data) {
CefRefPtr<CefStreamReader> GetBinaryResourceReader(const char* resource_name) {
int resource_id = GetResourceId(resource_name);
if (resource_id == 0)
if (resource_id == 0) {
return nullptr;
}
DWORD dwSize;
LPBYTE pBytes;

View File

@@ -50,46 +50,60 @@ std::wstring GetResourceString(UINT id) {
int GetCefMouseModifiers(WPARAM wparam) {
int modifiers = 0;
if (wparam & MK_CONTROL)
if (wparam & MK_CONTROL) {
modifiers |= EVENTFLAG_CONTROL_DOWN;
if (wparam & MK_SHIFT)
}
if (wparam & MK_SHIFT) {
modifiers |= EVENTFLAG_SHIFT_DOWN;
if (IsKeyDown(VK_MENU))
}
if (IsKeyDown(VK_MENU)) {
modifiers |= EVENTFLAG_ALT_DOWN;
if (wparam & MK_LBUTTON)
}
if (wparam & MK_LBUTTON) {
modifiers |= EVENTFLAG_LEFT_MOUSE_BUTTON;
if (wparam & MK_MBUTTON)
}
if (wparam & MK_MBUTTON) {
modifiers |= EVENTFLAG_MIDDLE_MOUSE_BUTTON;
if (wparam & MK_RBUTTON)
}
if (wparam & MK_RBUTTON) {
modifiers |= EVENTFLAG_RIGHT_MOUSE_BUTTON;
}
// Low bit set from GetKeyState indicates "toggled".
if (::GetKeyState(VK_NUMLOCK) & 1)
if (::GetKeyState(VK_NUMLOCK) & 1) {
modifiers |= EVENTFLAG_NUM_LOCK_ON;
if (::GetKeyState(VK_CAPITAL) & 1)
}
if (::GetKeyState(VK_CAPITAL) & 1) {
modifiers |= EVENTFLAG_CAPS_LOCK_ON;
}
return modifiers;
}
int GetCefKeyboardModifiers(WPARAM wparam, LPARAM lparam) {
int modifiers = 0;
if (IsKeyDown(VK_SHIFT))
if (IsKeyDown(VK_SHIFT)) {
modifiers |= EVENTFLAG_SHIFT_DOWN;
if (IsKeyDown(VK_CONTROL))
}
if (IsKeyDown(VK_CONTROL)) {
modifiers |= EVENTFLAG_CONTROL_DOWN;
if (IsKeyDown(VK_MENU))
}
if (IsKeyDown(VK_MENU)) {
modifiers |= EVENTFLAG_ALT_DOWN;
}
// Low bit set from GetKeyState indicates "toggled".
if (::GetKeyState(VK_NUMLOCK) & 1)
if (::GetKeyState(VK_NUMLOCK) & 1) {
modifiers |= EVENTFLAG_NUM_LOCK_ON;
if (::GetKeyState(VK_CAPITAL) & 1)
}
if (::GetKeyState(VK_CAPITAL) & 1) {
modifiers |= EVENTFLAG_CAPS_LOCK_ON;
}
switch (wparam) {
case VK_RETURN:
if ((lparam >> 16) & KF_EXTENDED)
if ((lparam >> 16) & KF_EXTENDED) {
modifiers |= EVENTFLAG_IS_KEY_PAD;
}
break;
case VK_INSERT:
case VK_DELETE:
@@ -101,8 +115,9 @@ int GetCefKeyboardModifiers(WPARAM wparam, LPARAM lparam) {
case VK_DOWN:
case VK_LEFT:
case VK_RIGHT:
if (!((lparam >> 16) & KF_EXTENDED))
if (!((lparam >> 16) & KF_EXTENDED)) {
modifiers |= EVENTFLAG_IS_KEY_PAD;
}
break;
case VK_NUMLOCK:
case VK_NUMPAD0:
@@ -124,22 +139,25 @@ int GetCefKeyboardModifiers(WPARAM wparam, LPARAM lparam) {
modifiers |= EVENTFLAG_IS_KEY_PAD;
break;
case VK_SHIFT:
if (IsKeyDown(VK_LSHIFT))
if (IsKeyDown(VK_LSHIFT)) {
modifiers |= EVENTFLAG_IS_LEFT;
else if (IsKeyDown(VK_RSHIFT))
} else if (IsKeyDown(VK_RSHIFT)) {
modifiers |= EVENTFLAG_IS_RIGHT;
}
break;
case VK_CONTROL:
if (IsKeyDown(VK_LCONTROL))
if (IsKeyDown(VK_LCONTROL)) {
modifiers |= EVENTFLAG_IS_LEFT;
else if (IsKeyDown(VK_RCONTROL))
} else if (IsKeyDown(VK_RCONTROL)) {
modifiers |= EVENTFLAG_IS_RIGHT;
}
break;
case VK_MENU:
if (IsKeyDown(VK_LMENU))
if (IsKeyDown(VK_LMENU)) {
modifiers |= EVENTFLAG_IS_LEFT;
else if (IsKeyDown(VK_RMENU))
} else if (IsKeyDown(VK_RMENU)) {
modifiers |= EVENTFLAG_IS_RIGHT;
}
break;
case VK_LWIN:
modifiers |= EVENTFLAG_IS_LEFT;

View File

@@ -25,15 +25,18 @@ ClientApp::ClientApp() {}
ClientApp::ProcessType ClientApp::GetProcessType(
CefRefPtr<CefCommandLine> command_line) {
// The command-line flag won't be specified for the browser process.
if (!command_line->HasSwitch(kProcessType))
if (!command_line->HasSwitch(kProcessType)) {
return BrowserProcess;
}
const std::string& process_type = command_line->GetSwitchValue(kProcessType);
if (process_type == kRendererProcess)
if (process_type == kRendererProcess) {
return RendererProcess;
}
#if defined(OS_LINUX)
else if (process_type == kZygoteProcess)
else if (process_type == kZygoteProcess) {
return ZygoteProcess;
}
#endif
return OtherProcess;

View File

@@ -21,15 +21,17 @@ int RunMain(int argc, char* argv[]) {
#if defined(CEF_USE_SANDBOX)
// Initialize the macOS sandbox for this helper process.
CefScopedSandboxContext sandbox_context;
if (!sandbox_context.Initialize(argc, argv))
if (!sandbox_context.Initialize(argc, argv)) {
return 1;
}
#endif
// Load the CEF framework library at runtime instead of linking directly
// as required by the macOS sandbox implementation.
CefScopedLibraryLoader library_loader;
if (!library_loader.LoadInHelper())
if (!library_loader.LoadInHelper()) {
return 1;
}
CefMainArgs main_args(argc, argv);
@@ -40,10 +42,11 @@ int RunMain(int argc, char* argv[]) {
// Create a ClientApp of the correct type.
CefRefPtr<CefApp> app;
ClientApp::ProcessType process_type = ClientApp::GetProcessType(command_line);
if (process_type == ClientApp::RendererProcess)
if (process_type == ClientApp::RendererProcess) {
app = new ClientAppRenderer();
else if (process_type == ClientApp::OtherProcess)
} else if (process_type == ClientApp::OtherProcess) {
app = new ClientAppOther();
}
// Execute the secondary process.
return CefExecuteProcess(main_args, app, nullptr);

View File

@@ -14,29 +14,33 @@ ClientAppRenderer::ClientAppRenderer() {
void ClientAppRenderer::OnWebKitInitialized() {
DelegateSet::iterator it = delegates_.begin();
for (; it != delegates_.end(); ++it)
for (; it != delegates_.end(); ++it) {
(*it)->OnWebKitInitialized(this);
}
}
void ClientAppRenderer::OnBrowserCreated(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDictionaryValue> extra_info) {
DelegateSet::iterator it = delegates_.begin();
for (; it != delegates_.end(); ++it)
for (; it != delegates_.end(); ++it) {
(*it)->OnBrowserCreated(this, browser, extra_info);
}
}
void ClientAppRenderer::OnBrowserDestroyed(CefRefPtr<CefBrowser> browser) {
DelegateSet::iterator it = delegates_.begin();
for (; it != delegates_.end(); ++it)
for (; it != delegates_.end(); ++it) {
(*it)->OnBrowserDestroyed(this, browser);
}
}
CefRefPtr<CefLoadHandler> ClientAppRenderer::GetLoadHandler() {
CefRefPtr<CefLoadHandler> load_handler;
DelegateSet::iterator it = delegates_.begin();
for (; it != delegates_.end() && !load_handler.get(); ++it)
for (; it != delegates_.end() && !load_handler.get(); ++it) {
load_handler = (*it)->GetLoadHandler(this);
}
return load_handler;
}
@@ -45,16 +49,18 @@ void ClientAppRenderer::OnContextCreated(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefV8Context> context) {
DelegateSet::iterator it = delegates_.begin();
for (; it != delegates_.end(); ++it)
for (; it != delegates_.end(); ++it) {
(*it)->OnContextCreated(this, browser, frame, context);
}
}
void ClientAppRenderer::OnContextReleased(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefV8Context> context) {
DelegateSet::iterator it = delegates_.begin();
for (; it != delegates_.end(); ++it)
for (; it != delegates_.end(); ++it) {
(*it)->OnContextReleased(this, browser, frame, context);
}
}
void ClientAppRenderer::OnUncaughtException(
@@ -74,8 +80,9 @@ void ClientAppRenderer::OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefDOMNode> node) {
DelegateSet::iterator it = delegates_.begin();
for (; it != delegates_.end(); ++it)
for (; it != delegates_.end(); ++it) {
(*it)->OnFocusedNodeChanged(this, browser, frame, node);
}
}
bool ClientAppRenderer::OnProcessMessageReceived(