1// Copyright 2014 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 "athena/main/athena_content_client.h"
6
7#include "base/files/file_path.h"
8#include "base/path_service.h"
9#include "content/public/common/pepper_plugin_info.h"
10#include "ppapi/shared_impl/ppapi_permissions.h"
11
12namespace athena {
13
14AthenaContentClient::AthenaContentClient() {}
15
16AthenaContentClient::~AthenaContentClient() {}
17
18void AthenaContentClient::AddPepperPlugins(
19    std::vector<content::PepperPluginInfo>* plugins) {
20  const char kPDFPluginMimeType[] = "application/pdf";
21  const char kPDFPluginExtension[] = "pdf";
22  const char kPDFPluginDescription[] = "Portable Document Format";
23  const char kPDFPluginPrintPreviewMimeType[] =
24      "application/x-google-chrome-print-preview-pdf";
25  const uint32 kPDFPluginPermissions =
26      ppapi::PERMISSION_PRIVATE | ppapi::PERMISSION_DEV;
27  const char kPDFPluginName[] = "Chrome PDF Viewer";
28  const base::FilePath::CharType kPDFPluginFileName[] =
29      FILE_PATH_LITERAL("libpdf.so");
30
31  base::FilePath module;
32  if (!PathService::Get(base::DIR_MODULE, &module))
33    return;
34
35  content::PepperPluginInfo pdf;
36  pdf.path = base::FilePath(module.Append(kPDFPluginFileName));
37  pdf.name = kPDFPluginName;
38  content::WebPluginMimeType pdf_mime_type(
39      kPDFPluginMimeType, kPDFPluginExtension, kPDFPluginDescription);
40  content::WebPluginMimeType print_preview_pdf_mime_type(
41      kPDFPluginPrintPreviewMimeType,
42      kPDFPluginExtension,
43      kPDFPluginDescription);
44  pdf.mime_types.push_back(pdf_mime_type);
45  pdf.mime_types.push_back(print_preview_pdf_mime_type);
46  pdf.permissions = kPDFPluginPermissions;
47  plugins->push_back(pdf);
48
49  ShellContentClient::AddPepperPlugins(plugins);
50}
51
52}  // namespace athena
53