| 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/browser/component_updater/flash_component_installer.h" | 5 #include "chrome/browser/component_updater/flash_component_installer.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
| 12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 16 #include "base/stringprintf.h" | 16 #include "base/stringprintf.h" |
| 17 #include "base/values.h" | 17 #include "base/values.h" |
| 18 #include "chrome/browser/component_updater/component_updater_service.h" | 18 #include "chrome/browser/component_updater/component_updater_service.h" |
| 19 #include "chrome/browser/plugin_prefs.h" | 19 #include "chrome/browser/plugin_prefs.h" |
| 20 #include "chrome/common/chrome_paths.h" | 20 #include "chrome/common/chrome_paths.h" |
| 21 #include "content/browser/browser_thread.h" | 21 #include "content/browser/browser_thread.h" |
| 22 #include "content/common/pepper_plugin_registry.h" | |
| 23 #include "ppapi/c/private/ppb_pdf.h" | 22 #include "ppapi/c/private/ppb_pdf.h" |
| 24 #include "webkit/plugins/npapi/plugin_list.h" | 23 #include "webkit/plugins/npapi/plugin_list.h" |
| 25 #include "webkit/plugins/plugin_constants.h" | 24 #include "webkit/plugins/plugin_constants.h" |
| 26 #include "webkit/plugins/ppapi/plugin_module.h" | 25 #include "webkit/plugins/ppapi/plugin_module.h" |
| 26 #include "webkit/plugins/ppapi/ppapi_plugin_info.h" |
| 27 | 27 |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 // CRX hash. The extension id is: mimojjlkmoijpicakmndhoigimigcmbb. | 30 // CRX hash. The extension id is: mimojjlkmoijpicakmndhoigimigcmbb. |
| 31 const uint8 sha2_hash[] = {0xc8, 0xce, 0x99, 0xba, 0xce, 0x89, 0xf8, 0x20, | 31 const uint8 sha2_hash[] = {0xc8, 0xce, 0x99, 0xba, 0xce, 0x89, 0xf8, 0x20, |
| 32 0xac, 0xd3, 0x7e, 0x86, 0x8c, 0x86, 0x2c, 0x11, | 32 0xac, 0xd3, 0x7e, 0x86, 0x8c, 0x86, 0x2c, 0x11, |
| 33 0xb9, 0x40, 0xc5, 0x55, 0xaf, 0x08, 0x63, 0x70, | 33 0xb9, 0x40, 0xc5, 0x55, 0xaf, 0x08, 0x63, 0x70, |
| 34 0x54, 0xf9, 0x56, 0xd3, 0xe7, 0x88, 0xba, 0x8c}; | 34 0x54, 0xf9, 0x56, 0xd3, 0xe7, 0x88, 0xba, 0x8c}; |
| 35 | 35 |
| 36 // File name of the Pepper Flash plugin on different platforms. | 36 // File name of the Pepper Flash plugin on different platforms. |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 // It might be that flapper is using as a temporary hack the PDF interface | 101 // It might be that flapper is using as a temporary hack the PDF interface |
| 102 // so we need to check for that as well. TODO(cpu): make this more sane. | 102 // so we need to check for that as well. TODO(cpu): make this more sane. |
| 103 return (strcmp(interface_name, PPB_PDF_INTERFACE) == 0); | 103 return (strcmp(interface_name, PPB_PDF_INTERFACE) == 0); |
| 104 } | 104 } |
| 105 | 105 |
| 106 } // namespace | 106 } // namespace |
| 107 | 107 |
| 108 bool MakePepperFlashPluginInfo(const FilePath& flash_path, | 108 bool MakePepperFlashPluginInfo(const FilePath& flash_path, |
| 109 const Version& flash_version, | 109 const Version& flash_version, |
| 110 bool out_of_process, | 110 bool out_of_process, |
| 111 PepperPluginInfo* plugin_info) { | 111 webkit::ppapi::PluginInfo* plugin_info) { |
| 112 if (!flash_version.IsValid()) | 112 if (!flash_version.IsValid()) |
| 113 return false; | 113 return false; |
| 114 const std::vector<uint16> ver_nums = flash_version.components(); | 114 const std::vector<uint16> ver_nums = flash_version.components(); |
| 115 if (ver_nums.size() < 3) | 115 if (ver_nums.size() < 3) |
| 116 return false; | 116 return false; |
| 117 | 117 |
| 118 plugin_info->is_internal = false; | 118 plugin_info->is_internal = false; |
| 119 plugin_info->is_out_of_process = out_of_process; | 119 plugin_info->is_out_of_process = out_of_process; |
| 120 plugin_info->path = flash_path; | 120 plugin_info->path = flash_path; |
| 121 plugin_info->name = kFlashPluginName; | 121 plugin_info->name = kFlashPluginName; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 133 webkit::WebPluginMimeType spl_mime_type(kFlashPluginSplMimeType, | 133 webkit::WebPluginMimeType spl_mime_type(kFlashPluginSplMimeType, |
| 134 kFlashPluginSplExtension, | 134 kFlashPluginSplExtension, |
| 135 kFlashPluginName); | 135 kFlashPluginName); |
| 136 plugin_info->mime_types.push_back(spl_mime_type); | 136 plugin_info->mime_types.push_back(spl_mime_type); |
| 137 return true; | 137 return true; |
| 138 } | 138 } |
| 139 | 139 |
| 140 void RegisterPepperFlashWithChrome(const FilePath& path, | 140 void RegisterPepperFlashWithChrome(const FilePath& path, |
| 141 const Version& version) { | 141 const Version& version) { |
| 142 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 142 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 143 PepperPluginInfo plugin_info; | 143 webkit::ppapi::PluginInfo plugin_info; |
| 144 // Register it as out-of-process and disabled. | 144 // Register it as out-of-process and disabled. |
| 145 if (!MakePepperFlashPluginInfo(path, version, true, &plugin_info)) | 145 if (!MakePepperFlashPluginInfo(path, version, true, &plugin_info)) |
| 146 return; | 146 return; |
| 147 PluginPrefs::EnablePluginGlobally(false, plugin_info.path); | 147 PluginPrefs::EnablePluginGlobally(false, plugin_info.path); |
| 148 webkit::WebPluginInfo webplugin_info; |
| 149 webkit::ppapi::PepperToWebPluginInfo(plugin_info, &webplugin_info); |
| 148 webkit::npapi::PluginList::Singleton()->RegisterInternalPlugin( | 150 webkit::npapi::PluginList::Singleton()->RegisterInternalPlugin( |
| 149 plugin_info.ToWebPluginInfo()); | 151 webplugin_info); |
| 150 webkit::npapi::PluginList::Singleton()->RefreshPlugins(); | 152 webkit::npapi::PluginList::Singleton()->RefreshPlugins(); |
| 151 } | 153 } |
| 152 | 154 |
| 153 class PepperFlashComponentInstaller : public ComponentInstaller { | 155 class PepperFlashComponentInstaller : public ComponentInstaller { |
| 154 public: | 156 public: |
| 155 explicit PepperFlashComponentInstaller(const Version& version); | 157 explicit PepperFlashComponentInstaller(const Version& version); |
| 156 | 158 |
| 157 virtual ~PepperFlashComponentInstaller() {} | 159 virtual ~PepperFlashComponentInstaller() {} |
| 158 | 160 |
| 159 virtual void OnUpdateError(int error) OVERRIDE; | 161 virtual void OnUpdateError(int error) OVERRIDE; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 NewRunnableFunction(&FinishPepperFlashUpdateRegistration, cus, version)); | 263 NewRunnableFunction(&FinishPepperFlashUpdateRegistration, cus, version)); |
| 262 } | 264 } |
| 263 | 265 |
| 264 void RegisterPepperFlashComponent(ComponentUpdateService* cus) { | 266 void RegisterPepperFlashComponent(ComponentUpdateService* cus) { |
| 265 #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) | 267 #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) |
| 266 // TODO(cpu): support Mac and Linux flash pepper. | 268 // TODO(cpu): support Mac and Linux flash pepper. |
| 267 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 269 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
| 268 NewRunnableFunction(&StartPepperFlashUpdateRegistration, cus)); | 270 NewRunnableFunction(&StartPepperFlashUpdateRegistration, cus)); |
| 269 #endif | 271 #endif |
| 270 } | 272 } |
| OLD | NEW |