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
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
|
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -6068,7 +6068,7 @@ bool ChromeContentBrowserClient::ShouldA
const url::Origin& embedder_origin,
const content::PepperPluginInfo& plugin_info) {
#if BUILDFLAG(ENABLE_PDF)
- if (plugin_info.name == ChromeContentClient::kPDFInternalPluginName) {
+ if (plugin_info.name == ChromeContentClient::GetPDFInternalPluginName()) {
return IsPdfInternalPluginAllowedOrigin(embedder_origin);
}
#endif // BUILDFLAG(ENABLE_PDF)
--- a/chrome/browser/pdf/pdf_extension_util.cc
+++ b/chrome/browser/pdf/pdf_extension_util.cc
@@ -170,7 +170,7 @@ std::string GetManifest() {
DCHECK(manifest_contents.find(kNameTag) != std::string::npos);
base::ReplaceFirstSubstringAfterOffset(
&manifest_contents, 0, kNameTag,
- ChromeContentClient::kPDFExtensionPluginName);
+ ChromeContentClient::GetPDFExtensionPluginName());
return manifest_contents;
}
--- a/chrome/browser/plugins/pdf_iframe_navigation_throttle_unittest.cc
+++ b/chrome/browser/plugins/pdf_iframe_navigation_throttle_unittest.cc
@@ -67,7 +67,7 @@ class PDFIFrameNavigationThrottleTest :
// Register a fake PDF Viewer plugin into our plugin service.
content::WebPluginInfo info;
info.name =
- base::ASCIIToUTF16(ChromeContentClient::kPDFExtensionPluginName);
+ base::ASCIIToUTF16(ChromeContentClient::GetPDFExtensionPluginName());
info.mime_types.push_back(content::WebPluginMimeType(
kPDFMimeType, "pdf", "Fake PDF description"));
plugin_service->RegisterInternalPlugin(info, true);
--- a/chrome/browser/plugins/plugin_prefs.cc
+++ b/chrome/browser/plugins/plugin_prefs.cc
@@ -40,7 +40,7 @@ bool IsPDFViewerPlugin(const std::u16str
// plugin, which is also used for Print Preview. Note that only the PDF viewer
// and Print Preview can create the internal PDF plugin in the first place.
return plugin_name ==
- base::ASCIIToUTF16(ChromeContentClient::kPDFExtensionPluginName);
+ base::ASCIIToUTF16(ChromeContentClient::GetPDFExtensionPluginName());
}
} // namespace
--- a/chrome/browser/plugins/plugin_prefs_unittest.cc
+++ b/chrome/browser/plugins/plugin_prefs_unittest.cc
@@ -24,11 +24,11 @@ class PluginPrefsTest : public ::testing
TEST_F(PluginPrefsTest, AlwaysOpenPdfExternally) {
EXPECT_EQ(PluginPrefs::NO_POLICY,
plugin_prefs_->PolicyStatusForPlugin(base::ASCIIToUTF16(
- ChromeContentClient::kPDFExtensionPluginName)));
+ ChromeContentClient::GetPDFExtensionPluginName())));
SetAlwaysOpenPdfExternally(true);
EXPECT_EQ(PluginPrefs::POLICY_DISABLED,
plugin_prefs_->PolicyStatusForPlugin(base::ASCIIToUTF16(
- ChromeContentClient::kPDFExtensionPluginName)));
+ ChromeContentClient::GetPDFExtensionPluginName())));
}
--- a/chrome/browser/resources/plugin_metadata/plugins_chromeos.json
+++ b/chrome/browser/resources/plugin_metadata/plugins_chromeos.json
@@ -44,6 +44,19 @@
"name": "Chrome PDF Viewer",
"group_name_matcher": "*Chrome PDF Viewer*"
},
+ "microsoft-edge-pdf": {
+ "mime_types": [
+ ],
+ "versions": [
+ {
+ "version": "0",
+ "status": "fully_trusted",
+ "comment": "Microsoft Edge PDF has no version information."
+ }
+ ],
+ "name": "Microsoft Edge PDF Viewer",
+ "group_name_matcher": "*Microsoft Edge PDF Viewer*"
+ },
"chromium-pdf": {
"mime_types": [
],
@@ -70,6 +83,19 @@
"name": "Chrome PDF Plugin",
"group_name_matcher": "*Chrome PDF Plugin*"
},
+ "microsoft-edge-pdf-plugin": {
+ "mime_types": [
+ ],
+ "versions": [
+ {
+ "version": "0",
+ "status": "fully_trusted",
+ "comment": "Microsoft Edge PDF Plugin has no version information."
+ }
+ ],
+ "name": "Microsoft Edge PDF Plugin",
+ "group_name_matcher": "*Microsoft Edge PDF Plugin*"
+ },
"chromium-pdf-plugin": {
"mime_types": [
],
--- a/chrome/browser/resources/plugin_metadata/plugins_linux.json
+++ b/chrome/browser/resources/plugin_metadata/plugins_linux.json
@@ -36,6 +36,19 @@
"name": "Chrome PDF Viewer",
"group_name_matcher": "*Chrome PDF Viewer*"
},
+ "microsoft-edge-pdf": {
+ "mime_types": [
+ ],
+ "versions": [
+ {
+ "version": "0",
+ "status": "fully_trusted",
+ "comment": "Microsoft Edge PDF has no version information."
+ }
+ ],
+ "name": "Microsoft Edge PDF Viewer",
+ "group_name_matcher": "*Microsoft Edge PDF Viewer*"
+ },
"chromium-pdf": {
"mime_types": [
],
@@ -62,6 +75,19 @@
"name": "Chrome PDF Plugin",
"group_name_matcher": "*Chrome PDF Plugin*"
},
+ "microsoft-edge-pdf-plugin": {
+ "mime_types": [
+ ],
+ "versions": [
+ {
+ "version": "0",
+ "status": "fully_trusted",
+ "comment": "Google Chrome PDF Plugin has no version information."
+ }
+ ],
+ "name": "Microsoft Edge PDF Plugin",
+ "group_name_matcher": "*Microsoft Edge PDF Plugin*"
+ },
"chromium-pdf-plugin": {
"mime_types": [
],
--- a/chrome/browser/resources/plugin_metadata/plugins_mac.json
+++ b/chrome/browser/resources/plugin_metadata/plugins_mac.json
@@ -33,6 +33,19 @@
"name": "Chrome PDF Viewer",
"group_name_matcher": "*Chrome PDF Viewer*"
},
+ "microsoft-edge-pdf": {
+ "mime_types": [
+ ],
+ "versions": [
+ {
+ "version": "0",
+ "status": "fully_trusted",
+ "comment": "Microsoft Edge PDF Viewer has no version information."
+ }
+ ],
+ "name": "Microsoft Edge PDF Viewer",
+ "group_name_matcher": "*Microsoft Edge PDF Viewer*"
+ },
"chromium-pdf": {
"mime_types": [
],
@@ -59,6 +72,19 @@
"name": "Chrome PDF Plugin",
"group_name_matcher": "*Chrome PDF Plugin*"
},
+ "microsoft-edge-pdf-plugin": {
+ "mime_types": [
+ ],
+ "versions": [
+ {
+ "version": "0",
+ "status": "fully_trusted",
+ "comment": "Microsoft Edge PDF Plugin has no version information."
+ }
+ ],
+ "name": "Microsoft Edge PDF Plugin",
+ "group_name_matcher": "*Microsoft Edge PDF Plugin*"
+ },
"chromium-pdf-plugin": {
"mime_types": [
],
--- a/chrome/browser/resources/plugin_metadata/plugins_win.json
+++ b/chrome/browser/resources/plugin_metadata/plugins_win.json
@@ -33,6 +33,19 @@
"name": "Chrome PDF Viewer",
"group_name_matcher": "*Chrome PDF Viewer*"
},
+ "microsoft-edge-pdf": {
+ "mime_types": [
+ ],
+ "versions": [
+ {
+ "version": "0",
+ "status": "fully_trusted",
+ "comment": "Microsoft Edge PDF Viewer has no version information."
+ }
+ ],
+ "name": "Microsoft Edge PDF Viewer",
+ "group_name_matcher": "*Microsoft Edge PDF Viewer*"
+ },
"chromium-pdf": {
"mime_types": [
],
@@ -59,6 +72,19 @@
"name": "Chrome PDF Plugin",
"group_name_matcher": "*Chrome PDF Plugin*"
},
+ "microsoft-edge-pdf-plugin": {
+ "mime_types": [
+ ],
+ "versions": [
+ {
+ "version": "0",
+ "status": "fully_trusted",
+ "comment": "Microsoft Edge PDF Plugin has no version information."
+ }
+ ],
+ "name": "Microsoft Edge PDF Plugin",
+ "group_name_matcher": "*Microsoft Edge PDF Plugin*"
+ },
"chromium-pdf-plugin": {
"mime_types": [
],
--- a/chrome/browser/ungoogled_flag_choices.h
+++ b/chrome/browser/ungoogled_flag_choices.h
@@ -34,4 +34,9 @@ const FeatureEntry::Choice kScrollEventC
"scroll-tabs",
"never"}
};
+const FeatureEntry::Choice kPDFPluginNameChoices[] = {
+ {"Chromium", "", ""},
+ {"Google Chrome", switches::kPDFPluginName, "chrome"},
+ {"Microsoft Edge", switches::kPDFPluginName, "edge"},
+};
#endif // CHROME_BROWSER_UNGOOGLED_FLAG_CHOICES_H_
--- a/chrome/browser/ungoogled_flag_entries.h
+++ b/chrome/browser/ungoogled_flag_entries.h
@@ -36,4 +36,8 @@
"Scroll switches tab",
"Switch to the left/right tab if the wheel-scroll happens over the tabstrip, or the empty space beside the tabstrip. ungoogled-chromium flag.",
kOsDesktop, MULTI_VALUE_TYPE(kScrollEventChangesTab)},
+ {"pdf-plugin-name",
+ "Set internal PDF plugin name",
+ "Sets the internal PDF viewer plugin name. Useful for sites that probe JS API navigator.plugins. ungoogled-chromium flag.",
+ kOsDesktop, MULTI_VALUE_TYPE(kPDFPluginNameChoices)},
#endif // CHROME_BROWSER_UNGOOGLED_FLAG_ENTRIES_H_
--- a/chrome/common/BUILD.gn
+++ b/chrome/common/BUILD.gn
@@ -246,6 +246,7 @@ static_library("common") {
"//components/no_state_prefetch/common",
"//components/no_state_prefetch/common:mojo_bindings",
"//components/page_load_metrics/common:common",
+ "//components/ungoogled:ungoogled_switches",
]
if (enable_pdf) {
--- a/chrome/common/chrome_content_client.cc
+++ b/chrome/common/chrome_content_client.cc
@@ -126,7 +126,7 @@ void ComputeBuiltInPlugins(std::vector<c
content::PepperPluginInfo pdf_info;
pdf_info.is_internal = true;
pdf_info.is_out_of_process = true;
- pdf_info.name = ChromeContentClient::kPDFInternalPluginName;
+ pdf_info.name = ChromeContentClient::GetPDFInternalPluginName();
pdf_info.description = kPDFPluginDescription;
pdf_info.path = base::FilePath(ChromeContentClient::kPDFPluginPath);
content::WebPluginMimeType pdf_mime_type(
--- a/chrome/common/chrome_content_client.h
+++ b/chrome/common/chrome_content_client.h
@@ -41,8 +41,8 @@ class ChromeContentClient : public conte
static const base::FilePath::CharType kNaClPluginFileName[];
#endif
- static const char kPDFExtensionPluginName[];
- static const char kPDFInternalPluginName[];
+ static const char *GetPDFExtensionPluginName();
+ static const char *GetPDFInternalPluginName();
static const base::FilePath::CharType kPDFPluginPath[];
ChromeContentClient();
--- a/chrome/common/chrome_content_client_constants.cc
+++ b/chrome/common/chrome_content_client_constants.cc
@@ -2,8 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <string>
+
+#include "base/command_line.h"
#include "build/branding_buildflags.h"
#include "chrome/common/chrome_content_client.h"
+#include "components/ungoogled/ungoogled_switches.h"
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
const base::FilePath::CharType ChromeContentClient::kNotPresent[] =
@@ -15,15 +19,52 @@ const base::FilePath::CharType ChromeCon
FILE_PATH_LITERAL("internal-nacl-plugin");
#endif
-#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
-const char ChromeContentClient::kPDFExtensionPluginName[] = "Chrome PDF Viewer";
-const char ChromeContentClient::kPDFInternalPluginName[] = "Chrome PDF Plugin";
-#else
-const char ChromeContentClient::kPDFExtensionPluginName[] =
+namespace {
+
+const char kChromePDFExtensionPluginName[] =
+ "Chrome PDF Viewer";
+const char kChromePDFInternalPluginName[] =
+ "Chrome PDF Plugin";
+const char kEdgePDFExtensionPluginName[] =
+ "Microsoft Edge PDF Viewer";
+const char kEdgePDFInternalPluginName[] =
+ "Microsoft Edge PDF Plugin";
+const char kChromiumPDFExtensionPluginName[] =
"Chromium PDF Viewer";
-const char ChromeContentClient::kPDFInternalPluginName[] =
+const char kChromiumPDFInternalPluginName[] =
"Chromium PDF Plugin";
-#endif
+
+} // namespace
+
+// static
+const char *ChromeContentClient::GetPDFExtensionPluginName() {
+ const base::CommandLine& command_line =
+ *base::CommandLine::ForCurrentProcess();
+ if (command_line.HasSwitch(switches::kPDFPluginName)) {
+ std::string switch_value = command_line.GetSwitchValueASCII(switches::kPDFPluginName);
+ if (switch_value == "edge") {
+ return kEdgePDFExtensionPluginName;
+ } else if (switch_value == "chrome") {
+ return kChromePDFExtensionPluginName;
+ }
+ }
+ return kChromiumPDFExtensionPluginName;
+}
+
+// static
+const char *ChromeContentClient::GetPDFInternalPluginName() {
+ const base::CommandLine& command_line =
+ *base::CommandLine::ForCurrentProcess();
+ if (command_line.HasSwitch(switches::kPDFPluginName)) {
+ std::string switch_value = command_line.GetSwitchValueASCII(switches::kPDFPluginName);
+ if (switch_value == "edge") {
+ return kEdgePDFInternalPluginName;
+ } else if (switch_value == "chrome") {
+ return kChromePDFInternalPluginName;
+ }
+ }
+ return kChromiumPDFInternalPluginName;
+}
const base::FilePath::CharType ChromeContentClient::kPDFPluginPath[] =
FILE_PATH_LITERAL("internal-pdf-viewer");
--- a/chrome/renderer/chrome_content_renderer_client.cc
+++ b/chrome/renderer/chrome_content_renderer_client.cc
@@ -1027,7 +1027,7 @@ WebPlugin* ChromeContentRendererClient::
}
}
} else if (info.name ==
- ASCIIToUTF16(ChromeContentClient::kPDFExtensionPluginName)) {
+ ASCIIToUTF16(ChromeContentClient::GetPDFExtensionPluginName())) {
// Report PDF load metrics. Since the PDF plugin is comprised of an
// extension that loads a second plugin, avoid double counting by
// ignoring the creation of the second plugin.
@@ -1059,7 +1059,7 @@ WebPlugin* ChromeContentRendererClient::
#if BUILDFLAG(ENABLE_PDF)
if (info.name ==
- ASCIIToUTF16(ChromeContentClient::kPDFInternalPluginName)) {
+ ASCIIToUTF16(ChromeContentClient::GetPDFInternalPluginName())) {
return pdf::CreateInternalPlugin(
info, std::move(params), render_frame,
std::make_unique<ChromePdfInternalPluginDelegate>());
@@ -1072,7 +1072,7 @@ WebPlugin* ChromeContentRendererClient::
PluginUMAReporter::GetInstance()->ReportPluginDisabled(orig_mime_type,
url);
if (info.name ==
- ASCIIToUTF16(ChromeContentClient::kPDFExtensionPluginName)) {
+ ASCIIToUTF16(ChromeContentClient::GetPDFExtensionPluginName())) {
ReportPDFLoadStatus(
PDFLoadStatus::kShowedDisabledPluginPlaceholderForEmbeddedPdf);
|