Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(267)

Side by Side Diff: chrome/browser/pdf/pdf_extension_util.cc

Issue 956163002: Correctly whitelist the PDF plugin in the PDF extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2311
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/pdf/pdf_extension_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/pdf/pdf_extension_util.h" 5 #include "chrome/browser/pdf/pdf_extension_util.h"
6 6
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "chrome/common/chrome_content_client.h" 8 #include "chrome/common/chrome_content_client.h"
9 #include "chrome/common/chrome_switches.h" 9 #include "chrome/common/chrome_switches.h"
10 #include "chrome/grit/browser_resources.h" 10 #include "chrome/grit/browser_resources.h"
11 #include "ui/base/resource/resource_bundle.h" 11 #include "ui/base/resource/resource_bundle.h"
12 12
13 namespace pdf_extension_util { 13 namespace pdf_extension_util {
14 14
15 namespace { 15 namespace {
16 16
17 // Tags in the manifest to be replaced. 17 // Tags in the manifest to be replaced.
18 const char kNameTag[] = "<NAME>"; 18 const char kNameTag[] = "<NAME>";
19 const char kIndexTag[] = "<INDEX>"; 19 const char kIndexTag[] = "<INDEX>";
20 20
21 // The index html pages to load for the material and non-material version of 21 // The index html pages to load for the material and non-material version of
22 // the viewer. 22 // the viewer.
23 const char kRegularIndex[] = "index.html"; 23 const char kRegularIndex[] = "index.html";
24 const char kMaterialIndex[] = "index-material.html"; 24 const char kMaterialIndex[] = "index-material.html";
25 25
26 } // namespace 26 } // namespace
27 27
28 // These should match the keys for the Chrome and Chromium PDF Viewer entries in
29 // chrome/browser/resources/plugin_metadata/plugins_*.json.
30 #if defined(GOOGLE_CHROME_BUILD)
31 const char kPdfResourceIdentifier[] = "google-chrome-pdf";
32 #else
33 const char kPdfResourceIdentifier[] = "chromium-pdf";
34 #endif
35
28 std::string GetManifest() { 36 std::string GetManifest() {
29 std::string manifest_contents = 37 std::string manifest_contents =
30 ResourceBundle::GetSharedInstance().GetRawDataResource( 38 ResourceBundle::GetSharedInstance().GetRawDataResource(
31 IDR_PDF_MANIFEST).as_string(); 39 IDR_PDF_MANIFEST).as_string();
32 DCHECK(manifest_contents.find(kNameTag) != std::string::npos); 40 DCHECK(manifest_contents.find(kNameTag) != std::string::npos);
33 ReplaceFirstSubstringAfterOffset( 41 ReplaceFirstSubstringAfterOffset(
34 &manifest_contents, 0, kNameTag, ChromeContentClient::kPDFPluginName); 42 &manifest_contents, 0, kNameTag, ChromeContentClient::kPDFPluginName);
35 43
36 DCHECK(manifest_contents.find(kIndexTag) != std::string::npos); 44 DCHECK(manifest_contents.find(kIndexTag) != std::string::npos);
37 std::string index = switches::PdfMaterialUIEnabled() ? 45 std::string index = switches::PdfMaterialUIEnabled() ?
38 kMaterialIndex : kRegularIndex; 46 kMaterialIndex : kRegularIndex;
39 ReplaceSubstringsAfterOffset(&manifest_contents, 0, kIndexTag, index); 47 ReplaceSubstringsAfterOffset(&manifest_contents, 0, kIndexTag, index);
40 return manifest_contents; 48 return manifest_contents;
41 } 49 }
42 50
43 } // namespace pdf_extension_util 51 } // namespace pdf_extension_util
OLDNEW
« no previous file with comments | « chrome/browser/pdf/pdf_extension_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698