| 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" | |
| 20 #include "chrome/common/chrome_paths.h" | 19 #include "chrome/common/chrome_paths.h" |
| 21 #include "content/browser/browser_thread.h" | 20 #include "content/browser/browser_thread.h" |
| 22 #include "content/common/pepper_plugin_registry.h" | 21 #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" |
| 27 | 26 |
| 28 namespace { | 27 namespace { |
| 29 | 28 |
| (...skipping 71 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 | 100 // 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. | 101 // so we need to check for that as well. TODO(cpu): make this more sane. |
| 103 return (strcmp(interface_name, PPB_PDF_INTERFACE) == 0); | 102 return (strcmp(interface_name, PPB_PDF_INTERFACE) == 0); |
| 104 } | 103 } |
| 105 | 104 |
| 106 } // namespace | 105 } // namespace |
| 107 | 106 |
| 108 bool MakePepperFlashPluginInfo(const FilePath& flash_path, | 107 bool MakePepperFlashPluginInfo(const FilePath& flash_path, |
| 109 const Version& flash_version, | 108 const Version& flash_version, |
| 110 bool out_of_process, | 109 bool out_of_process, |
| 110 bool enabled, |
| 111 PepperPluginInfo* plugin_info) { | 111 PepperPluginInfo* 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; |
| 122 plugin_info->enabled = enabled; |
| 122 | 123 |
| 123 // The description is like "Shockwave Flash 10.2 r154". | 124 // The description is like "Shockwave Flash 10.2 r154". |
| 124 plugin_info->description = StringPrintf("%s %d.%d r%d", | 125 plugin_info->description = StringPrintf("%s %d.%d r%d", |
| 125 kFlashPluginName, ver_nums[0], ver_nums[1], ver_nums[2]); | 126 kFlashPluginName, ver_nums[0], ver_nums[1], ver_nums[2]); |
| 126 | 127 |
| 127 plugin_info->version = flash_version.GetString(); | 128 plugin_info->version = flash_version.GetString(); |
| 128 | 129 |
| 129 webkit::WebPluginMimeType swf_mime_type(kFlashPluginSwfMimeType, | 130 webkit::WebPluginMimeType swf_mime_type(kFlashPluginSwfMimeType, |
| 130 kFlashPluginSwfExtension, | 131 kFlashPluginSwfExtension, |
| 131 kFlashPluginName); | 132 kFlashPluginName); |
| 132 plugin_info->mime_types.push_back(swf_mime_type); | 133 plugin_info->mime_types.push_back(swf_mime_type); |
| 133 webkit::WebPluginMimeType spl_mime_type(kFlashPluginSplMimeType, | 134 webkit::WebPluginMimeType spl_mime_type(kFlashPluginSplMimeType, |
| 134 kFlashPluginSplExtension, | 135 kFlashPluginSplExtension, |
| 135 kFlashPluginName); | 136 kFlashPluginName); |
| 136 plugin_info->mime_types.push_back(spl_mime_type); | 137 plugin_info->mime_types.push_back(spl_mime_type); |
| 137 return true; | 138 return true; |
| 138 } | 139 } |
| 139 | 140 |
| 140 void RegisterPepperFlashWithChrome(const FilePath& path, | 141 void RegisterPepperFlashWithChrome(const FilePath& path, |
| 141 const Version& version) { | 142 const Version& version) { |
| 142 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 143 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 143 PepperPluginInfo plugin_info; | 144 PepperPluginInfo plugin_info; |
| 144 // Register it as out-of-process and disabled. | 145 // Register it as out-of-process and disabled. |
| 145 if (!MakePepperFlashPluginInfo(path, version, true, &plugin_info)) | 146 if (!MakePepperFlashPluginInfo(path, version, true, false, &plugin_info)) |
| 146 return; | 147 return; |
| 147 PluginPrefs::EnablePluginGlobally(false, plugin_info.path); | |
| 148 webkit::npapi::PluginList::Singleton()->RegisterInternalPlugin( | 148 webkit::npapi::PluginList::Singleton()->RegisterInternalPlugin( |
| 149 plugin_info.ToWebPluginInfo()); | 149 plugin_info.ToWebPluginInfo()); |
| 150 webkit::npapi::PluginList::Singleton()->RefreshPlugins(); | 150 webkit::npapi::PluginList::Singleton()->RefreshPlugins(); |
| 151 } | 151 } |
| 152 | 152 |
| 153 class PepperFlashComponentInstaller : public ComponentInstaller { | 153 class PepperFlashComponentInstaller : public ComponentInstaller { |
| 154 public: | 154 public: |
| 155 explicit PepperFlashComponentInstaller(const Version& version); | 155 explicit PepperFlashComponentInstaller(const Version& version); |
| 156 | 156 |
| 157 virtual ~PepperFlashComponentInstaller() {} | 157 virtual ~PepperFlashComponentInstaller() {} |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 NewRunnableFunction(&FinishPepperFlashUpdateRegistration, cus, version)); | 257 NewRunnableFunction(&FinishPepperFlashUpdateRegistration, cus, version)); |
| 258 } | 258 } |
| 259 | 259 |
| 260 void RegisterPepperFlashComponent(ComponentUpdateService* cus) { | 260 void RegisterPepperFlashComponent(ComponentUpdateService* cus) { |
| 261 #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) | 261 #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) |
| 262 // TODO(cpu): support Mac and Linux flash pepper. | 262 // TODO(cpu): support Mac and Linux flash pepper. |
| 263 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 263 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
| 264 NewRunnableFunction(&StartPepperFlashUpdateRegistration, cus)); | 264 NewRunnableFunction(&StartPepperFlashUpdateRegistration, cus)); |
| 265 #endif | 265 #endif |
| 266 } | 266 } |
| OLD | NEW |