diff --git a/chrome/browser/ui/webui/internals/web_app/web_app_internals_page_handler_impl.cc b/chrome/browser/ui/webui/internals/web_app/web_app_internals_page_handler_impl.cc
index 339fc5a6c..5e23be6fb 100644
--- a/chrome/browser/ui/webui/internals/web_app/web_app_internals_page_handler_impl.cc
+++ b/chrome/browser/ui/webui/internals/web_app/web_app_internals_page_handler_impl.cc
@@ -23,7 +23,7 @@ namespace {
template <typename T>
std::string ConvertToString(const T& value) {
- return (std::stringstream() << value).str();
+ return static_cast<const std::stringstream &>(std::stringstream() << value).str();
}
} // namespace
diff --git a/chrome/browser/web_applications/external_web_app_manager.cc b/chrome/browser/web_applications/external_web_app_manager.cc
index 3da14c154..64c2e80a9 100644
--- a/chrome/browser/web_applications/external_web_app_manager.cc
+++ b/chrome/browser/web_applications/external_web_app_manager.cc
@@ -100,7 +100,7 @@ LoadedConfigs LoadConfigsBlocking(const base::FilePath& config_dir) {
deserializer.Deserialize(nullptr, &error_msg);
if (!app_config) {
result.errors.push_back(
- (std::stringstream() << file << " was not valid JSON: " << error_msg)
+ static_cast<const std::stringstream &>(std::stringstream() << file << " was not valid JSON: " << error_msg)
.str());
VLOG(1) << result.errors.back();
continue;
diff --git a/chrome/browser/web_applications/external_web_app_utils.cc b/chrome/browser/web_applications/external_web_app_utils.cc
index 8b3414d06..6d0718198 100644
--- a/chrome/browser/web_applications/external_web_app_utils.cc
+++ b/chrome/browser/web_applications/external_web_app_utils.cc
@@ -158,7 +158,7 @@ OptionsOrError ParseConfig(FileUtilsWrapper& file_utils,
options.require_manifest = true;
if (app_config.type() != base::Value::Type::DICTIONARY) {
- return (std::stringstream()
+ return static_cast<const std::stringstream &>(std::stringstream()
<< file << " was not a dictionary as the top level")
.str();
}
@@ -166,18 +166,18 @@ OptionsOrError ParseConfig(FileUtilsWrapper& file_utils,
// user_type
const base::Value* value = app_config.FindListKey(kUserType);
if (!value) {
- return (std::stringstream() << file << " missing " << kUserType).str();
+ return static_cast<const std::stringstream &>(std::stringstream() << file << " missing " << kUserType).str();
}
for (const auto& item : value->GetList()) {
if (!item.is_string()) {
- return (std::stringstream()
+ return static_cast<const std::stringstream &>(std::stringstream()
<< file << " has invalid " << kUserType << item)
.str();
}
options.user_type_allowlist.push_back(item.GetString());
}
if (options.user_type_allowlist.empty()) {
- return (std::stringstream() << file << " has empty " << kUserType).str();
+ return static_cast<const std::stringstream &>(std::stringstream() << file << " has empty " << kUserType).str();
}
// feature_name
@@ -188,18 +188,18 @@ OptionsOrError ParseConfig(FileUtilsWrapper& file_utils,
// app_url
value = app_config.FindKeyOfType(kAppUrl, base::Value::Type::STRING);
if (!value) {
- return (std::stringstream() << file << " had a missing " << kAppUrl).str();
+ return static_cast<const std::stringstream &>(std::stringstream() << file << " had a missing " << kAppUrl).str();
}
options.install_url = GURL(value->GetString());
if (!options.install_url.is_valid()) {
- return (std::stringstream() << file << " had an invalid " << kAppUrl).str();
+ return static_cast<const std::stringstream &>(std::stringstream() << file << " had an invalid " << kAppUrl).str();
}
// only_for_new_users
value = app_config.FindKey(kOnlyForNewUsers);
if (value) {
if (!value->is_bool()) {
- return (std::stringstream()
+ return static_cast<const std::stringstream &>(std::stringstream()
<< file << " had an invalid " << kOnlyForNewUsers)
.str();
}
@@ -211,7 +211,7 @@ OptionsOrError ParseConfig(FileUtilsWrapper& file_utils,
value = app_config.FindKey(kHideFromUser);
if (value) {
if (!value->is_bool()) {
- return (std::stringstream()
+ return static_cast<const std::stringstream &>(std::stringstream()
<< file << " had an invalid " << kHideFromUser)
.str();
}
@@ -226,7 +226,7 @@ OptionsOrError ParseConfig(FileUtilsWrapper& file_utils,
value = app_config.FindKey(kCreateShortcuts);
if (value) {
if (!value->is_bool()) {
- return (std::stringstream()
+ return static_cast<const std::stringstream &>(std::stringstream()
<< file << " had an invalid " << kCreateShortcuts)
.str();
}
@@ -242,7 +242,7 @@ OptionsOrError ParseConfig(FileUtilsWrapper& file_utils,
value = app_config.FindKey(kDisableIfArcSupported);
if (value) {
if (!value->is_bool()) {
- return (std::stringstream()
+ return static_cast<const std::stringstream &>(std::stringstream()
<< file << " had an invalid " << kDisableIfArcSupported)
.str();
}
@@ -253,7 +253,7 @@ OptionsOrError ParseConfig(FileUtilsWrapper& file_utils,
value = app_config.FindKey(kDisableIfTabletFormFactor);
if (value) {
if (!value->is_bool()) {
- return (std::stringstream()
+ return static_cast<const std::stringstream &>(std::stringstream()
<< file << " had an invalid " << kDisableIfTabletFormFactor)
.str();
}
@@ -263,7 +263,7 @@ OptionsOrError ParseConfig(FileUtilsWrapper& file_utils,
// launch_container
value = app_config.FindKeyOfType(kLaunchContainer, base::Value::Type::STRING);
if (!value) {
- return (std::stringstream()
+ return static_cast<const std::stringstream &>(std::stringstream()
<< file << " had an invalid " << kLaunchContainer)
.str();
}
@@ -273,7 +273,7 @@ OptionsOrError ParseConfig(FileUtilsWrapper& file_utils,
} else if (launch_container_str == kLaunchContainerWindow) {
options.user_display_mode = DisplayMode::kStandalone;
} else {
- return (std::stringstream()
+ return static_cast<const std::stringstream &>(std::stringstream()
<< file << " had an invalid " << kLaunchContainer << ": "
<< launch_container_str)
.str();
@@ -283,7 +283,7 @@ OptionsOrError ParseConfig(FileUtilsWrapper& file_utils,
value = app_config.FindKey(kLaunchQueryParams);
if (value) {
if (!value->is_string()) {
- return (std::stringstream()
+ return static_cast<const std::stringstream &>(std::stringstream()
<< file << " had an invalid " << kLaunchQueryParams)
.str();
}
@@ -294,7 +294,7 @@ OptionsOrError ParseConfig(FileUtilsWrapper& file_utils,
value = app_config.FindKey(kLoadAndAwaitServiceWorkerRegistration);
if (value) {
if (!value->is_bool()) {
- return (std::stringstream() << file << " had an invalid "
+ return static_cast<const std::stringstream &>(std::stringstream() << file << " had an invalid "
<< kLoadAndAwaitServiceWorkerRegistration)
.str();
}
@@ -305,20 +305,20 @@ OptionsOrError ParseConfig(FileUtilsWrapper& file_utils,
value = app_config.FindKey(kServiceWorkerRegistrationUrl);
if (value) {
if (!options.load_and_await_service_worker_registration) {
- return (std::stringstream()
+ return static_cast<const std::stringstream &>(std::stringstream()
<< file << " should not specify a "
<< kServiceWorkerRegistrationUrl << " while "
<< kLoadAndAwaitServiceWorkerRegistration << " is disabled")
.str();
}
if (!value->is_string()) {
- return (std::stringstream()
+ return static_cast<const std::stringstream &>(std::stringstream()
<< file << " had an invalid " << kServiceWorkerRegistrationUrl)
.str();
}
options.service_worker_registration_url.emplace(value->GetString());
if (!options.service_worker_registration_url->is_valid()) {
- return (std::stringstream()
+ return static_cast<const std::stringstream &>(std::stringstream()
<< file << " had an invalid " << kServiceWorkerRegistrationUrl)
.str();
}
@@ -328,7 +328,7 @@ OptionsOrError ParseConfig(FileUtilsWrapper& file_utils,
value = app_config.FindKey(kUninstallAndReplace);
if (value) {
if (!value->is_list()) {
- return (std::stringstream()
+ return static_cast<const std::stringstream &>(std::stringstream()
<< file << " had an invalid " << kUninstallAndReplace)
.str();
}
@@ -336,7 +336,7 @@ OptionsOrError ParseConfig(FileUtilsWrapper& file_utils,
for (const auto& app_id_value : uninstall_and_replace_values) {
if (!app_id_value.is_string()) {
- return (std::stringstream() << file << " had an invalid "
+ return static_cast<const std::stringstream &>(std::stringstream() << file << " had an invalid "
<< kUninstallAndReplace << " entry")
.str();
}
@@ -348,7 +348,7 @@ OptionsOrError ParseConfig(FileUtilsWrapper& file_utils,
value = app_config.FindKey(kOnlyUseOfflineManifest);
if (value) {
if (!value->is_bool()) {
- return (std::stringstream()
+ return static_cast<const std::stringstream &>(std::stringstream()
<< file << " had an invalid " << kOnlyUseOfflineManifest)
.str();
}
@@ -369,7 +369,7 @@ OptionsOrError ParseConfig(FileUtilsWrapper& file_utils,
}
if (options.only_use_app_info_factory && !options.app_info_factory) {
- return (std::stringstream()
+ return static_cast<const std::stringstream &>(std::stringstream()
<< file << kOnlyUseOfflineManifest << " set with no "
<< kOfflineManifest << " available")
.str();
@@ -389,7 +389,7 @@ WebApplicationInfoFactoryOrError ParseOfflineManifest(
const std::string* name_string =
offline_manifest.FindStringKey(kOfflineManifestName);
if (!name_string) {
- return (std::stringstream()
+ return static_cast<const std::stringstream &>(std::stringstream()
<< file << " " << kOfflineManifest << " " << kOfflineManifestName
<< " missing or invalid.")
.str();
@@ -397,7 +397,7 @@ WebApplicationInfoFactoryOrError ParseOfflineManifest(
if (!base::UTF8ToUTF16(name_string->data(), name_string->size(),
&app_info.title) ||
app_info.title.empty()) {
- return (std::stringstream()
+ return static_cast<const std::stringstream &>(std::stringstream()
<< file << " " << kOfflineManifest << " " << kOfflineManifestName
<< " invalid: " << *name_string)
.str();
@@ -407,14 +407,14 @@ WebApplicationInfoFactoryOrError ParseOfflineManifest(
const std::string* start_url_string =
offline_manifest.FindStringKey(kOfflineManifestStartUrl);
if (!start_url_string) {
- return (std::stringstream()
+ return static_cast<const std::stringstream &>(std::stringstream()
<< file << " " << kOfflineManifest << " "
<< kOfflineManifestStartUrl << " missing or invalid.")
.str();
}
app_info.start_url = GURL(*start_url_string);
if (!app_info.start_url.is_valid()) {
- return (std::stringstream()
+ return static_cast<const std::stringstream &>(std::stringstream()
<< file << " " << kOfflineManifest << " "
<< kOfflineManifestStartUrl << " invalid: " << *start_url_string)
.str();
@@ -424,21 +424,21 @@ WebApplicationInfoFactoryOrError ParseOfflineManifest(
const std::string* scope_string =
offline_manifest.FindStringKey(kOfflineManifestScope);
if (!scope_string) {
- return (std::stringstream()
+ return static_cast<const std::stringstream &>(std::stringstream()
<< file << " " << kOfflineManifest << " " << kOfflineManifestScope
<< " missing or invalid.")
.str();
}
app_info.scope = GURL(*scope_string);
if (!app_info.scope.is_valid()) {
- return (std::stringstream()
+ return static_cast<const std::stringstream &>(std::stringstream()
<< file << " " << kOfflineManifest << " " << kOfflineManifestScope
<< " invalid: " << *scope_string)
.str();
}
if (!base::StartsWith(app_info.start_url.path(), app_info.scope.path(),
base::CompareCase::SENSITIVE)) {
- return (std::stringstream()
+ return static_cast<const std::stringstream &>(std::stringstream()
<< file << " " << kOfflineManifest << " " << kOfflineManifestScope
<< " (" << app_info.start_url << ") not within "
<< kOfflineManifestScope << " (" << app_info.scope << ").")
@@ -449,14 +449,14 @@ WebApplicationInfoFactoryOrError ParseOfflineManifest(
const std::string* display_string =
offline_manifest.FindStringKey(kOfflineManifestDisplay);
if (!display_string) {
- return (std::stringstream()
+ return static_cast<const std::stringstream &>(std::stringstream()
<< file << " " << kOfflineManifest << " " << kOfflineManifestDisplay
<< " missing or invalid.")
.str();
}
DisplayMode display = blink::DisplayModeFromString(*display_string);
if (display == DisplayMode::kUndefined) {
- return (std::stringstream()
+ return static_cast<const std::stringstream &>(std::stringstream()
<< file << " " << kOfflineManifest << " " << kOfflineManifestDisplay
<< " invalid: " << display_string)
.str();
@@ -467,14 +467,14 @@ WebApplicationInfoFactoryOrError ParseOfflineManifest(
const base::Value* icon_files =
offline_manifest.FindListKey(kOfflineManifestIconAnyPngs);
if (!icon_files || icon_files->GetList().empty()) {
- return (std::stringstream()
+ return static_cast<const std::stringstream &>(std::stringstream()
<< file << " " << kOfflineManifest << " "
<< kOfflineManifestIconAnyPngs << " missing, empty or invalid.")
.str();
}
for (const base::Value& icon_file : icon_files->GetList()) {
if (!icon_file.is_string()) {
- return (std::stringstream()
+ return static_cast<const std::stringstream &>(std::stringstream()
<< file << " " << kOfflineManifest << " "
<< kOfflineManifestIconAnyPngs << " " << icon_file << " invalid.")
.str();
@@ -483,7 +483,7 @@ WebApplicationInfoFactoryOrError ParseOfflineManifest(
base::FilePath icon_path = dir.AppendASCII(icon_file.GetString());
std::string icon_data;
if (!file_utils.ReadFileToString(icon_path, &icon_data)) {
- return (std::stringstream() << file << " " << kOfflineManifest << " "
+ return static_cast<const std::stringstream &>(std::stringstream() << file << " " << kOfflineManifest << " "
<< kOfflineManifestIconAnyPngs << " "
<< icon_file << " failed to read.")
.str();
@@ -493,14 +493,14 @@ WebApplicationInfoFactoryOrError ParseOfflineManifest(
if (!gfx::PNGCodec::Decode(
reinterpret_cast<const unsigned char*>(icon_data.c_str()),
icon_data.size(), &bitmap)) {
- return (std::stringstream() << file << " " << kOfflineManifest << " "
+ return static_cast<const std::stringstream &>(std::stringstream() << file << " " << kOfflineManifest << " "
<< kOfflineManifestIconAnyPngs << " "
<< icon_file << " failed to decode.")
.str();
}
if (bitmap.width() != bitmap.height()) {
- return (std::stringstream() << file << " " << kOfflineManifest << " "
+ return static_cast<const std::stringstream &>(std::stringstream() << file << " " << kOfflineManifest << " "
<< kOfflineManifestIconAnyPngs << " "
<< icon_file << " must be square: "
<< bitmap.width() << "x" << bitmap.height())
@@ -521,7 +521,7 @@ WebApplicationInfoFactoryOrError ParseOfflineManifest(
SkColor theme_color;
if (!theme_color_argb_hex ||
!base::HexStringToUInt(*theme_color_argb_hex, &theme_color)) {
- return (std::stringstream() << file << " " << kOfflineManifest << " "
+ return static_cast<const std::stringstream &>(std::stringstream() << file << " " << kOfflineManifest << " "
<< kOfflineManifestThemeColorArgbHex
<< " invalid: " << *theme_color_value)
.str();