Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(470)

Side by Side Diff: chrome/common/chrome_content_client.cc

Issue 2463913002: Do not replace up-to-date System Flash with Component Flash. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 widevine_cdm.mime_types.push_back(widevine_cdm_mime_type); 224 widevine_cdm.mime_types.push_back(widevine_cdm_mime_type);
225 widevine_cdm.permissions = kWidevineCdmPluginPermissions; 225 widevine_cdm.permissions = kWidevineCdmPluginPermissions;
226 plugins->push_back(widevine_cdm); 226 plugins->push_back(widevine_cdm);
227 } 227 }
228 #endif // defined(WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT) 228 #endif // defined(WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT)
229 } 229 }
230 230
231 // Creates a PepperPluginInfo for the specified plugin. 231 // Creates a PepperPluginInfo for the specified plugin.
232 // |path| is the full path to the plugin. 232 // |path| is the full path to the plugin.
233 // |version| is a string representation of the plugin version. 233 // |version| is a string representation of the plugin version.
234 // |is_debug| is whether the plugin is the debug version or not.
235 // |is_external| is whether the plugin is supplied external to Chrome e.g. a 234 // |is_external| is whether the plugin is supplied external to Chrome e.g. a
236 // system installation of Adobe Flash. 235 // system installation of Adobe Flash.
237 // |is_bundled| distinguishes between component updated plugin and a bundled
238 // plugin.
239 content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path, 236 content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path,
240 const std::string& version, 237 const std::string& version,
241 bool is_debug, 238 bool is_external) {
242 bool is_external,
243 bool is_bundled) {
244 content::PepperPluginInfo plugin; 239 content::PepperPluginInfo plugin;
245 240
246 plugin.is_out_of_process = true; 241 plugin.is_out_of_process = true;
247 plugin.name = content::kFlashPluginName; 242 plugin.name = content::kFlashPluginName;
248 plugin.path = path; 243 plugin.path = path;
249 #if defined(OS_WIN)
250 plugin.is_on_local_drive = !base::IsOnNetworkDrive(path);
251 #endif
252 plugin.permissions = chrome::kPepperFlashPermissions; 244 plugin.permissions = chrome::kPepperFlashPermissions;
253 plugin.is_debug = is_debug;
254 plugin.is_external = is_external; 245 plugin.is_external = is_external;
255 plugin.is_bundled = is_bundled;
256 246
257 std::vector<std::string> flash_version_numbers = base::SplitString( 247 std::vector<std::string> flash_version_numbers = base::SplitString(
258 version, ".", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); 248 version, ".", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
259 if (flash_version_numbers.size() < 1) 249 if (flash_version_numbers.size() < 1)
260 flash_version_numbers.push_back("11"); 250 flash_version_numbers.push_back("11");
261 if (flash_version_numbers.size() < 2) 251 if (flash_version_numbers.size() < 2)
262 flash_version_numbers.push_back("2"); 252 flash_version_numbers.push_back("2");
263 if (flash_version_numbers.size() < 3) 253 if (flash_version_numbers.size() < 3)
264 flash_version_numbers.push_back("999"); 254 flash_version_numbers.push_back("999");
265 if (flash_version_numbers.size() < 4) 255 if (flash_version_numbers.size() < 4)
(...skipping 20 matching lines...) Expand all
286 switches::kPpapiFlashPath); 276 switches::kPpapiFlashPath);
287 if (flash_path.empty()) 277 if (flash_path.empty())
288 return false; 278 return false;
289 279
290 // Also get the version from the command-line. Should be something like 11.2 280 // Also get the version from the command-line. Should be something like 11.2
291 // or 11.2.123.45. 281 // or 11.2.123.45.
292 std::string flash_version = 282 std::string flash_version =
293 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 283 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
294 switches::kPpapiFlashVersion); 284 switches::kPpapiFlashVersion);
295 285
296 *plugin = CreatePepperFlashInfo(base::FilePath(flash_path), 286 *plugin = CreatePepperFlashInfo(base::FilePath(flash_path), flash_version,
297 flash_version, false, true, false); 287 true);
298 return true; 288 return true;
299 } 289 }
300 290
301 #if defined(OS_LINUX) 291 #if defined(OS_LINUX)
302 // This method is used on Linux only because of architectural differences in how 292 // This method is used on Linux only because of architectural differences in how
303 // it loads the component updated flash plugin, and not because the other 293 // it loads the component updated flash plugin, and not because the other
304 // platforms do not support component updated flash. On other platforms, the 294 // platforms do not support component updated flash. On other platforms, the
305 // component updater sends an IPC message to all threads, at undefined points in 295 // component updater sends an IPC message to all threads, at undefined points in
306 // time, with the URL of the component updated flash. Because the linux zygote 296 // time, with the URL of the component updated flash. Because the linux zygote
307 // thread has no access to the file system after it warms up, it must preload 297 // thread has no access to the file system after it warms up, it must preload
308 // the component updated flash. 298 // the component updated flash.
309 bool GetComponentUpdatedPepperFlash(content::PepperPluginInfo* plugin) { 299 bool GetComponentUpdatedPepperFlash(content::PepperPluginInfo* plugin) {
310 #if defined(FLAPPER_AVAILABLE) 300 #if defined(FLAPPER_AVAILABLE)
311 if (component_flash_hint_file::DoesHintFileExist()) { 301 if (component_flash_hint_file::DoesHintFileExist()) {
312 base::FilePath flash_path; 302 base::FilePath flash_path;
313 std::string version; 303 std::string version;
314 if (component_flash_hint_file::VerifyAndReturnFlashLocation(&flash_path, 304 if (component_flash_hint_file::VerifyAndReturnFlashLocation(&flash_path,
315 &version)) { 305 &version)) {
316 // Test if the file can be mapped as executable. If the user's home 306 // Test if the file can be mapped as executable. If the user's home
317 // directory is mounted noexec, the component flash plugin will not load. 307 // directory is mounted noexec, the component flash plugin will not load.
318 // By testing for this, Chrome can fallback to the bundled flash plugin. 308 // By testing for this, Chrome can fallback to the bundled flash plugin.
319 if (!component_flash_hint_file::TestExecutableMapping(flash_path)) { 309 if (!component_flash_hint_file::TestExecutableMapping(flash_path)) {
320 LOG(WARNING) << "The component updated flash plugin could not be " 310 LOG(WARNING) << "The component updated flash plugin could not be "
321 "mapped as executable. Attempting to fallback to the " 311 "mapped as executable. Attempting to fallback to the "
322 "bundled or system plugin."; 312 "bundled or system plugin.";
323 return false; 313 return false;
324 } 314 }
325 *plugin = CreatePepperFlashInfo(flash_path, version, false, false, false); 315 *plugin = CreatePepperFlashInfo(flash_path, version, false);
326 return true; 316 return true;
327 } 317 }
328 LOG(ERROR) 318 LOG(ERROR)
329 << "Failed to locate and load the component updated flash plugin."; 319 << "Failed to locate and load the component updated flash plugin.";
330 } 320 }
331 #endif // defined(FLAPPER_AVAILABLE) 321 #endif // defined(FLAPPER_AVAILABLE)
332 return false; 322 return false;
333 } 323 }
334 #endif // defined(OS_LINUX) 324 #endif // defined(OS_LINUX)
335 325
(...skipping 23 matching lines...) Expand all
359 if (!manifest_value.get()) 349 if (!manifest_value.get())
360 return false; 350 return false;
361 base::DictionaryValue* manifest = NULL; 351 base::DictionaryValue* manifest = NULL;
362 if (!manifest_value->GetAsDictionary(&manifest)) 352 if (!manifest_value->GetAsDictionary(&manifest))
363 return false; 353 return false;
364 354
365 base::Version version; 355 base::Version version;
366 if (!chrome::CheckPepperFlashManifest(*manifest, &version)) 356 if (!chrome::CheckPepperFlashManifest(*manifest, &version))
367 return false; 357 return false;
368 358
369 *plugin = CreatePepperFlashInfo(flash_filename, 359 *plugin = CreatePepperFlashInfo(flash_filename, version.GetString(), true);
370 version.GetString(),
371 chrome::IsSystemFlashScriptDebuggerPresent(),
372 true,
373 false);
374 return true; 360 return true;
375 } 361 }
376 #endif // defined(ENABLE_PLUGINS) 362 #endif // defined(ENABLE_PLUGINS)
377 363
378 std::string GetProduct() { 364 std::string GetProduct() {
379 return version_info::GetProductNameAndVersionForUserAgent(); 365 return version_info::GetProductNameAndVersionForUserAgent();
380 } 366 }
381 367
382 } // namespace 368 } // namespace
383 369
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 #endif 438 #endif
453 } 439 }
454 440
455 #if defined(ENABLE_PLUGINS) 441 #if defined(ENABLE_PLUGINS)
456 // static 442 // static
457 content::PepperPluginInfo* ChromeContentClient::FindMostRecentPlugin( 443 content::PepperPluginInfo* ChromeContentClient::FindMostRecentPlugin(
458 const std::vector<content::PepperPluginInfo*>& plugins) { 444 const std::vector<content::PepperPluginInfo*>& plugins) {
459 if (plugins.empty()) 445 if (plugins.empty())
460 return nullptr; 446 return nullptr;
461 447
462 using PluginSortKey = std::tuple<base::Version, bool, bool, bool, bool>; 448 using PluginSortKey = std::tuple<base::Version, bool>;
463 449
464 std::map<PluginSortKey, content::PepperPluginInfo*> plugin_map; 450 std::map<PluginSortKey, content::PepperPluginInfo*> plugin_map;
465 451
466 for (auto* plugin : plugins) { 452 for (auto* plugin : plugins) {
467 base::Version version(plugin->version); 453 base::Version version(plugin->version);
468 DCHECK(version.IsValid()); 454 DCHECK(version.IsValid());
469 plugin_map[PluginSortKey(version, plugin->is_debug, 455 plugin_map[PluginSortKey(version, plugin->is_external)] = plugin;
470 plugin->is_bundled, plugin->is_on_local_drive,
471 !plugin->is_external)] = plugin;
472 } 456 }
473 457
474 return plugin_map.rbegin()->second; 458 return plugin_map.rbegin()->second;
475 } 459 }
476 #endif // defined(ENABLE_PLUGINS) 460 #endif // defined(ENABLE_PLUGINS)
477 461
478 void ChromeContentClient::AddPepperPlugins( 462 void ChromeContentClient::AddPepperPlugins(
479 std::vector<content::PepperPluginInfo>* plugins) { 463 std::vector<content::PepperPluginInfo>* plugins) {
480 #if defined(ENABLE_PLUGINS) 464 #if defined(ENABLE_PLUGINS)
481 ComputeBuiltInPlugins(plugins); 465 ComputeBuiltInPlugins(plugins);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 plugins->push_back(*max_flash); 499 plugins->push_back(*max_flash);
516 } else { 500 } else {
517 #if defined(GOOGLE_CHROME_BUILD) && defined(FLAPPER_AVAILABLE) 501 #if defined(GOOGLE_CHROME_BUILD) && defined(FLAPPER_AVAILABLE)
518 // Add a fake Flash plugin even though it doesn't actually exist - if a 502 // Add a fake Flash plugin even though it doesn't actually exist - if a
519 // web page requests it, it will be component-updated on-demand. There is 503 // web page requests it, it will be component-updated on-demand. There is
520 // nothing that guarantees the component update will give us the 504 // nothing that guarantees the component update will give us the
521 // FLAPPER_VERSION_STRING version of Flash, but using this version seems 505 // FLAPPER_VERSION_STRING version of Flash, but using this version seems
522 // better than any other hardcoded alternative. 506 // better than any other hardcoded alternative.
523 plugins->push_back(CreatePepperFlashInfo( 507 plugins->push_back(CreatePepperFlashInfo(
524 base::FilePath::FromUTF8Unsafe(ChromeContentClient::kNotPresent), 508 base::FilePath::FromUTF8Unsafe(ChromeContentClient::kNotPresent),
525 FLAPPER_VERSION_STRING, false, false, true)); 509 FLAPPER_VERSION_STRING, false));
526 #endif // defined(GOOGLE_CHROME_BUILD) && defined(FLAPPER_AVAILABLE) 510 #endif // defined(GOOGLE_CHROME_BUILD) && defined(FLAPPER_AVAILABLE)
527 } 511 }
528 #endif // defined(ENABLE_PLUGINS) 512 #endif // defined(ENABLE_PLUGINS)
529 } 513 }
530 514
531 void ChromeContentClient::AddContentDecryptionModules( 515 void ChromeContentClient::AddContentDecryptionModules(
532 std::vector<content::CdmInfo>* cdms) { 516 std::vector<content::CdmInfo>* cdms) {
533 // TODO(jrummell): Need to have a better flag to indicate systems Widevine 517 // TODO(jrummell): Need to have a better flag to indicate systems Widevine
534 // is available on. For now we continue to use ENABLE_PEPPER_CDMS so that 518 // is available on. For now we continue to use ENABLE_PEPPER_CDMS so that
535 // we can experiment between pepper and mojo. 519 // we can experiment between pepper and mojo.
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 if (!origin_trial_policy_) 667 if (!origin_trial_policy_)
684 origin_trial_policy_ = base::MakeUnique<ChromeOriginTrialPolicy>(); 668 origin_trial_policy_ = base::MakeUnique<ChromeOriginTrialPolicy>();
685 return origin_trial_policy_.get(); 669 return origin_trial_policy_.get();
686 } 670 }
687 671
688 #if defined(OS_ANDROID) 672 #if defined(OS_ANDROID)
689 media::MediaClientAndroid* ChromeContentClient::GetMediaClientAndroid() { 673 media::MediaClientAndroid* ChromeContentClient::GetMediaClientAndroid() {
690 return new ChromeMediaClientAndroid(); 674 return new ChromeMediaClientAndroid();
691 } 675 }
692 #endif // OS_ANDROID 676 #endif // OS_ANDROID
OLDNEW
« no previous file with comments | « chrome/browser/component_updater/pepper_flash_component_installer.cc ('k') | chrome/common/chrome_content_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698