| OLD | NEW |
| 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" | |
| 10 #include "chrome/grit/browser_resources.h" | 9 #include "chrome/grit/browser_resources.h" |
| 11 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
| 12 | 11 |
| 13 namespace pdf_extension_util { | 12 namespace pdf_extension_util { |
| 14 | 13 |
| 15 namespace { | 14 namespace { |
| 16 | 15 |
| 17 // Tags in the manifest to be replaced. | 16 // Tags in the manifest to be replaced. |
| 18 const char kNameTag[] = "<NAME>"; | 17 const char kNameTag[] = "<NAME>"; |
| 19 const char kIndexTag[] = "<INDEX>"; | |
| 20 | |
| 21 // The index html pages to load for the material and non-material version of | |
| 22 // the viewer. | |
| 23 const char kRegularIndex[] = "index.html"; | |
| 24 const char kMaterialIndex[] = "index-material.html"; | |
| 25 | 18 |
| 26 } // namespace | 19 } // namespace |
| 27 | 20 |
| 28 // These should match the keys for the Chrome and Chromium PDF Viewer entries in | 21 // These should match the keys for the Chrome and Chromium PDF Viewer entries in |
| 29 // chrome/browser/resources/plugin_metadata/plugins_*.json. | 22 // chrome/browser/resources/plugin_metadata/plugins_*.json. |
| 30 #if defined(GOOGLE_CHROME_BUILD) | 23 #if defined(GOOGLE_CHROME_BUILD) |
| 31 const char kPdfResourceIdentifier[] = "google-chrome-pdf"; | 24 const char kPdfResourceIdentifier[] = "google-chrome-pdf"; |
| 32 #else | 25 #else |
| 33 const char kPdfResourceIdentifier[] = "chromium-pdf"; | 26 const char kPdfResourceIdentifier[] = "chromium-pdf"; |
| 34 #endif | 27 #endif |
| 35 | 28 |
| 36 std::string GetManifest() { | 29 std::string GetManifest() { |
| 37 std::string manifest_contents = | 30 std::string manifest_contents = |
| 38 ResourceBundle::GetSharedInstance().GetRawDataResource( | 31 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 39 IDR_PDF_MANIFEST).as_string(); | 32 IDR_PDF_MANIFEST).as_string(); |
| 40 DCHECK(manifest_contents.find(kNameTag) != std::string::npos); | 33 DCHECK(manifest_contents.find(kNameTag) != std::string::npos); |
| 41 base::ReplaceFirstSubstringAfterOffset( | 34 base::ReplaceFirstSubstringAfterOffset( |
| 42 &manifest_contents, 0, kNameTag, ChromeContentClient::kPDFPluginName); | 35 &manifest_contents, 0, kNameTag, ChromeContentClient::kPDFPluginName); |
| 43 | 36 |
| 44 DCHECK(manifest_contents.find(kIndexTag) != std::string::npos); | |
| 45 std::string index = switches::PdfMaterialUIEnabled() ? | |
| 46 kMaterialIndex : kRegularIndex; | |
| 47 base::ReplaceSubstringsAfterOffset(&manifest_contents, 0, kIndexTag, index); | |
| 48 return manifest_contents; | 37 return manifest_contents; |
| 49 } | 38 } |
| 50 | 39 |
| 51 } // namespace pdf_extension_util | 40 } // namespace pdf_extension_util |
| OLD | NEW |