Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <stdint.h> | 5 #include <stdint.h> |
| 6 #include <string.h> | 6 #include <string.h> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/files/file_enumerator.h" | 13 #include "base/files/file_enumerator.h" |
| 14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 15 #include "base/files/file_util.h" | 15 #include "base/files/file_util.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/path_service.h" | 17 #include "base/path_service.h" |
| 18 #include "base/stl_util.h" | |
| 18 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
| 19 #include "base/strings/stringprintf.h" | 20 #include "base/strings/stringprintf.h" |
| 20 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| 21 #include "base/version.h" | 22 #include "base/version.h" |
| 22 #include "build/build_config.h" | 23 #include "build/build_config.h" |
| 23 #include "chrome/browser/component_updater/flash_component_installer.h" | 24 #include "chrome/browser/component_updater/flash_component_installer.h" |
| 24 #include "chrome/browser/plugins/plugin_prefs.h" | 25 #include "chrome/browser/plugins/plugin_prefs.h" |
| 25 #include "chrome/common/chrome_constants.h" | 26 #include "chrome/common/chrome_constants.h" |
| 26 #include "chrome/common/chrome_paths.h" | 27 #include "chrome/common/chrome_paths.h" |
| 27 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
| 29 #include "chrome/common/component_flash_hint_file.h" | |
| 28 #include "chrome/common/pepper_flash.h" | 30 #include "chrome/common/pepper_flash.h" |
| 29 #include "chrome/common/ppapi_utils.h" | 31 #include "chrome/common/ppapi_utils.h" |
| 30 #include "components/component_updater/component_updater_service.h" | 32 #include "components/component_updater/component_updater_service.h" |
| 31 #include "components/update_client/update_client.h" | 33 #include "components/update_client/update_client.h" |
| 32 #include "content/public/browser/browser_thread.h" | 34 #include "content/public/browser/browser_thread.h" |
| 33 #include "content/public/browser/plugin_service.h" | 35 #include "content/public/browser/plugin_service.h" |
| 34 #include "content/public/common/content_constants.h" | 36 #include "content/public/common/content_constants.h" |
| 35 #include "content/public/common/pepper_plugin_info.h" | 37 #include "content/public/common/pepper_plugin_info.h" |
| 36 #include "flapper_version.h" // In SHARED_INTERMEDIATE_DIR. NOLINT | 38 #include "flapper_version.h" // In SHARED_INTERMEDIATE_DIR. NOLINT |
| 37 #include "ppapi/shared_impl/ppapi_permissions.h" | 39 #include "ppapi/shared_impl/ppapi_permissions.h" |
| 38 | 40 |
| 39 using content::BrowserThread; | 41 using content::BrowserThread; |
| 40 using content::PluginService; | 42 using content::PluginService; |
| 41 | 43 |
| 42 namespace component_updater { | 44 namespace component_updater { |
| 43 | 45 |
| 44 namespace { | 46 namespace { |
| 45 | 47 |
| 46 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX) | 48 #if defined(GOOGLE_CHROME_BUILD) |
| 47 // CRX hash. The extension id is: mimojjlkmoijpicakmndhoigimigcmbb. | 49 // CRX hash. The extension id is: mimojjlkmoijpicakmndhoigimigcmbb. |
| 48 const uint8_t kSha2Hash[] = {0xc8, 0xce, 0x99, 0xba, 0xce, 0x89, 0xf8, 0x20, | 50 const uint8_t kSha2Hash[] = {0xc8, 0xce, 0x99, 0xba, 0xce, 0x89, 0xf8, 0x20, |
| 49 0xac, 0xd3, 0x7e, 0x86, 0x8c, 0x86, 0x2c, 0x11, | 51 0xac, 0xd3, 0x7e, 0x86, 0x8c, 0x86, 0x2c, 0x11, |
| 50 0xb9, 0x40, 0xc5, 0x55, 0xaf, 0x08, 0x63, 0x70, | 52 0xb9, 0x40, 0xc5, 0x55, 0xaf, 0x08, 0x63, 0x70, |
| 51 0x54, 0xf9, 0x56, 0xd3, 0xe7, 0x88, 0xba, 0x8c}; | 53 0x54, 0xf9, 0x56, 0xd3, 0xe7, 0x88, 0xba, 0x8c}; |
| 52 | 54 |
| 53 // If we don't have a Pepper Flash component, this is the version we claim. | 55 // If we don't have a Pepper Flash component, this is the version we claim. |
| 54 const char kNullVersion[] = "0.0.0.0"; | 56 const char kNullVersion[] = "0.0.0.0"; |
| 55 | 57 |
| 56 #endif // defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX) | 58 #endif // defined(GOOGLE_CHROME_BUILD) |
| 57 | 59 |
| 58 // The base directory on Windows looks like: | 60 // The base directory on Windows looks like: |
| 59 // <profile>\AppData\Local\Google\Chrome\User Data\PepperFlash\. | 61 // <profile>\AppData\Local\Google\Chrome\User Data\PepperFlash\. |
| 60 base::FilePath GetPepperFlashBaseDirectory() { | 62 base::FilePath GetPepperFlashBaseDirectory() { |
| 61 base::FilePath result; | 63 base::FilePath result; |
| 62 PathService::Get(chrome::DIR_COMPONENT_UPDATED_PEPPER_FLASH_PLUGIN, &result); | 64 PathService::Get(chrome::DIR_COMPONENT_UPDATED_PEPPER_FLASH_PLUGIN, &result); |
| 63 return result; | 65 return result; |
| 64 } | 66 } |
| 65 | 67 |
| 66 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX) | 68 #if defined(GOOGLE_CHROME_BUILD) |
| 67 // Pepper Flash plugins have the version encoded in the path itself | 69 // Pepper Flash plugins have the version encoded in the path itself |
| 68 // so we need to enumerate the directories to find the full path. | 70 // so we need to enumerate the directories to find the full path. |
| 69 // On success, |latest_dir| returns something like: | 71 // On success, |latest_dir| returns something like: |
| 70 // <profile>\AppData\Local\Google\Chrome\User Data\PepperFlash\10.3.44.555\. | 72 // <profile>\AppData\Local\Google\Chrome\User Data\PepperFlash\10.3.44.555\. |
| 71 // |latest_version| returns the corresponding version number. |older_dirs| | 73 // |latest_version| returns the corresponding version number. |older_dirs| |
| 72 // returns directories of all older versions. | 74 // returns directories of all older versions. |
| 73 bool GetPepperFlashDirectory(base::FilePath* latest_dir, | 75 bool GetPepperFlashDirectory(base::FilePath* latest_dir, |
| 74 Version* latest_version, | 76 Version* latest_version, |
| 75 std::vector<base::FilePath>* older_dirs) { | 77 std::vector<base::FilePath>* older_dirs) { |
| 76 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 78 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 92 older_dirs->push_back(path); | 94 older_dirs->push_back(path); |
| 93 } | 95 } |
| 94 } else { | 96 } else { |
| 95 *latest_dir = path; | 97 *latest_dir = path; |
| 96 *latest_version = version; | 98 *latest_version = version; |
| 97 found = true; | 99 found = true; |
| 98 } | 100 } |
| 99 } | 101 } |
| 100 return found; | 102 return found; |
| 101 } | 103 } |
| 102 #endif // defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX) | 104 #endif // defined(GOOGLE_CHROME_BUILD) |
| 103 | 105 |
| 106 #if !defined(OS_LINUX) || defined(GOOGLE_CHROME_BUILD) | |
|
jln (very slow on Chromium)
2015/08/06 18:48:14
Why is this needed? Wasn't this building unconditi
Greg K
2015/08/07 21:15:28
On Linux, because PepperFlashComponentInstaller::I
| |
| 104 bool MakePepperFlashPluginInfo(const base::FilePath& flash_path, | 107 bool MakePepperFlashPluginInfo(const base::FilePath& flash_path, |
| 105 const Version& flash_version, | 108 const Version& flash_version, |
| 106 bool out_of_process, | 109 bool out_of_process, |
| 107 content::PepperPluginInfo* plugin_info) { | 110 content::PepperPluginInfo* plugin_info) { |
| 108 if (!flash_version.IsValid()) | 111 if (!flash_version.IsValid()) |
| 109 return false; | 112 return false; |
| 110 const std::vector<uint32_t> ver_nums = flash_version.components(); | 113 const std::vector<uint32_t> ver_nums = flash_version.components(); |
| 111 if (ver_nums.size() < 3) | 114 if (ver_nums.size() < 3) |
| 112 return false; | 115 return false; |
| 113 | 116 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 | 173 |
| 171 // If the version is newer, remove the old one first. | 174 // If the version is newer, remove the old one first. |
| 172 PluginService::GetInstance()->UnregisterInternalPlugin(it->path); | 175 PluginService::GetInstance()->UnregisterInternalPlugin(it->path); |
| 173 break; | 176 break; |
| 174 } | 177 } |
| 175 | 178 |
| 176 PluginService::GetInstance()->RegisterInternalPlugin( | 179 PluginService::GetInstance()->RegisterInternalPlugin( |
| 177 plugin_info.ToWebPluginInfo(), true); | 180 plugin_info.ToWebPluginInfo(), true); |
| 178 PluginService::GetInstance()->RefreshPlugins(); | 181 PluginService::GetInstance()->RefreshPlugins(); |
| 179 } | 182 } |
| 183 #endif // !defined(OS_LINUX) || defined(GOOGLE_CHROME_BUILD) | |
| 180 | 184 |
| 181 } // namespace | 185 } // namespace |
| 182 | 186 |
| 183 class PepperFlashComponentInstaller : public update_client::CrxInstaller { | 187 class PepperFlashComponentInstaller : public update_client::CrxInstaller { |
| 184 public: | 188 public: |
| 185 explicit PepperFlashComponentInstaller(const Version& version); | 189 explicit PepperFlashComponentInstaller(const Version& version); |
| 186 | 190 |
| 187 // ComponentInstaller implementation: | 191 // ComponentInstaller implementation: |
| 188 void OnUpdateError(int error) override; | 192 void OnUpdateError(int error) override; |
| 189 | 193 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 212 } | 216 } |
| 213 | 217 |
| 214 bool PepperFlashComponentInstaller::Install( | 218 bool PepperFlashComponentInstaller::Install( |
| 215 const base::DictionaryValue& manifest, | 219 const base::DictionaryValue& manifest, |
| 216 const base::FilePath& unpack_path) { | 220 const base::FilePath& unpack_path) { |
| 217 Version version; | 221 Version version; |
| 218 if (!chrome::CheckPepperFlashManifest(manifest, &version)) | 222 if (!chrome::CheckPepperFlashManifest(manifest, &version)) |
| 219 return false; | 223 return false; |
| 220 if (current_version_.CompareTo(version) > 0) | 224 if (current_version_.CompareTo(version) > 0) |
| 221 return false; | 225 return false; |
| 222 if (!base::PathExists(unpack_path.Append(chrome::kPepperFlashPluginFilename))) | 226 const base::FilePath unpacked_plugin = |
| 227 unpack_path.Append(chrome::kPepperFlashPluginFilename); | |
| 228 if (!base::PathExists(unpacked_plugin)) | |
| 223 return false; | 229 return false; |
| 224 // Passed the basic tests. Time to install it. | 230 // Passed the basic tests. Time to install it. |
| 225 base::FilePath path = | 231 base::FilePath path = |
| 226 GetPepperFlashBaseDirectory().AppendASCII(version.GetString()); | 232 GetPepperFlashBaseDirectory().AppendASCII(version.GetString()); |
| 227 if (base::PathExists(path)) | 233 if (base::PathExists(path)) |
| 228 return false; | 234 return false; |
| 235 current_version_ = version; | |
| 236 | |
| 229 if (!base::Move(unpack_path, path)) | 237 if (!base::Move(unpack_path, path)) |
| 230 return false; | 238 return false; |
| 239 #if defined(OS_LINUX) | |
| 240 const base::FilePath flash_path = | |
| 241 path.Append(chrome::kPepperFlashPluginFilename); | |
| 242 // Populate the component updated flash hint file so that the zygote can | |
| 243 // locate and preload the latest version of flash. | |
| 244 if (!chrome::ComponentFlashHintFile::RecordFlashUpdate(flash_path, flash_path, | |
| 245 version.GetString())) { | |
| 246 if (!base::DeleteFile(path, true)) | |
| 247 LOG(WARNING) << "Hint file creation failed, but unable to delete " | |
|
jln (very slow on Chromium)
2015/08/06 18:48:14
I would upgrade to ERROR, but your choice.
Greg K
2015/08/07 21:15:28
Done.
| |
| 248 "installed flash plugin."; | |
| 249 return false; | |
| 250 } | |
| 251 #else | |
| 231 // Installation is done. Now tell the rest of chrome. Both the path service | 252 // Installation is done. Now tell the rest of chrome. Both the path service |
| 232 // and to the plugin service. | 253 // and to the plugin service. On Linux, a restart is required to use the new |
| 233 current_version_ = version; | 254 // Flash version, so we do not do this. |
| 234 PathService::Override(chrome::DIR_PEPPER_FLASH_PLUGIN, path); | 255 PathService::Override(chrome::DIR_PEPPER_FLASH_PLUGIN, path); |
| 235 path = path.Append(chrome::kPepperFlashPluginFilename); | 256 path = path.Append(chrome::kPepperFlashPluginFilename); |
| 236 BrowserThread::PostTask( | 257 BrowserThread::PostTask( |
| 237 BrowserThread::UI, | 258 BrowserThread::UI, |
| 238 FROM_HERE, | 259 FROM_HERE, |
| 239 base::Bind(&RegisterPepperFlashWithChrome, path, version)); | 260 base::Bind(&RegisterPepperFlashWithChrome, path, version)); |
| 261 #endif // !defined(OS_LINUX) | |
| 240 return true; | 262 return true; |
| 241 } | 263 } |
| 242 | 264 |
| 243 bool PepperFlashComponentInstaller::GetInstalledFile( | 265 bool PepperFlashComponentInstaller::GetInstalledFile( |
| 244 const std::string& file, | 266 const std::string& file, |
| 245 base::FilePath* installed_file) { | 267 base::FilePath* installed_file) { |
| 246 return false; | 268 return false; |
| 247 } | 269 } |
| 248 | 270 |
| 249 bool PepperFlashComponentInstaller::Uninstall() { | 271 bool PepperFlashComponentInstaller::Uninstall() { |
| 250 return false; | 272 return false; |
| 251 } | 273 } |
| 252 | 274 |
| 253 | 275 |
| 254 | 276 |
| 255 namespace { | 277 namespace { |
| 256 | 278 |
| 257 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX) | 279 #if defined(GOOGLE_CHROME_BUILD) |
| 258 void FinishPepperFlashUpdateRegistration(ComponentUpdateService* cus, | 280 void FinishPepperFlashUpdateRegistration(ComponentUpdateService* cus, |
| 259 const Version& version) { | 281 const Version& version) { |
| 260 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 282 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 261 update_client::CrxComponent pepflash; | 283 update_client::CrxComponent pepflash; |
| 262 pepflash.name = "pepper_flash"; | 284 pepflash.name = "pepper_flash"; |
| 263 pepflash.installer = new PepperFlashComponentInstaller(version); | 285 pepflash.installer = new PepperFlashComponentInstaller(version); |
| 264 pepflash.version = version; | 286 pepflash.version = version; |
| 265 pepflash.pk_hash.assign(kSha2Hash, &kSha2Hash[sizeof(kSha2Hash)]); | 287 pepflash.pk_hash.assign(kSha2Hash, &kSha2Hash[sizeof(kSha2Hash)]); |
| 266 if (!cus->RegisterComponent(pepflash)) | 288 if (!cus->RegisterComponent(pepflash)) |
| 267 NOTREACHED() << "Pepper Flash component registration failed."; | 289 NOTREACHED() << "Pepper Flash component registration failed."; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 304 FROM_HERE, | 326 FROM_HERE, |
| 305 base::Bind(&FinishPepperFlashUpdateRegistration, cus, version)); | 327 base::Bind(&FinishPepperFlashUpdateRegistration, cus, version)); |
| 306 | 328 |
| 307 // Remove older versions of Pepper Flash. | 329 // Remove older versions of Pepper Flash. |
| 308 for (std::vector<base::FilePath>::iterator iter = older_dirs.begin(); | 330 for (std::vector<base::FilePath>::iterator iter = older_dirs.begin(); |
| 309 iter != older_dirs.end(); | 331 iter != older_dirs.end(); |
| 310 ++iter) { | 332 ++iter) { |
| 311 base::DeleteFile(*iter, true); | 333 base::DeleteFile(*iter, true); |
| 312 } | 334 } |
| 313 } | 335 } |
| 314 #endif // defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX) | 336 #endif // defined(GOOGLE_CHROME_BUILD) |
| 315 | 337 |
| 316 } // namespace | 338 } // namespace |
| 317 | 339 |
| 318 void RegisterPepperFlashComponent(ComponentUpdateService* cus) { | 340 void RegisterPepperFlashComponent(ComponentUpdateService* cus) { |
| 319 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX) | 341 #if defined(GOOGLE_CHROME_BUILD) |
| 320 // Component updated flash supersedes bundled flash therefore if that one | 342 // Component updated flash supersedes bundled flash therefore if that one |
| 321 // is disabled then this one should never install. | 343 // is disabled then this one should never install. |
| 322 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 344 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
| 323 if (cmd_line->HasSwitch(switches::kDisableBundledPpapiFlash)) | 345 if (cmd_line->HasSwitch(switches::kDisableBundledPpapiFlash)) |
| 324 return; | 346 return; |
| 325 BrowserThread::PostTask(BrowserThread::FILE, | 347 BrowserThread::PostTask(BrowserThread::FILE, |
| 326 FROM_HERE, | 348 FROM_HERE, |
| 327 base::Bind(&StartPepperFlashUpdateRegistration, cus)); | 349 base::Bind(&StartPepperFlashUpdateRegistration, cus)); |
| 328 #endif | 350 #endif // defined(GOOGLE_CHROME_BUILD) |
| 329 } | 351 } |
| 330 | 352 |
| 331 } // namespace component_updater | 353 } // namespace component_updater |
| OLD | NEW |