1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
|
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();
|