mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Update source files for bracket style
This commit is contained in:
@@ -87,12 +87,14 @@ void AlloyContentClient::AddPlugins(
|
||||
void AlloyContentClient::AddContentDecryptionModules(
|
||||
std::vector<content::CdmInfo>* cdms,
|
||||
std::vector<media::CdmHostFilePath>* cdm_host_file_paths) {
|
||||
if (cdms)
|
||||
if (cdms) {
|
||||
RegisterCdmInfo(cdms);
|
||||
}
|
||||
|
||||
#if BUILDFLAG(ENABLE_CDM_HOST_VERIFICATION)
|
||||
if (cdm_host_file_paths)
|
||||
if (cdm_host_file_paths) {
|
||||
cef::AddCdmHostFilePaths(cdm_host_file_paths);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -103,8 +105,9 @@ void AlloyContentClient::AddAdditionalSchemes(Schemes* schemes) {
|
||||
std::u16string AlloyContentClient::GetLocalizedString(int message_id) {
|
||||
std::u16string value =
|
||||
ui::ResourceBundle::GetSharedInstance().GetLocalizedString(message_id);
|
||||
if (value.empty())
|
||||
if (value.empty()) {
|
||||
LOG(ERROR) << "No localized string available for id " << message_id;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
@@ -113,8 +116,9 @@ std::u16string AlloyContentClient::GetLocalizedString(
|
||||
int message_id,
|
||||
const std::u16string& replacement) {
|
||||
std::u16string value = l10n_util::GetStringFUTF16(message_id, replacement);
|
||||
if (value.empty())
|
||||
if (value.empty()) {
|
||||
LOG(ERROR) << "No localized string available for id " << message_id;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
@@ -125,8 +129,9 @@ base::StringPiece AlloyContentClient::GetDataResource(
|
||||
base::StringPiece value =
|
||||
ui::ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(
|
||||
resource_id, scale_factor);
|
||||
if (value.empty())
|
||||
if (value.empty()) {
|
||||
LOG(ERROR) << "No data resource available for id " << resource_id;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
@@ -136,8 +141,9 @@ base::RefCountedMemory* AlloyContentClient::GetDataResourceBytes(
|
||||
base::RefCountedMemory* value =
|
||||
ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes(
|
||||
resource_id);
|
||||
if (!value)
|
||||
if (!value) {
|
||||
LOG(ERROR) << "No data resource bytes available for id " << resource_id;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
@@ -145,8 +151,9 @@ base::RefCountedMemory* AlloyContentClient::GetDataResourceBytes(
|
||||
gfx::Image& AlloyContentClient::GetNativeImageNamed(int resource_id) {
|
||||
gfx::Image& value =
|
||||
ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id);
|
||||
if (value.IsEmpty())
|
||||
if (value.IsEmpty()) {
|
||||
LOG(ERROR) << "No native image available for id " << resource_id;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
@@ -128,20 +128,23 @@ absl::optional<int> AlloyMainDelegate::BasicStartupComplete() {
|
||||
if (settings_->framework_dir_path.length > 0) {
|
||||
base::FilePath file_path =
|
||||
base::FilePath(CefString(&settings_->framework_dir_path));
|
||||
if (!file_path.empty())
|
||||
if (!file_path.empty()) {
|
||||
command_line->AppendSwitchPath(switches::kFrameworkDirPath, file_path);
|
||||
}
|
||||
}
|
||||
|
||||
if (settings_->main_bundle_path.length > 0) {
|
||||
base::FilePath file_path =
|
||||
base::FilePath(CefString(&settings_->main_bundle_path));
|
||||
if (!file_path.empty())
|
||||
if (!file_path.empty()) {
|
||||
command_line->AppendSwitchPath(switches::kMainBundlePath, file_path);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (no_sandbox)
|
||||
if (no_sandbox) {
|
||||
command_line->AppendSwitch(sandbox::policy::switches::kNoSandbox);
|
||||
}
|
||||
|
||||
if (settings_->user_agent.length > 0) {
|
||||
command_line->AppendSwitchASCII(
|
||||
@@ -162,18 +165,22 @@ absl::optional<int> AlloyMainDelegate::BasicStartupComplete() {
|
||||
|
||||
base::FilePath log_file;
|
||||
bool has_log_file_cmdline = false;
|
||||
if (settings_->log_file.length > 0)
|
||||
if (settings_->log_file.length > 0) {
|
||||
log_file = base::FilePath(CefString(&settings_->log_file));
|
||||
}
|
||||
if (log_file.empty() && command_line->HasSwitch(switches::kLogFile)) {
|
||||
log_file = command_line->GetSwitchValuePath(switches::kLogFile);
|
||||
if (!log_file.empty())
|
||||
if (!log_file.empty()) {
|
||||
has_log_file_cmdline = true;
|
||||
}
|
||||
}
|
||||
if (log_file.empty())
|
||||
if (log_file.empty()) {
|
||||
log_file = resource_util::GetDefaultLogFilePath();
|
||||
}
|
||||
DCHECK(!log_file.empty());
|
||||
if (!has_log_file_cmdline)
|
||||
if (!has_log_file_cmdline) {
|
||||
command_line->AppendSwitchPath(switches::kLogFile, log_file);
|
||||
}
|
||||
|
||||
if (settings_->log_severity != LOGSEVERITY_DEFAULT) {
|
||||
std::string log_severity;
|
||||
@@ -199,8 +206,9 @@ absl::optional<int> AlloyMainDelegate::BasicStartupComplete() {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (!log_severity.empty())
|
||||
if (!log_severity.empty()) {
|
||||
command_line->AppendSwitchASCII(switches::kLogSeverity, log_severity);
|
||||
}
|
||||
}
|
||||
|
||||
if (settings_->javascript_flags.length > 0) {
|
||||
@@ -224,8 +232,9 @@ absl::optional<int> AlloyMainDelegate::BasicStartupComplete() {
|
||||
if (settings_->locales_dir_path.length > 0) {
|
||||
base::FilePath file_path =
|
||||
base::FilePath(CefString(&settings_->locales_dir_path));
|
||||
if (!file_path.empty())
|
||||
if (!file_path.empty()) {
|
||||
command_line->AppendSwitchPath(switches::kLocalesDirPath, file_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,8 +281,9 @@ absl::optional<int> AlloyMainDelegate::BasicStartupComplete() {
|
||||
std::string disable_features_str =
|
||||
command_line->GetSwitchValueASCII(switches::kDisableFeatures);
|
||||
for (auto feature_str : disable_features) {
|
||||
if (!disable_features_str.empty())
|
||||
if (!disable_features_str.empty()) {
|
||||
disable_features_str += ",";
|
||||
}
|
||||
disable_features_str += feature_str;
|
||||
}
|
||||
command_line->AppendSwitchASCII(switches::kDisableFeatures,
|
||||
@@ -368,8 +378,9 @@ void AlloyMainDelegate::PreSandboxStartup() {
|
||||
|
||||
resource_util::OverrideUserDataDir(settings_, command_line);
|
||||
|
||||
if (command_line->HasSwitch(switches::kDisablePackLoading))
|
||||
if (command_line->HasSwitch(switches::kDisablePackLoading)) {
|
||||
resource_bundle_delegate_.set_pack_loading_disabled(true);
|
||||
}
|
||||
|
||||
// Initialize crash reporting state for this process/module.
|
||||
// chrome::DIR_CRASH_DUMPS must be configured before calling this function.
|
||||
@@ -425,8 +436,9 @@ content::ContentUtilityClient* AlloyMainDelegate::CreateContentUtilityClient() {
|
||||
}
|
||||
|
||||
CefRefPtr<CefRequestContext> AlloyMainDelegate::GetGlobalRequestContext() {
|
||||
if (!browser_client_)
|
||||
if (!browser_client_) {
|
||||
return nullptr;
|
||||
}
|
||||
return browser_client_->request_context();
|
||||
}
|
||||
|
||||
@@ -441,36 +453,41 @@ CefBrowserContext* AlloyMainDelegate::CreateNewBrowserContext(
|
||||
|
||||
scoped_refptr<base::SingleThreadTaskRunner>
|
||||
AlloyMainDelegate::GetBackgroundTaskRunner() {
|
||||
if (browser_client_)
|
||||
if (browser_client_) {
|
||||
return browser_client_->background_task_runner();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
scoped_refptr<base::SingleThreadTaskRunner>
|
||||
AlloyMainDelegate::GetUserVisibleTaskRunner() {
|
||||
if (browser_client_)
|
||||
if (browser_client_) {
|
||||
return browser_client_->user_visible_task_runner();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
scoped_refptr<base::SingleThreadTaskRunner>
|
||||
AlloyMainDelegate::GetUserBlockingTaskRunner() {
|
||||
if (browser_client_)
|
||||
if (browser_client_) {
|
||||
return browser_client_->user_blocking_task_runner();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
scoped_refptr<base::SingleThreadTaskRunner>
|
||||
AlloyMainDelegate::GetRenderTaskRunner() {
|
||||
if (renderer_client_)
|
||||
if (renderer_client_) {
|
||||
return renderer_client_->render_task_runner();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
scoped_refptr<base::SingleThreadTaskRunner>
|
||||
AlloyMainDelegate::GetWebWorkerTaskRunner() {
|
||||
if (renderer_client_)
|
||||
if (renderer_client_) {
|
||||
return renderer_client_->GetCurrentTaskRunner();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -485,10 +502,12 @@ void AlloyMainDelegate::InitializeResourceBundle() {
|
||||
resources_dir =
|
||||
command_line->GetSwitchValuePath(switches::kResourcesDirPath);
|
||||
}
|
||||
if (resources_dir.empty())
|
||||
if (resources_dir.empty()) {
|
||||
resources_dir = resource_util::GetResourcesDir();
|
||||
if (!resources_dir.empty())
|
||||
}
|
||||
if (!resources_dir.empty()) {
|
||||
base::PathService::Override(chrome::DIR_RESOURCES, resources_dir);
|
||||
}
|
||||
|
||||
if (!resource_bundle_delegate_.pack_loading_disabled()) {
|
||||
if (!resources_dir.empty()) {
|
||||
@@ -501,11 +520,13 @@ void AlloyMainDelegate::InitializeResourceBundle() {
|
||||
resources_dir.Append(FILE_PATH_LITERAL("chrome_200_percent.pak"));
|
||||
}
|
||||
|
||||
if (command_line->HasSwitch(switches::kLocalesDirPath))
|
||||
if (command_line->HasSwitch(switches::kLocalesDirPath)) {
|
||||
locales_dir = command_line->GetSwitchValuePath(switches::kLocalesDirPath);
|
||||
}
|
||||
|
||||
if (!locales_dir.empty())
|
||||
if (!locales_dir.empty()) {
|
||||
base::PathService::Override(ui::DIR_LOCALES, locales_dir);
|
||||
}
|
||||
}
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
@@ -516,8 +537,9 @@ void AlloyMainDelegate::InitializeResourceBundle() {
|
||||
// https://crbug.com/1178117.
|
||||
auto module_handle =
|
||||
::GetModuleHandle(CefAppManager::Get()->GetResourceDllName());
|
||||
if (!module_handle)
|
||||
if (!module_handle) {
|
||||
module_handle = ::GetModuleHandle(NULL);
|
||||
}
|
||||
|
||||
ui::SetResourcesDataDLL(module_handle);
|
||||
#endif
|
||||
@@ -529,14 +551,16 @@ void AlloyMainDelegate::InitializeResourceBundle() {
|
||||
ui::ResourceBundle::InitSharedInstanceWithLocale(
|
||||
locale, &resource_bundle_delegate_,
|
||||
ui::ResourceBundle::LOAD_COMMON_RESOURCES);
|
||||
if (!loaded_locale.empty() && g_browser_process)
|
||||
if (!loaded_locale.empty() && g_browser_process) {
|
||||
g_browser_process->SetApplicationLocale(loaded_locale);
|
||||
}
|
||||
|
||||
ui::ResourceBundle& resource_bundle = ui::ResourceBundle::GetSharedInstance();
|
||||
|
||||
if (!resource_bundle_delegate_.pack_loading_disabled()) {
|
||||
if (loaded_locale.empty())
|
||||
if (loaded_locale.empty()) {
|
||||
LOG(ERROR) << "Could not load locale pak for " << locale;
|
||||
}
|
||||
|
||||
resource_bundle_delegate_.set_allow_pack_file_load(true);
|
||||
|
||||
|
@@ -50,20 +50,23 @@ void CefAppManager::AddCustomScheme(CefSchemeInfo* scheme_info) {
|
||||
// resource_dispatcher_host_impl.cc ShouldServiceRequest.
|
||||
content::ChildProcessSecurityPolicy* policy =
|
||||
content::ChildProcessSecurityPolicy::GetInstance();
|
||||
if (!policy->IsWebSafeScheme(scheme_info->scheme_name))
|
||||
if (!policy->IsWebSafeScheme(scheme_info->scheme_name)) {
|
||||
policy->RegisterWebSafeScheme(scheme_info->scheme_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CefAppManager::HasCustomScheme(const std::string& scheme_name) {
|
||||
DCHECK(scheme_info_list_locked_);
|
||||
if (scheme_info_list_.empty())
|
||||
if (scheme_info_list_.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SchemeInfoList::const_iterator it = scheme_info_list_.begin();
|
||||
for (; it != scheme_info_list_.end(); ++it) {
|
||||
if (it->scheme_name == scheme_name)
|
||||
if (it->scheme_name == scheme_name) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@@ -26,8 +26,9 @@ CEF_EXPORT void cef_trace_event_instant(const char* /* category */,
|
||||
uint64 arg2_val,
|
||||
int copy) {
|
||||
DCHECK(name);
|
||||
if (!name)
|
||||
if (!name) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (copy) {
|
||||
if (arg1_name == nullptr && arg2_name == nullptr) {
|
||||
@@ -60,8 +61,9 @@ CEF_EXPORT void cef_trace_event_begin(const char* /* category */,
|
||||
uint64 arg2_val,
|
||||
int copy) {
|
||||
DCHECK(name);
|
||||
if (!name)
|
||||
if (!name) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (copy) {
|
||||
if (arg1_name == nullptr && arg2_name == nullptr) {
|
||||
@@ -93,8 +95,9 @@ CEF_EXPORT void cef_trace_event_end(const char* /* category */,
|
||||
uint64 arg2_val,
|
||||
int copy) {
|
||||
DCHECK(name);
|
||||
if (!name)
|
||||
if (!name) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (copy) {
|
||||
if (arg1_name == nullptr && arg2_name == nullptr) {
|
||||
@@ -126,8 +129,9 @@ CEF_EXPORT void cef_trace_counter(const char* /* category */,
|
||||
uint64 value2_val,
|
||||
int copy) {
|
||||
DCHECK(name);
|
||||
if (!name)
|
||||
if (!name) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (copy) {
|
||||
if (value1_name == nullptr && value2_name == nullptr) {
|
||||
@@ -155,8 +159,9 @@ CEF_EXPORT void cef_trace_counter_id(const char* /* category */,
|
||||
uint64 value2_val,
|
||||
int copy) {
|
||||
DCHECK(name);
|
||||
if (!name)
|
||||
if (!name) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (copy) {
|
||||
if (value1_name == nullptr && value2_name == nullptr) {
|
||||
@@ -184,8 +189,9 @@ CEF_EXPORT void cef_trace_event_async_begin(const char* /* category */,
|
||||
uint64 arg2_val,
|
||||
int copy) {
|
||||
DCHECK(name);
|
||||
if (!name)
|
||||
if (!name) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (copy) {
|
||||
if (arg1_name == nullptr && arg2_name == nullptr) {
|
||||
@@ -216,8 +222,9 @@ CEF_EXPORT void cef_trace_event_async_step_into(const char* /* category */,
|
||||
uint64 arg1_val,
|
||||
int copy) {
|
||||
DCHECK(name);
|
||||
if (!name)
|
||||
if (!name) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (copy) {
|
||||
if (arg1_name == nullptr) {
|
||||
@@ -247,8 +254,9 @@ CEF_EXPORT void cef_trace_event_async_step_past(const char* /* category */,
|
||||
uint64 arg1_val,
|
||||
int copy) {
|
||||
DCHECK(name);
|
||||
if (!name)
|
||||
if (!name) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (copy) {
|
||||
if (arg1_name == nullptr) {
|
||||
@@ -279,8 +287,9 @@ CEF_EXPORT void cef_trace_event_async_end(const char* /* category */,
|
||||
uint64 arg2_val,
|
||||
int copy) {
|
||||
DCHECK(name);
|
||||
if (!name)
|
||||
if (!name) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (copy) {
|
||||
if (arg1_name == nullptr && arg2_name == nullptr) {
|
||||
|
@@ -45,8 +45,9 @@ void CefCrashReportUploadThread::ProcessPendingReports() {
|
||||
// Count how many reports have completed in the last 24 hours.
|
||||
recent_upload_ct_ = 0;
|
||||
for (const CrashReportDatabase::Report& report : reports) {
|
||||
if (report.last_upload_attempt_time > now - kSeconds)
|
||||
if (report.last_upload_attempt_time > now - kSeconds) {
|
||||
recent_upload_ct_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,8 +60,8 @@ void CefCrashReportUploadThread::ProcessPendingReport(
|
||||
// Always allow upload if it's been explicitly requested by the user.
|
||||
if (!report.upload_explicitly_requested) {
|
||||
if (!UploadsEnabled()) {
|
||||
// Don’t attempt an upload if there’s no URL or if uploads have been
|
||||
// disabled in the database’s settings.
|
||||
// Don't attempt an upload if there's no URL or if uploads have been
|
||||
// disabled in the database's settings.
|
||||
database_->SkipReportUpload(
|
||||
report.uuid, Metrics::CrashSkippedReason::kUploadsDisabled);
|
||||
return;
|
||||
@@ -92,7 +93,7 @@ void CefCrashReportUploadThread::ProcessPendingReport(
|
||||
case CrashReportDatabase::kReportNotFound:
|
||||
case CrashReportDatabase::kFileSystemError:
|
||||
case CrashReportDatabase::kDatabaseError:
|
||||
// In these cases, SkipReportUpload() might not work either, but it’s best
|
||||
// In these cases, SkipReportUpload() might not work either, but it's best
|
||||
// to at least try to get the report out of the way.
|
||||
database_->SkipReportUpload(report.uuid,
|
||||
Metrics::CrashSkippedReason::kDatabaseError);
|
||||
@@ -110,8 +111,9 @@ void CefCrashReportUploadThread::ProcessPendingReport(
|
||||
case UploadResult::kSuccess:
|
||||
// The upload completed successfully.
|
||||
database_->RecordUploadComplete(std::move(upload_report), response_body);
|
||||
if (MaxUploadsEnabled())
|
||||
if (MaxUploadsEnabled()) {
|
||||
recent_upload_ct_++;
|
||||
}
|
||||
ResetBackoff();
|
||||
break;
|
||||
case UploadResult::kPermanentFailure:
|
||||
@@ -148,8 +150,9 @@ bool CefCrashReportUploadThread::MaxUploadsExceeded() const {
|
||||
}
|
||||
|
||||
bool CefCrashReportUploadThread::BackoffPending() const {
|
||||
if (!options_.rate_limit)
|
||||
if (!options_.rate_limit) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Settings* const settings = database_->GetSettings();
|
||||
|
||||
@@ -157,16 +160,18 @@ bool CefCrashReportUploadThread::BackoffPending() const {
|
||||
if (settings->GetNextUploadAttemptTime(&next_upload_time) &&
|
||||
next_upload_time > 0) {
|
||||
const time_t now = time(nullptr);
|
||||
if (now < next_upload_time)
|
||||
if (now < next_upload_time) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CefCrashReportUploadThread::IncreaseBackoff() {
|
||||
if (!options_.rate_limit)
|
||||
if (!options_.rate_limit) {
|
||||
return;
|
||||
}
|
||||
|
||||
const int kHour = 60 * 60; // 1 hour
|
||||
const int kBackoffSchedule[] = {
|
||||
@@ -183,10 +188,12 @@ void CefCrashReportUploadThread::IncreaseBackoff() {
|
||||
Settings* settings = database_->GetSettings();
|
||||
|
||||
int backoff_step = 0;
|
||||
if (settings->GetBackoffStep(&backoff_step) && backoff_step < 0)
|
||||
if (settings->GetBackoffStep(&backoff_step) && backoff_step < 0) {
|
||||
backoff_step = 0;
|
||||
if (++backoff_step > kBackoffScheduleSize)
|
||||
}
|
||||
if (++backoff_step > kBackoffScheduleSize) {
|
||||
backoff_step = kBackoffScheduleSize;
|
||||
}
|
||||
|
||||
time_t next_upload_time = time(nullptr); // now
|
||||
next_upload_time += kBackoffSchedule[backoff_step - 1];
|
||||
@@ -203,8 +210,9 @@ void CefCrashReportUploadThread::IncreaseBackoff() {
|
||||
}
|
||||
|
||||
void CefCrashReportUploadThread::ResetBackoff() {
|
||||
if (!options_.rate_limit)
|
||||
if (!options_.rate_limit) {
|
||||
return;
|
||||
}
|
||||
|
||||
Settings* settings = database_->GetSettings();
|
||||
settings->SetBackoffStep(0);
|
||||
|
@@ -17,8 +17,9 @@ ParameterMap FilterParameters(const ParameterMap& parameters) {
|
||||
for (size_t i = 0; true; ++i) {
|
||||
const std::string& key = "K-" + std::string(1, 'A' + i);
|
||||
ParameterMap::iterator it = in_map.find(key);
|
||||
if (it == in_map.end())
|
||||
if (it == in_map.end()) {
|
||||
break;
|
||||
}
|
||||
key_map += it->second;
|
||||
in_map.erase(it);
|
||||
}
|
||||
|
@@ -19,12 +19,14 @@ ChromeContentClientCef::~ChromeContentClientCef() = default;
|
||||
void ChromeContentClientCef::AddContentDecryptionModules(
|
||||
std::vector<content::CdmInfo>* cdms,
|
||||
std::vector<media::CdmHostFilePath>* cdm_host_file_paths) {
|
||||
if (cdms)
|
||||
if (cdms) {
|
||||
RegisterCdmInfo(cdms);
|
||||
}
|
||||
|
||||
#if BUILDFLAG(ENABLE_CDM_HOST_VERIFICATION)
|
||||
if (cdm_host_file_paths)
|
||||
if (cdm_host_file_paths) {
|
||||
cef::AddCdmHostFilePaths(cdm_host_file_paths);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@@ -60,8 +60,9 @@ ChromeMainDelegateCef::~ChromeMainDelegateCef() = default;
|
||||
absl::optional<int> ChromeMainDelegateCef::BasicStartupComplete() {
|
||||
// Returns false if startup should proceed.
|
||||
auto result = ChromeMainDelegate::BasicStartupComplete();
|
||||
if (result.has_value())
|
||||
if (result.has_value()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
||||
|
||||
@@ -142,8 +143,9 @@ absl::optional<int> ChromeMainDelegateCef::BasicStartupComplete() {
|
||||
std::string disable_features_str =
|
||||
command_line->GetSwitchValueASCII(switches::kDisableFeatures);
|
||||
for (auto feature_str : disable_features) {
|
||||
if (!disable_features_str.empty())
|
||||
if (!disable_features_str.empty()) {
|
||||
disable_features_str += ",";
|
||||
}
|
||||
disable_features_str += feature_str;
|
||||
}
|
||||
command_line->AppendSwitchASCII(switches::kDisableFeatures,
|
||||
@@ -247,8 +249,9 @@ ChromeMainDelegateCef::CreateContentRendererClient() {
|
||||
|
||||
CefRefPtr<CefRequestContext> ChromeMainDelegateCef::GetGlobalRequestContext() {
|
||||
auto browser_client = content_browser_client();
|
||||
if (browser_client)
|
||||
if (browser_client) {
|
||||
return browser_client->request_context();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -263,40 +266,45 @@ CefBrowserContext* ChromeMainDelegateCef::CreateNewBrowserContext(
|
||||
scoped_refptr<base::SingleThreadTaskRunner>
|
||||
ChromeMainDelegateCef::GetBackgroundTaskRunner() {
|
||||
auto browser_client = content_browser_client();
|
||||
if (browser_client)
|
||||
if (browser_client) {
|
||||
return browser_client->background_task_runner();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
scoped_refptr<base::SingleThreadTaskRunner>
|
||||
ChromeMainDelegateCef::GetUserVisibleTaskRunner() {
|
||||
auto browser_client = content_browser_client();
|
||||
if (browser_client)
|
||||
if (browser_client) {
|
||||
return browser_client->user_visible_task_runner();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
scoped_refptr<base::SingleThreadTaskRunner>
|
||||
ChromeMainDelegateCef::GetUserBlockingTaskRunner() {
|
||||
auto browser_client = content_browser_client();
|
||||
if (browser_client)
|
||||
if (browser_client) {
|
||||
return browser_client->user_blocking_task_runner();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
scoped_refptr<base::SingleThreadTaskRunner>
|
||||
ChromeMainDelegateCef::GetRenderTaskRunner() {
|
||||
auto renderer_client = content_renderer_client();
|
||||
if (renderer_client)
|
||||
if (renderer_client) {
|
||||
return renderer_client->render_task_runner();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
scoped_refptr<base::SingleThreadTaskRunner>
|
||||
ChromeMainDelegateCef::GetWebWorkerTaskRunner() {
|
||||
auto renderer_client = content_renderer_client();
|
||||
if (renderer_client)
|
||||
if (renderer_client) {
|
||||
return renderer_client->GetCurrentTaskRunner();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -308,7 +316,8 @@ ChromeContentBrowserClientCef* ChromeMainDelegateCef::content_browser_client()
|
||||
|
||||
ChromeContentRendererClientCef* ChromeMainDelegateCef::content_renderer_client()
|
||||
const {
|
||||
if (!g_chrome_content_renderer_client.IsCreated())
|
||||
if (!g_chrome_content_renderer_client.IsCreated()) {
|
||||
return nullptr;
|
||||
}
|
||||
return g_chrome_content_renderer_client.Pointer();
|
||||
}
|
@@ -65,8 +65,9 @@ void CefCommandLineImpl::GetArgv(std::vector<CefString>& argv) {
|
||||
CEF_VALUE_VERIFY_RETURN_VOID(false);
|
||||
const base::CommandLine::StringVector& cmd_argv = const_value().argv();
|
||||
base::CommandLine::StringVector::const_iterator it = cmd_argv.begin();
|
||||
for (; it != cmd_argv.end(); ++it)
|
||||
for (; it != cmd_argv.end(); ++it) {
|
||||
argv.push_back(*it);
|
||||
}
|
||||
}
|
||||
|
||||
CefString CefCommandLineImpl::GetCommandLineString() {
|
||||
@@ -104,8 +105,9 @@ void CefCommandLineImpl::GetSwitches(SwitchMap& switches) {
|
||||
CEF_VALUE_VERIFY_RETURN_VOID(false);
|
||||
const base::CommandLine::SwitchMap& map = const_value().GetSwitches();
|
||||
base::CommandLine::SwitchMap::const_iterator it = map.begin();
|
||||
for (; it != map.end(); ++it)
|
||||
for (; it != map.end(); ++it) {
|
||||
switches.insert(std::make_pair(it->first, it->second));
|
||||
}
|
||||
}
|
||||
|
||||
void CefCommandLineImpl::AppendSwitch(const CefString& name) {
|
||||
@@ -132,8 +134,9 @@ void CefCommandLineImpl::GetArguments(ArgumentList& arguments) {
|
||||
CEF_VALUE_VERIFY_RETURN_VOID(false);
|
||||
const base::CommandLine::StringVector& vec = const_value().GetArgs();
|
||||
base::CommandLine::StringVector::const_iterator it = vec.begin();
|
||||
for (; it != vec.end(); ++it)
|
||||
for (; it != vec.end(); ++it) {
|
||||
arguments.push_back(*it);
|
||||
}
|
||||
}
|
||||
|
||||
void CefCommandLineImpl::AppendArgument(const CefString& argument) {
|
||||
@@ -168,8 +171,9 @@ CefRefPtr<CefCommandLine> CefCommandLine::GetGlobalCommandLine() {
|
||||
static CefRefPtr<CefCommandLineImpl> commandLinePtr;
|
||||
if (!commandLinePtr.get()) {
|
||||
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
||||
if (command_line)
|
||||
if (command_line) {
|
||||
commandLinePtr = new CefCommandLineImpl(command_line, false, true);
|
||||
}
|
||||
}
|
||||
return commandLinePtr.get();
|
||||
}
|
||||
|
@@ -62,16 +62,18 @@ PathString GetCrashConfigPath() {
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
// Start with the path to the running executable.
|
||||
wchar_t module_path[MAX_PATH];
|
||||
if (GetModuleFileName(nullptr, module_path, MAX_PATH) == 0)
|
||||
if (GetModuleFileName(nullptr, module_path, MAX_PATH) == 0) {
|
||||
return PathString();
|
||||
}
|
||||
|
||||
PathString config_path = module_path;
|
||||
|
||||
// Remove the executable file name.
|
||||
PathString::size_type last_backslash =
|
||||
config_path.rfind(kPathSep, config_path.size());
|
||||
if (last_backslash != PathString::npos)
|
||||
if (last_backslash != PathString::npos) {
|
||||
config_path.erase(last_backslash + 1);
|
||||
}
|
||||
|
||||
config_path += L"crash_reporter.cfg";
|
||||
return config_path;
|
||||
@@ -86,8 +88,9 @@ PathString GetCrashConfigPath() {
|
||||
|
||||
if (config_path.empty()) {
|
||||
// Start with the path to the running executable.
|
||||
if (!base::PathService::Get(base::DIR_EXE, &config_path))
|
||||
if (!base::PathService::Get(base::DIR_EXE, &config_path)) {
|
||||
return PathString();
|
||||
}
|
||||
}
|
||||
|
||||
return config_path.Append(FILE_PATH_LITERAL("crash_reporter.cfg")).value();
|
||||
@@ -106,11 +109,13 @@ const unsigned maxFilenameLength = 255;
|
||||
const char kInvalidFileChars[] = "<>:\"/\\|?*";
|
||||
|
||||
bool isInvalidFileCharacter(unsigned char c) {
|
||||
if (c < ' ' || c == 0x7F)
|
||||
if (c < ' ' || c == 0x7F) {
|
||||
return true;
|
||||
}
|
||||
for (size_t i = 0; i < sizeof(kInvalidFileChars); ++i) {
|
||||
if (c == kInvalidFileChars[i])
|
||||
if (c == kInvalidFileChars[i]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -124,8 +129,9 @@ bool isAbsolutePath(const std::string& s) {
|
||||
}
|
||||
|
||||
std::string extractAbsolutePathStart(std::string& s) {
|
||||
if (!isAbsolutePath(s))
|
||||
if (!isAbsolutePath(s)) {
|
||||
return std::string();
|
||||
}
|
||||
|
||||
std::string start;
|
||||
if (s[0] == kPathSep) {
|
||||
@@ -141,14 +147,16 @@ std::string extractAbsolutePathStart(std::string& s) {
|
||||
}
|
||||
|
||||
std::string sanitizePathComponentPart(const std::string& s) {
|
||||
if (s.empty())
|
||||
if (s.empty()) {
|
||||
return std::string();
|
||||
}
|
||||
|
||||
std::string result;
|
||||
result.reserve(s.length());
|
||||
for (size_t i = 0; i < s.length(); ++i) {
|
||||
if (!isInvalidFileCharacter(s[i]))
|
||||
if (!isInvalidFileCharacter(s[i])) {
|
||||
result.push_back(s[i]);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -170,13 +178,15 @@ std::string sanitizePathComponent(const std::string& s) {
|
||||
ext = sanitizePathComponentPart(ext);
|
||||
|
||||
// Remove a ridiculously-long extension.
|
||||
if (ext.length() >= maxFilenameLength)
|
||||
if (ext.length() >= maxFilenameLength) {
|
||||
ext = std::string();
|
||||
}
|
||||
|
||||
// Truncate an overly-long filename, reserving one character for a dot.
|
||||
std::string::size_type max_name_len = maxFilenameLength - ext.length() - 1;
|
||||
if (name.length() > max_name_len)
|
||||
if (name.length() > max_name_len) {
|
||||
name = name.substr(0, max_name_len);
|
||||
}
|
||||
|
||||
return ext.empty() ? name : name + "." + ext;
|
||||
}
|
||||
@@ -193,10 +203,12 @@ std::string sanitizePath(const std::string& s) {
|
||||
base::SPLIT_WANT_NONEMPTY);
|
||||
for (size_t i = 0; i < parts.size(); ++i) {
|
||||
std::string part = parts[i];
|
||||
if (part != "." && part != "..")
|
||||
if (part != "." && part != "..") {
|
||||
part = sanitizePathComponent(part);
|
||||
if (!result.empty() && result[result.length() - 1] != kPathSep)
|
||||
}
|
||||
if (!result.empty() && result[result.length() - 1] != kPathSep) {
|
||||
result += kPathSep;
|
||||
}
|
||||
result += part;
|
||||
}
|
||||
|
||||
@@ -204,25 +216,31 @@ std::string sanitizePath(const std::string& s) {
|
||||
}
|
||||
|
||||
std::string joinPath(const std::string& s1, const std::string& s2) {
|
||||
if (s1.empty() && s2.empty())
|
||||
if (s1.empty() && s2.empty()) {
|
||||
return std::string();
|
||||
if (s1.empty())
|
||||
}
|
||||
if (s1.empty()) {
|
||||
return s2;
|
||||
if (s2.empty())
|
||||
}
|
||||
if (s2.empty()) {
|
||||
return s1;
|
||||
}
|
||||
|
||||
// Don't try to join absolute paths on Windows.
|
||||
// Skip this check on POSIX where it's more difficult to differentiate.
|
||||
if (isAbsolutePath(s2))
|
||||
if (isAbsolutePath(s2)) {
|
||||
return s2;
|
||||
}
|
||||
|
||||
std::string result = s1;
|
||||
if (result[result.size() - 1] != kPathSep)
|
||||
if (result[result.size() - 1] != kPathSep) {
|
||||
result += kPathSep;
|
||||
if (s2[0] == kPathSep)
|
||||
}
|
||||
if (s2[0] == kPathSep) {
|
||||
result += s2.substr(1);
|
||||
else
|
||||
} else {
|
||||
result += s2;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -260,8 +278,9 @@ bool ParseBool(const std::string& value) {
|
||||
|
||||
int ParseZeroBasedInt(const std::string& value) {
|
||||
int int_val;
|
||||
if (base::StringToInt(value, &int_val) && int_val > 0)
|
||||
if (base::StringToInt(value, &int_val) && int_val > 0) {
|
||||
return int_val;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -309,18 +328,21 @@ bool GetDefaultUserDataDirectory(std::wstring* result,
|
||||
if (user_data_dir.empty()) {
|
||||
// LOCALAPPDATA was not set; fallback to the temporary files path.
|
||||
DWORD size = ::GetTempPath(0, nullptr);
|
||||
if (!size)
|
||||
if (!size) {
|
||||
return false;
|
||||
}
|
||||
user_data_dir.resize(size + 1);
|
||||
size = ::GetTempPath(size + 1, &user_data_dir[0]);
|
||||
if (!size || size >= user_data_dir.size())
|
||||
if (!size || size >= user_data_dir.size()) {
|
||||
return false;
|
||||
}
|
||||
user_data_dir.resize(size);
|
||||
}
|
||||
|
||||
result->swap(user_data_dir);
|
||||
if ((*result)[result->length() - 1] != L'\\')
|
||||
if ((*result)[result->length() - 1] != L'\\') {
|
||||
result->push_back(L'\\');
|
||||
}
|
||||
result->append(install_sub_directory);
|
||||
result->push_back(L'\\');
|
||||
result->append(kUserDataDirname);
|
||||
@@ -334,13 +356,15 @@ bool GetDefaultCrashDumpLocation(std::wstring* crash_dir,
|
||||
// In order to be able to start crash handling very early, we do not rely on
|
||||
// chrome's PathService entries (for DIR_CRASH_DUMPS) being available on
|
||||
// Windows. See https://crbug.com/564398.
|
||||
if (!GetDefaultUserDataDirectory(crash_dir, install_sub_directory))
|
||||
if (!GetDefaultUserDataDirectory(crash_dir, install_sub_directory)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// We have to make sure the user data dir exists on first run. See
|
||||
// http://crbug.com/591504.
|
||||
if (!install_static::RecursiveDirectoryCreate(*crash_dir))
|
||||
if (!install_static::RecursiveDirectoryCreate(*crash_dir)) {
|
||||
return false;
|
||||
}
|
||||
crash_dir->append(L"\\Crashpad");
|
||||
return true;
|
||||
}
|
||||
@@ -352,20 +376,23 @@ CefCrashReporterClient::~CefCrashReporterClient() {}
|
||||
|
||||
// Be aware that logging is not initialized at the time this method is called.
|
||||
bool CefCrashReporterClient::ReadCrashConfigFile() {
|
||||
if (has_crash_config_file_)
|
||||
if (has_crash_config_file_) {
|
||||
return true;
|
||||
}
|
||||
|
||||
PathString config_path = GetCrashConfigPath();
|
||||
if (config_path.empty())
|
||||
if (config_path.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
FILE* fp = _wfopen(config_path.c_str(), L"r");
|
||||
#else
|
||||
FILE* fp = fopen(config_path.c_str(), "r");
|
||||
#endif
|
||||
if (!fp)
|
||||
if (!fp) {
|
||||
return false;
|
||||
}
|
||||
|
||||
char line[1000];
|
||||
|
||||
@@ -383,8 +410,9 @@ bool CefCrashReporterClient::ReadCrashConfigFile() {
|
||||
while (fgets(line, sizeof(line) - 1, fp) != nullptr) {
|
||||
std::string str = line;
|
||||
base::TrimString(str, base::kWhitespaceASCII, &str);
|
||||
if (str.empty() || str[0] == '#')
|
||||
if (str.empty() || str[0] == '#') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (str == "[Config]") {
|
||||
current_section = kConfigSection;
|
||||
@@ -397,19 +425,22 @@ bool CefCrashReporterClient::ReadCrashConfigFile() {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (current_section == kNoSection)
|
||||
if (current_section == kNoSection) {
|
||||
continue;
|
||||
}
|
||||
|
||||
size_t div = str.find('=');
|
||||
if (div == std::string::npos)
|
||||
if (div == std::string::npos) {
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string name_str = str.substr(0, div);
|
||||
base::TrimString(name_str, base::kWhitespaceASCII, &name_str);
|
||||
std::string val_str = str.substr(div + 1);
|
||||
base::TrimString(val_str, base::kWhitespaceASCII, &val_str);
|
||||
if (name_str.empty())
|
||||
if (name_str.empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (current_section == kConfigSection) {
|
||||
if (name_str == "ServerURL") {
|
||||
@@ -429,13 +460,15 @@ bool CefCrashReporterClient::ReadCrashConfigFile() {
|
||||
}
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
else if (name_str == "ExternalHandler") {
|
||||
if (!val_str.empty())
|
||||
if (!val_str.empty()) {
|
||||
external_handler_ = sanitizePath(val_str);
|
||||
}
|
||||
} else if (name_str == "AppName") {
|
||||
if (!val_str.empty()) {
|
||||
val_str = sanitizePathComponent(val_str);
|
||||
if (!val_str.empty())
|
||||
if (!val_str.empty()) {
|
||||
app_name_ = val_str;
|
||||
}
|
||||
}
|
||||
}
|
||||
#elif BUILDFLAG(IS_MAC)
|
||||
@@ -507,8 +540,9 @@ bool CefCrashReporterClient::ReadCrashConfigFile() {
|
||||
crashpad::Annotation::kValueMaxSize);
|
||||
ids[i].Set(base::StringPiece(map_keys.data() + offset, length));
|
||||
offset += length;
|
||||
if (offset >= map_keys.size())
|
||||
if (offset >= map_keys.size()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -537,14 +571,16 @@ bool CefCrashReporterClient::HasCrashConfigFile() const {
|
||||
|
||||
// static
|
||||
void CefCrashReporterClient::InitializeCrashReportingForProcess() {
|
||||
if (g_crash_reporter_client)
|
||||
if (g_crash_reporter_client) {
|
||||
return;
|
||||
}
|
||||
|
||||
g_crash_reporter_client = new CefCrashReporterClient();
|
||||
ANNOTATE_LEAKING_OBJECT_PTR(g_crash_reporter_client);
|
||||
|
||||
if (!g_crash_reporter_client->ReadCrashConfigFile())
|
||||
if (!g_crash_reporter_client->ReadCrashConfigFile()) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::wstring process_type = install_static::GetSwitchValueFromCommandLine(
|
||||
::GetCommandLineW(), install_static::kProcessType);
|
||||
@@ -589,8 +625,9 @@ void CefCrashReporterClient::GetProductNameAndVersion(
|
||||
bool CefCrashReporterClient::GetCrashDumpLocation(std::wstring* crash_dir) {
|
||||
// By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate
|
||||
// location to write breakpad crash dumps can be set.
|
||||
if (GetAlternativeCrashDumpLocation(crash_dir))
|
||||
if (GetAlternativeCrashDumpLocation(crash_dir)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return GetDefaultCrashDumpLocation(crash_dir, base::UTF8ToWide(app_name_));
|
||||
}
|
||||
@@ -652,8 +689,9 @@ std::string CefCrashReporterClient::GetUploadUrl() {
|
||||
// for supported arguments.
|
||||
void CefCrashReporterClient::GetCrashOptionalArguments(
|
||||
std::vector<std::string>* arguments) {
|
||||
if (!rate_limit_)
|
||||
if (!rate_limit_) {
|
||||
arguments->push_back(std::string("--no-rate-limit"));
|
||||
}
|
||||
|
||||
if (max_uploads_ > 0) {
|
||||
arguments->push_back(std::string("--max-uploads=") +
|
||||
@@ -675,10 +713,12 @@ void CefCrashReporterClient::GetCrashOptionalArguments(
|
||||
|
||||
std::wstring CefCrashReporterClient::GetCrashExternalHandler(
|
||||
const std::wstring& exe_dir) {
|
||||
if (external_handler_.empty())
|
||||
if (external_handler_.empty()) {
|
||||
return CrashReporterClient::GetCrashExternalHandler(exe_dir);
|
||||
if (isAbsolutePath(external_handler_))
|
||||
}
|
||||
if (isAbsolutePath(external_handler_)) {
|
||||
return base::UTF8ToWide(external_handler_);
|
||||
}
|
||||
return base::UTF8ToWide(
|
||||
joinPath(base::WideToUTF8(exe_dir), external_handler_));
|
||||
}
|
||||
@@ -738,12 +778,14 @@ IDKEY_FUNCTION(L, 1024)
|
||||
|
||||
bool CefCrashReporterClient::SetCrashKeyValue(const base::StringPiece& key,
|
||||
const base::StringPiece& value) {
|
||||
if (key.empty() || crash_keys_.empty())
|
||||
if (key.empty() || crash_keys_.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
KeyMap::const_iterator it = crash_keys_.find(NormalizeCrashKey(key));
|
||||
if (it == crash_keys_.end())
|
||||
if (it == crash_keys_.end()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const KeySize size = it->second.first;
|
||||
const size_t index = it->second.second;
|
||||
|
@@ -90,8 +90,9 @@ base::LazyInstance<CefCrashReporterClient>::Leaky g_crash_reporter_client =
|
||||
void InitCrashReporter(const base::CommandLine& command_line,
|
||||
const std::string& process_type) {
|
||||
CefCrashReporterClient* crash_client = g_crash_reporter_client.Pointer();
|
||||
if (!crash_client->HasCrashConfigFile())
|
||||
if (!crash_client->HasCrashConfigFile()) {
|
||||
return;
|
||||
}
|
||||
|
||||
crash_reporter::SetCrashReporterClient(crash_client);
|
||||
|
||||
@@ -139,8 +140,9 @@ void InitCrashReporter(const base::CommandLine& command_line,
|
||||
|
||||
// Used to exclude command-line flags from crash reporting.
|
||||
bool IsBoringCEFSwitch(const std::string& flag) {
|
||||
if (crash_keys::IsBoringChromeSwitch(flag))
|
||||
if (crash_keys::IsBoringChromeSwitch(flag)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static const char* const kIgnoreSwitches[] = {
|
||||
// CEF internals.
|
||||
@@ -154,14 +156,16 @@ bool IsBoringCEFSwitch(const std::string& flag) {
|
||||
"service-request-channel-token",
|
||||
};
|
||||
|
||||
if (!base::StartsWith(flag, "--", base::CompareCase::SENSITIVE))
|
||||
if (!base::StartsWith(flag, "--", base::CompareCase::SENSITIVE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t end = flag.find("=");
|
||||
size_t len = (end == std::string::npos) ? flag.length() - 2 : end - 2;
|
||||
for (size_t i = 0; i < std::size(kIgnoreSwitches); ++i) {
|
||||
if (flag.compare(2, len, kIgnoreSwitches[i]) == 0)
|
||||
if (flag.compare(2, len, kIgnoreSwitches[i]) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -174,8 +178,9 @@ bool Enabled() {
|
||||
|
||||
bool SetCrashKeyValue(const base::StringPiece& key,
|
||||
const base::StringPiece& value) {
|
||||
if (!g_crash_reporting_enabled)
|
||||
if (!g_crash_reporting_enabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
return SetCrashKeyValueTrampoline(key, value);
|
||||
|
@@ -102,28 +102,32 @@ CefString CefDragDataImpl::GetFileName() {
|
||||
|
||||
size_t CefDragDataImpl::GetFileContents(CefRefPtr<CefStreamWriter> writer) {
|
||||
base::AutoLock lock_scope(lock_);
|
||||
if (data_.file_contents.empty())
|
||||
if (data_.file_contents.empty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
char* data = const_cast<char*>(data_.file_contents.c_str());
|
||||
size_t size = data_.file_contents.size();
|
||||
|
||||
if (!writer.get())
|
||||
if (!writer.get()) {
|
||||
return size;
|
||||
}
|
||||
|
||||
return writer->Write(data, 1, size);
|
||||
}
|
||||
|
||||
bool CefDragDataImpl::GetFileNames(std::vector<CefString>& names) {
|
||||
base::AutoLock lock_scope(lock_);
|
||||
if (data_.filenames.empty())
|
||||
if (data_.filenames.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<ui::FileInfo>::const_iterator it = data_.filenames.begin();
|
||||
for (; it != data_.filenames.end(); ++it) {
|
||||
auto name = it->display_name.value();
|
||||
if (name.empty())
|
||||
if (name.empty()) {
|
||||
name = it->path.value();
|
||||
}
|
||||
names.push_back(name);
|
||||
}
|
||||
|
||||
@@ -190,8 +194,9 @@ void CefDragDataImpl::ClearFilenames() {
|
||||
|
||||
void CefDragDataImpl::SetReadOnly(bool read_only) {
|
||||
base::AutoLock lock_scope(lock_);
|
||||
if (read_only_ == read_only)
|
||||
if (read_only_ == read_only) {
|
||||
return;
|
||||
}
|
||||
|
||||
read_only_ = read_only;
|
||||
}
|
||||
|
@@ -14,15 +14,17 @@ namespace cef {
|
||||
|
||||
// static
|
||||
base::StringPiece ChromeGeneratedSchemas::Get(const std::string& name) {
|
||||
if (!ChromeFunctionRegistry::IsSupported(name))
|
||||
if (!ChromeFunctionRegistry::IsSupported(name)) {
|
||||
return base::StringPiece();
|
||||
}
|
||||
return extensions::api::ChromeGeneratedSchemas::Get(name);
|
||||
}
|
||||
|
||||
// static
|
||||
bool ChromeGeneratedSchemas::IsGenerated(std::string name) {
|
||||
if (!ChromeFunctionRegistry::IsSupported(name))
|
||||
if (!ChromeFunctionRegistry::IsSupported(name)) {
|
||||
return false;
|
||||
}
|
||||
return extensions::api::ChromeGeneratedSchemas::IsGenerated(name);
|
||||
}
|
||||
|
||||
|
@@ -7,7 +7,7 @@
|
||||
#include "libcef/common/extensions/chrome_generated_schemas.h"
|
||||
|
||||
#include "cef/grit/cef_resources.h"
|
||||
//#include "cef/libcef/common/extensions/api/generated_schemas.h"
|
||||
// #include "cef/libcef/common/extensions/api/generated_schemas.h"
|
||||
#include "cef/libcef/common/extensions/api/cef_api_features.h"
|
||||
#include "cef/libcef/common/extensions/api/cef_manifest_features.h"
|
||||
#include "cef/libcef/common/extensions/api/cef_permission_features.h"
|
||||
@@ -52,8 +52,9 @@ bool CefExtensionsAPIProvider::IsAPISchemaGenerated(const std::string& name) {
|
||||
// return true;
|
||||
|
||||
// Chrome APIs whitelisted by CEF.
|
||||
if (api::cef::ChromeGeneratedSchemas::IsGenerated(name))
|
||||
if (api::cef::ChromeGeneratedSchemas::IsGenerated(name)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -67,8 +68,9 @@ base::StringPiece CefExtensionsAPIProvider::GetAPISchema(
|
||||
// return api::cef::CefGeneratedSchemas::Get(name);
|
||||
|
||||
// Chrome APIs whitelisted by CEF.
|
||||
if (api::cef::ChromeGeneratedSchemas::IsGenerated(name))
|
||||
if (api::cef::ChromeGeneratedSchemas::IsGenerated(name)) {
|
||||
return api::cef::ChromeGeneratedSchemas::Get(name);
|
||||
}
|
||||
|
||||
return base::StringPiece();
|
||||
}
|
||||
|
@@ -29,8 +29,9 @@ bool PrintPreviewEnabled() {
|
||||
// Not currently supported on macOS.
|
||||
return false;
|
||||
#else
|
||||
if (!PdfExtensionEnabled())
|
||||
if (!PdfExtensionEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||
switches::kDisablePrintPreview)) {
|
||||
|
@@ -24,14 +24,16 @@ bool AllowFileIO() {
|
||||
} // namespace
|
||||
|
||||
bool CefCreateDirectory(const CefString& full_path) {
|
||||
if (!AllowFileIO())
|
||||
if (!AllowFileIO()) {
|
||||
return false;
|
||||
}
|
||||
return base::CreateDirectory(full_path);
|
||||
}
|
||||
|
||||
bool CefGetTempDirectory(CefString& temp_dir) {
|
||||
if (!AllowFileIO())
|
||||
if (!AllowFileIO()) {
|
||||
return false;
|
||||
}
|
||||
base::FilePath result;
|
||||
if (base::GetTempDir(&result)) {
|
||||
temp_dir = result.value();
|
||||
@@ -42,8 +44,9 @@ bool CefGetTempDirectory(CefString& temp_dir) {
|
||||
|
||||
bool CefCreateNewTempDirectory(const CefString& prefix,
|
||||
CefString& new_temp_path) {
|
||||
if (!AllowFileIO())
|
||||
if (!AllowFileIO()) {
|
||||
return false;
|
||||
}
|
||||
base::FilePath result;
|
||||
if (base::CreateNewTempDirectory(prefix, &result)) {
|
||||
new_temp_path = result.value();
|
||||
@@ -55,8 +58,9 @@ bool CefCreateNewTempDirectory(const CefString& prefix,
|
||||
bool CefCreateTempDirectoryInDirectory(const CefString& base_dir,
|
||||
const CefString& prefix,
|
||||
CefString& new_dir) {
|
||||
if (!AllowFileIO())
|
||||
if (!AllowFileIO()) {
|
||||
return false;
|
||||
}
|
||||
base::FilePath result;
|
||||
if (base::CreateTemporaryDirInDir(base_dir, prefix, &result)) {
|
||||
new_dir = result.value();
|
||||
@@ -66,14 +70,16 @@ bool CefCreateTempDirectoryInDirectory(const CefString& base_dir,
|
||||
}
|
||||
|
||||
bool CefDirectoryExists(const CefString& path) {
|
||||
if (!AllowFileIO())
|
||||
if (!AllowFileIO()) {
|
||||
return false;
|
||||
}
|
||||
return base::DirectoryExists(path);
|
||||
}
|
||||
|
||||
bool CefDeleteFile(const CefString& path, bool recursive) {
|
||||
if (!AllowFileIO())
|
||||
if (!AllowFileIO()) {
|
||||
return false;
|
||||
}
|
||||
if (recursive) {
|
||||
return base::DeletePathRecursively(path);
|
||||
} else {
|
||||
@@ -84,7 +90,8 @@ bool CefDeleteFile(const CefString& path, bool recursive) {
|
||||
bool CefZipDirectory(const CefString& src_dir,
|
||||
const CefString& dest_file,
|
||||
bool include_hidden_files) {
|
||||
if (!AllowFileIO())
|
||||
if (!AllowFileIO()) {
|
||||
return false;
|
||||
}
|
||||
return zip::Zip(src_dir, dest_file, include_hidden_files);
|
||||
}
|
||||
|
@@ -13,19 +13,23 @@ namespace {
|
||||
|
||||
int GetJSONReaderOptions(cef_json_parser_options_t options) {
|
||||
int op = base::JSON_PARSE_RFC;
|
||||
if (options & JSON_PARSER_ALLOW_TRAILING_COMMAS)
|
||||
if (options & JSON_PARSER_ALLOW_TRAILING_COMMAS) {
|
||||
op |= base::JSON_ALLOW_TRAILING_COMMAS;
|
||||
}
|
||||
return op;
|
||||
}
|
||||
|
||||
int GetJSONWriterOptions(cef_json_writer_options_t options) {
|
||||
int op = 0;
|
||||
if (options & JSON_WRITER_OMIT_BINARY_VALUES)
|
||||
if (options & JSON_WRITER_OMIT_BINARY_VALUES) {
|
||||
op |= base::JSONWriter::OPTIONS_OMIT_BINARY_VALUES;
|
||||
if (options & JSON_WRITER_OMIT_DOUBLE_TYPE_PRESERVATION)
|
||||
}
|
||||
if (options & JSON_WRITER_OMIT_DOUBLE_TYPE_PRESERVATION) {
|
||||
op |= base::JSONWriter::OPTIONS_OMIT_DOUBLE_TYPE_PRESERVATION;
|
||||
if (options & JSON_WRITER_PRETTY_PRINT)
|
||||
}
|
||||
if (options & JSON_WRITER_PRETTY_PRINT) {
|
||||
op |= base::JSONWriter::OPTIONS_PRETTY_PRINT;
|
||||
}
|
||||
return op;
|
||||
}
|
||||
|
||||
@@ -40,8 +44,9 @@ CefRefPtr<CefValue> CefParseJSON(const CefString& json_string,
|
||||
CefRefPtr<CefValue> CefParseJSON(const void* json,
|
||||
size_t json_size,
|
||||
cef_json_parser_options_t options) {
|
||||
if (!json || json_size == 0)
|
||||
if (!json || json_size == 0) {
|
||||
return nullptr;
|
||||
}
|
||||
absl::optional<base::Value> parse_result = base::JSONReader::Read(
|
||||
base::StringPiece(static_cast<const char*>(json), json_size),
|
||||
GetJSONReaderOptions(options));
|
||||
@@ -73,8 +78,9 @@ CefRefPtr<CefValue> CefParseJSONAndReturnError(
|
||||
|
||||
CefString CefWriteJSON(CefRefPtr<CefValue> node,
|
||||
cef_json_writer_options_t options) {
|
||||
if (!node.get() || !node->IsValid())
|
||||
if (!node.get() || !node->IsValid()) {
|
||||
return CefString();
|
||||
}
|
||||
|
||||
CefValueImpl* impl = static_cast<CefValueImpl*>(node.get());
|
||||
CefValueImpl::ScopedLockedValue scoped_value(impl);
|
||||
|
@@ -24,8 +24,9 @@ std::string GenerateHeaders(const HeaderMap& map) {
|
||||
|
||||
if (!key.empty()) {
|
||||
// Delimit with "\r\n".
|
||||
if (!headers.empty())
|
||||
if (!headers.empty()) {
|
||||
headers += "\r\n";
|
||||
}
|
||||
|
||||
headers += std::string(key) + ": " + std::string(value);
|
||||
}
|
||||
@@ -50,8 +51,9 @@ void MakeASCIILower(std::string* str) {
|
||||
HeaderMap::iterator FindHeaderInMap(const std::string& nameLower,
|
||||
HeaderMap& map) {
|
||||
for (auto it = map.begin(); it != map.end(); ++it) {
|
||||
if (base::EqualsCaseInsensitiveASCII(it->first.ToString(), nameLower))
|
||||
if (base::EqualsCaseInsensitiveASCII(it->first.ToString(), nameLower)) {
|
||||
return it;
|
||||
}
|
||||
}
|
||||
|
||||
return map.end();
|
||||
|
@@ -10,7 +10,8 @@
|
||||
scoped_refptr<base::RefCountedMemory> NetResourceProvider(int key) {
|
||||
// Chrome performs substitution of localized strings for directory listings.
|
||||
scoped_refptr<base::RefCountedMemory> value = ChromeNetResourceProvider(key);
|
||||
if (!value)
|
||||
if (!value) {
|
||||
LOG(ERROR) << "No data resource available for id " << key;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
@@ -17,8 +17,9 @@
|
||||
namespace scheme {
|
||||
|
||||
void AddInternalSchemes(content::ContentClient::Schemes* schemes) {
|
||||
if (!cef::IsAlloyRuntimeEnabled())
|
||||
if (!cef::IsAlloyRuntimeEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// chrome: and chrome-devtools: schemes are registered in
|
||||
// RenderThreadImpl::RegisterSchemes().
|
||||
@@ -39,16 +40,21 @@ void AddInternalSchemes(content::ContentClient::Schemes* schemes) {
|
||||
// with Blink only.
|
||||
for (size_t i = 0; i < sizeof(internal_schemes) / sizeof(internal_schemes[0]);
|
||||
++i) {
|
||||
if (internal_schemes[i].is_standard)
|
||||
if (internal_schemes[i].is_standard) {
|
||||
schemes->standard_schemes.push_back(internal_schemes[i].scheme_name);
|
||||
if (internal_schemes[i].is_local)
|
||||
}
|
||||
if (internal_schemes[i].is_local) {
|
||||
schemes->local_schemes.push_back(internal_schemes[i].scheme_name);
|
||||
if (internal_schemes[i].is_secure)
|
||||
}
|
||||
if (internal_schemes[i].is_secure) {
|
||||
schemes->secure_schemes.push_back(internal_schemes[i].scheme_name);
|
||||
if (internal_schemes[i].is_cors_enabled)
|
||||
}
|
||||
if (internal_schemes[i].is_cors_enabled) {
|
||||
schemes->cors_enabled_schemes.push_back(internal_schemes[i].scheme_name);
|
||||
if (internal_schemes[i].is_csp_bypassing)
|
||||
}
|
||||
if (internal_schemes[i].is_csp_bypassing) {
|
||||
schemes->csp_bypassing_schemes.push_back(internal_schemes[i].scheme_name);
|
||||
}
|
||||
CefAppManager::Get()->AddCustomScheme(&internal_schemes[i]);
|
||||
}
|
||||
}
|
||||
@@ -72,8 +78,9 @@ bool IsInternalHandledScheme(const std::string& scheme) {
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < sizeof(schemes) / sizeof(schemes[0]); ++i) {
|
||||
if (scheme == schemes[i])
|
||||
if (scheme == schemes[i]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@@ -18,8 +18,9 @@ GURL MakeGURL(const CefString& url, bool fixup) {
|
||||
new_url.insert(0, fixed_scheme);
|
||||
gurl = GURL(new_url);
|
||||
}
|
||||
if (fixup)
|
||||
if (fixup) {
|
||||
FixupGURL(gurl);
|
||||
}
|
||||
return gurl;
|
||||
}
|
||||
|
||||
|
@@ -34,8 +34,9 @@ bool GetCookieDomain(const GURL& url,
|
||||
const net::ParsedCookie& pc,
|
||||
std::string* result) {
|
||||
std::string domain_string;
|
||||
if (pc.HasDomain())
|
||||
if (pc.HasDomain()) {
|
||||
domain_string = pc.Domain();
|
||||
}
|
||||
net::CookieInclusionStatus status;
|
||||
return net::cookie_util::GetCookieDomainWithString(url, domain_string, status,
|
||||
result);
|
||||
@@ -116,8 +117,9 @@ scoped_refptr<net::HttpResponseHeaders> MakeResponseHeaders(
|
||||
int64_t content_length,
|
||||
const std::multimap<std::string, std::string>& extra_headers,
|
||||
bool allow_existing_header_override) {
|
||||
if (status_code <= 0)
|
||||
if (status_code <= 0) {
|
||||
status_code = 200;
|
||||
}
|
||||
|
||||
auto headers = WrapRefCounted(new net::HttpResponseHeaders(
|
||||
MakeStatusLine(status_code, status_text, false)));
|
||||
@@ -149,10 +151,11 @@ scoped_refptr<net::HttpResponseHeaders> MakeResponseHeaders(
|
||||
const std::string& name_lowercase = base::ToLowerASCII(pair.first);
|
||||
if (set_headers_lowercase.find(name_lowercase) !=
|
||||
set_headers_lowercase.end()) {
|
||||
if (allow_existing_header_override)
|
||||
if (allow_existing_header_override) {
|
||||
headers->RemoveHeader(pair.first);
|
||||
else
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,8 +172,9 @@ net::RedirectInfo MakeRedirectInfo(const network::ResourceRequest& request,
|
||||
bool insecure_scheme_was_upgraded = false;
|
||||
|
||||
GURL location = new_location;
|
||||
if (status_code == 0)
|
||||
if (status_code == 0) {
|
||||
status_code = net::HTTP_TEMPORARY_REDIRECT;
|
||||
}
|
||||
|
||||
// If this a redirect to HTTP of a request that had the
|
||||
// 'upgrade-insecure-requests' policy set, upgrade it to HTTPS.
|
||||
@@ -229,8 +233,9 @@ bool MakeCefCookie(const net::CanonicalCookie& cc, CefCookie& cookie) {
|
||||
cookie.creation = CefBaseTime(cc.CreationDate());
|
||||
cookie.last_access = CefBaseTime(cc.LastAccessDate());
|
||||
cookie.has_expires = cc.IsPersistent();
|
||||
if (cookie.has_expires)
|
||||
if (cookie.has_expires) {
|
||||
cookie.expires = CefBaseTime(cc.ExpiryDate());
|
||||
}
|
||||
cookie.same_site = MakeCefCookieSameSite(cc.SameSite());
|
||||
cookie.priority = MakeCefCookiePriority(cc.Priority());
|
||||
|
||||
@@ -242,16 +247,19 @@ bool MakeCefCookie(const GURL& url,
|
||||
CefCookie& cookie) {
|
||||
// Parse the cookie.
|
||||
net::ParsedCookie pc(cookie_line);
|
||||
if (!pc.IsValid())
|
||||
if (!pc.IsValid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string cookie_domain;
|
||||
if (!GetCookieDomain(url, pc, &cookie_domain))
|
||||
if (!GetCookieDomain(url, pc, &cookie_domain)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string path_string;
|
||||
if (pc.HasPath())
|
||||
if (pc.HasPath()) {
|
||||
path_string = pc.Path();
|
||||
}
|
||||
std::string cookie_path =
|
||||
net::CanonicalCookie::CanonPathWithString(url, path_string);
|
||||
base::Time creation_time = base::Time::Now();
|
||||
@@ -267,8 +275,9 @@ bool MakeCefCookie(const GURL& url,
|
||||
cookie.creation = CefBaseTime(creation_time);
|
||||
cookie.last_access = CefBaseTime(creation_time);
|
||||
cookie.has_expires = !cookie_expires.is_null();
|
||||
if (cookie.has_expires)
|
||||
if (cookie.has_expires) {
|
||||
cookie.expires = CefBaseTime(cookie_expires);
|
||||
}
|
||||
cookie.same_site = MakeCefCookieSameSite(pc.SameSite());
|
||||
cookie.priority = MakeCefCookiePriority(pc.Priority());
|
||||
|
||||
|
@@ -17,12 +17,14 @@ bool CefResolveURL(const CefString& base_url,
|
||||
const CefString& relative_url,
|
||||
CefString& resolved_url) {
|
||||
GURL base_gurl(base_url.ToString());
|
||||
if (!base_gurl.is_valid())
|
||||
if (!base_gurl.is_valid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GURL combined_gurl = base_gurl.Resolve(relative_url.ToString());
|
||||
if (!combined_gurl.is_valid())
|
||||
if (!combined_gurl.is_valid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
resolved_url = combined_gurl.spec();
|
||||
return true;
|
||||
@@ -30,8 +32,9 @@ bool CefResolveURL(const CefString& base_url,
|
||||
|
||||
bool CefParseURL(const CefString& url, CefURLParts& parts) {
|
||||
GURL gurl(url.ToString());
|
||||
if (!gurl.is_valid())
|
||||
if (!gurl.is_valid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CefString(&parts.spec).FromString(gurl.spec());
|
||||
CefString(&parts.scheme).FromString(gurl.scheme());
|
||||
@@ -69,19 +72,24 @@ bool CefCreateURL(const CefURLParts& parts, CefString& url) {
|
||||
ss << scheme << "://";
|
||||
if (!username.empty()) {
|
||||
ss << username;
|
||||
if (!password.empty())
|
||||
if (!password.empty()) {
|
||||
ss << ":" << password;
|
||||
}
|
||||
ss << "@";
|
||||
}
|
||||
ss << host;
|
||||
if (!port.empty())
|
||||
if (!port.empty()) {
|
||||
ss << ":" << port;
|
||||
if (!path.empty())
|
||||
}
|
||||
if (!path.empty()) {
|
||||
ss << path;
|
||||
if (!query.empty())
|
||||
}
|
||||
if (!query.empty()) {
|
||||
ss << "?" << query;
|
||||
if (!fragment.empty())
|
||||
}
|
||||
if (!fragment.empty()) {
|
||||
ss << "#" << fragment;
|
||||
}
|
||||
gurl = GURL(ss.str());
|
||||
}
|
||||
|
||||
@@ -114,13 +122,15 @@ void CefGetExtensionsForMimeType(const CefString& mime_type,
|
||||
VectorType ext;
|
||||
net::GetExtensionsForMimeType(mime_type, &ext);
|
||||
VectorType::const_iterator it = ext.begin();
|
||||
for (; it != ext.end(); ++it)
|
||||
for (; it != ext.end(); ++it) {
|
||||
extensions.push_back(*it);
|
||||
}
|
||||
}
|
||||
|
||||
CefString CefBase64Encode(const void* data, size_t data_size) {
|
||||
if (data_size == 0)
|
||||
if (data_size == 0) {
|
||||
return CefString();
|
||||
}
|
||||
|
||||
base::StringPiece input(static_cast<const char*>(data), data_size);
|
||||
std::string output;
|
||||
@@ -129,13 +139,15 @@ CefString CefBase64Encode(const void* data, size_t data_size) {
|
||||
}
|
||||
|
||||
CefRefPtr<CefBinaryValue> CefBase64Decode(const CefString& data) {
|
||||
if (data.size() == 0)
|
||||
if (data.size() == 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const std::string& input = data;
|
||||
std::string output;
|
||||
if (base::Base64Decode(input, &output))
|
||||
if (base::Base64Decode(input, &output)) {
|
||||
return CefBinaryValue::Create(output.data(), output.size());
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -148,9 +160,10 @@ CefString CefURIDecode(const CefString& text,
|
||||
cef_uri_unescape_rule_t unescape_rule) {
|
||||
const base::UnescapeRule::Type type =
|
||||
static_cast<base::UnescapeRule::Type>(unescape_rule);
|
||||
if (convert_to_utf8)
|
||||
if (convert_to_utf8) {
|
||||
return base::UnescapeAndDecodeUTF8URLComponentWithAdjustments(
|
||||
text.ToString(), type, nullptr);
|
||||
else
|
||||
} else {
|
||||
return base::UnescapeURLComponent(text.ToString(), type);
|
||||
}
|
||||
}
|
||||
|
@@ -54,8 +54,9 @@ bool CefProcessMessageImpl::IsReadOnly() {
|
||||
}
|
||||
|
||||
CefRefPtr<CefProcessMessage> CefProcessMessageImpl::Copy() {
|
||||
if (!IsValid())
|
||||
if (!IsValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
return new CefProcessMessageImpl(name_, arguments_->Copy());
|
||||
}
|
||||
|
||||
|
@@ -123,8 +123,9 @@ void GetHeaderMap(const net::HttpRequestHeaders& headers,
|
||||
CefRequest::HeaderMap& map) {
|
||||
map.clear();
|
||||
|
||||
if (headers.IsEmpty())
|
||||
if (headers.IsEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
net::HttpRequestHeaders::Iterator it(headers);
|
||||
while (it.GetNext()) {
|
||||
@@ -287,8 +288,9 @@ CefString CefRequestImpl::GetHeaderByName(const CefString& name) {
|
||||
HttpHeaderUtils::MakeASCIILower(&nameLower);
|
||||
|
||||
auto it = HttpHeaderUtils::FindHeaderInMap(nameLower, headermap_);
|
||||
if (it != headermap_.end())
|
||||
if (it != headermap_.end()) {
|
||||
return it->second;
|
||||
}
|
||||
|
||||
return CefString();
|
||||
}
|
||||
@@ -312,8 +314,9 @@ void CefRequestImpl::SetHeaderByName(const CefString& name,
|
||||
// There may be multiple values, so remove any first.
|
||||
for (auto it = headermap_.begin(); it != headermap_.end();) {
|
||||
if (base::EqualsCaseInsensitiveASCII(it->first.ToString(), nameStr)) {
|
||||
if (!overwrite)
|
||||
if (!overwrite) {
|
||||
return;
|
||||
}
|
||||
it = headermap_.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
@@ -434,11 +437,13 @@ void CefRequestImpl::Get(network::ResourceRequest* request,
|
||||
bool changed_only) const {
|
||||
base::AutoLock lock_scope(lock_);
|
||||
|
||||
if (ShouldSet(kChangedUrl, changed_only))
|
||||
if (ShouldSet(kChangedUrl, changed_only)) {
|
||||
request->url = url_;
|
||||
}
|
||||
|
||||
if (ShouldSet(kChangedMethod, changed_only))
|
||||
if (ShouldSet(kChangedMethod, changed_only)) {
|
||||
request->method = method_;
|
||||
}
|
||||
|
||||
if (ShouldSet(kChangedReferrer, changed_only)) {
|
||||
request->referrer = referrer_url_;
|
||||
@@ -547,8 +552,9 @@ void CefRequestImpl::Get(const cef::mojom::RequestParamsPtr& params,
|
||||
blink::WebURLRequest& request) {
|
||||
request.SetUrl(params->url);
|
||||
request.SetRequestorOrigin(blink::WebSecurityOrigin::Create(params->url));
|
||||
if (!params->method.empty())
|
||||
if (!params->method.empty()) {
|
||||
request.SetHttpMethod(blink::WebString::FromASCII(params->method));
|
||||
}
|
||||
|
||||
if (params->referrer && params->referrer->url.is_valid()) {
|
||||
const blink::WebString& referrer =
|
||||
@@ -593,8 +599,9 @@ void CefRequestImpl::Get(const cef::mojom::RequestParamsPtr& params,
|
||||
blink::GetWebHTTPBodyForRequestBody(*params->upload_data));
|
||||
}
|
||||
|
||||
if (!params->site_for_cookies.IsNull())
|
||||
if (!params->site_for_cookies.IsNull()) {
|
||||
request.SetSiteForCookies(params->site_for_cookies);
|
||||
}
|
||||
|
||||
int flags = params->load_flags;
|
||||
if (!(flags & kURCachePolicyMask)) {
|
||||
@@ -620,8 +627,9 @@ void CefRequestImpl::Get(cef::mojom::RequestParamsPtr& params) const {
|
||||
params->referrer = blink::mojom::Referrer::New(
|
||||
referrer_url_, NetReferrerPolicyToBlinkReferrerPolicy(referrer_policy_));
|
||||
|
||||
if (!headermap_.empty())
|
||||
if (!headermap_.empty()) {
|
||||
params->headers = HttpHeaderUtils::GenerateHeaders(headermap_);
|
||||
}
|
||||
|
||||
if (postdata_) {
|
||||
CefPostDataImpl* impl = static_cast<CefPostDataImpl*>(postdata_.get());
|
||||
@@ -634,23 +642,27 @@ void CefRequestImpl::Get(cef::mojom::RequestParamsPtr& params) const {
|
||||
|
||||
void CefRequestImpl::SetReadOnly(bool read_only) {
|
||||
base::AutoLock lock_scope(lock_);
|
||||
if (read_only_ == read_only)
|
||||
if (read_only_ == read_only) {
|
||||
return;
|
||||
}
|
||||
|
||||
read_only_ = read_only;
|
||||
|
||||
if (postdata_.get())
|
||||
if (postdata_.get()) {
|
||||
static_cast<CefPostDataImpl*>(postdata_.get())->SetReadOnly(read_only);
|
||||
}
|
||||
}
|
||||
|
||||
void CefRequestImpl::SetTrackChanges(bool track_changes,
|
||||
bool backup_on_change) {
|
||||
base::AutoLock lock_scope(lock_);
|
||||
if (track_changes_ == track_changes)
|
||||
if (track_changes_ == track_changes) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!track_changes && backup_on_change_)
|
||||
if (!track_changes && backup_on_change_) {
|
||||
backup_.reset();
|
||||
}
|
||||
|
||||
track_changes_ = track_changes;
|
||||
backup_on_change_ = track_changes ? backup_on_change : false;
|
||||
@@ -667,28 +679,34 @@ void CefRequestImpl::RevertChanges() {
|
||||
DCHECK(!read_only_);
|
||||
DCHECK(track_changes_);
|
||||
DCHECK(backup_on_change_);
|
||||
if (!backup_)
|
||||
if (!backup_) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Restore the original values if a backup exists.
|
||||
if (backup_->backups_ & kChangedUrl)
|
||||
if (backup_->backups_ & kChangedUrl) {
|
||||
url_ = backup_->url_;
|
||||
if (backup_->backups_ & kChangedMethod)
|
||||
}
|
||||
if (backup_->backups_ & kChangedMethod) {
|
||||
method_ = backup_->method_;
|
||||
}
|
||||
if (backup_->backups_ & kChangedReferrer) {
|
||||
referrer_url_ = backup_->referrer_url_;
|
||||
referrer_policy_ = backup_->referrer_policy_;
|
||||
}
|
||||
if (backup_->backups_ & kChangedPostData)
|
||||
if (backup_->backups_ & kChangedPostData) {
|
||||
postdata_ = backup_->postdata_;
|
||||
}
|
||||
if (backup_->backups_ & kChangedHeaderMap) {
|
||||
DCHECK(backup_->headermap_);
|
||||
headermap_.swap(*backup_->headermap_);
|
||||
}
|
||||
if (backup_->backups_ & kChangedFlags)
|
||||
if (backup_->backups_ & kChangedFlags) {
|
||||
flags_ = backup_->flags_;
|
||||
if (backup_->backups_ & kChangedSiteForCookies)
|
||||
}
|
||||
if (backup_->backups_ & kChangedSiteForCookies) {
|
||||
site_for_cookies_ = backup_->site_for_cookies_;
|
||||
}
|
||||
|
||||
backup_.reset();
|
||||
}
|
||||
@@ -767,12 +785,14 @@ cef_referrer_policy_t CefRequestImpl::BlinkReferrerPolicyToNetReferrerPolicy(
|
||||
|
||||
void CefRequestImpl::Changed(uint8_t changes) {
|
||||
lock_.AssertAcquired();
|
||||
if (!track_changes_)
|
||||
if (!track_changes_) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (backup_on_change_) {
|
||||
if (!backup_)
|
||||
if (!backup_) {
|
||||
backup_.reset(new Backup());
|
||||
}
|
||||
|
||||
// Set the backup values if not already set.
|
||||
if ((changes & kChangedUrl) && !(backup_->backups_ & kChangedUrl)) {
|
||||
@@ -820,16 +840,19 @@ bool CefRequestImpl::ShouldSet(uint8_t changes, bool changed_only) const {
|
||||
lock_.AssertAcquired();
|
||||
|
||||
// Always change if changes are not being tracked.
|
||||
if (!track_changes_)
|
||||
if (!track_changes_) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Always change if changed-only was not requested.
|
||||
if (!changed_only)
|
||||
if (!changed_only) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Change if the |changes| bit flag has been set.
|
||||
if ((changes_ & changes) == changes)
|
||||
if ((changes_ & changes) == changes) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((changes & kChangedPostData) == kChangedPostData) {
|
||||
// Change if the post data object was modified directly.
|
||||
@@ -971,8 +994,9 @@ scoped_refptr<network::ResourceRequestBody> CefPostDataImpl::GetBody() const {
|
||||
|
||||
void CefPostDataImpl::SetReadOnly(bool read_only) {
|
||||
base::AutoLock lock_scope(lock_);
|
||||
if (read_only_ == read_only)
|
||||
if (read_only_ == read_only) {
|
||||
return;
|
||||
}
|
||||
|
||||
read_only_ = read_only;
|
||||
|
||||
@@ -984,8 +1008,9 @@ void CefPostDataImpl::SetReadOnly(bool read_only) {
|
||||
|
||||
void CefPostDataImpl::SetTrackChanges(bool track_changes) {
|
||||
base::AutoLock lock_scope(lock_);
|
||||
if (track_changes_ == track_changes)
|
||||
if (track_changes_ == track_changes) {
|
||||
return;
|
||||
}
|
||||
|
||||
track_changes_ = track_changes;
|
||||
has_changes_ = false;
|
||||
@@ -999,13 +1024,15 @@ void CefPostDataImpl::SetTrackChanges(bool track_changes) {
|
||||
|
||||
bool CefPostDataImpl::HasChanges() const {
|
||||
base::AutoLock lock_scope(lock_);
|
||||
if (has_changes_)
|
||||
if (has_changes_) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ElementVector::const_iterator it = elements_.begin();
|
||||
for (; it != elements_.end(); ++it) {
|
||||
if (static_cast<CefPostDataElementImpl*>(it->get())->HasChanges())
|
||||
if (static_cast<CefPostDataElementImpl*>(it->get())->HasChanges()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -1013,8 +1040,9 @@ bool CefPostDataImpl::HasChanges() const {
|
||||
|
||||
void CefPostDataImpl::Changed() {
|
||||
lock_.AssertAcquired();
|
||||
if (track_changes_ && !has_changes_)
|
||||
if (track_changes_ && !has_changes_) {
|
||||
has_changes_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
// CefPostDataElement ---------------------------------------------------------
|
||||
@@ -1076,8 +1104,9 @@ void CefPostDataElementImpl::SetToBytes(size_t size, const void* bytes) {
|
||||
// Assign the new data
|
||||
void* data = malloc(size);
|
||||
DCHECK(data != nullptr);
|
||||
if (data == nullptr)
|
||||
if (data == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(data, bytes, size);
|
||||
|
||||
@@ -1097,8 +1126,9 @@ CefString CefPostDataElementImpl::GetFile() {
|
||||
base::AutoLock lock_scope(lock_);
|
||||
DCHECK(type_ == PDE_TYPE_FILE);
|
||||
CefString filename;
|
||||
if (type_ == PDE_TYPE_FILE)
|
||||
if (type_ == PDE_TYPE_FILE) {
|
||||
filename.FromString(data_.filename.str, data_.filename.length, false);
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
|
||||
@@ -1106,8 +1136,9 @@ size_t CefPostDataElementImpl::GetBytesCount() {
|
||||
base::AutoLock lock_scope(lock_);
|
||||
DCHECK(type_ == PDE_TYPE_BYTES);
|
||||
size_t size = 0;
|
||||
if (type_ == PDE_TYPE_BYTES)
|
||||
if (type_ == PDE_TYPE_BYTES) {
|
||||
size = data_.bytes.size;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
@@ -1154,16 +1185,18 @@ void CefPostDataElementImpl::Get(network::ResourceRequestBody& body) const {
|
||||
|
||||
void CefPostDataElementImpl::SetReadOnly(bool read_only) {
|
||||
base::AutoLock lock_scope(lock_);
|
||||
if (read_only_ == read_only)
|
||||
if (read_only_ == read_only) {
|
||||
return;
|
||||
}
|
||||
|
||||
read_only_ = read_only;
|
||||
}
|
||||
|
||||
void CefPostDataElementImpl::SetTrackChanges(bool track_changes) {
|
||||
base::AutoLock lock_scope(lock_);
|
||||
if (track_changes_ == track_changes)
|
||||
if (track_changes_ == track_changes) {
|
||||
return;
|
||||
}
|
||||
|
||||
track_changes_ = track_changes;
|
||||
has_changes_ = false;
|
||||
@@ -1176,18 +1209,21 @@ bool CefPostDataElementImpl::HasChanges() const {
|
||||
|
||||
void CefPostDataElementImpl::Changed() {
|
||||
lock_.AssertAcquired();
|
||||
if (track_changes_ && !has_changes_)
|
||||
if (track_changes_ && !has_changes_) {
|
||||
has_changes_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
void CefPostDataElementImpl::Cleanup() {
|
||||
if (type_ == PDE_TYPE_EMPTY)
|
||||
if (type_ == PDE_TYPE_EMPTY) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (type_ == PDE_TYPE_BYTES)
|
||||
if (type_ == PDE_TYPE_BYTES) {
|
||||
free(data_.bytes.bytes);
|
||||
else if (type_ == PDE_TYPE_FILE)
|
||||
} else if (type_ == PDE_TYPE_FILE) {
|
||||
cef_string_clear(&data_.filename);
|
||||
}
|
||||
type_ = PDE_TYPE_EMPTY;
|
||||
memset(&data_, 0, sizeof(data_));
|
||||
}
|
||||
|
@@ -15,8 +15,9 @@ base::FilePath CefResourceBundleDelegate::GetPathForResourcePack(
|
||||
base::FilePath CefResourceBundleDelegate::GetPathForLocalePack(
|
||||
const base::FilePath& pack_path,
|
||||
const std::string& locale) {
|
||||
if (!pack_loading_disabled_)
|
||||
if (!pack_loading_disabled_) {
|
||||
return pack_path;
|
||||
}
|
||||
return base::FilePath();
|
||||
}
|
||||
|
||||
@@ -74,8 +75,9 @@ bool CefResourceBundleDelegate::GetLocalizedString(
|
||||
application->GetResourceBundleHandler();
|
||||
if (handler.get()) {
|
||||
CefString cef_str;
|
||||
if (handler->GetLocalizedString(message_id, cef_str))
|
||||
if (handler->GetLocalizedString(message_id, cef_str)) {
|
||||
*value = cef_str;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -10,8 +10,9 @@
|
||||
CefResourceBundleImpl::CefResourceBundleImpl() {}
|
||||
|
||||
CefString CefResourceBundleImpl::GetLocalizedString(int string_id) {
|
||||
if (!ui::ResourceBundle::HasSharedInstance())
|
||||
if (!ui::ResourceBundle::HasSharedInstance()) {
|
||||
return CefString();
|
||||
}
|
||||
|
||||
return ui::ResourceBundle::GetSharedInstance().GetLocalizedString(string_id);
|
||||
}
|
||||
@@ -24,14 +25,16 @@ CefRefPtr<CefBinaryValue> CefResourceBundleImpl::GetDataResource(
|
||||
CefRefPtr<CefBinaryValue> CefResourceBundleImpl::GetDataResourceForScale(
|
||||
int resource_id,
|
||||
ScaleFactor scale_factor) {
|
||||
if (!ui::ResourceBundle::HasSharedInstance())
|
||||
if (!ui::ResourceBundle::HasSharedInstance()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
base::RefCountedMemory* result =
|
||||
ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale(
|
||||
resource_id, static_cast<ui::ResourceScaleFactor>(scale_factor));
|
||||
if (!result)
|
||||
if (!result) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return CefBinaryValue::Create(result->data(), result->size());
|
||||
}
|
||||
|
@@ -57,8 +57,9 @@ bool GetDefaultUserDataDirectory(base::FilePath* result) {
|
||||
|
||||
// Based on chrome/common/chrome_paths_mac.mm.
|
||||
bool GetDefaultUserDataDirectory(base::FilePath* result) {
|
||||
if (!base::PathService::Get(base::DIR_APP_DATA, result))
|
||||
if (!base::PathService::Get(base::DIR_APP_DATA, result)) {
|
||||
return false;
|
||||
}
|
||||
*result = result->Append(FILE_PATH_LITERAL("CEF"));
|
||||
*result = result->Append(FILE_PATH_LITERAL("User Data"));
|
||||
return true;
|
||||
@@ -68,8 +69,9 @@ bool GetDefaultUserDataDirectory(base::FilePath* result) {
|
||||
|
||||
// Based on chrome/common/chrome_paths_win.cc.
|
||||
bool GetDefaultUserDataDirectory(base::FilePath* result) {
|
||||
if (!base::PathService::Get(base::DIR_LOCAL_APP_DATA, result))
|
||||
if (!base::PathService::Get(base::DIR_LOCAL_APP_DATA, result)) {
|
||||
return false;
|
||||
}
|
||||
*result = result->Append(FILE_PATH_LITERAL("CEF"));
|
||||
*result = result->Append(FILE_PATH_LITERAL("User Data"));
|
||||
return true;
|
||||
@@ -99,14 +101,17 @@ base::FilePath GetUserDataPath(CefSettings* settings,
|
||||
// This may be set for sub-processes.
|
||||
base::FilePath result =
|
||||
command_line->GetSwitchValuePath(switches::kUserDataDir);
|
||||
if (!result.empty())
|
||||
if (!result.empty()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (GetDefaultUserDataDirectory(&result))
|
||||
if (GetDefaultUserDataDirectory(&result)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (base::PathService::Get(base::DIR_TEMP, &result))
|
||||
if (base::PathService::Get(base::DIR_TEMP, &result)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
NOTREACHED();
|
||||
return result;
|
||||
@@ -138,8 +143,9 @@ bool GetDefaultDownloadDirectory(base::FilePath* result) {
|
||||
|
||||
bool GetDefaultDownloadSafeDirectory(base::FilePath* result) {
|
||||
// Start with the default download directory.
|
||||
if (!GetDefaultDownloadDirectory(result))
|
||||
if (!GetDefaultDownloadDirectory(result)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (DownloadPathIsDangerous(*result)) {
|
||||
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX)
|
||||
|
@@ -104,8 +104,9 @@ CefString CefResponseImpl::GetHeaderByName(const CefString& name) {
|
||||
HttpHeaderUtils::MakeASCIILower(&nameLower);
|
||||
|
||||
auto it = HttpHeaderUtils::FindHeaderInMap(nameLower, header_map_);
|
||||
if (it != header_map_.end())
|
||||
if (it != header_map_.end()) {
|
||||
return it->second;
|
||||
}
|
||||
|
||||
return CefString();
|
||||
}
|
||||
@@ -122,8 +123,9 @@ void CefResponseImpl::SetHeaderByName(const CefString& name,
|
||||
// There may be multiple values, so remove any first.
|
||||
for (auto it = header_map_.begin(); it != header_map_.end();) {
|
||||
if (base::EqualsCaseInsensitiveASCII(it->first.ToString(), nameLower)) {
|
||||
if (!overwrite)
|
||||
if (!overwrite) {
|
||||
return;
|
||||
}
|
||||
it = header_map_.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
@@ -159,12 +161,14 @@ scoped_refptr<net::HttpResponseHeaders> CefResponseImpl::GetResponseHeaders() {
|
||||
base::AutoLock lock_scope(lock_);
|
||||
|
||||
std::string mime_type = mime_type_;
|
||||
if (mime_type.empty())
|
||||
if (mime_type.empty()) {
|
||||
mime_type = "text/html";
|
||||
}
|
||||
|
||||
std::multimap<std::string, std::string> extra_headers;
|
||||
for (const auto& pair : header_map_)
|
||||
for (const auto& pair : header_map_) {
|
||||
extra_headers.insert(std::make_pair(pair.first, pair.second));
|
||||
}
|
||||
|
||||
return net_service::MakeResponseHeaders(
|
||||
status_code_, status_text_, mime_type, charset_, -1, extra_headers,
|
||||
@@ -180,8 +184,9 @@ void CefResponseImpl::SetResponseHeaders(
|
||||
|
||||
size_t iter = 0;
|
||||
std::string name, value;
|
||||
while (headers.EnumerateHeaderLines(&iter, &name, &value))
|
||||
while (headers.EnumerateHeaderLines(&iter, &name, &value)) {
|
||||
header_map_.insert(std::make_pair(name, value));
|
||||
}
|
||||
|
||||
status_code_ = headers.response_code();
|
||||
status_text_ = headers.GetStatusText();
|
||||
|
@@ -18,8 +18,9 @@ namespace {
|
||||
|
||||
void AppendArray(const std::vector<std::string>& source,
|
||||
std::vector<std::string>* target) {
|
||||
if (source.empty())
|
||||
if (source.empty()) {
|
||||
return;
|
||||
}
|
||||
target->insert(target->end(), source.begin(), source.end());
|
||||
}
|
||||
} // namespace
|
||||
@@ -46,16 +47,21 @@ bool CefSchemeRegistrarImpl::AddCustomScheme(const CefString& scheme_name,
|
||||
|
||||
// The |is_display_isolated| value is excluded here because it's registered
|
||||
// with Blink only.
|
||||
if (is_standard)
|
||||
if (is_standard) {
|
||||
schemes_.standard_schemes.push_back(scheme);
|
||||
if (is_local)
|
||||
}
|
||||
if (is_local) {
|
||||
schemes_.local_schemes.push_back(scheme);
|
||||
if (is_secure)
|
||||
}
|
||||
if (is_secure) {
|
||||
schemes_.secure_schemes.push_back(scheme);
|
||||
if (is_cors_enabled)
|
||||
}
|
||||
if (is_cors_enabled) {
|
||||
schemes_.cors_enabled_schemes.push_back(scheme);
|
||||
if (is_csp_bypassing)
|
||||
}
|
||||
if (is_csp_bypassing) {
|
||||
schemes_.csp_bypassing_schemes.push_back(scheme);
|
||||
}
|
||||
|
||||
CefSchemeInfo scheme_info = {
|
||||
scheme, is_standard, is_local, is_display_isolated,
|
||||
|
@@ -29,8 +29,9 @@ CEF_EXPORT int cef_string_list_value(cef_string_list_t list,
|
||||
DCHECK(value);
|
||||
StringList* impl = reinterpret_cast<StringList*>(list);
|
||||
DCHECK_LT(index, impl->size());
|
||||
if (index >= impl->size())
|
||||
if (index >= impl->size()) {
|
||||
return false;
|
||||
}
|
||||
const CefString& str = (*impl)[index];
|
||||
return cef_string_copy(str.c_str(), str.length(), value);
|
||||
}
|
||||
|
@@ -29,8 +29,9 @@ CEF_EXPORT int cef_string_map_find(cef_string_map_t map,
|
||||
DCHECK(value);
|
||||
StringMap* impl = reinterpret_cast<StringMap*>(map);
|
||||
StringMap::const_iterator it = impl->find(CefString(key));
|
||||
if (it == impl->end())
|
||||
if (it == impl->end()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const CefString& val = it->second;
|
||||
return cef_string_set(val.c_str(), val.length(), value, true);
|
||||
@@ -43,13 +44,15 @@ CEF_EXPORT int cef_string_map_key(cef_string_map_t map,
|
||||
DCHECK(key);
|
||||
StringMap* impl = reinterpret_cast<StringMap*>(map);
|
||||
DCHECK_LT(index, impl->size());
|
||||
if (index >= impl->size())
|
||||
if (index >= impl->size()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
StringMap::const_iterator it = impl->begin();
|
||||
for (size_t ct = 0; it != impl->end(); ++it, ct++) {
|
||||
if (ct == index)
|
||||
if (ct == index) {
|
||||
return cef_string_set(it->first.c_str(), it->first.length(), key, true);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -61,8 +64,9 @@ CEF_EXPORT int cef_string_map_value(cef_string_map_t map,
|
||||
DCHECK(value);
|
||||
StringMap* impl = reinterpret_cast<StringMap*>(map);
|
||||
DCHECK_LT(index, impl->size());
|
||||
if (index >= impl->size())
|
||||
if (index >= impl->size()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
StringMap::const_iterator it = impl->begin();
|
||||
for (size_t ct = 0; it != impl->end(); ++it, ct++) {
|
||||
|
@@ -42,18 +42,21 @@ CEF_EXPORT int cef_string_multimap_enumerate(cef_string_multimap_t map,
|
||||
CefString key_str(key);
|
||||
|
||||
DCHECK_LT(value_index, impl->count(key_str));
|
||||
if (value_index >= impl->count(key_str))
|
||||
if (value_index >= impl->count(key_str)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::pair<StringMultimap::iterator, StringMultimap::iterator> range_it =
|
||||
impl->equal_range(key_str);
|
||||
|
||||
size_t count = value_index;
|
||||
while (count-- && range_it.first != range_it.second)
|
||||
while (count-- && range_it.first != range_it.second) {
|
||||
range_it.first++;
|
||||
}
|
||||
|
||||
if (range_it.first == range_it.second)
|
||||
if (range_it.first == range_it.second) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const CefString& val = range_it.first->second;
|
||||
return cef_string_set(val.c_str(), val.length(), value, true);
|
||||
@@ -66,13 +69,15 @@ CEF_EXPORT int cef_string_multimap_key(cef_string_multimap_t map,
|
||||
DCHECK(key);
|
||||
StringMultimap* impl = reinterpret_cast<StringMultimap*>(map);
|
||||
DCHECK_LT(index, impl->size());
|
||||
if (index >= impl->size())
|
||||
if (index >= impl->size()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
StringMultimap::const_iterator it = impl->begin();
|
||||
for (size_t ct = 0; it != impl->end(); ++it, ct++) {
|
||||
if (ct == index)
|
||||
if (ct == index) {
|
||||
return cef_string_set(it->first.c_str(), it->first.length(), key, true);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -84,8 +89,9 @@ CEF_EXPORT int cef_string_multimap_value(cef_string_multimap_t map,
|
||||
DCHECK(value);
|
||||
StringMultimap* impl = reinterpret_cast<StringMultimap*>(map);
|
||||
DCHECK_LT(index, impl->size());
|
||||
if (index >= impl->size())
|
||||
if (index >= impl->size()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
StringMultimap::const_iterator it = impl->begin();
|
||||
for (size_t ct = 0; it != impl->end(); ++it, ct++) {
|
||||
|
@@ -42,8 +42,9 @@ CEF_EXPORT int cef_string_wide_set(const wchar_t* src,
|
||||
if (copy) {
|
||||
if (src && src_len > 0) {
|
||||
output->str = new wchar_t[src_len + 1];
|
||||
if (!output->str)
|
||||
if (!output->str) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
memcpy(output->str, src, src_len * sizeof(wchar_t));
|
||||
output->str[src_len] = 0;
|
||||
@@ -66,8 +67,9 @@ CEF_EXPORT int cef_string_utf8_set(const char* src,
|
||||
if (copy) {
|
||||
if (src && src_len > 0) {
|
||||
output->str = new char[src_len + 1];
|
||||
if (!output->str)
|
||||
if (!output->str) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
memcpy(output->str, src, src_len * sizeof(char));
|
||||
output->str[src_len] = 0;
|
||||
@@ -91,8 +93,9 @@ CEF_EXPORT int cef_string_utf16_set(const char16* src,
|
||||
if (copy) {
|
||||
if (src && src_len > 0) {
|
||||
output->str = new char16[src_len + 1];
|
||||
if (!output->str)
|
||||
if (!output->str) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
memcpy(output->str, src, src_len * sizeof(char16));
|
||||
output->str[src_len] = 0;
|
||||
@@ -109,8 +112,9 @@ CEF_EXPORT int cef_string_utf16_set(const char16* src,
|
||||
|
||||
CEF_EXPORT void cef_string_wide_clear(cef_string_wide_t* str) {
|
||||
DCHECK(str != nullptr);
|
||||
if (str->dtor && str->str)
|
||||
if (str->dtor && str->str) {
|
||||
str->dtor(str->str);
|
||||
}
|
||||
|
||||
str->str = nullptr;
|
||||
str->length = 0;
|
||||
@@ -119,8 +123,9 @@ CEF_EXPORT void cef_string_wide_clear(cef_string_wide_t* str) {
|
||||
|
||||
CEF_EXPORT void cef_string_utf8_clear(cef_string_utf8_t* str) {
|
||||
DCHECK(str != nullptr);
|
||||
if (str->dtor && str->str)
|
||||
if (str->dtor && str->str) {
|
||||
str->dtor(str->str);
|
||||
}
|
||||
|
||||
str->str = nullptr;
|
||||
str->length = 0;
|
||||
@@ -129,8 +134,9 @@ CEF_EXPORT void cef_string_utf8_clear(cef_string_utf8_t* str) {
|
||||
|
||||
CEF_EXPORT void cef_string_utf16_clear(cef_string_utf16_t* str) {
|
||||
DCHECK(str != nullptr);
|
||||
if (str->dtor && str->str)
|
||||
if (str->dtor && str->str) {
|
||||
str->dtor(str->str);
|
||||
}
|
||||
|
||||
str->str = nullptr;
|
||||
str->length = 0;
|
||||
@@ -139,36 +145,41 @@ CEF_EXPORT void cef_string_utf16_clear(cef_string_utf16_t* str) {
|
||||
|
||||
CEF_EXPORT int cef_string_wide_cmp(const cef_string_wide_t* str1,
|
||||
const cef_string_wide_t* str2) {
|
||||
if (str1->length == 0 && str2->length == 0)
|
||||
if (str1->length == 0 && str2->length == 0) {
|
||||
return 0;
|
||||
}
|
||||
int r = wcsncmp(str1->str, str2->str, std::min(str1->length, str2->length));
|
||||
if (r == 0) {
|
||||
if (str1->length > str2->length)
|
||||
if (str1->length > str2->length) {
|
||||
return 1;
|
||||
else if (str1->length < str2->length)
|
||||
} else if (str1->length < str2->length) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
CEF_EXPORT int cef_string_utf8_cmp(const cef_string_utf8_t* str1,
|
||||
const cef_string_utf8_t* str2) {
|
||||
if (str1->length == 0 && str2->length == 0)
|
||||
if (str1->length == 0 && str2->length == 0) {
|
||||
return 0;
|
||||
}
|
||||
int r = strncmp(str1->str, str2->str, std::min(str1->length, str2->length));
|
||||
if (r == 0) {
|
||||
if (str1->length > str2->length)
|
||||
if (str1->length > str2->length) {
|
||||
return 1;
|
||||
else if (str1->length < str2->length)
|
||||
} else if (str1->length < str2->length) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
CEF_EXPORT int cef_string_utf16_cmp(const cef_string_utf16_t* str1,
|
||||
const cef_string_utf16_t* str2) {
|
||||
if (str1->length == 0 && str2->length == 0)
|
||||
if (str1->length == 0 && str2->length == 0) {
|
||||
return 0;
|
||||
}
|
||||
#if defined(WCHAR_T_IS_UTF32)
|
||||
int r = std::char_traits<std::u16string::value_type>::compare(
|
||||
reinterpret_cast<std::u16string::value_type*>(str1->str),
|
||||
@@ -178,10 +189,11 @@ CEF_EXPORT int cef_string_utf16_cmp(const cef_string_utf16_t* str1,
|
||||
int r = wcsncmp(str1->str, str2->str, std::min(str1->length, str2->length));
|
||||
#endif
|
||||
if (r == 0) {
|
||||
if (str1->length > str2->length)
|
||||
if (str1->length > str2->length) {
|
||||
return 1;
|
||||
else if (str1->length < str2->length)
|
||||
} else if (str1->length < str2->length) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
@@ -191,8 +203,9 @@ CEF_EXPORT int cef_string_wide_to_utf8(const wchar_t* src,
|
||||
cef_string_utf8_t* output) {
|
||||
std::string str;
|
||||
bool ret = base::WideToUTF8(src, src_len, &str);
|
||||
if (!cef_string_utf8_set(str.c_str(), str.length(), output, true))
|
||||
if (!cef_string_utf8_set(str.c_str(), str.length(), output, true)) {
|
||||
return false;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -201,8 +214,9 @@ CEF_EXPORT int cef_string_utf8_to_wide(const char* src,
|
||||
cef_string_wide_t* output) {
|
||||
std::wstring str;
|
||||
bool ret = base::UTF8ToWide(src, src_len, &str);
|
||||
if (!cef_string_wide_set(str.c_str(), str.length(), output, true))
|
||||
if (!cef_string_wide_set(str.c_str(), str.length(), output, true)) {
|
||||
return false;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -212,8 +226,9 @@ CEF_EXPORT int cef_string_wide_to_utf16(const wchar_t* src,
|
||||
std::u16string str;
|
||||
bool ret = base::WideToUTF16(src, src_len, &str);
|
||||
if (!cef_string_utf16_set(reinterpret_cast<const char16*>(str.c_str()),
|
||||
str.length(), output, true))
|
||||
str.length(), output, true)) {
|
||||
return false;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -223,8 +238,9 @@ CEF_EXPORT int cef_string_utf16_to_wide(const char16* src,
|
||||
std::wstring str;
|
||||
bool ret = base::UTF16ToWide(
|
||||
reinterpret_cast<const std::u16string::value_type*>(src), src_len, &str);
|
||||
if (!cef_string_wide_set(str.c_str(), str.length(), output, true))
|
||||
if (!cef_string_wide_set(str.c_str(), str.length(), output, true)) {
|
||||
return false;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -234,8 +250,9 @@ CEF_EXPORT int cef_string_utf8_to_utf16(const char* src,
|
||||
std::u16string str;
|
||||
bool ret = base::UTF8ToUTF16(src, src_len, &str);
|
||||
if (!cef_string_utf16_set(reinterpret_cast<const char16*>(str.c_str()),
|
||||
str.length(), output, true))
|
||||
str.length(), output, true)) {
|
||||
return false;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -245,8 +262,9 @@ CEF_EXPORT int cef_string_utf16_to_utf8(const char16* src,
|
||||
std::string str;
|
||||
bool ret = base::UTF16ToUTF8(
|
||||
reinterpret_cast<const std::u16string::value_type*>(src), src_len, &str);
|
||||
if (!cef_string_utf8_set(str.c_str(), str.length(), output, true))
|
||||
if (!cef_string_utf8_set(str.c_str(), str.length(), output, true)) {
|
||||
return false;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@@ -24,8 +24,9 @@ using content::BrowserThread;
|
||||
CefRefPtr<CefTaskRunner> CefTaskRunner::GetForCurrentThread() {
|
||||
scoped_refptr<base::SingleThreadTaskRunner> task_runner =
|
||||
CefTaskRunnerImpl::GetCurrentTaskRunner();
|
||||
if (task_runner.get())
|
||||
if (task_runner.get()) {
|
||||
return new CefTaskRunnerImpl(task_runner);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -33,8 +34,9 @@ CefRefPtr<CefTaskRunner> CefTaskRunner::GetForCurrentThread() {
|
||||
CefRefPtr<CefTaskRunner> CefTaskRunner::GetForThread(CefThreadId threadId) {
|
||||
scoped_refptr<base::SingleThreadTaskRunner> task_runner =
|
||||
CefTaskRunnerImpl::GetTaskRunner(threadId);
|
||||
if (task_runner.get())
|
||||
if (task_runner.get()) {
|
||||
return new CefTaskRunnerImpl(task_runner);
|
||||
}
|
||||
|
||||
LOG(WARNING) << "Invalid thread id " << threadId;
|
||||
return nullptr;
|
||||
@@ -52,13 +54,15 @@ CefTaskRunnerImpl::CefTaskRunnerImpl(
|
||||
scoped_refptr<base::SingleThreadTaskRunner> CefTaskRunnerImpl::GetTaskRunner(
|
||||
CefThreadId threadId) {
|
||||
auto* manager = CefTaskRunnerManager::Get();
|
||||
if (!manager)
|
||||
if (!manager) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
switch (threadId) {
|
||||
case TID_UI:
|
||||
if (BrowserThread::IsThreadInitialized(BrowserThread::UI))
|
||||
if (BrowserThread::IsThreadInitialized(BrowserThread::UI)) {
|
||||
return content::GetUIThreadTaskRunner({});
|
||||
}
|
||||
break;
|
||||
case TID_FILE_BACKGROUND:
|
||||
return manager->GetBackgroundTaskRunner();
|
||||
@@ -69,8 +73,9 @@ scoped_refptr<base::SingleThreadTaskRunner> CefTaskRunnerImpl::GetTaskRunner(
|
||||
case TID_PROCESS_LAUNCHER:
|
||||
return content::GetProcessLauncherTaskRunner();
|
||||
case TID_IO:
|
||||
if (BrowserThread::IsThreadInitialized(BrowserThread::IO))
|
||||
if (BrowserThread::IsThreadInitialized(BrowserThread::IO)) {
|
||||
return content::GetIOThreadTaskRunner({});
|
||||
}
|
||||
break;
|
||||
case TID_RENDERER:
|
||||
return manager->GetRenderTaskRunner();
|
||||
@@ -85,8 +90,9 @@ scoped_refptr<base::SingleThreadTaskRunner> CefTaskRunnerImpl::GetTaskRunner(
|
||||
scoped_refptr<base::SingleThreadTaskRunner>
|
||||
CefTaskRunnerImpl::GetCurrentTaskRunner() {
|
||||
auto* manager = CefTaskRunnerManager::Get();
|
||||
if (!manager)
|
||||
if (!manager) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// For named browser process threads return the same TaskRunner as
|
||||
// GetTaskRunner(). Otherwise BelongsToThread() will return incorrect results.
|
||||
@@ -104,8 +110,9 @@ CefTaskRunnerImpl::GetCurrentTaskRunner() {
|
||||
|
||||
// Check for a MessageLoopProxy. This covers all of the named browser and
|
||||
// render process threads, plus a few extra.
|
||||
if (auto task_runner = base::ThreadTaskRunnerHandle::Get())
|
||||
if (auto task_runner = base::ThreadTaskRunnerHandle::Get()) {
|
||||
return task_runner;
|
||||
}
|
||||
|
||||
// Check for a WebWorker thread.
|
||||
return manager->GetWebWorkerTaskRunner();
|
||||
|
@@ -244,14 +244,16 @@ class CefTranslatorTestImpl : public CefTranslatorTest {
|
||||
// PRIMITIVE LIST VALUES
|
||||
|
||||
bool SetIntList(const std::vector<int>& val) override {
|
||||
if (val.size() != 2U)
|
||||
if (val.size() != 2U) {
|
||||
return false;
|
||||
}
|
||||
return val[0] == TEST_INT_VAL && val[1] == TEST_INT_VAL2;
|
||||
}
|
||||
|
||||
bool GetIntListByRef(IntList& val) override {
|
||||
if (val.size() != GetIntListSize())
|
||||
if (val.size() != GetIntListSize()) {
|
||||
return false;
|
||||
}
|
||||
val.clear();
|
||||
val.push_back(TEST_INT_VAL);
|
||||
val.push_back(TEST_INT_VAL2);
|
||||
@@ -273,15 +275,17 @@ class CefTranslatorTestImpl : public CefTranslatorTest {
|
||||
// STRING LIST VALUES
|
||||
|
||||
bool SetStringList(const std::vector<CefString>& val) override {
|
||||
if (val.size() != 3U)
|
||||
if (val.size() != 3U) {
|
||||
return false;
|
||||
}
|
||||
return val[0] == TEST_STRING_VAL && val[1] == TEST_STRING_VAL2 &&
|
||||
val[2] == TEST_STRING_VAL3;
|
||||
}
|
||||
|
||||
bool GetStringListByRef(StringList& val) override {
|
||||
if (val.size() != 0U)
|
||||
if (val.size() != 0U) {
|
||||
return false;
|
||||
}
|
||||
val.push_back(TEST_STRING_VAL);
|
||||
val.push_back(TEST_STRING_VAL2);
|
||||
val.push_back(TEST_STRING_VAL3);
|
||||
@@ -291,26 +295,31 @@ class CefTranslatorTestImpl : public CefTranslatorTest {
|
||||
// STRING MAP VALUES
|
||||
|
||||
bool SetStringMap(const StringMap& val) override {
|
||||
if (val.size() != 3U)
|
||||
if (val.size() != 3U) {
|
||||
return false;
|
||||
}
|
||||
|
||||
StringMap::const_iterator it;
|
||||
|
||||
it = val.find(TEST_STRING_KEY);
|
||||
if (it == val.end() || it->second != TEST_STRING_VAL)
|
||||
if (it == val.end() || it->second != TEST_STRING_VAL) {
|
||||
return false;
|
||||
}
|
||||
it = val.find(TEST_STRING_KEY2);
|
||||
if (it == val.end() || it->second != TEST_STRING_VAL2)
|
||||
if (it == val.end() || it->second != TEST_STRING_VAL2) {
|
||||
return false;
|
||||
}
|
||||
it = val.find(TEST_STRING_KEY3);
|
||||
if (it == val.end() || it->second != TEST_STRING_VAL3)
|
||||
if (it == val.end() || it->second != TEST_STRING_VAL3) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GetStringMapByRef(std::map<CefString, CefString>& val) override {
|
||||
if (val.size() != 0U)
|
||||
if (val.size() != 0U) {
|
||||
return false;
|
||||
}
|
||||
|
||||
val.insert(std::make_pair(TEST_STRING_KEY, TEST_STRING_VAL));
|
||||
val.insert(std::make_pair(TEST_STRING_KEY2, TEST_STRING_VAL2));
|
||||
@@ -322,26 +331,31 @@ class CefTranslatorTestImpl : public CefTranslatorTest {
|
||||
|
||||
bool SetStringMultimap(
|
||||
const std::multimap<CefString, CefString>& val) override {
|
||||
if (val.size() != 3U)
|
||||
if (val.size() != 3U) {
|
||||
return false;
|
||||
}
|
||||
|
||||
StringMultimap::const_iterator it;
|
||||
|
||||
it = val.find(TEST_STRING_KEY);
|
||||
if (it == val.end() || it->second != TEST_STRING_VAL)
|
||||
if (it == val.end() || it->second != TEST_STRING_VAL) {
|
||||
return false;
|
||||
}
|
||||
it = val.find(TEST_STRING_KEY2);
|
||||
if (it == val.end() || it->second != TEST_STRING_VAL2)
|
||||
if (it == val.end() || it->second != TEST_STRING_VAL2) {
|
||||
return false;
|
||||
}
|
||||
it = val.find(TEST_STRING_KEY3);
|
||||
if (it == val.end() || it->second != TEST_STRING_VAL3)
|
||||
if (it == val.end() || it->second != TEST_STRING_VAL3) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GetStringMultimapByRef(StringMultimap& val) override {
|
||||
if (val.size() != 0U)
|
||||
if (val.size() != 0U) {
|
||||
return false;
|
||||
}
|
||||
|
||||
val.insert(std::make_pair(TEST_STRING_KEY, TEST_STRING_VAL));
|
||||
val.insert(std::make_pair(TEST_STRING_KEY2, TEST_STRING_VAL2));
|
||||
@@ -364,15 +378,17 @@ class CefTranslatorTestImpl : public CefTranslatorTest {
|
||||
// STRUCT LIST VALUES
|
||||
|
||||
bool SetPointList(const std::vector<CefPoint>& val) override {
|
||||
if (val.size() != 2U)
|
||||
if (val.size() != 2U) {
|
||||
return false;
|
||||
}
|
||||
return val[0].x == TEST_X_VAL && val[0].y == TEST_Y_VAL &&
|
||||
val[1].x == TEST_X_VAL2 && val[1].y == TEST_Y_VAL2;
|
||||
}
|
||||
|
||||
bool GetPointListByRef(PointList& val) override {
|
||||
if (val.size() != GetPointListSize())
|
||||
if (val.size() != GetPointListSize()) {
|
||||
return false;
|
||||
}
|
||||
val.clear();
|
||||
val.push_back(CefPoint(TEST_X_VAL, TEST_Y_VAL));
|
||||
val.push_back(CefPoint(TEST_X_VAL2, TEST_Y_VAL2));
|
||||
@@ -413,16 +429,18 @@ class CefTranslatorTestImpl : public CefTranslatorTest {
|
||||
const std::vector<CefRefPtr<CefTranslatorTestRefPtrLibrary>>& val,
|
||||
int val1,
|
||||
int val2) override {
|
||||
if (val.size() != 2U)
|
||||
if (val.size() != 2U) {
|
||||
return false;
|
||||
}
|
||||
return val[0]->GetValue() == val1 && val[1]->GetValue() == val2;
|
||||
}
|
||||
|
||||
bool GetRefPtrLibraryListByRef(RefPtrLibraryList& val,
|
||||
int val1,
|
||||
int val2) override {
|
||||
if (val.size() != GetRefPtrLibraryListSize())
|
||||
if (val.size() != GetRefPtrLibraryListSize()) {
|
||||
return false;
|
||||
}
|
||||
val.clear();
|
||||
val.push_back(new CefTranslatorTestRefPtrLibraryChildImpl(val1, 0));
|
||||
val.push_back(new CefTranslatorTestRefPtrLibraryImpl(val2));
|
||||
@@ -458,8 +476,9 @@ class CefTranslatorTestImpl : public CefTranslatorTest {
|
||||
const std::vector<CefRefPtr<CefTranslatorTestRefPtrClient>>& val,
|
||||
int val1,
|
||||
int val2) override {
|
||||
if (val.size() != 2U)
|
||||
if (val.size() != 2U) {
|
||||
return false;
|
||||
}
|
||||
return val[0]->GetValue() == val1 && val[1]->GetValue() == val2;
|
||||
}
|
||||
|
||||
@@ -467,8 +486,9 @@ class CefTranslatorTestImpl : public CefTranslatorTest {
|
||||
RefPtrClientList& val,
|
||||
CefRefPtr<CefTranslatorTestRefPtrClient> val1,
|
||||
CefRefPtr<CefTranslatorTestRefPtrClient> val2) override {
|
||||
if (val.size() != GetRefPtrClientListSize())
|
||||
if (val.size() != GetRefPtrClientListSize()) {
|
||||
return false;
|
||||
}
|
||||
val.clear();
|
||||
val.push_back(val1);
|
||||
val.push_back(val2);
|
||||
@@ -542,8 +562,9 @@ class CefTranslatorTestImpl : public CefTranslatorTest {
|
||||
const std::vector<CefRawPtr<CefTranslatorTestScopedLibrary>>& val,
|
||||
int val1,
|
||||
int val2) override {
|
||||
if (val.size() != 2U)
|
||||
if (val.size() != 2U) {
|
||||
return false;
|
||||
}
|
||||
return val[0]->GetValue() == val1 && val[1]->GetValue() == val2;
|
||||
}
|
||||
|
||||
@@ -564,8 +585,9 @@ class CefTranslatorTestImpl : public CefTranslatorTest {
|
||||
const std::vector<CefRawPtr<CefTranslatorTestScopedClient>>& val,
|
||||
int val1,
|
||||
int val2) override {
|
||||
if (val.size() != 2U)
|
||||
if (val.size() != 2U) {
|
||||
return false;
|
||||
}
|
||||
return val[0]->GetValue() == val1 && val[1]->GetValue() == val2;
|
||||
}
|
||||
|
||||
|
@@ -63,8 +63,9 @@ bool CefThreadImpl::Create(const CefString& display_name,
|
||||
cef_com_init_mode_t com_init_mode) {
|
||||
owner_task_runner_ = CefTaskRunnerImpl::GetCurrentTaskRunner();
|
||||
DCHECK(owner_task_runner_);
|
||||
if (!owner_task_runner_)
|
||||
if (!owner_task_runner_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
thread_.reset(new base::Thread(display_name));
|
||||
|
||||
@@ -99,8 +100,9 @@ bool CefThreadImpl::Create(const CefString& display_name,
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
if (com_init_mode != COM_INIT_MODE_NONE) {
|
||||
if (com_init_mode == COM_INIT_MODE_STA)
|
||||
if (com_init_mode == COM_INIT_MODE_STA) {
|
||||
options.message_pump_type = base::MessagePumpType::UI;
|
||||
}
|
||||
thread_->init_com_with_mta(com_init_mode == COM_INIT_MODE_MTA);
|
||||
}
|
||||
#endif
|
||||
@@ -124,20 +126,23 @@ cef_platform_thread_id_t CefThreadImpl::GetPlatformThreadId() {
|
||||
}
|
||||
|
||||
void CefThreadImpl::Stop() {
|
||||
if (!owner_task_runner_)
|
||||
if (!owner_task_runner_) {
|
||||
return;
|
||||
}
|
||||
if (!owner_task_runner_->RunsTasksInCurrentSequence()) {
|
||||
NOTREACHED() << "called on invalid thread";
|
||||
return;
|
||||
}
|
||||
|
||||
if (thread_)
|
||||
if (thread_) {
|
||||
StopAndDestroy(thread_.release());
|
||||
}
|
||||
}
|
||||
|
||||
bool CefThreadImpl::IsRunning() {
|
||||
if (!owner_task_runner_)
|
||||
if (!owner_task_runner_) {
|
||||
return false;
|
||||
}
|
||||
if (!owner_task_runner_->RunsTasksInCurrentSequence()) {
|
||||
NOTREACHED() << "called on invalid thread";
|
||||
return false;
|
||||
|
@@ -40,8 +40,9 @@ void cef_time_to_basetime(const cef_time_t& cef_time, base::Time& time) {
|
||||
void cef_time_from_basetime(const base::Time& time, cef_time_t& cef_time) {
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
int64_t t = time.ToDeltaSinceWindowsEpoch().InMicroseconds();
|
||||
if (!CanConvertToFileTime(t))
|
||||
if (!CanConvertToFileTime(t)) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
base::Time::Exploded exploded;
|
||||
@@ -57,8 +58,9 @@ void cef_time_from_basetime(const base::Time& time, cef_time_t& cef_time) {
|
||||
}
|
||||
|
||||
CEF_EXPORT int cef_time_to_timet(const cef_time_t* cef_time, time_t* time) {
|
||||
if (!cef_time || !time)
|
||||
if (!cef_time || !time) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
base::Time base_time;
|
||||
cef_time_to_basetime(*cef_time, base_time);
|
||||
@@ -67,8 +69,9 @@ CEF_EXPORT int cef_time_to_timet(const cef_time_t* cef_time, time_t* time) {
|
||||
}
|
||||
|
||||
CEF_EXPORT int cef_time_from_timet(time_t time, cef_time_t* cef_time) {
|
||||
if (!cef_time)
|
||||
if (!cef_time) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
base::Time base_time = base::Time::FromTimeT(time);
|
||||
cef_time_from_basetime(base_time, *cef_time);
|
||||
@@ -76,8 +79,9 @@ CEF_EXPORT int cef_time_from_timet(time_t time, cef_time_t* cef_time) {
|
||||
}
|
||||
|
||||
CEF_EXPORT int cef_time_to_doublet(const cef_time_t* cef_time, double* time) {
|
||||
if (!cef_time || !time)
|
||||
if (!cef_time || !time) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
base::Time base_time;
|
||||
cef_time_to_basetime(*cef_time, base_time);
|
||||
@@ -86,8 +90,9 @@ CEF_EXPORT int cef_time_to_doublet(const cef_time_t* cef_time, double* time) {
|
||||
}
|
||||
|
||||
CEF_EXPORT int cef_time_from_doublet(double time, cef_time_t* cef_time) {
|
||||
if (!cef_time)
|
||||
if (!cef_time) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
base::Time base_time = base::Time::FromDoubleT(time);
|
||||
cef_time_from_basetime(base_time, *cef_time);
|
||||
@@ -95,8 +100,9 @@ CEF_EXPORT int cef_time_from_doublet(double time, cef_time_t* cef_time) {
|
||||
}
|
||||
|
||||
CEF_EXPORT int cef_time_now(cef_time_t* cef_time) {
|
||||
if (!cef_time)
|
||||
if (!cef_time) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
base::Time base_time = base::Time::Now();
|
||||
cef_time_from_basetime(base_time, *cef_time);
|
||||
@@ -110,8 +116,9 @@ CEF_EXPORT cef_basetime_t cef_basetime_now() {
|
||||
CEF_EXPORT int cef_time_delta(const cef_time_t* cef_time1,
|
||||
const cef_time_t* cef_time2,
|
||||
long long* delta) {
|
||||
if (!cef_time1 || !cef_time2 || !delta)
|
||||
if (!cef_time1 || !cef_time2 || !delta) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
base::Time base_time1, base_time2;
|
||||
cef_time_to_basetime(*cef_time1, base_time1);
|
||||
@@ -124,8 +131,9 @@ CEF_EXPORT int cef_time_delta(const cef_time_t* cef_time1,
|
||||
|
||||
CEF_EXPORT int cef_time_to_basetime(const cef_time_t* from,
|
||||
cef_basetime_t* to) {
|
||||
if (!from || !to)
|
||||
if (!from || !to) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
base::Time::Exploded exploded;
|
||||
exploded.year = from->year;
|
||||
@@ -144,8 +152,9 @@ CEF_EXPORT int cef_time_to_basetime(const cef_time_t* from,
|
||||
|
||||
CEF_EXPORT int cef_time_from_basetime(const cef_basetime_t from,
|
||||
cef_time_t* to) {
|
||||
if (!to)
|
||||
if (!to) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
base::Time time = CefBaseTime(from);
|
||||
|
||||
|
@@ -11,26 +11,30 @@ CefTrackNode::CefTrackNode() : track_next_(nullptr), track_prev_(nullptr) {}
|
||||
CefTrackNode::~CefTrackNode() {}
|
||||
|
||||
void CefTrackNode::InsertTrackPrev(CefTrackNode* object) {
|
||||
if (track_prev_)
|
||||
if (track_prev_) {
|
||||
track_prev_->SetTrackNext(object);
|
||||
}
|
||||
object->SetTrackNext(this);
|
||||
object->SetTrackPrev(track_prev_);
|
||||
track_prev_ = object;
|
||||
}
|
||||
|
||||
void CefTrackNode::InsertTrackNext(CefTrackNode* object) {
|
||||
if (track_next_)
|
||||
if (track_next_) {
|
||||
track_next_->SetTrackPrev(object);
|
||||
}
|
||||
object->SetTrackPrev(this);
|
||||
object->SetTrackNext(track_next_);
|
||||
track_next_ = object;
|
||||
}
|
||||
|
||||
void CefTrackNode::RemoveTracking() {
|
||||
if (track_next_)
|
||||
if (track_next_) {
|
||||
track_next_->SetTrackPrev(track_prev_);
|
||||
if (track_prev_)
|
||||
}
|
||||
if (track_prev_) {
|
||||
track_prev_->SetTrackNext(track_next_);
|
||||
}
|
||||
track_next_ = nullptr;
|
||||
track_prev_ = nullptr;
|
||||
}
|
||||
|
@@ -32,8 +32,9 @@ CefRefPtr<CefURLRequest> CefURLRequest::Create(
|
||||
// In the browser process.
|
||||
CefRefPtr<CefBrowserURLRequest> impl =
|
||||
new CefBrowserURLRequest(nullptr, request, client, request_context);
|
||||
if (impl->Start())
|
||||
if (impl->Start()) {
|
||||
return impl.get();
|
||||
}
|
||||
return nullptr;
|
||||
} else {
|
||||
NOTREACHED() << "called in unsupported process";
|
||||
|
@@ -18,8 +18,9 @@ void OverrideChildProcessPath() {
|
||||
base::FilePath child_process_path =
|
||||
base::CommandLine::ForCurrentProcess()->GetSwitchValuePath(
|
||||
switches::kBrowserSubprocessPath);
|
||||
if (child_process_path.empty())
|
||||
if (child_process_path.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Used by ChildProcessHost::GetChildPath and PlatformCrashpadInitialization.
|
||||
base::PathService::Override(content::CHILD_PROCESS_EXE, child_process_path);
|
||||
|
@@ -23,8 +23,9 @@ namespace {
|
||||
// Returns the path to the Frameworks directory inside the top-level app bundle.
|
||||
base::FilePath GetFrameworksPath() {
|
||||
base::FilePath bundle_path = GetMainBundlePath();
|
||||
if (bundle_path.empty())
|
||||
if (bundle_path.empty()) {
|
||||
return base::FilePath();
|
||||
}
|
||||
|
||||
return bundle_path.Append(FILE_PATH_LITERAL("Contents"))
|
||||
.Append(FILE_PATH_LITERAL("Frameworks"));
|
||||
@@ -79,12 +80,14 @@ base::FilePath GetFrameworkDirectory() {
|
||||
base::FilePath frameworks_path =
|
||||
base::CommandLine::ForCurrentProcess()->GetSwitchValuePath(
|
||||
switches::kFrameworkDirPath);
|
||||
if (!frameworks_path.empty())
|
||||
if (!frameworks_path.empty()) {
|
||||
return frameworks_path;
|
||||
}
|
||||
|
||||
frameworks_path = GetFrameworksPath();
|
||||
if (frameworks_path.empty())
|
||||
if (frameworks_path.empty()) {
|
||||
return base::FilePath();
|
||||
}
|
||||
|
||||
return frameworks_path.Append(GetFrameworkName())
|
||||
.AddExtension(FILE_PATH_LITERAL(".framework"));
|
||||
@@ -92,8 +95,9 @@ base::FilePath GetFrameworkDirectory() {
|
||||
|
||||
base::FilePath GetFrameworkResourcesDirectory() {
|
||||
base::FilePath frameworks_path = GetFrameworkDirectory();
|
||||
if (frameworks_path.empty())
|
||||
if (frameworks_path.empty()) {
|
||||
return base::FilePath();
|
||||
}
|
||||
|
||||
return frameworks_path.Append(FILE_PATH_LITERAL("Resources"));
|
||||
}
|
||||
@@ -109,8 +113,9 @@ base::FilePath GetMainBundlePath() {
|
||||
base::FilePath main_bundle_path =
|
||||
base::CommandLine::ForCurrentProcess()->GetSwitchValuePath(
|
||||
switches::kMainBundlePath);
|
||||
if (!main_bundle_path.empty())
|
||||
if (!main_bundle_path.empty()) {
|
||||
return main_bundle_path;
|
||||
}
|
||||
|
||||
return base::mac::GetAppBundlePath(GetMainProcessPath());
|
||||
}
|
||||
@@ -122,8 +127,9 @@ std::string GetMainBundleID() {
|
||||
|
||||
base::FilePath GetMainResourcesDirectory() {
|
||||
base::FilePath bundle_path = GetMainBundlePath();
|
||||
if (bundle_path.empty())
|
||||
if (bundle_path.empty()) {
|
||||
return base::FilePath();
|
||||
}
|
||||
|
||||
return bundle_path.Append(FILE_PATH_LITERAL("Contents"))
|
||||
.Append(FILE_PATH_LITERAL("Resources"));
|
||||
@@ -131,8 +137,9 @@ base::FilePath GetMainResourcesDirectory() {
|
||||
|
||||
base::FilePath GetChildProcessPath() {
|
||||
base::FilePath frameworks_path = GetFrameworksPath();
|
||||
if (frameworks_path.empty())
|
||||
if (frameworks_path.empty()) {
|
||||
return base::FilePath();
|
||||
}
|
||||
|
||||
std::string exe_name = GetMainProcessPath().BaseName().value();
|
||||
return frameworks_path.Append(FILE_PATH_LITERAL(exe_name + " Helper.app"))
|
||||
|
@@ -62,8 +62,9 @@ void CefValueController::Remove(void* value, bool notify_object) {
|
||||
// Remove all references.
|
||||
if (reference_map_.size() > 0) {
|
||||
ReferenceMap::iterator it = reference_map_.begin();
|
||||
for (; it != reference_map_.end(); ++it)
|
||||
for (; it != reference_map_.end(); ++it) {
|
||||
it->second->OnControlRemoved();
|
||||
}
|
||||
reference_map_.clear();
|
||||
}
|
||||
|
||||
@@ -73,8 +74,9 @@ void CefValueController::Remove(void* value, bool notify_object) {
|
||||
ReferenceMap::iterator it = reference_map_.find(value);
|
||||
if (it != reference_map_.end()) {
|
||||
// Remove the reference.
|
||||
if (notify_object)
|
||||
if (notify_object) {
|
||||
it->second->OnControlRemoved();
|
||||
}
|
||||
reference_map_.erase(it);
|
||||
}
|
||||
}
|
||||
@@ -90,8 +92,9 @@ CefValueController::Object* CefValueController::Get(void* value) {
|
||||
return owner_object_;
|
||||
} else {
|
||||
ReferenceMap::iterator it = reference_map_.find(value);
|
||||
if (it != reference_map_.end())
|
||||
if (it != reference_map_.end()) {
|
||||
return it->second;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
@@ -120,12 +123,14 @@ void CefValueController::RemoveDependencies(void* value) {
|
||||
// Controller should already be locked.
|
||||
DCHECK(locked());
|
||||
|
||||
if (dependency_map_.empty())
|
||||
if (dependency_map_.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
DependencyMap::iterator it_dependency = dependency_map_.find(value);
|
||||
if (it_dependency == dependency_map_.end())
|
||||
if (it_dependency == dependency_map_.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Start with the set of dependencies for the current value.
|
||||
DependencySet remove_set = it_dependency->second;
|
||||
@@ -189,8 +194,9 @@ void CefValueController::TakeFrom(CefValueController* other) {
|
||||
// Evaluate each child.
|
||||
DependencySet::iterator it_other_set = it_other->second.begin();
|
||||
for (; it_other_set != it_other->second.end(); ++it_other_set) {
|
||||
if (it_me->second.find(*it_other_set) == it_me->second.end())
|
||||
if (it_me->second.find(*it_other_set) == it_me->second.end()) {
|
||||
it_me->second.insert(*it_other_set);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -203,8 +209,9 @@ void CefValueController::Swap(void* old_value, void* new_value) {
|
||||
// Controller should already be locked.
|
||||
DCHECK(locked());
|
||||
|
||||
if (owner_value_ == old_value)
|
||||
if (owner_value_ == old_value) {
|
||||
owner_value_ = new_value;
|
||||
}
|
||||
|
||||
if (!reference_map_.empty()) {
|
||||
ReferenceMap::iterator it = reference_map_.find(old_value);
|
||||
|
@@ -36,16 +36,18 @@ class CefValueController
|
||||
explicit AutoLock(CefValueController* impl)
|
||||
: impl_(impl), verified_(impl && impl->VerifyThread()) {
|
||||
DCHECK(impl);
|
||||
if (verified_)
|
||||
if (verified_) {
|
||||
impl_->lock();
|
||||
}
|
||||
}
|
||||
|
||||
AutoLock(const AutoLock&) = delete;
|
||||
AutoLock& operator=(const AutoLock&) = delete;
|
||||
|
||||
~AutoLock() {
|
||||
if (verified_)
|
||||
if (verified_) {
|
||||
impl_->unlock();
|
||||
}
|
||||
}
|
||||
|
||||
inline bool verified() { return verified_; }
|
||||
@@ -270,8 +272,9 @@ class CefValueBase : public CefType, public CefValueController::Object {
|
||||
controller_->AddReference(value_, this);
|
||||
|
||||
// Add a dependency on the parent value.
|
||||
if (parent_value)
|
||||
if (parent_value) {
|
||||
controller_->AddDependency(parent_value, value_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,8 +282,9 @@ class CefValueBase : public CefType, public CefValueController::Object {
|
||||
CefValueBase& operator=(const CefValueBase&) = delete;
|
||||
|
||||
~CefValueBase() override {
|
||||
if (controller_.get() && value_)
|
||||
if (controller_.get() && value_) {
|
||||
Delete();
|
||||
}
|
||||
}
|
||||
|
||||
// True if the underlying value is referenced instead of owned.
|
||||
@@ -397,8 +401,9 @@ class CefValueBase : public CefType, public CefValueController::Object {
|
||||
// Used to indicate that this object owns the controller.
|
||||
inline void SetOwnsController() {
|
||||
CefValueController::AutoLock lock_scope(controller_.get());
|
||||
if (lock_scope.verified())
|
||||
if (lock_scope.verified()) {
|
||||
controller_->SetOwner(value_, this);
|
||||
}
|
||||
}
|
||||
|
||||
// Encapsulates value locking and verification logic.
|
||||
|
@@ -134,12 +134,15 @@ void CefValueImpl::SwapValue(base::Value* new_value,
|
||||
bool CefValueImpl::IsValid() {
|
||||
base::AutoLock lock_scope(lock_);
|
||||
|
||||
if (binary_value_)
|
||||
if (binary_value_) {
|
||||
return binary_value_->IsValid();
|
||||
if (dictionary_value_)
|
||||
}
|
||||
if (dictionary_value_) {
|
||||
return dictionary_value_->IsValid();
|
||||
if (list_value_)
|
||||
}
|
||||
if (list_value_) {
|
||||
return list_value_->IsValid();
|
||||
}
|
||||
|
||||
return (value_ != nullptr);
|
||||
}
|
||||
@@ -147,12 +150,15 @@ bool CefValueImpl::IsValid() {
|
||||
bool CefValueImpl::IsOwned() {
|
||||
base::AutoLock lock_scope(lock_);
|
||||
|
||||
if (binary_value_)
|
||||
if (binary_value_) {
|
||||
return binary_value_->IsOwned();
|
||||
if (dictionary_value_)
|
||||
}
|
||||
if (dictionary_value_) {
|
||||
return dictionary_value_->IsOwned();
|
||||
if (list_value_)
|
||||
}
|
||||
if (list_value_) {
|
||||
return list_value_->IsOwned();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -160,58 +166,72 @@ bool CefValueImpl::IsOwned() {
|
||||
bool CefValueImpl::IsReadOnly() {
|
||||
base::AutoLock lock_scope(lock_);
|
||||
|
||||
if (binary_value_)
|
||||
if (binary_value_) {
|
||||
return true;
|
||||
if (dictionary_value_)
|
||||
}
|
||||
if (dictionary_value_) {
|
||||
return dictionary_value_->IsReadOnly();
|
||||
if (list_value_)
|
||||
}
|
||||
if (list_value_) {
|
||||
return list_value_->IsReadOnly();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CefValueImpl::IsSame(CefRefPtr<CefValue> that) {
|
||||
if (that.get() == this)
|
||||
if (that.get() == this) {
|
||||
return true;
|
||||
if (!that.get() || that->GetType() != GetType())
|
||||
}
|
||||
if (!that.get() || that->GetType() != GetType()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CefValueImpl* impl = static_cast<CefValueImpl*>(that.get());
|
||||
|
||||
base::AutoLock lock_scope(lock_);
|
||||
base::AutoLock lock_scope2(impl->lock_);
|
||||
|
||||
if (binary_value_)
|
||||
if (binary_value_) {
|
||||
return binary_value_->IsSame(impl->binary_value_);
|
||||
if (dictionary_value_)
|
||||
}
|
||||
if (dictionary_value_) {
|
||||
return dictionary_value_->IsSame(impl->dictionary_value_);
|
||||
if (list_value_)
|
||||
}
|
||||
if (list_value_) {
|
||||
return list_value_->IsSame(impl->list_value_);
|
||||
}
|
||||
|
||||
// Simple types are never the same.
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CefValueImpl::IsEqual(CefRefPtr<CefValue> that) {
|
||||
if (that.get() == this)
|
||||
if (that.get() == this) {
|
||||
return true;
|
||||
if (!that.get() || that->GetType() != GetType())
|
||||
}
|
||||
if (!that.get() || that->GetType() != GetType()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CefValueImpl* impl = static_cast<CefValueImpl*>(that.get());
|
||||
|
||||
base::AutoLock lock_scope(lock_);
|
||||
base::AutoLock lock_scope2(impl->lock_);
|
||||
|
||||
if (binary_value_)
|
||||
if (binary_value_) {
|
||||
return binary_value_->IsEqual(impl->binary_value_);
|
||||
if (dictionary_value_)
|
||||
}
|
||||
if (dictionary_value_) {
|
||||
return dictionary_value_->IsEqual(impl->dictionary_value_);
|
||||
if (list_value_)
|
||||
}
|
||||
if (list_value_) {
|
||||
return list_value_->IsEqual(impl->list_value_);
|
||||
}
|
||||
|
||||
if (!value_) // Invalid types are equal.
|
||||
if (!value_) { // Invalid types are equal.
|
||||
return true;
|
||||
}
|
||||
|
||||
return *value_ == *(impl->value_.get());
|
||||
}
|
||||
@@ -219,14 +239,18 @@ bool CefValueImpl::IsEqual(CefRefPtr<CefValue> that) {
|
||||
CefRefPtr<CefValue> CefValueImpl::Copy() {
|
||||
base::AutoLock lock_scope(lock_);
|
||||
|
||||
if (binary_value_)
|
||||
if (binary_value_) {
|
||||
return new CefValueImpl(binary_value_->Copy());
|
||||
if (dictionary_value_)
|
||||
}
|
||||
if (dictionary_value_) {
|
||||
return new CefValueImpl(dictionary_value_->Copy(false));
|
||||
if (list_value_)
|
||||
}
|
||||
if (list_value_) {
|
||||
return new CefValueImpl(list_value_->Copy());
|
||||
if (value_)
|
||||
}
|
||||
if (value_) {
|
||||
return new CefValueImpl(new base::Value(value_->Clone()));
|
||||
}
|
||||
|
||||
return new CefValueImpl();
|
||||
}
|
||||
@@ -234,12 +258,15 @@ CefRefPtr<CefValue> CefValueImpl::Copy() {
|
||||
CefValueType CefValueImpl::GetType() {
|
||||
base::AutoLock lock_scope(lock_);
|
||||
|
||||
if (binary_value_)
|
||||
if (binary_value_) {
|
||||
return VTYPE_BINARY;
|
||||
if (dictionary_value_)
|
||||
}
|
||||
if (dictionary_value_) {
|
||||
return VTYPE_DICTIONARY;
|
||||
if (list_value_)
|
||||
}
|
||||
if (list_value_) {
|
||||
return VTYPE_LIST;
|
||||
}
|
||||
|
||||
if (value_) {
|
||||
switch (value_->type()) {
|
||||
@@ -266,8 +293,9 @@ bool CefValueImpl::GetBool() {
|
||||
base::AutoLock lock_scope(lock_);
|
||||
|
||||
bool ret_value = false;
|
||||
if (value_ && value_->is_bool())
|
||||
if (value_ && value_->is_bool()) {
|
||||
ret_value = value_->GetBool();
|
||||
}
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
@@ -275,8 +303,9 @@ int CefValueImpl::GetInt() {
|
||||
base::AutoLock lock_scope(lock_);
|
||||
|
||||
int ret_value = 0;
|
||||
if (value_ && value_->is_int())
|
||||
if (value_ && value_->is_int()) {
|
||||
ret_value = value_->GetInt();
|
||||
}
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
@@ -284,8 +313,9 @@ double CefValueImpl::GetDouble() {
|
||||
base::AutoLock lock_scope(lock_);
|
||||
|
||||
double ret_value = 0;
|
||||
if (value_ && value_->is_double())
|
||||
if (value_ && value_->is_double()) {
|
||||
ret_value = value_->GetDouble();
|
||||
}
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
@@ -293,8 +323,9 @@ CefString CefValueImpl::GetString() {
|
||||
base::AutoLock lock_scope(lock_);
|
||||
|
||||
std::string ret_value;
|
||||
if (value_ && value_->is_string())
|
||||
if (value_ && value_->is_string()) {
|
||||
ret_value = value_->GetString();
|
||||
}
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
@@ -405,8 +436,9 @@ void CefValueImpl::AcquireLock() NO_THREAD_SAFETY_ANALYSIS {
|
||||
lock_.Acquire();
|
||||
|
||||
CefValueController* controller = GetValueController();
|
||||
if (controller)
|
||||
if (controller) {
|
||||
controller->lock();
|
||||
}
|
||||
}
|
||||
|
||||
void CefValueImpl::ReleaseLock() NO_THREAD_SAFETY_ANALYSIS {
|
||||
@@ -441,8 +473,9 @@ CefRefPtr<CefBinaryValue> CefBinaryValue::Create(const void* data,
|
||||
size_t data_size) {
|
||||
DCHECK(data);
|
||||
DCHECK_GT(data_size, (size_t)0);
|
||||
if (!data || data_size == 0)
|
||||
if (!data || data_size == 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new CefBinaryValueImpl(static_cast<char*>(const_cast<void*>(data)),
|
||||
data_size);
|
||||
@@ -458,8 +491,9 @@ CefRefPtr<CefBinaryValue> CefBinaryValueImpl::GetOrCreateRef(
|
||||
DCHECK(controller);
|
||||
|
||||
CefValueController::Object* object = controller->Get(value);
|
||||
if (object)
|
||||
if (object) {
|
||||
return static_cast<CefBinaryValueImpl*>(object);
|
||||
}
|
||||
|
||||
return new CefBinaryValueImpl(value, parent_value,
|
||||
CefBinaryValueImpl::kReference, controller);
|
||||
@@ -513,8 +547,9 @@ bool CefBinaryValueImpl::IsEqualValue(const base::Value* that) {
|
||||
}
|
||||
|
||||
base::Value* CefBinaryValueImpl::GetValueUnsafe() {
|
||||
if (!VerifyAttached())
|
||||
if (!VerifyAttached()) {
|
||||
return nullptr;
|
||||
}
|
||||
controller()->AssertLockAcquired();
|
||||
return const_cast<base::Value*>(&const_value());
|
||||
}
|
||||
@@ -528,10 +563,12 @@ bool CefBinaryValueImpl::IsOwned() {
|
||||
}
|
||||
|
||||
bool CefBinaryValueImpl::IsSame(CefRefPtr<CefBinaryValue> that) {
|
||||
if (!that.get())
|
||||
if (!that.get()) {
|
||||
return false;
|
||||
if (that.get() == this)
|
||||
}
|
||||
if (that.get() == this) {
|
||||
return true;
|
||||
}
|
||||
|
||||
CEF_VALUE_VERIFY_RETURN(false, false);
|
||||
return static_cast<CefBinaryValueImpl*>(that.get())
|
||||
@@ -539,10 +576,12 @@ bool CefBinaryValueImpl::IsSame(CefRefPtr<CefBinaryValue> that) {
|
||||
}
|
||||
|
||||
bool CefBinaryValueImpl::IsEqual(CefRefPtr<CefBinaryValue> that) {
|
||||
if (!that.get())
|
||||
if (!that.get()) {
|
||||
return false;
|
||||
if (that.get() == this)
|
||||
}
|
||||
if (that.get() == this) {
|
||||
return true;
|
||||
}
|
||||
|
||||
CEF_VALUE_VERIFY_RETURN(false, false);
|
||||
return static_cast<CefBinaryValueImpl*>(that.get())
|
||||
@@ -565,15 +604,17 @@ size_t CefBinaryValueImpl::GetData(void* buffer,
|
||||
size_t data_offset) {
|
||||
DCHECK(buffer);
|
||||
DCHECK_GT(buffer_size, (size_t)0);
|
||||
if (!buffer || buffer_size == 0)
|
||||
if (!buffer || buffer_size == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
CEF_VALUE_VERIFY_RETURN(false, 0);
|
||||
|
||||
size_t size = const_value().GetBlob().size();
|
||||
DCHECK_LT(data_offset, size);
|
||||
if (data_offset >= size)
|
||||
if (data_offset >= size) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
size = std::min(buffer_size, size - data_offset);
|
||||
auto* data = const_value().GetBlob().data();
|
||||
@@ -605,8 +646,9 @@ CefRefPtr<CefDictionaryValue> CefDictionaryValueImpl::GetOrCreateRef(
|
||||
bool read_only,
|
||||
CefValueController* controller) {
|
||||
CefValueController::Object* object = controller->Get(value);
|
||||
if (object)
|
||||
if (object) {
|
||||
return static_cast<CefDictionaryValueImpl*>(object);
|
||||
}
|
||||
|
||||
return new CefDictionaryValueImpl(value, parent_value,
|
||||
CefDictionaryValueImpl::kReference,
|
||||
@@ -656,8 +698,9 @@ bool CefDictionaryValueImpl::IsEqualValue(const base::DictionaryValue* that) {
|
||||
}
|
||||
|
||||
base::DictionaryValue* CefDictionaryValueImpl::GetValueUnsafe() {
|
||||
if (!VerifyAttached())
|
||||
if (!VerifyAttached()) {
|
||||
return nullptr;
|
||||
}
|
||||
controller()->AssertLockAcquired();
|
||||
return const_cast<base::DictionaryValue*>(&const_value());
|
||||
}
|
||||
@@ -675,10 +718,12 @@ bool CefDictionaryValueImpl::IsReadOnly() {
|
||||
}
|
||||
|
||||
bool CefDictionaryValueImpl::IsSame(CefRefPtr<CefDictionaryValue> that) {
|
||||
if (!that.get())
|
||||
if (!that.get()) {
|
||||
return false;
|
||||
if (that.get() == this)
|
||||
}
|
||||
if (that.get() == this) {
|
||||
return true;
|
||||
}
|
||||
|
||||
CEF_VALUE_VERIFY_RETURN(false, false);
|
||||
return static_cast<CefDictionaryValueImpl*>(that.get())
|
||||
@@ -686,10 +731,12 @@ bool CefDictionaryValueImpl::IsSame(CefRefPtr<CefDictionaryValue> that) {
|
||||
}
|
||||
|
||||
bool CefDictionaryValueImpl::IsEqual(CefRefPtr<CefDictionaryValue> that) {
|
||||
if (!that.get())
|
||||
if (!that.get()) {
|
||||
return false;
|
||||
if (that.get() == this)
|
||||
}
|
||||
if (that.get() == this) {
|
||||
return true;
|
||||
}
|
||||
|
||||
CEF_VALUE_VERIFY_RETURN(false, false);
|
||||
return static_cast<CefDictionaryValueImpl*>(that.get())
|
||||
@@ -972,8 +1019,9 @@ bool CefDictionaryValueImpl::RemoveInternal(const CefString& key) {
|
||||
// comparison purposes.
|
||||
const base::Value* actual_value =
|
||||
const_value().FindKey(base::StringPiece(key));
|
||||
if (!actual_value)
|
||||
if (!actual_value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// |actual_value| is no longer valid after this call.
|
||||
absl::optional<base::Value> out_value =
|
||||
@@ -1039,8 +1087,9 @@ CefRefPtr<CefListValue> CefListValueImpl::GetOrCreateRef(
|
||||
bool read_only,
|
||||
CefValueController* controller) {
|
||||
CefValueController::Object* object = controller->Get(value);
|
||||
if (object)
|
||||
if (object) {
|
||||
return static_cast<CefListValueImpl*>(object);
|
||||
}
|
||||
|
||||
return new CefListValueImpl(value, parent_value, CefListValueImpl::kReference,
|
||||
read_only, controller);
|
||||
@@ -1088,8 +1137,9 @@ bool CefListValueImpl::IsEqualValue(const base::ListValue* that) {
|
||||
}
|
||||
|
||||
base::ListValue* CefListValueImpl::GetValueUnsafe() {
|
||||
if (!VerifyAttached())
|
||||
if (!VerifyAttached()) {
|
||||
return nullptr;
|
||||
}
|
||||
controller()->AssertLockAcquired();
|
||||
return const_cast<base::ListValue*>(&const_value());
|
||||
}
|
||||
@@ -1107,10 +1157,12 @@ bool CefListValueImpl::IsReadOnly() {
|
||||
}
|
||||
|
||||
bool CefListValueImpl::IsSame(CefRefPtr<CefListValue> that) {
|
||||
if (!that.get())
|
||||
if (!that.get()) {
|
||||
return false;
|
||||
if (that.get() == this)
|
||||
}
|
||||
if (that.get() == this) {
|
||||
return true;
|
||||
}
|
||||
|
||||
CEF_VALUE_VERIFY_RETURN(false, false);
|
||||
return static_cast<CefListValueImpl*>(that.get())
|
||||
@@ -1118,10 +1170,12 @@ bool CefListValueImpl::IsSame(CefRefPtr<CefListValue> that) {
|
||||
}
|
||||
|
||||
bool CefListValueImpl::IsEqual(CefRefPtr<CefListValue> that) {
|
||||
if (!that.get())
|
||||
if (!that.get()) {
|
||||
return false;
|
||||
if (that.get() == this)
|
||||
}
|
||||
if (that.get() == this) {
|
||||
return true;
|
||||
}
|
||||
|
||||
CEF_VALUE_VERIFY_RETURN(false, false);
|
||||
return static_cast<CefListValueImpl*>(that.get())
|
||||
@@ -1142,15 +1196,17 @@ bool CefListValueImpl::SetSize(size_t size) {
|
||||
size_t current_size = const_value().GetList().size();
|
||||
if (size < current_size) {
|
||||
// Clean up any values above the requested size.
|
||||
for (size_t i = current_size - 1; i >= size; --i)
|
||||
for (size_t i = current_size - 1; i >= size; --i) {
|
||||
RemoveInternal(i);
|
||||
}
|
||||
} else if (size > 0) {
|
||||
// Expand the list size.
|
||||
// TODO: This approach seems inefficient. See https://crbug.com/1187066#c17
|
||||
// for background.
|
||||
auto& list = mutable_value()->GetList();
|
||||
while (list.size() < size)
|
||||
while (list.size() < size) {
|
||||
mutable_value()->Append(base::Value());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1409,8 +1465,9 @@ bool CefListValueImpl::SetList(size_t index, CefRefPtr<CefListValue> value) {
|
||||
|
||||
bool CefListValueImpl::RemoveInternal(size_t index) {
|
||||
auto& list = mutable_value()->GetList();
|
||||
if (index >= list.size())
|
||||
if (index >= list.size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// The std::move() call below which removes the Value from the list will
|
||||
// return a new Value object with the moved contents of the Value that exists
|
||||
@@ -1447,8 +1504,9 @@ base::Value* CefListValueImpl::SetInternal(size_t index, base::Value* value) {
|
||||
// Expand the list size.
|
||||
// TODO: This approach seems inefficient. See
|
||||
// https://crbug.com/1187066#c17 for background.
|
||||
while (list.size() <= index)
|
||||
while (list.size() <= index) {
|
||||
mutable_value()->Append(base::Value());
|
||||
}
|
||||
}
|
||||
list[index] = std::move(*value);
|
||||
}
|
||||
|
@@ -49,13 +49,15 @@ bool CefWaitableEventImpl::IsSignaled() {
|
||||
}
|
||||
|
||||
void CefWaitableEventImpl::Wait() {
|
||||
if (!AllowWait())
|
||||
if (!AllowWait()) {
|
||||
return;
|
||||
}
|
||||
event_.Wait();
|
||||
}
|
||||
|
||||
bool CefWaitableEventImpl::TimedWait(int64 max_ms) {
|
||||
if (!AllowWait())
|
||||
if (!AllowWait()) {
|
||||
return false;
|
||||
}
|
||||
return event_.TimedWait(base::Milliseconds(max_ms));
|
||||
}
|
||||
|
Reference in New Issue
Block a user