• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "libcef/browser/extensions/pdf_extension_util.h"
6 
7 #include "base/strings/string_util.h"
8 #include "chrome/grit/browser_resources.h"
9 #include "ui/base/resource/resource_bundle.h"
10 
11 namespace extensions {
12 namespace pdf_extension_util {
13 
14 namespace {
15 
16 // Tags in the manifest to be replaced.
17 const char kNameTag[] = "<NAME>";
18 
19 }  // namespace
20 
21 // These should match the keys for the Chrome and Chromium PDF Viewer entries in
22 // chrome/browser/resources/plugin_metadata/plugins_*.json.
23 #if defined(GOOGLE_CHROME_BUILD)
24 const char kPdfResourceIdentifier[] = "google-chrome-pdf";
25 #else
26 const char kPdfResourceIdentifier[] = "chromium-pdf";
27 #endif
28 
29 // Match the GOOGLE_CHROME_BUILD value from ChromeContentClient::kPDFPluginName
30 // to avoid breaking Websites that specifically look for this string in the
31 // plugin list.
32 const char kPdfPluginName[] = "Chrome PDF Viewer";
33 
GetManifest()34 std::string GetManifest() {
35   std::string manifest_contents =
36       ui::ResourceBundle::GetSharedInstance().LoadDataResourceString(
37           IDR_PDF_MANIFEST);
38   DCHECK(manifest_contents.find(kNameTag) != std::string::npos);
39   base::ReplaceFirstSubstringAfterOffset(&manifest_contents, 0, kNameTag,
40                                          kPdfPluginName);
41 
42   return manifest_contents;
43 }
44 
45 }  // namespace pdf_extension_util
46 }  // namespace extensions
47