2015-07-16 23:40:01 +02:00
|
|
|
// Copyright 2015 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "libcef/browser/extensions/pdf_extension_util.h"
|
|
|
|
|
|
|
|
#include "base/strings/string_util.h"
|
2016-07-14 03:35:07 +02:00
|
|
|
#include "chrome/grit/browser_resources.h"
|
2015-07-16 23:40:01 +02:00
|
|
|
#include "ui/base/resource/resource_bundle.h"
|
|
|
|
|
|
|
|
namespace extensions {
|
|
|
|
namespace pdf_extension_util {
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
// Tags in the manifest to be replaced.
|
|
|
|
const char kNameTag[] = "<NAME>";
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
// These should match the keys for the Chrome and Chromium PDF Viewer entries in
|
|
|
|
// chrome/browser/resources/plugin_metadata/plugins_*.json.
|
|
|
|
#if defined(GOOGLE_CHROME_BUILD)
|
|
|
|
const char kPdfResourceIdentifier[] = "google-chrome-pdf";
|
|
|
|
#else
|
|
|
|
const char kPdfResourceIdentifier[] = "chromium-pdf";
|
|
|
|
#endif
|
|
|
|
|
2016-08-24 15:25:11 +02:00
|
|
|
// Match the GOOGLE_CHROME_BUILD value from ChromeContentClient::kPDFPluginName
|
|
|
|
// to avoid breaking Websites that specifically look for this string in the
|
|
|
|
// plugin list.
|
|
|
|
const char kPdfPluginName[] = "Chrome PDF Viewer";
|
2015-07-16 23:40:01 +02:00
|
|
|
|
|
|
|
std::string GetManifest() {
|
2020-07-02 20:45:16 +02:00
|
|
|
std::string manifest_contents =
|
|
|
|
ui::ResourceBundle::GetSharedInstance().LoadDataResourceString(
|
|
|
|
IDR_PDF_MANIFEST);
|
2015-07-16 23:40:01 +02:00
|
|
|
DCHECK(manifest_contents.find(kNameTag) != std::string::npos);
|
2017-05-17 11:29:28 +02:00
|
|
|
base::ReplaceFirstSubstringAfterOffset(&manifest_contents, 0, kNameTag,
|
|
|
|
kPdfPluginName);
|
2015-07-16 23:40:01 +02:00
|
|
|
|
|
|
|
return manifest_contents;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace pdf_extension_util
|
|
|
|
} // namespace extensions
|