| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
| 11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
| 12 #include "base/stringprintf.h" | 12 #include "base/stringprintf.h" |
| 13 #include "base/string_split.h" | 13 #include "base/string_split.h" |
| 14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 15 #include "base/win/windows_version.h" | 15 #include "base/win/windows_version.h" |
| 16 #include "chrome/common/child_process_logging.h" | 16 #include "chrome/common/child_process_logging.h" |
| 17 #include "chrome/common/chrome_paths.h" | 17 #include "chrome/common/chrome_paths.h" |
| 18 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
| 19 #include "chrome/common/chrome_version_info.h" | 19 #include "chrome/common/chrome_version_info.h" |
| 20 #include "chrome/common/render_messages.h" | 20 #include "chrome/common/render_messages.h" |
| 21 #include "content/common/pepper_plugin_registry.h" | |
| 22 #include "remoting/client/plugin/pepper_entrypoints.h" | 21 #include "remoting/client/plugin/pepper_entrypoints.h" |
| 23 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
| 24 #include "ui/base/resource/resource_bundle.h" | 23 #include "ui/base/resource/resource_bundle.h" |
| 25 #include "webkit/glue/user_agent.h" | 24 #include "webkit/glue/user_agent.h" |
| 26 #include "webkit/plugins/plugin_constants.h" | 25 #include "webkit/plugins/plugin_constants.h" |
| 26 #include "webkit/plugins/ppapi/ppapi_plugin_info.h" |
| 27 | 27 |
| 28 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
| 29 #include "content/common/sandbox_policy.h" | 29 #include "content/common/sandbox_policy.h" |
| 30 #include "sandbox/src/sandbox.h" | 30 #include "sandbox/src/sandbox.h" |
| 31 #endif | 31 #endif |
| 32 | 32 |
| 33 namespace { | 33 namespace { |
| 34 | 34 |
| 35 const char kPDFPluginName[] = "Chrome PDF Viewer"; | 35 const char kPDFPluginName[] = "Chrome PDF Viewer"; |
| 36 const char kPDFPluginMimeType[] = "application/pdf"; | 36 const char kPDFPluginMimeType[] = "application/pdf"; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 56 // TODO(wez): Remove the old MIME-type once client code no longer needs it. | 56 // TODO(wez): Remove the old MIME-type once client code no longer needs it. |
| 57 const char kRemotingViewerPluginOldMimeType[] = | 57 const char kRemotingViewerPluginOldMimeType[] = |
| 58 "pepper-application/x-chromoting"; | 58 "pepper-application/x-chromoting"; |
| 59 #endif | 59 #endif |
| 60 | 60 |
| 61 // Appends the known built-in plugins to the given vector. Some built-in | 61 // Appends the known built-in plugins to the given vector. Some built-in |
| 62 // plugins are "internal" which means they are compiled into the Chrome binary, | 62 // plugins are "internal" which means they are compiled into the Chrome binary, |
| 63 // and some are extra shared libraries distributed with the browser (these are | 63 // and some are extra shared libraries distributed with the browser (these are |
| 64 // not marked internal, aside from being automatically registered, they're just | 64 // not marked internal, aside from being automatically registered, they're just |
| 65 // regular plugins). | 65 // regular plugins). |
| 66 void ComputeBuiltInPlugins(std::vector<PepperPluginInfo>* plugins) { | 66 void ComputeBuiltInPlugins(std::vector<webkit::ppapi::PluginInfo>* plugins) { |
| 67 // PDF. | 67 // PDF. |
| 68 // | 68 // |
| 69 // Once we're sandboxed, we can't know if the PDF plugin is available or not; | 69 // Once we're sandboxed, we can't know if the PDF plugin is available or not; |
| 70 // but (on Linux) this function is always called once before we're sandboxed. | 70 // but (on Linux) this function is always called once before we're sandboxed. |
| 71 // So the first time through test if the file is available and then skip the | 71 // So the first time through test if the file is available and then skip the |
| 72 // check on subsequent calls if yes. | 72 // check on subsequent calls if yes. |
| 73 static bool skip_pdf_file_check = false; | 73 static bool skip_pdf_file_check = false; |
| 74 FilePath path; | 74 FilePath path; |
| 75 if (PathService::Get(chrome::FILE_PDF_PLUGIN, &path)) { | 75 if (PathService::Get(chrome::FILE_PDF_PLUGIN, &path)) { |
| 76 if (skip_pdf_file_check || file_util::PathExists(path)) { | 76 if (skip_pdf_file_check || file_util::PathExists(path)) { |
| 77 PepperPluginInfo pdf; | 77 webkit::ppapi::PluginInfo pdf; |
| 78 pdf.path = path; | 78 pdf.path = path; |
| 79 pdf.name = kPDFPluginName; | 79 pdf.name = kPDFPluginName; |
| 80 webkit::WebPluginMimeType pdf_mime_type(kPDFPluginMimeType, | 80 webkit::WebPluginMimeType pdf_mime_type(kPDFPluginMimeType, |
| 81 kPDFPluginExtension, | 81 kPDFPluginExtension, |
| 82 kPDFPluginDescription); | 82 kPDFPluginDescription); |
| 83 webkit::WebPluginMimeType print_preview_pdf_mime_type( | 83 webkit::WebPluginMimeType print_preview_pdf_mime_type( |
| 84 kPDFPluginPrintPreviewMimeType, | 84 kPDFPluginPrintPreviewMimeType, |
| 85 kPDFPluginExtension, | 85 kPDFPluginExtension, |
| 86 kPDFPluginDescription); | 86 kPDFPluginDescription); |
| 87 pdf.mime_types.push_back(pdf_mime_type); | 87 pdf.mime_types.push_back(pdf_mime_type); |
| 88 pdf.mime_types.push_back(print_preview_pdf_mime_type); | 88 pdf.mime_types.push_back(print_preview_pdf_mime_type); |
| 89 plugins->push_back(pdf); | 89 plugins->push_back(pdf); |
| 90 | 90 |
| 91 skip_pdf_file_check = true; | 91 skip_pdf_file_check = true; |
| 92 } | 92 } |
| 93 } | 93 } |
| 94 | 94 |
| 95 // Handle the Native Client just like the PDF plugin. This means that it is | 95 // Handle the Native Client just like the PDF plugin. This means that it is |
| 96 // enabled by default. This allows apps installed from the Chrome Web Store | 96 // enabled by default. This allows apps installed from the Chrome Web Store |
| 97 // to use NaCl even if the command line switch isn't set. For other uses of | 97 // to use NaCl even if the command line switch isn't set. For other uses of |
| 98 // NaCl we check for the command line switch. | 98 // NaCl we check for the command line switch. |
| 99 static bool skip_nacl_file_check = false; | 99 static bool skip_nacl_file_check = false; |
| 100 if (PathService::Get(chrome::FILE_NACL_PLUGIN, &path)) { | 100 if (PathService::Get(chrome::FILE_NACL_PLUGIN, &path)) { |
| 101 if (skip_nacl_file_check || file_util::PathExists(path)) { | 101 if (skip_nacl_file_check || file_util::PathExists(path)) { |
| 102 PepperPluginInfo nacl; | 102 webkit::ppapi::PluginInfo nacl; |
| 103 nacl.path = path; | 103 nacl.path = path; |
| 104 nacl.name = kNaClPluginName; | 104 nacl.name = kNaClPluginName; |
| 105 webkit::WebPluginMimeType nacl_mime_type(kNaClPluginMimeType, | 105 webkit::WebPluginMimeType nacl_mime_type(kNaClPluginMimeType, |
| 106 kNaClPluginExtension, | 106 kNaClPluginExtension, |
| 107 kNaClPluginDescription); | 107 kNaClPluginDescription); |
| 108 nacl.mime_types.push_back(nacl_mime_type); | 108 nacl.mime_types.push_back(nacl_mime_type); |
| 109 plugins->push_back(nacl); | 109 plugins->push_back(nacl); |
| 110 | 110 |
| 111 skip_nacl_file_check = true; | 111 skip_nacl_file_check = true; |
| 112 } | 112 } |
| 113 } | 113 } |
| 114 | 114 |
| 115 // The Remoting Viewer plugin is built-in. | 115 // The Remoting Viewer plugin is built-in. |
| 116 #if defined(ENABLE_REMOTING) | 116 #if defined(ENABLE_REMOTING) |
| 117 PepperPluginInfo info; | 117 webkit::ppapi::PluginInfo info; |
| 118 info.is_internal = true; | 118 info.is_internal = true; |
| 119 info.name = kRemotingViewerPluginName; | 119 info.name = kRemotingViewerPluginName; |
| 120 info.path = FilePath(kRemotingViewerPluginPath); | 120 info.path = FilePath(kRemotingViewerPluginPath); |
| 121 webkit::WebPluginMimeType remoting_mime_type( | 121 webkit::WebPluginMimeType remoting_mime_type( |
| 122 kRemotingViewerPluginMimeType, | 122 kRemotingViewerPluginMimeType, |
| 123 std::string(), | 123 std::string(), |
| 124 std::string()); | 124 std::string()); |
| 125 info.mime_types.push_back(remoting_mime_type); | 125 info.mime_types.push_back(remoting_mime_type); |
| 126 webkit::WebPluginMimeType old_remoting_mime_type( | 126 webkit::WebPluginMimeType old_remoting_mime_type( |
| 127 kRemotingViewerPluginOldMimeType, | 127 kRemotingViewerPluginOldMimeType, |
| 128 std::string(), | 128 std::string(), |
| 129 std::string()); | 129 std::string()); |
| 130 info.mime_types.push_back(old_remoting_mime_type); | 130 info.mime_types.push_back(old_remoting_mime_type); |
| 131 info.internal_entry_points.get_interface = remoting::PPP_GetInterface; | 131 info.internal_entry_points.get_interface = remoting::PPP_GetInterface; |
| 132 info.internal_entry_points.initialize_module = | 132 info.internal_entry_points.initialize_module = |
| 133 remoting::PPP_InitializeModule; | 133 remoting::PPP_InitializeModule; |
| 134 info.internal_entry_points.shutdown_module = remoting::PPP_ShutdownModule; | 134 info.internal_entry_points.shutdown_module = remoting::PPP_ShutdownModule; |
| 135 | 135 |
| 136 plugins->push_back(info); | 136 plugins->push_back(info); |
| 137 #endif | 137 #endif |
| 138 } | 138 } |
| 139 | 139 |
| 140 void AddOutOfProcessFlash(std::vector<PepperPluginInfo>* plugins) { | 140 void AddOutOfProcessFlash(std::vector<webkit::ppapi::PluginInfo>* plugins) { |
| 141 // Flash being out of process is handled separately than general plugins | 141 // Flash being out of process is handled separately than general plugins |
| 142 // for testing purposes. | 142 // for testing purposes. |
| 143 bool flash_out_of_process = !CommandLine::ForCurrentProcess()->HasSwitch( | 143 bool flash_out_of_process = !CommandLine::ForCurrentProcess()->HasSwitch( |
| 144 switches::kPpapiFlashInProcess); | 144 switches::kPpapiFlashInProcess); |
| 145 | 145 |
| 146 // Handle any Pepper Flash first. | 146 // Handle any Pepper Flash first. |
| 147 const CommandLine::StringType flash_path = | 147 const CommandLine::StringType flash_path = |
| 148 CommandLine::ForCurrentProcess()->GetSwitchValueNative( | 148 CommandLine::ForCurrentProcess()->GetSwitchValueNative( |
| 149 switches::kPpapiFlashPath); | 149 switches::kPpapiFlashPath); |
| 150 if (flash_path.empty()) | 150 if (flash_path.empty()) |
| 151 return; | 151 return; |
| 152 | 152 |
| 153 PepperPluginInfo plugin; | 153 webkit::ppapi::PluginInfo plugin; |
| 154 plugin.is_out_of_process = flash_out_of_process; | 154 plugin.is_out_of_process = flash_out_of_process; |
| 155 plugin.path = FilePath(flash_path); | 155 plugin.path = FilePath(flash_path); |
| 156 plugin.name = kFlashPluginName; | 156 plugin.name = kFlashPluginName; |
| 157 | 157 |
| 158 const std::string flash_version = | 158 const std::string flash_version = |
| 159 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 159 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 160 switches::kPpapiFlashVersion); | 160 switches::kPpapiFlashVersion); |
| 161 std::vector<std::string> flash_version_numbers; | 161 std::vector<std::string> flash_version_numbers; |
| 162 base::SplitString(flash_version, '.', &flash_version_numbers); | 162 base::SplitString(flash_version, '.', &flash_version_numbers); |
| 163 if (flash_version_numbers.size() < 1) | 163 if (flash_version_numbers.size() < 1) |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 | 262 |
| 263 void ChromeContentClient::SetActiveURL(const GURL& url) { | 263 void ChromeContentClient::SetActiveURL(const GURL& url) { |
| 264 child_process_logging::SetActiveURL(url); | 264 child_process_logging::SetActiveURL(url); |
| 265 } | 265 } |
| 266 | 266 |
| 267 void ChromeContentClient::SetGpuInfo(const GPUInfo& gpu_info) { | 267 void ChromeContentClient::SetGpuInfo(const GPUInfo& gpu_info) { |
| 268 child_process_logging::SetGpuInfo(gpu_info); | 268 child_process_logging::SetGpuInfo(gpu_info); |
| 269 } | 269 } |
| 270 | 270 |
| 271 void ChromeContentClient::AddPepperPlugins( | 271 void ChromeContentClient::AddPepperPlugins( |
| 272 std::vector<PepperPluginInfo>* plugins) { | 272 std::vector<webkit::ppapi::PluginInfo>* plugins) { |
| 273 ComputeBuiltInPlugins(plugins); | 273 ComputeBuiltInPlugins(plugins); |
| 274 AddOutOfProcessFlash(plugins); | 274 AddOutOfProcessFlash(plugins); |
| 275 } | 275 } |
| 276 | 276 |
| 277 bool ChromeContentClient::CanSendWhileSwappedOut(const IPC::Message* msg) { | 277 bool ChromeContentClient::CanSendWhileSwappedOut(const IPC::Message* msg) { |
| 278 // Any Chrome-specific messages that must be allowed to be sent from swapped | 278 // Any Chrome-specific messages that must be allowed to be sent from swapped |
| 279 // out renderers. | 279 // out renderers. |
| 280 switch (msg->type()) { | 280 switch (msg->type()) { |
| 281 case ChromeViewHostMsg_DomOperationResponse::ID: | 281 case ChromeViewHostMsg_DomOperationResponse::ID: |
| 282 return true; | 282 return true; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 policy->SetJobLevel(sandbox::JOB_UNPROTECTED, 0); | 370 policy->SetJobLevel(sandbox::JOB_UNPROTECTED, 0); |
| 371 policy->SetTokenLevel( | 371 policy->SetTokenLevel( |
| 372 sandbox::USER_UNPROTECTED, sandbox::USER_UNPROTECTED); | 372 sandbox::USER_UNPROTECTED, sandbox::USER_UNPROTECTED); |
| 373 } | 373 } |
| 374 | 374 |
| 375 return true; | 375 return true; |
| 376 } | 376 } |
| 377 #endif | 377 #endif |
| 378 | 378 |
| 379 } // namespace chrome | 379 } // namespace chrome |
| OLD | NEW |