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

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

Issue 893823002: Register system Pepper Flash plugin if no packaged Pepper plugin is found. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments. read location of pepperflash from registry. Created 5 years, 10 months 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
« no previous file with comments | « chrome/common/DEPS ('k') | chrome/common/chrome_paths.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/debug/crash_logging.h" 8 #include "base/debug/crash_logging.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/json/json_reader.h"
10 #include "base/path_service.h" 11 #include "base/path_service.h"
11 #include "base/strings/string16.h" 12 #include "base/strings/string16.h"
12 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/string_split.h" 14 #include "base/strings/string_split.h"
14 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
15 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
16 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
17 #include "build/build_config.h" 18 #include "build/build_config.h"
18 #include "chrome/common/child_process_logging.h" 19 #include "chrome/common/child_process_logging.h"
20 #include "chrome/common/chrome_constants.h"
19 #include "chrome/common/chrome_paths.h" 21 #include "chrome/common/chrome_paths.h"
20 #include "chrome/common/chrome_switches.h" 22 #include "chrome/common/chrome_switches.h"
21 #include "chrome/common/chrome_version_info.h" 23 #include "chrome/common/chrome_version_info.h"
22 #include "chrome/common/crash_keys.h" 24 #include "chrome/common/crash_keys.h"
25 #include "chrome/common/pepper_flash.h"
23 #include "chrome/common/render_messages.h" 26 #include "chrome/common/render_messages.h"
24 #include "chrome/common/url_constants.h" 27 #include "chrome/common/url_constants.h"
25 #include "chrome/grit/common_resources.h" 28 #include "chrome/grit/common_resources.h"
26 #include "components/dom_distiller/core/url_constants.h" 29 #include "components/dom_distiller/core/url_constants.h"
27 #include "content/public/common/content_constants.h" 30 #include "content/public/common/content_constants.h"
28 #include "content/public/common/content_switches.h" 31 #include "content/public/common/content_switches.h"
29 #include "content/public/common/url_constants.h" 32 #include "content/public/common/url_constants.h"
30 #include "content/public/common/user_agent.h" 33 #include "content/public/common/user_agent.h"
31 #include "extensions/common/constants.h" 34 #include "extensions/common/constants.h"
32 #include "gpu/config/gpu_info.h" 35 #include "gpu/config/gpu_info.h"
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 #endif 310 #endif
308 } 311 }
309 312
310 content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path, 313 content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path,
311 const std::string& version) { 314 const std::string& version) {
312 content::PepperPluginInfo plugin; 315 content::PepperPluginInfo plugin;
313 316
314 plugin.is_out_of_process = true; 317 plugin.is_out_of_process = true;
315 plugin.name = content::kFlashPluginName; 318 plugin.name = content::kFlashPluginName;
316 plugin.path = path; 319 plugin.path = path;
317 plugin.permissions = kPepperFlashPermissions; 320 plugin.permissions = chrome::kPepperFlashPermissions;
318 321
319 std::vector<std::string> flash_version_numbers; 322 std::vector<std::string> flash_version_numbers;
320 base::SplitString(version, '.', &flash_version_numbers); 323 base::SplitString(version, '.', &flash_version_numbers);
321 if (flash_version_numbers.size() < 1) 324 if (flash_version_numbers.size() < 1)
322 flash_version_numbers.push_back("11"); 325 flash_version_numbers.push_back("11");
323 // |SplitString()| puts in an empty string given an empty string. :( 326 // |SplitString()| puts in an empty string given an empty string. :(
324 else if (flash_version_numbers[0].empty()) 327 else if (flash_version_numbers[0].empty())
325 flash_version_numbers[0] = "11"; 328 flash_version_numbers[0] = "11";
326 if (flash_version_numbers.size() < 2) 329 if (flash_version_numbers.size() < 2)
327 flash_version_numbers.push_back("2"); 330 flash_version_numbers.push_back("2");
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 base::FilePath flash_path; 383 base::FilePath flash_path;
381 if (!PathService::Get(chrome::FILE_PEPPER_FLASH_PLUGIN, &flash_path)) 384 if (!PathService::Get(chrome::FILE_PEPPER_FLASH_PLUGIN, &flash_path))
382 return false; 385 return false;
383 386
384 *plugin = CreatePepperFlashInfo(flash_path, FLAPPER_VERSION_STRING); 387 *plugin = CreatePepperFlashInfo(flash_path, FLAPPER_VERSION_STRING);
385 return true; 388 return true;
386 #else 389 #else
387 return false; 390 return false;
388 #endif // FLAPPER_AVAILABLE 391 #endif // FLAPPER_AVAILABLE
389 } 392 }
390 #endif // defined(ENABLE_PLUGINS) 393
394 #if defined(OS_WIN)
395 const char kPepperFlashDLLBaseName[] =
396 #if defined(ARCH_CPU_X86)
397 "pepflashplayer32_";
398 #elif defined(ARCH_CPU_X86_64)
399 "pepflashplayer64_";
400 #else
401 #error Unsupported Windows CPU architecture.
402 #endif // defined(ARCH_CPU_X86)
403 #endif // defined(OS_WIN)
404
405 bool GetSystemPepperFlash(content::PepperPluginInfo* plugin) {
406 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
407 #if defined(FLAPPER_AVAILABLE)
408 // If flapper is available, only try system plugin if
409 // --disable-bundled-ppapi-flash is specified.
410 if (!command_line->HasSwitch(switches::kDisableBundledPpapiFlash))
411 return false;
412 #endif // defined(FLAPPER_AVAILABLE)
413
414 // Do not try and find System Pepper Flash if there is a specific path on
415 // the commmand-line.
416 if (command_line->HasSwitch(switches::kPpapiFlashPath))
417 return false;
418
419 base::FilePath flash_path;
420 if (!PathService::Get(chrome::DIR_PEPPER_FLASH_SYSTEM_PLUGIN, &flash_path))
421 return false;
422
423 if (!base::PathExists(flash_path))
424 return false;
425
426 base::FilePath manifest_path(flash_path.AppendASCII("manifest.json"));
427
428 std::string manifest_data;
429 if (!base::ReadFileToString(manifest_path, &manifest_data))
430 return false;
431 scoped_ptr<base::Value> manifest_value(
432 base::JSONReader::Read(manifest_data, base::JSON_ALLOW_TRAILING_COMMAS));
433 if (!manifest_value.get())
434 return false;
435 base::DictionaryValue* manifest = NULL;
436 if (!manifest_value->GetAsDictionary(&manifest))
437 return false;
438
439 Version version;
440 if (!chrome::CheckPepperFlashManifest(*manifest, &version))
441 return false;
442
443 #if defined(OS_WIN)
444 // PepperFlash DLLs on Windows look like basename_v_x_y_z.dll.
445 std::string filename(kPepperFlashDLLBaseName);
446 filename.append(version.GetString());
447 base::ReplaceChars(filename, ".", "_", &filename);
448 filename.append(".dll");
449
450 base::FilePath path(flash_path.Append(base::ASCIIToUTF16(filename)));
451 #else
452 // PepperFlash on OS X is called PepperFlashPlayer.plugin
453 base::FilePath path(flash_path.Append(chrome::kPepperFlashPluginFilename));
454 #endif
455
456 if (!base::PathExists(path))
457 return false;
458
459 *plugin = CreatePepperFlashInfo(path, version.GetString());
460 return true;
461 }
462 #endif // defined(ENABLE_PLUGINS)
391 463
392 std::string GetProduct() { 464 std::string GetProduct() {
393 chrome::VersionInfo version_info; 465 chrome::VersionInfo version_info;
394 return version_info.ProductNameAndVersionForUserAgent(); 466 return version_info.ProductNameAndVersionForUserAgent();
395 } 467 }
396 468
397 } // namespace 469 } // namespace
398 470
399 std::string GetUserAgent() { 471 std::string GetUserAgent() {
400 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 472 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 548
477 void ChromeContentClient::AddPepperPlugins( 549 void ChromeContentClient::AddPepperPlugins(
478 std::vector<content::PepperPluginInfo>* plugins) { 550 std::vector<content::PepperPluginInfo>* plugins) {
479 #if defined(ENABLE_PLUGINS) 551 #if defined(ENABLE_PLUGINS)
480 ComputeBuiltInPlugins(plugins); 552 ComputeBuiltInPlugins(plugins);
481 AddPepperFlashFromCommandLine(plugins); 553 AddPepperFlashFromCommandLine(plugins);
482 554
483 content::PepperPluginInfo plugin; 555 content::PepperPluginInfo plugin;
484 if (GetBundledPepperFlash(&plugin)) 556 if (GetBundledPepperFlash(&plugin))
485 plugins->push_back(plugin); 557 plugins->push_back(plugin);
558 if (GetSystemPepperFlash(&plugin))
559 plugins->push_back(plugin);
486 #endif 560 #endif
487 } 561 }
488 562
489 void ChromeContentClient::AddAdditionalSchemes( 563 void ChromeContentClient::AddAdditionalSchemes(
490 std::vector<std::string>* standard_schemes, 564 std::vector<std::string>* standard_schemes,
491 std::vector<std::string>* savable_schemes) { 565 std::vector<std::string>* savable_schemes) {
492 standard_schemes->push_back(extensions::kExtensionScheme); 566 standard_schemes->push_back(extensions::kExtensionScheme);
493 savable_schemes->push_back(extensions::kExtensionScheme); 567 savable_schemes->push_back(extensions::kExtensionScheme);
494 standard_schemes->push_back(chrome::kChromeNativeScheme); 568 standard_schemes->push_back(chrome::kChromeNativeScheme);
495 standard_schemes->push_back(extensions::kExtensionResourceScheme); 569 standard_schemes->push_back(extensions::kExtensionResourceScheme);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 int sandbox_type, 624 int sandbox_type,
551 int* sandbox_profile_resource_id) const { 625 int* sandbox_profile_resource_id) const {
552 DCHECK(sandbox_profile_resource_id); 626 DCHECK(sandbox_profile_resource_id);
553 if (sandbox_type == NACL_SANDBOX_TYPE_NACL_LOADER) { 627 if (sandbox_type == NACL_SANDBOX_TYPE_NACL_LOADER) {
554 *sandbox_profile_resource_id = IDR_NACL_SANDBOX_PROFILE; 628 *sandbox_profile_resource_id = IDR_NACL_SANDBOX_PROFILE;
555 return true; 629 return true;
556 } 630 }
557 return false; 631 return false;
558 } 632 }
559 #endif 633 #endif
OLDNEW
« no previous file with comments | « chrome/common/DEPS ('k') | chrome/common/chrome_paths.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698