OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/common/chrome_content_client.h" | 5 #include "chrome/common/chrome_content_client.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/debug/crash_logging.h" | 8 #include "base/debug/crash_logging.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 #endif | 57 #endif |
58 | 58 |
59 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \ | 59 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \ |
60 !defined(WIDEVINE_CDM_IS_COMPONENT) | 60 !defined(WIDEVINE_CDM_IS_COMPONENT) |
61 #include "chrome/common/widevine_cdm_constants.h" | 61 #include "chrome/common/widevine_cdm_constants.h" |
62 #endif | 62 #endif |
63 | 63 |
64 namespace { | 64 namespace { |
65 | 65 |
66 #if defined(ENABLE_PLUGINS) | 66 #if defined(ENABLE_PLUGINS) |
| 67 const char kPDFPluginMimeType[] = "application/pdf"; |
67 const char kPDFPluginExtension[] = "pdf"; | 68 const char kPDFPluginExtension[] = "pdf"; |
68 const char kPDFPluginDescription[] = "Portable Document Format"; | 69 const char kPDFPluginDescription[] = "Portable Document Format"; |
| 70 const char kPDFPluginPrintPreviewMimeType[] = |
| 71 "application/x-google-chrome-print-preview-pdf"; |
69 const char kPDFPluginOutOfProcessMimeType[] = | 72 const char kPDFPluginOutOfProcessMimeType[] = |
70 "application/x-google-chrome-pdf"; | 73 "application/x-google-chrome-pdf"; |
71 const uint32 kPDFPluginPermissions = ppapi::PERMISSION_PRIVATE | | 74 const uint32 kPDFPluginPermissions = ppapi::PERMISSION_PRIVATE | |
72 ppapi::PERMISSION_DEV; | 75 ppapi::PERMISSION_DEV; |
73 | 76 |
74 const char kO1DPluginName[] = "Google Talk Plugin Video Renderer"; | 77 const char kO1DPluginName[] = "Google Talk Plugin Video Renderer"; |
75 const char kO1DPluginMimeType[] ="application/o1d"; | 78 const char kO1DPluginMimeType[] ="application/o1d"; |
76 const char kO1DPluginExtension[] = ""; | 79 const char kO1DPluginExtension[] = ""; |
77 const char kO1DPluginDescription[] = "Google Talk Plugin Video Renderer"; | 80 const char kO1DPluginDescription[] = "Google Talk Plugin Video Renderer"; |
78 const uint32 kO1DPluginPermissions = ppapi::PERMISSION_PRIVATE | | 81 const uint32 kO1DPluginPermissions = ppapi::PERMISSION_PRIVATE | |
79 ppapi::PERMISSION_DEV; | 82 ppapi::PERMISSION_DEV; |
80 | 83 |
81 const char kEffectsPluginName[] = "Google Talk Effects Plugin"; | 84 const char kEffectsPluginName[] = "Google Talk Effects Plugin"; |
82 const char kEffectsPluginMimeType[] ="application/x-ppapi-hangouts-effects"; | 85 const char kEffectsPluginMimeType[] ="application/x-ppapi-hangouts-effects"; |
83 const char kEffectsPluginExtension[] = ""; | 86 const char kEffectsPluginExtension[] = ""; |
84 const char kEffectsPluginDescription[] = "Google Talk Effects Plugin"; | 87 const char kEffectsPluginDescription[] = "Google Talk Effects Plugin"; |
85 const uint32 kEffectsPluginPermissions = ppapi::PERMISSION_PRIVATE | | 88 const uint32 kEffectsPluginPermissions = ppapi::PERMISSION_PRIVATE | |
86 ppapi::PERMISSION_DEV; | 89 ppapi::PERMISSION_DEV; |
87 | 90 |
88 const char kGTalkPluginName[] = "Google Talk Plugin"; | 91 const char kGTalkPluginName[] = "Google Talk Plugin"; |
89 const char kGTalkPluginMimeType[] ="application/googletalk"; | 92 const char kGTalkPluginMimeType[] ="application/googletalk"; |
90 const char kGTalkPluginExtension[] = ".googletalk"; | 93 const char kGTalkPluginExtension[] = ".googletalk"; |
91 const char kGTalkPluginDescription[] = "Google Talk Plugin"; | 94 const char kGTalkPluginDescription[] = "Google Talk Plugin"; |
92 const uint32 kGTalkPluginPermissions = ppapi::PERMISSION_PRIVATE | | 95 const uint32 kGTalkPluginPermissions = ppapi::PERMISSION_PRIVATE | |
93 ppapi::PERMISSION_DEV; | 96 ppapi::PERMISSION_DEV; |
94 | 97 |
95 content::PepperPluginInfo::GetInterfaceFunc g_pdf_get_interface; | |
96 content::PepperPluginInfo::PPP_InitializeModuleFunc g_pdf_initialize_module; | |
97 content::PepperPluginInfo::PPP_ShutdownModuleFunc g_pdf_shutdown_module; | |
98 | |
99 #if defined(ENABLE_REMOTING) | 98 #if defined(ENABLE_REMOTING) |
100 | 99 |
101 content::PepperPluginInfo::GetInterfaceFunc g_remoting_get_interface; | 100 content::PepperPluginInfo::GetInterfaceFunc g_remoting_get_interface; |
102 content::PepperPluginInfo::PPP_InitializeModuleFunc | 101 content::PepperPluginInfo::PPP_InitializeModuleFunc |
103 g_remoting_initialize_module; | 102 g_remoting_initialize_module; |
104 content::PepperPluginInfo::PPP_ShutdownModuleFunc g_remoting_shutdown_module; | 103 content::PepperPluginInfo::PPP_ShutdownModuleFunc g_remoting_shutdown_module; |
105 | 104 |
106 #if defined(GOOGLE_CHROME_BUILD) | 105 #if defined(GOOGLE_CHROME_BUILD) |
107 const char kRemotingViewerPluginName[] = "Chrome Remote Desktop Viewer"; | 106 const char kRemotingViewerPluginName[] = "Chrome Remote Desktop Viewer"; |
108 #else | 107 #else |
(...skipping 18 matching lines...) Expand all Loading... |
127 content::PepperPluginInfo::PPP_InitializeModuleFunc g_nacl_initialize_module; | 126 content::PepperPluginInfo::PPP_InitializeModuleFunc g_nacl_initialize_module; |
128 content::PepperPluginInfo::PPP_ShutdownModuleFunc g_nacl_shutdown_module; | 127 content::PepperPluginInfo::PPP_ShutdownModuleFunc g_nacl_shutdown_module; |
129 #endif | 128 #endif |
130 | 129 |
131 // Appends the known built-in plugins to the given vector. Some built-in | 130 // Appends the known built-in plugins to the given vector. Some built-in |
132 // plugins are "internal" which means they are compiled into the Chrome binary, | 131 // plugins are "internal" which means they are compiled into the Chrome binary, |
133 // and some are extra shared libraries distributed with the browser (these are | 132 // and some are extra shared libraries distributed with the browser (these are |
134 // not marked internal, aside from being automatically registered, they're just | 133 // not marked internal, aside from being automatically registered, they're just |
135 // regular plugins). | 134 // regular plugins). |
136 void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) { | 135 void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) { |
137 content::PepperPluginInfo pdf_info; | 136 // PDF. |
138 pdf_info.is_internal = true; | 137 // |
139 pdf_info.is_out_of_process = true; | 138 // Once we're sandboxed, we can't know if the PDF plugin is available or not; |
140 pdf_info.name = ChromeContentClient::kPDFPluginName; | 139 // but (on Linux) this function is always called once before we're sandboxed. |
141 pdf_info.description = kPDFPluginDescription; | 140 // So the first time through test if the file is available and then skip the |
142 pdf_info.path = base::FilePath::FromUTF8Unsafe( | 141 // check on subsequent calls if yes. |
143 ChromeContentClient::kPDFPluginPath); | 142 static bool skip_pdf_file_check = false; |
144 content::WebPluginMimeType pdf_mime_type( | 143 base::FilePath path; |
145 kPDFPluginOutOfProcessMimeType, | 144 if (PathService::Get(chrome::FILE_PDF_PLUGIN, &path)) { |
146 kPDFPluginExtension, | 145 if (skip_pdf_file_check || base::PathExists(path)) { |
147 kPDFPluginDescription); | 146 content::PepperPluginInfo pdf; |
148 pdf_info.mime_types.push_back(pdf_mime_type); | 147 pdf.path = path; |
149 pdf_info.internal_entry_points.get_interface = g_pdf_get_interface; | 148 pdf.name = ChromeContentClient::kPDFPluginName; |
150 pdf_info.internal_entry_points.initialize_module = g_pdf_initialize_module; | 149 if (switches::OutOfProcessPdfEnabled()) { |
151 pdf_info.internal_entry_points.shutdown_module = g_pdf_shutdown_module; | 150 pdf.is_out_of_process = true; |
152 pdf_info.permissions = kPDFPluginPermissions; | 151 content::WebPluginMimeType pdf_mime_type(kPDFPluginOutOfProcessMimeType, |
153 plugins->push_back(pdf_info); | 152 kPDFPluginExtension, |
| 153 kPDFPluginDescription); |
| 154 pdf.mime_types.push_back(pdf_mime_type); |
| 155 // TODO(raymes): Make print preview work with out of process PDF. |
| 156 } else { |
| 157 content::WebPluginMimeType pdf_mime_type(kPDFPluginMimeType, |
| 158 kPDFPluginExtension, |
| 159 kPDFPluginDescription); |
| 160 content::WebPluginMimeType print_preview_pdf_mime_type( |
| 161 kPDFPluginPrintPreviewMimeType, |
| 162 kPDFPluginExtension, |
| 163 kPDFPluginDescription); |
| 164 pdf.mime_types.push_back(pdf_mime_type); |
| 165 pdf.mime_types.push_back(print_preview_pdf_mime_type); |
| 166 } |
| 167 pdf.permissions = kPDFPluginPermissions; |
| 168 plugins->push_back(pdf); |
154 | 169 |
155 base::FilePath path; | 170 skip_pdf_file_check = true; |
| 171 } |
| 172 } |
156 | 173 |
157 #if !defined(DISABLE_NACL) | 174 #if !defined(DISABLE_NACL) |
158 // Handle Native Client just like the PDF plugin. This means that it is | 175 // Handle Native Client just like the PDF plugin. This means that it is |
159 // enabled by default for the non-portable case. This allows apps installed | 176 // enabled by default for the non-portable case. This allows apps installed |
160 // from the Chrome Web Store to use NaCl even if the command line switch | 177 // from the Chrome Web Store to use NaCl even if the command line switch |
161 // isn't set. For other uses of NaCl we check for the command line switch. | 178 // isn't set. For other uses of NaCl we check for the command line switch. |
162 if (PathService::Get(chrome::FILE_NACL_PLUGIN, &path)) { | 179 if (PathService::Get(chrome::FILE_NACL_PLUGIN, &path)) { |
163 content::PepperPluginInfo nacl; | 180 content::PepperPluginInfo nacl; |
164 // The nacl plugin is now built into the Chromium binary. | 181 // The nacl plugin is now built into the Chromium binary. |
165 nacl.is_internal = true; | 182 nacl.is_internal = true; |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 void ChromeContentClient::SetNaClEntryFunctions( | 447 void ChromeContentClient::SetNaClEntryFunctions( |
431 content::PepperPluginInfo::GetInterfaceFunc get_interface, | 448 content::PepperPluginInfo::GetInterfaceFunc get_interface, |
432 content::PepperPluginInfo::PPP_InitializeModuleFunc initialize_module, | 449 content::PepperPluginInfo::PPP_InitializeModuleFunc initialize_module, |
433 content::PepperPluginInfo::PPP_ShutdownModuleFunc shutdown_module) { | 450 content::PepperPluginInfo::PPP_ShutdownModuleFunc shutdown_module) { |
434 g_nacl_get_interface = get_interface; | 451 g_nacl_get_interface = get_interface; |
435 g_nacl_initialize_module = initialize_module; | 452 g_nacl_initialize_module = initialize_module; |
436 g_nacl_shutdown_module = shutdown_module; | 453 g_nacl_shutdown_module = shutdown_module; |
437 } | 454 } |
438 #endif | 455 #endif |
439 | 456 |
440 #if defined(ENABLE_PLUGINS) | |
441 void ChromeContentClient::SetPDFEntryFunctions( | |
442 content::PepperPluginInfo::GetInterfaceFunc get_interface, | |
443 content::PepperPluginInfo::PPP_InitializeModuleFunc initialize_module, | |
444 content::PepperPluginInfo::PPP_ShutdownModuleFunc shutdown_module) { | |
445 g_pdf_get_interface = get_interface; | |
446 g_pdf_initialize_module = initialize_module; | |
447 g_pdf_shutdown_module = shutdown_module; | |
448 } | |
449 #endif | |
450 | |
451 void ChromeContentClient::SetActiveURL(const GURL& url) { | 457 void ChromeContentClient::SetActiveURL(const GURL& url) { |
452 base::debug::SetCrashKeyValue(crash_keys::kActiveURL, | 458 base::debug::SetCrashKeyValue(crash_keys::kActiveURL, |
453 url.possibly_invalid_spec()); | 459 url.possibly_invalid_spec()); |
454 } | 460 } |
455 | 461 |
456 void ChromeContentClient::SetGpuInfo(const gpu::GPUInfo& gpu_info) { | 462 void ChromeContentClient::SetGpuInfo(const gpu::GPUInfo& gpu_info) { |
457 #if !defined(OS_ANDROID) | 463 #if !defined(OS_ANDROID) |
458 base::debug::SetCrashKeyValue(crash_keys::kGPUVendorID, | 464 base::debug::SetCrashKeyValue(crash_keys::kGPUVendorID, |
459 base::StringPrintf("0x%04x", gpu_info.gpu.vendor_id)); | 465 base::StringPrintf("0x%04x", gpu_info.gpu.vendor_id)); |
460 base::debug::SetCrashKeyValue(crash_keys::kGPUDeviceID, | 466 base::debug::SetCrashKeyValue(crash_keys::kGPUDeviceID, |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 int sandbox_type, | 556 int sandbox_type, |
551 int* sandbox_profile_resource_id) const { | 557 int* sandbox_profile_resource_id) const { |
552 DCHECK(sandbox_profile_resource_id); | 558 DCHECK(sandbox_profile_resource_id); |
553 if (sandbox_type == NACL_SANDBOX_TYPE_NACL_LOADER) { | 559 if (sandbox_type == NACL_SANDBOX_TYPE_NACL_LOADER) { |
554 *sandbox_profile_resource_id = IDR_NACL_SANDBOX_PROFILE; | 560 *sandbox_profile_resource_id = IDR_NACL_SANDBOX_PROFILE; |
555 return true; | 561 return true; |
556 } | 562 } |
557 return false; | 563 return false; |
558 } | 564 } |
559 #endif | 565 #endif |
OLD | NEW |