mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2024-12-11 17:15:57 +01:00
55 lines
1.7 KiB
C++
55 lines
1.7 KiB
C++
// 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"
|
|
#include "chrome/common/chrome_switches.h"
|
|
#include "grit/cef_resources.h"
|
|
#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>";
|
|
const char kIndexTag[] = "<INDEX>";
|
|
|
|
// The index html pages to load for the material and non-material version of
|
|
// the viewer.
|
|
const char kRegularIndex[] = "index.html";
|
|
const char kMaterialIndex[] = "index-material.html";
|
|
|
|
} // 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
|
|
|
|
const char kPdfPluginName[] = "Chromium PDF Viewer";
|
|
|
|
std::string GetManifest() {
|
|
std::string manifest_contents =
|
|
ResourceBundle::GetSharedInstance().GetRawDataResource(
|
|
IDR_PDF_MANIFEST).as_string();
|
|
DCHECK(manifest_contents.find(kNameTag) != std::string::npos);
|
|
ReplaceFirstSubstringAfterOffset(
|
|
&manifest_contents, 0, kNameTag, kPdfPluginName);
|
|
|
|
DCHECK(manifest_contents.find(kIndexTag) != std::string::npos);
|
|
std::string index = switches::PdfMaterialUIEnabled() ?
|
|
kMaterialIndex : kRegularIndex;
|
|
ReplaceSubstringsAfterOffset(&manifest_contents, 0, kIndexTag, index);
|
|
return manifest_contents;
|
|
}
|
|
|
|
} // namespace pdf_extension_util
|
|
} // namespace extensions
|