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

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

Issue 11049004: Remove Legacy NPAPI Flash Sandbox support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « chrome/common/chrome_content_client.h ('k') | content/browser/plugin_process_host.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/cpu.h" 8 #include "base/cpu.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 switches::kEnableBundledPpapiFlash); 303 switches::kEnableBundledPpapiFlash);
304 304
305 *plugin = CreatePepperFlashInfo(flash_path, FLAPPER_VERSION_STRING); 305 *plugin = CreatePepperFlashInfo(flash_path, FLAPPER_VERSION_STRING);
306 *override_npapi_flash = force_enable || IsPepperFlashEnabledByDefault(); 306 *override_npapi_flash = force_enable || IsPepperFlashEnabledByDefault();
307 return true; 307 return true;
308 #else 308 #else
309 return false; 309 return false;
310 #endif // FLAPPER_AVAILABLE 310 #endif // FLAPPER_AVAILABLE
311 } 311 }
312 312
313 #if defined(OS_WIN)
314 // Launches the privileged flash broker, used when flash is sandboxed.
315 // The broker is the same flash dll, except that it uses a different
316 // entrypoint (BrokerMain) and it is hosted in windows' generic surrogate
317 // process rundll32. After launching the broker we need to pass to
318 // the flash plugin the process id of the broker via the command line
319 // using --flash-broker=pid.
320 // More info about rundll32 at http://support.microsoft.com/kb/164787.
321 bool LoadFlashBroker(const FilePath& plugin_path, CommandLine* cmd_line) {
322 FilePath rundll;
323 if (!PathService::Get(base::DIR_SYSTEM, &rundll))
324 return false;
325 rundll = rundll.AppendASCII("rundll32.exe");
326 // Rundll32 cannot handle paths with spaces, so we use the short path.
327 wchar_t short_path[MAX_PATH];
328 if (0 == ::GetShortPathNameW(plugin_path.value().c_str(),
329 short_path, arraysize(short_path)))
330 return false;
331 // Here is the kicker, if the user has disabled 8.3 (short path) support
332 // on the volume GetShortPathNameW does not fail but simply returns the
333 // input path. In this case if the path had any spaces then rundll32 will
334 // incorrectly interpret its parameters. So we quote the path, even though
335 // the kb/164787 says you should not.
336 std::wstring cmd_final =
337 base::StringPrintf(L"%ls \"%ls\",BrokerMain browser=chrome",
338 rundll.value().c_str(),
339 short_path);
340 base::ProcessHandle process;
341 base::LaunchOptions options;
342 options.start_hidden = true;
343 if (!base::LaunchProcess(cmd_final, options, &process))
344 return false;
345
346 cmd_line->AppendSwitchASCII("flash-broker",
347 base::Int64ToString(::GetProcessId(process)));
348
349 // The flash broker, unders some circumstances can linger beyond the lifetime
350 // of the flash player, so we put it in a job object, when the browser
351 // terminates the job object is destroyed (by the OS) and the flash broker
352 // is terminated.
353 HANDLE job = ::CreateJobObjectW(NULL, NULL);
354 if (base::SetJobObjectAsKillOnJobClose(job)) {
355 ::AssignProcessToJobObject(job, process);
356 // Yes, we are leaking the object here. Read comment above.
357 } else {
358 ::CloseHandle(job);
359 return false;
360 }
361
362 ::CloseHandle(process);
363 return true;
364 }
365 #endif // OS_WIN
366
367 } // namespace 313 } // namespace
368 314
369 namespace chrome { 315 namespace chrome {
370 316
371 const char* const ChromeContentClient::kPDFPluginName = ::kPDFPluginName; 317 const char* const ChromeContentClient::kPDFPluginName = ::kPDFPluginName;
372 const char* const ChromeContentClient::kNaClPluginName = ::kNaClPluginName; 318 const char* const ChromeContentClient::kNaClPluginName = ::kNaClPluginName;
373 const char* const ChromeContentClient::kNaClOldPluginName = 319 const char* const ChromeContentClient::kNaClOldPluginName =
374 ::kNaClOldPluginName; 320 ::kNaClOldPluginName;
375 321
376 void ChromeContentClient::SetActiveURL(const GURL& url) { 322 void ChromeContentClient::SetActiveURL(const GURL& url) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 int resource_id, 403 int resource_id,
458 ui::ScaleFactor scale_factor) const { 404 ui::ScaleFactor scale_factor) const {
459 return ResourceBundle::GetSharedInstance().GetRawDataResource( 405 return ResourceBundle::GetSharedInstance().GetRawDataResource(
460 resource_id, scale_factor); 406 resource_id, scale_factor);
461 } 407 }
462 408
463 gfx::Image& ChromeContentClient::GetNativeImageNamed(int resource_id) const { 409 gfx::Image& ChromeContentClient::GetNativeImageNamed(int resource_id) const {
464 return ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id); 410 return ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id);
465 } 411 }
466 412
467 #if defined(OS_WIN)
468 bool ChromeContentClient::SandboxPlugin(CommandLine* command_line,
469 sandbox::TargetPolicy* policy) {
470 std::wstring plugin_dll = command_line->
471 GetSwitchValueNative(switches::kPluginPath);
472
473 FilePath builtin_flash;
474 if (!PathService::Get(chrome::FILE_FLASH_PLUGIN_EXISTING, &builtin_flash))
475 return false;
476
477 FilePath plugin_path(plugin_dll);
478 if (plugin_path.BaseName() != builtin_flash.BaseName())
479 return false;
480
481 if (base::win::GetVersion() <= base::win::VERSION_XP ||
482 CommandLine::ForCurrentProcess()->HasSwitch(
483 switches::kDisableFlashSandbox)) {
484 return false;
485 }
486
487 // Add policy for the plugin proxy window pump event
488 // used by WebPluginDelegateProxy::HandleInputEvent().
489 if (policy->AddRule(sandbox::TargetPolicy::SUBSYS_HANDLES,
490 sandbox::TargetPolicy::HANDLES_DUP_ANY,
491 L"Event") != sandbox::SBOX_ALL_OK) {
492 NOTREACHED();
493 return false;
494 }
495
496 // Add the policy for the pipes.
497 if (policy->AddRule(sandbox::TargetPolicy::SUBSYS_NAMED_PIPES,
498 sandbox::TargetPolicy::NAMEDPIPES_ALLOW_ANY,
499 L"\\\\.\\pipe\\chrome.*") != sandbox::SBOX_ALL_OK) {
500 NOTREACHED();
501 return false;
502 }
503
504 // Spawn the flash broker and apply sandbox policy.
505 if (LoadFlashBroker(plugin_path, command_line)) {
506 // UI job restrictions break windowless Flash, so just pick up single
507 // process limit for now.
508 policy->SetJobLevel(sandbox::JOB_UNPROTECTED, 0);
509 policy->SetTokenLevel(sandbox::USER_RESTRICTED_SAME_ACCESS,
510 sandbox::USER_INTERACTIVE);
511 // Allow the Flash plugin to forward some messages back to Chrome.
512 if (base::win::GetVersion() == base::win::VERSION_VISTA) {
513 // Per-window message filters required on Win7 or later must be added to:
514 // render_widget_host_view_win.cc RenderWidgetHostViewWin::ReparentWindow
515 ::ChangeWindowMessageFilter(WM_MOUSEWHEEL, MSGFLT_ADD);
516 ::ChangeWindowMessageFilter(WM_APPCOMMAND, MSGFLT_ADD);
517 }
518 policy->SetIntegrityLevel(sandbox::INTEGRITY_LEVEL_LOW);
519 } else {
520 // Could not start the broker, use a very weak policy instead.
521 DLOG(WARNING) << "Failed to start flash broker";
522 policy->SetJobLevel(sandbox::JOB_UNPROTECTED, 0);
523 policy->SetTokenLevel(
524 sandbox::USER_UNPROTECTED, sandbox::USER_UNPROTECTED);
525 }
526
527 return true;
528 }
529 #endif
530
531 #if defined(OS_MACOSX) && !defined(OS_IOS) 413 #if defined(OS_MACOSX) && !defined(OS_IOS)
532 bool ChromeContentClient::GetSandboxProfileForSandboxType( 414 bool ChromeContentClient::GetSandboxProfileForSandboxType(
533 int sandbox_type, 415 int sandbox_type,
534 int* sandbox_profile_resource_id) const { 416 int* sandbox_profile_resource_id) const {
535 DCHECK(sandbox_profile_resource_id); 417 DCHECK(sandbox_profile_resource_id);
536 if (sandbox_type == CHROME_SANDBOX_TYPE_NACL_LOADER) { 418 if (sandbox_type == CHROME_SANDBOX_TYPE_NACL_LOADER) {
537 *sandbox_profile_resource_id = IDR_NACL_SANDBOX_PROFILE; 419 *sandbox_profile_resource_id = IDR_NACL_SANDBOX_PROFILE;
538 return true; 420 return true;
539 } 421 }
540 return false; 422 return false;
541 } 423 }
542 424
543 std::string ChromeContentClient::GetCarbonInterposePath() const { 425 std::string ChromeContentClient::GetCarbonInterposePath() const {
544 return std::string(kInterposeLibraryPath); 426 return std::string(kInterposeLibraryPath);
545 } 427 }
546 #endif 428 #endif
547 429
548 bool ChromeContentClient::GetBundledFieldTrialPepperFlash( 430 bool ChromeContentClient::GetBundledFieldTrialPepperFlash(
549 content::PepperPluginInfo* plugin, 431 content::PepperPluginInfo* plugin,
550 bool* override_npapi_flash) { 432 bool* override_npapi_flash) {
551 if (!ConductingPepperFlashFieldTrial()) 433 if (!ConductingPepperFlashFieldTrial())
552 return false; 434 return false;
553 return GetBundledPepperFlash(plugin, override_npapi_flash); 435 return GetBundledPepperFlash(plugin, override_npapi_flash);
554 } 436 }
555 437
556 } // namespace chrome 438 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/common/chrome_content_client.h ('k') | content/browser/plugin_process_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698