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

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

Issue 2357393003: Add check for file system access to the sandbox. (Closed)
Patch Set: Fix IsSandboxed() check when loading flash player. Created 4 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
« no previous file with comments | « chrome/common/DEPS ('k') | sandbox/linux/services/credentials.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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include "gpu/config/gpu_info.h" 45 #include "gpu/config/gpu_info.h"
46 #include "net/http/http_util.h" 46 #include "net/http/http_util.h"
47 #include "ui/base/l10n/l10n_util.h" 47 #include "ui/base/l10n/l10n_util.h"
48 #include "ui/base/layout.h" 48 #include "ui/base/layout.h"
49 #include "ui/base/resource/resource_bundle.h" 49 #include "ui/base/resource/resource_bundle.h"
50 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. 50 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
51 51
52 #if defined(OS_LINUX) 52 #if defined(OS_LINUX)
53 #include <fcntl.h> 53 #include <fcntl.h>
54 #include "chrome/common/component_flash_hint_file_linux.h" 54 #include "chrome/common/component_flash_hint_file_linux.h"
55 #include "sandbox/linux/services/credentials.h"
55 #endif // defined(OS_LINUX) 56 #endif // defined(OS_LINUX)
56 57
57 #if defined(OS_WIN) 58 #if defined(OS_WIN)
58 #include "base/win/windows_version.h" 59 #include "base/win/windows_version.h"
59 #endif 60 #endif
60 61
61 #if !defined(DISABLE_NACL) 62 #if !defined(DISABLE_NACL)
62 #include "components/nacl/common/nacl_constants.h" 63 #include "components/nacl/common/nacl_constants.h"
63 #include "components/nacl/common/nacl_process_type.h" 64 #include "components/nacl/common/nacl_process_type.h"
64 #include "components/nacl/common/nacl_sandbox_type.h" 65 #include "components/nacl/common/nacl_sandbox_type.h"
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 std::string flash_version = 293 std::string flash_version =
293 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 294 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
294 switches::kPpapiFlashVersion); 295 switches::kPpapiFlashVersion);
295 296
296 plugins->push_back( 297 plugins->push_back(
297 CreatePepperFlashInfo(base::FilePath(flash_path), 298 CreatePepperFlashInfo(base::FilePath(flash_path),
298 flash_version, false, true, false)); 299 flash_version, false, true, false));
299 } 300 }
300 301
301 #if defined(OS_LINUX) 302 #if defined(OS_LINUX)
302 // This function tests if DIR_USER_DATA can be accessed, as a simple check to
303 // see if the zygote has been sandboxed at this point.
304 bool IsUserDataDirAvailable() {
305 base::FilePath user_data_dir;
306 return PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
307 }
308
309 // This method is used on Linux only because of architectural differences in how 303 // This method is used on Linux only because of architectural differences in how
310 // it loads the component updated flash plugin, and not because the other 304 // it loads the component updated flash plugin, and not because the other
311 // platforms do not support component updated flash. On other platforms, the 305 // platforms do not support component updated flash. On other platforms, the
312 // component updater sends an IPC message to all threads, at undefined points in 306 // component updater sends an IPC message to all threads, at undefined points in
313 // time, with the URL of the component updated flash. Because the linux zygote 307 // time, with the URL of the component updated flash. Because the linux zygote
314 // thread has no access to the file system after it warms up, it must preload 308 // thread has no access to the file system after it warms up, it must preload
315 // the component updated flash. 309 // the component updated flash.
316 bool GetComponentUpdatedPepperFlash(content::PepperPluginInfo* plugin) { 310 bool GetComponentUpdatedPepperFlash(content::PepperPluginInfo* plugin) {
317 #if defined(FLAPPER_AVAILABLE) 311 #if defined(FLAPPER_AVAILABLE)
318 if (component_flash_hint_file::DoesHintFileExist()) { 312 if (component_flash_hint_file::DoesHintFileExist()) {
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 std::vector<content::PepperPluginInfo>* plugins) { 480 std::vector<content::PepperPluginInfo>* plugins) {
487 #if defined(ENABLE_PLUGINS) 481 #if defined(ENABLE_PLUGINS)
488 ComputeBuiltInPlugins(plugins); 482 ComputeBuiltInPlugins(plugins);
489 AddPepperFlashFromCommandLine(plugins); 483 AddPepperFlashFromCommandLine(plugins);
490 484
491 #if defined(OS_LINUX) 485 #if defined(OS_LINUX)
492 // Depending on the sandbox configurtion, the user data directory 486 // Depending on the sandbox configurtion, the user data directory
493 // is not always available. If it is not available, do not try and load any 487 // is not always available. If it is not available, do not try and load any
494 // flash plugin. The flash player, if any, preloaded before the sandbox 488 // flash plugin. The flash player, if any, preloaded before the sandbox
495 // initialization will continue to be used. 489 // initialization will continue to be used.
496 if (!IsUserDataDirAvailable()) { 490 if (!sandbox::Credentials::HasFileSystemAccess()) {
497 return; 491 return;
498 } 492 }
499 #endif // defined(OS_LINUX) 493 #endif // defined(OS_LINUX)
500 494
501 ScopedVector<content::PepperPluginInfo> flash_versions; 495 ScopedVector<content::PepperPluginInfo> flash_versions;
502 496
503 #if defined(OS_LINUX) 497 #if defined(OS_LINUX)
504 std::unique_ptr<content::PepperPluginInfo> component_flash( 498 std::unique_ptr<content::PepperPluginInfo> component_flash(
505 new content::PepperPluginInfo); 499 new content::PepperPluginInfo);
506 if (GetComponentUpdatedPepperFlash(component_flash.get())) 500 if (GetComponentUpdatedPepperFlash(component_flash.get()))
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 if (!origin_trial_policy_) 681 if (!origin_trial_policy_)
688 origin_trial_policy_ = base::MakeUnique<ChromeOriginTrialPolicy>(); 682 origin_trial_policy_ = base::MakeUnique<ChromeOriginTrialPolicy>();
689 return origin_trial_policy_.get(); 683 return origin_trial_policy_.get();
690 } 684 }
691 685
692 #if defined(OS_ANDROID) 686 #if defined(OS_ANDROID)
693 media::MediaClientAndroid* ChromeContentClient::GetMediaClientAndroid() { 687 media::MediaClientAndroid* ChromeContentClient::GetMediaClientAndroid() {
694 return new ChromeMediaClientAndroid(); 688 return new ChromeMediaClientAndroid();
695 } 689 }
696 #endif // OS_ANDROID 690 #endif // OS_ANDROID
OLDNEW
« no previous file with comments | « chrome/common/DEPS ('k') | sandbox/linux/services/credentials.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698