diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-11 21:56:11 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-11 21:56:11 +0000 |
commit | 415c2cdea5dfa8bc87bd36a91bdb8473026f943f (patch) | |
tree | 22aefe975f1be77a1bb18cdd96aeb86fbd96e096 /chrome | |
parent | 5471bc3e9d08d1d955c96a8193ee2d9638c1591a (diff) | |
download | chromium_src-415c2cdea5dfa8bc87bd36a91bdb8473026f943f.zip chromium_src-415c2cdea5dfa8bc87bd36a91bdb8473026f943f.tar.gz chromium_src-415c2cdea5dfa8bc87bd36a91bdb8473026f943f.tar.bz2 |
Move some chrome\common code to content in preparation for moving chrome\gpu.
TBR=avi
Review URL: http://codereview.chromium.org/6686002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77868 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
62 files changed, 54 insertions, 2517 deletions
diff --git a/chrome/app/chrome_main.cc b/chrome/app/chrome_main.cc index a1113b8..4aec819 100644 --- a/chrome/app/chrome_main.cc +++ b/chrome/app/chrome_main.cc @@ -32,14 +32,14 @@ #include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_version_info.h" #include "chrome/common/logging_chrome.h" -#include "chrome/common/main_function_params.h" #include "chrome/common/profiling.h" -#include "chrome/common/sandbox_init_wrapper.h" #include "chrome/common/set_process_title.h" #include "chrome/common/url_constants.h" #include "content/browser/renderer_host/render_process_host.h" #include "content/common/content_client.h" #include "content/common/content_paths.h" +#include "content/common/main_function_params.h" +#include "content/common/sandbox_init_wrapper.h" #include "ipc/ipc_switches.h" #include "ui/base/resource/resource_bundle.h" #include "ui/base/ui_base_paths.h" diff --git a/chrome/app/dummy_main_functions.cc b/chrome/app/dummy_main_functions.cc index 77867de..bb0b5e5 100644 --- a/chrome/app/dummy_main_functions.cc +++ b/chrome/app/dummy_main_functions.cc @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/common/main_function_params.h" #include "chrome/common/result_codes.h" +#include "content/common/main_function_params.h" // Native Client binary for 64-bit Windows can run only the NaCl loader or // the sandbox broker processes. Other process types are not supported. diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc index 3f58bcc..4f14f14 100644 --- a/chrome/browser/browser_main.cc +++ b/chrome/browser/browser_main.cc @@ -82,7 +82,6 @@ #include "chrome/common/json_pref_store.h" #include "chrome/common/jstemplate_builder.h" #include "chrome/common/logging_chrome.h" -#include "chrome/common/main_function_params.h" #include "chrome/common/net/net_resource_provider.h" #include "chrome/common/pref_names.h" #include "chrome/common/profiling.h" @@ -92,6 +91,7 @@ #include "content/browser/plugin_service.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" #include "content/common/child_process.h" +#include "content/common/main_function_params.h" #include "grit/app_locale_settings.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" diff --git a/chrome/browser/browser_main_mac.mm b/chrome/browser/browser_main_mac.mm index 15ee489..79ccb46 100644 --- a/chrome/browser/browser_main_mac.mm +++ b/chrome/browser/browser_main_mac.mm @@ -22,8 +22,8 @@ #include "chrome/browser/metrics/metrics_service.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" -#include "chrome/common/main_function_params.h" #include "chrome/common/result_codes.h" +#include "content/common/main_function_params.h" #include "net/socket/client_socket_factory.h" #include "ui/base/l10n/l10n_util_mac.h" #include "ui/base/resource/resource_bundle.h" diff --git a/chrome/browser/browser_main_win.cc b/chrome/browser/browser_main_win.cc index bfc872b..06f99f0 100644 --- a/chrome/browser/browser_main_win.cc +++ b/chrome/browser/browser_main_win.cc @@ -25,12 +25,12 @@ #include "chrome/browser/ui/views/uninstall_view.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/env_vars.h" -#include "chrome/common/main_function_params.h" #include "chrome/common/result_codes.h" #include "chrome/installer/util/browser_distribution.h" #include "chrome/installer/util/helper.h" #include "chrome/installer/util/install_util.h" #include "chrome/installer/util/shell_util.h" +#include "content/common/main_function_params.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" #include "net/base/winsock_init.h" diff --git a/chrome/browser/chrome_browser_application_mac.h b/chrome/browser/chrome_browser_application_mac.h index a1ebb04..510fa5b 100644 --- a/chrome/browser/chrome_browser_application_mac.h +++ b/chrome/browser/chrome_browser_application_mac.h @@ -8,7 +8,7 @@ #ifdef __OBJC__ -#import "chrome/common/chrome_application_mac.h" +#import "content/common/chrome_application_mac.h" @interface BrowserCrApplication : CrApplication // Our implementation of |-terminate:| only attempts to terminate the diff --git a/chrome/browser/tab_contents/popup_menu_helper_mac.mm b/chrome/browser/tab_contents/popup_menu_helper_mac.mm index a1324a7..1c4e0fb 100644 --- a/chrome/browser/tab_contents/popup_menu_helper_mac.mm +++ b/chrome/browser/tab_contents/popup_menu_helper_mac.mm @@ -10,8 +10,8 @@ #include "base/scoped_nsobject.h" #include "chrome/browser/renderer_host/render_widget_host_view_mac.h" #import "chrome/browser/ui/cocoa/base_view.h" -#import "chrome/common/chrome_application_mac.h" #include "content/browser/renderer_host/render_view_host.h" +#import "content/common/chrome_application_mac.h" #include "content/common/notification_source.h" #include "webkit/glue/webmenurunner_mac.h" diff --git a/chrome/browser/tab_contents/tab_contents_view_mac.mm b/chrome/browser/tab_contents/tab_contents_view_mac.mm index 0b5c377..fd2cd1e 100644 --- a/chrome/browser/tab_contents/tab_contents_view_mac.mm +++ b/chrome/browser/tab_contents/tab_contents_view_mac.mm @@ -18,13 +18,13 @@ #import "chrome/browser/ui/cocoa/tab_contents/web_drag_source.h" #import "chrome/browser/ui/cocoa/tab_contents/web_drop_target.h" #import "chrome/browser/ui/cocoa/view_id_util.h" -#import "chrome/common/chrome_application_mac.h" #include "chrome/common/render_messages.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/renderer_host/render_view_host_factory.h" #include "content/browser/renderer_host/render_widget_host.h" #include "content/browser/tab_contents/tab_contents.h" #include "content/browser/tab_contents/tab_contents_delegate.h" +#import "content/common/chrome_application_mac.h" #include "content/common/notification_details.h" #include "content/common/notification_source.h" #include "content/common/notification_type.h" diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h index 2598c70..67a9bf4 100644 --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h @@ -17,7 +17,7 @@ #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.h" #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" #include "chrome/browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.h" -#import "chrome/common/chrome_application_mac.h" +#import "content/common/chrome_application_mac.h" #include "webkit/glue/window_open_disposition.h" @class BookmarkBarController; diff --git a/chrome/browser/ui/cocoa/cocoa_test_helper.h b/chrome/browser/ui/cocoa/cocoa_test_helper.h index d7eb150..d7e5692 100644 --- a/chrome/browser/ui/cocoa/cocoa_test_helper.h +++ b/chrome/browser/ui/cocoa/cocoa_test_helper.h @@ -11,8 +11,8 @@ #include "base/path_service.h" #import "base/mac/scoped_nsautorelease_pool.h" #import "base/scoped_nsobject.h" -#import "chrome/common/chrome_application_mac.h" #include "chrome/common/chrome_constants.h" +#import "content/common/chrome_application_mac.h" #include "testing/platform_test.h" // Background windows normally will not display things such as focus diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi index 50ba4c0..cfa8da4 100644 --- a/chrome/chrome_common.gypi +++ b/chrome/chrome_common.gypi @@ -35,8 +35,6 @@ 'common/child_process_logging_linux.cc', 'common/child_process_logging_mac.mm', 'common/child_process_logging_win.cc', - 'common/chrome_application_mac.h', - 'common/chrome_application_mac.mm', 'common/chrome_counters.cc', 'common/chrome_counters.h', 'common/chrome_version_info.cc', @@ -53,16 +51,12 @@ 'common/content_settings_helper.h', 'common/content_settings_types.h', 'common/database_messages.h', - 'common/debug_flags.cc', - 'common/debug_flags.h', 'common/devtools_messages.cc', 'common/devtools_messages.h', 'common/devtools_messages_internal.h', 'common/dom_storage_messages.cc', 'common/dom_storage_messages.h', 'common/file_utilities_messages.h', - 'common/font_descriptor_mac.h', - 'common/font_descriptor_mac.mm', 'common/font_config_ipc_linux.cc', 'common/font_config_ipc_linux.h', 'common/geoposition.cc', @@ -86,7 +80,6 @@ 'common/instant_types.h', 'common/logging_chrome.cc', 'common/logging_chrome.h', - 'common/main_function_params.h', 'common/metrics_helpers.cc', 'common/metrics_helpers.h', 'common/mime_registry_messages.h', @@ -113,12 +106,6 @@ 'common/ref_counted_util.h', 'common/result_codes.h', 'common/safebrowsing_messages.h', - 'common/sandbox_init_wrapper.h', - 'common/sandbox_init_wrapper_linux.cc', - 'common/sandbox_init_wrapper_mac.cc', - 'common/sandbox_init_wrapper_win.cc', - 'common/sandbox_mac.h', - 'common/sandbox_mac.mm', 'common/sandbox_policy.cc', 'common/sandbox_policy.h', 'common/section_util_win.cc', @@ -261,8 +248,6 @@ 'common/extensions/url_pattern.h', 'common/extensions/user_script.cc', 'common/extensions/user_script.h', - 'common/font_loader_mac.h', - 'common/font_loader_mac.mm', 'common/gears_api.h', 'common/important_file_writer.cc', 'common/important_file_writer.h', diff --git a/chrome/chrome_dll.gypi b/chrome/chrome_dll.gypi index 71bd20a..0661678d 100644 --- a/chrome/chrome_dll.gypi +++ b/chrome/chrome_dll.gypi @@ -603,9 +603,11 @@ '../content/common/content_client.cc', '../content/common/content_paths.cc', '../content/common/content_switches.cc', + '../content/common/debug_flags.cc', '../content/common/notification_details.cc', '../content/common/notification_service.cc', '../content/common/notification_source.cc', + '../content/common/sandbox_init_wrapper_win.cc', ], 'msvs_settings': { 'VCLinkerTool': { diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 8285db2..7a4bea3 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -1730,7 +1730,6 @@ 'common/extensions/update_manifest_unittest.cc', 'common/extensions/url_pattern_unittest.cc', 'common/extensions/user_script_unittest.cc', - 'common/font_descriptor_mac_unittest.mm', 'common/gpu_feature_flags_unittest.cc', 'common/guid_unittest.cc', 'common/important_file_writer_unittest.cc', @@ -1748,11 +1747,6 @@ 'common/net/url_fetcher_unittest.cc', 'common/process_watcher_unittest.cc', 'common/render_messages_unittest.cc', - 'common/sandbox_mac_diraccess_unittest.mm', - 'common/sandbox_mac_fontloading_unittest.mm', - 'common/sandbox_mac_unittest_helper.h', - 'common/sandbox_mac_unittest_helper.mm', - 'common/sandbox_mac_system_access_unittest.mm', 'common/service_process_util_unittest.cc', 'common/switch_utils_unittest.cc', 'common/thumbnail_score_unittest.cc', @@ -1839,10 +1833,16 @@ '../content/browser/tab_contents/navigation_entry_unittest.cc', '../content/browser/tab_contents/render_view_host_manager_unittest.cc', '../content/browser/webui/web_ui_unittest.cc', + '../content/common/font_descriptor_mac_unittest.mm', '../content/common/gpu_info_unittest.cc', '../content/common/notification_service_unittest.cc', '../content/common/property_bag_unittest.cc', '../content/common/resource_dispatcher_unittest.cc', + '../content/common/sandbox_mac_diraccess_unittest.mm', + '../content/common/sandbox_mac_fontloading_unittest.mm', + '../content/common/sandbox_mac_unittest_helper.h', + '../content/common/sandbox_mac_unittest_helper.mm', + '../content/common/sandbox_mac_system_access_unittest.mm', '../testing/gtest_mac_unittest.mm', '../third_party/cld/encodings/compact_lang_det/compact_lang_det_unittest_small.cc', '../webkit/fileapi/file_system_dir_url_request_job_unittest.cc', diff --git a/chrome/common/chrome_application_mac.h b/chrome/common/chrome_application_mac.h deleted file mode 100644 index 2ea557c..0000000 --- a/chrome/common/chrome_application_mac.h +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_COMMON_CHROME_APPLICATION_MAC_H_ -#define CHROME_COMMON_CHROME_APPLICATION_MAC_H_ -#pragma once - -#if defined(__OBJC__) - -#import <AppKit/AppKit.h> - -#include "base/basictypes.h" -#include "base/message_pump_mac.h" -#include "base/scoped_nsobject.h" - -// Event hooks must implement this protocol. -@protocol CrApplicationEventHookProtocol -- (void)hookForEvent:(NSEvent*)theEvent; -@end - - -@interface CrApplication : NSApplication<CrAppProtocol> { - @private - BOOL handlingSendEvent_; - // Array of objects implementing the CrApplicationEventHookProtocol - scoped_nsobject<NSMutableArray> eventHooks_; -} -- (BOOL)isHandlingSendEvent; - -// Add or remove an event hook to be called for every sendEvent: -// that the application receives. These handlers are called before -// the normal [NSApplication sendEvent:] call is made. - -// This is not a good alternative to a nested event loop. It should -// be used only when normal event logic and notification breaks down -// (e.g. when clicking outside a canBecomeKey:NO window to "switch -// context" out of it). -- (void)addEventHook:(id<CrApplicationEventHookProtocol>)hook; -- (void)removeEventHook:(id<CrApplicationEventHookProtocol>)hook; - -+ (NSApplication*)sharedApplication; -@end - -namespace chrome_application_mac { - -// Controls the state of |handlingSendEvent_| in the event loop so that it is -// reset properly. -class ScopedSendingEvent { - public: - ScopedSendingEvent(); - ~ScopedSendingEvent(); - - private: - CrApplication* app_; - BOOL handling_; - DISALLOW_COPY_AND_ASSIGN(ScopedSendingEvent); -}; - -} // namespace chrome_application_mac - -#endif // defined(__OBJC__) - -namespace chrome_application_mac { - -// To be used to instantiate CrApplication from C++ code. -void RegisterCrApp(); - -} // namespace chrome_application_mac - -#endif // CHROME_COMMON_CHROME_APPLICATION_MAC_H_ diff --git a/chrome/common/chrome_application_mac.mm b/chrome/common/chrome_application_mac.mm deleted file mode 100644 index 3c1b013..0000000 --- a/chrome/common/chrome_application_mac.mm +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#import "chrome/common/chrome_application_mac.h" - -#include "base/logging.h" - -@interface CrApplication () -- (void)setHandlingSendEvent:(BOOL)handlingSendEvent; -@end - -@implementation CrApplication -// Initialize NSApplication using the custom subclass. Check whether NSApp -// was already initialized using another class, because that would break -// some things. -+ (NSApplication*)sharedApplication { - NSApplication* app = [super sharedApplication]; - if (![NSApp isKindOfClass:self]) { - LOG(ERROR) << "NSApp should be of type " << [[self className] UTF8String] - << ", not " << [[NSApp className] UTF8String]; - DCHECK(false) << "NSApp is of wrong type"; - } - return app; -} - -- (id)init { - if ((self = [super init])) { - eventHooks_.reset([[NSMutableArray alloc] init]); - } - return self; -} - -- (BOOL)isHandlingSendEvent { - return handlingSendEvent_; -} - -- (void)setHandlingSendEvent:(BOOL)handlingSendEvent { - handlingSendEvent_ = handlingSendEvent; -} - -- (void)sendEvent:(NSEvent*)event { - chrome_application_mac::ScopedSendingEvent sendingEventScoper; - for (id<CrApplicationEventHookProtocol> handler in eventHooks_.get()) { - [handler hookForEvent:event]; - } - [super sendEvent:event]; -} - -- (void)addEventHook:(id<CrApplicationEventHookProtocol>)handler { - [eventHooks_ addObject:handler]; -} - -- (void)removeEventHook:(id<CrApplicationEventHookProtocol>)handler { - [eventHooks_ removeObject:handler]; -} - -@end - -namespace chrome_application_mac { - -ScopedSendingEvent::ScopedSendingEvent() - : app_(static_cast<CrApplication*>([CrApplication sharedApplication])), - handling_([app_ isHandlingSendEvent]) { - [app_ setHandlingSendEvent:YES]; -} - -ScopedSendingEvent::~ScopedSendingEvent() { - [app_ setHandlingSendEvent:handling_]; -} - -void RegisterCrApp() { - [CrApplication sharedApplication]; -} - -} // namespace chrome_application_mac diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index 6effd95..d45118e 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -146,12 +146,6 @@ const char kDevicePolicyCacheDir[] = "device-policy-cache-dir"; // Triggers a pletora of diagnostic modes. const char kDiagnostics[] = "diagnostics"; -// Disables client-visible 3D APIs, in particular WebGL and Pepper 3D. -// This is controlled by policy and is kept separate from the other -// enable/disable switches to avoid accidentally regressing the policy -// support for controlling access to these APIs. -const char kDisable3DAPIs[] = "disable-3d-apis"; - // Disables accelerated compositing. const char kDisableAcceleratedCompositing[] = "disable-accelerated-compositing"; @@ -224,9 +218,6 @@ const char kDisableDeviceOrientation[] = "disable-device-orientation"; // disables such behavior. const char kDisableEnforcedThrottling[] = "disable-enforced-throttling"; -// Disable experimental WebGL support. -const char kDisableExperimentalWebGL[] = "disable-webgl"; - // Disable extensions. const char kDisableExtensions[] = "disable-extensions"; @@ -594,9 +585,6 @@ const char kExperimentalSpellcheckerFeatures[] = // numbers. const char kExplicitlyAllowedPorts[] = "explicitly-allowed-ports"; -// Causes the process to run as an extension subprocess. -const char kExtensionProcess[] = "extension"; - // Frequency in seconds for Extensions auto-update. const char kExtensionsUpdateFrequency[] = "extensions-update-frequency"; @@ -698,9 +686,6 @@ const char kImportFromFile[] = "import-from-file"; // Runs plugins inside the renderer process const char kInProcessPlugins[] = "in-process-plugins"; -// Runs WebGL inside the renderer process. -const char kInProcessWebGL[] = "in-process-webgl"; - // Causes the browser to launch directly in incognito mode. const char kIncognito[] = "incognito"; @@ -758,9 +743,6 @@ const char kNaClDebugPorts[] = "nacl-debug-ports"; // (used for launching NaCl loader processes on 64-bit Windows). const char kNaClBrokerProcess[] = "nacl-broker"; -// Causes the process to run as a NativeClient loader. -const char kNaClLoaderProcess[] = "nacl-loader"; - // Causes the Native Client process to display a dialog on launch. const char kNaClStartupDialog[] = "nacl-startup-dialog"; @@ -796,9 +778,6 @@ const char kNoPings[] = "no-pings"; // other proxy server flags that are passed. const char kNoProxyServer[] = "no-proxy-server"; -// Disables the sandbox for all process types that are normally sandboxed. -const char kNoSandbox[] = "no-sandbox"; - // Disables the service process from adding itself as an autorun process. This // does not delete existing autorun registrations, it just prevents the service // from registering a new one. @@ -859,9 +838,6 @@ const char kPrint[] = "print"; // detect the installed version of Chrome on Linux. const char kProductVersion[] = "product-version"; -// Causes the process to run as a profile import subprocess. -const char kProfileImportProcess[] = "profile-import"; - // Starts the sampling based profiler for the browser process at // startup. This will only work if chrome has been built with // the gyp variable profiling=1. The output will go to the value @@ -971,9 +947,6 @@ const char kSdchFilter[] = "enable-sdch"; // from the omnibox. const char kSearchInOmniboxHint[] = "search-in-omnibox-hint"; -// Causes the process to run as a service process. -const char kServiceProcess[] = "service"; - // The LSID of the account to use for the service process. const char kServiceAccountLsid[] = "service-account-lsid"; @@ -1088,13 +1061,6 @@ const char kUserScriptsDir[] = "user-scripts-dir"; // --args". const char kUtilityCmdPrefix[] = "utility-cmd-prefix"; -// Causes the process to run as a utility subprocess. -const char kUtilityProcess[] = "utility"; - -// The utility process is sandboxed, with access to one directory. This flag -// specifies the directory that can be accessed. -const char kUtilityProcessAllowedDir[] = "utility-allowed-dir"; - // Print version information and quit. const char kVersion[] = "version"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index 43975fe..cd2e128 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -56,7 +56,6 @@ extern const char kDebugPrint[]; extern const char kDeviceManagementUrl[]; extern const char kDevicePolicyCacheDir[]; extern const char kDiagnostics[]; -extern const char kDisable3DAPIs[]; extern const char kDisableAcceleratedCompositing[]; extern const char kDisableAcceleratedLayers[]; extern const char kDisableAcceleratedVideo[]; @@ -75,7 +74,6 @@ extern const char kDisableDesktopNotifications[]; extern const char kDisableDevTools[]; extern const char kDisableDeviceOrientation[]; extern const char kDisableEnforcedThrottling[]; -extern const char kDisableExperimentalWebGL[]; extern const char kDisableExtensionsFileAccessCheck[]; extern const char kDisableExtensions[]; extern const char kDisableFlashSandbox[]; @@ -175,7 +173,6 @@ extern const char kEnableWatchdog[]; extern const char kEnableWebAudio[]; extern const char kExperimentalSpellcheckerFeatures[]; extern const char kExplicitlyAllowedPorts[]; -extern const char kExtensionProcess[]; extern const char kExtensionsUpdateFrequency[]; extern const char kFlagSwitchesBegin[]; extern const char kFlagSwitchesEnd[]; @@ -199,7 +196,6 @@ extern const char kIgnoreGpuBlacklist[]; extern const char kImport[]; extern const char kImportFromFile[]; extern const char kInProcessPlugins[]; -extern const char kInProcessWebGL[]; extern const char kIncognito[]; extern const char kInstantURL[]; extern const char kJavaScriptFlags[]; @@ -217,7 +213,6 @@ extern const char kMultiProfiles[]; extern const char kNaClDebugIP[]; extern const char kNaClDebugPorts[]; extern const char kNaClBrokerProcess[]; -extern const char kNaClLoaderProcess[]; extern const char kNaClStartupDialog[]; extern const char kNoDefaultBrowserCheck[]; extern const char kNoEvents[]; @@ -226,7 +221,6 @@ extern const char kNoFirstRun[]; extern const char kNoJsRandomness[]; extern const char kNoProxyServer[]; extern const char kNoPings[]; -extern const char kNoSandbox[]; extern const char kNoServiceAutorun[]; extern const char kNoStartupWindow[]; extern const char kNotifyCloudPrintTokenExpired[]; @@ -245,7 +239,6 @@ extern const char kPrerenderSwitchValueEnabled[]; extern const char kPrerenderSwitchValuePrefetchOnly[]; extern const char kPrint[]; extern const char kProductVersion[]; -extern const char kProfileImportProcess[]; extern const char kProfilingAtStart[]; extern const char kProfilingFile[]; extern const char kProfilingFlush[]; @@ -267,7 +260,6 @@ extern const char kSbDisableDownloadProtection[]; extern const char kSbEnableDownloadWarningUI[]; extern const char kSdchFilter[]; extern const char kSearchInOmniboxHint[]; -extern const char kServiceProcess[]; extern const char kServiceAccountLsid[]; extern const char kShowCompositedLayerBorders[]; extern const char kShowCompositedLayerTree[]; @@ -299,8 +291,6 @@ extern const char kMaxSpdyConcurrentStreams[]; extern const char kUserDataDir[]; extern const char kUserScriptsDir[]; extern const char kUtilityCmdPrefix[]; -extern const char kUtilityProcess[]; -extern const char kUtilityProcessAllowedDir[]; extern const char kVersion[]; extern const char kWinHttpProxyResolver[]; diff --git a/chrome/common/debug_flags.cc b/chrome/common/debug_flags.cc deleted file mode 100644 index 31c6c0a..0000000 --- a/chrome/common/debug_flags.cc +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/common/debug_flags.h" - -#include "base/base_switches.h" -#include "base/command_line.h" -#include "base/utf_string_conversions.h" -#include "chrome/common/chrome_switches.h" -#include "ipc/ipc_switches.h" - -bool DebugFlags::ProcessDebugFlags(CommandLine* command_line, - ChildProcessInfo::ProcessType type, - bool is_in_sandbox) { - bool should_help_child = false; - const CommandLine& current_cmd_line = *CommandLine::ForCurrentProcess(); - if (current_cmd_line.HasSwitch(switches::kDebugChildren)) { - // Look to pass-on the kDebugOnStart flag. - std::string value = current_cmd_line.GetSwitchValueASCII( - switches::kDebugChildren); - if (value.empty() || - (type == ChildProcessInfo::WORKER_PROCESS && - value == switches::kWorkerProcess) || - (type == ChildProcessInfo::RENDER_PROCESS && - value == switches::kRendererProcess) || - (type == ChildProcessInfo::PLUGIN_PROCESS && - value == switches::kPluginProcess)) { - command_line->AppendSwitch(switches::kDebugOnStart); - should_help_child = true; - } - command_line->AppendSwitchASCII(switches::kDebugChildren, value); - } else if (current_cmd_line.HasSwitch(switches::kWaitForDebuggerChildren)) { - // Look to pass-on the kWaitForDebugger flag. - std::string value = current_cmd_line.GetSwitchValueASCII( - switches::kWaitForDebuggerChildren); - if (value.empty() || - (type == ChildProcessInfo::WORKER_PROCESS && - value == switches::kWorkerProcess) || - (type == ChildProcessInfo::RENDER_PROCESS && - value == switches::kRendererProcess) || - (type == ChildProcessInfo::PLUGIN_PROCESS && - value == switches::kPluginProcess)) { - command_line->AppendSwitch(switches::kWaitForDebugger); - } - command_line->AppendSwitchASCII(switches::kWaitForDebuggerChildren, value); - } - return should_help_child; -} diff --git a/chrome/common/debug_flags.h b/chrome/common/debug_flags.h deleted file mode 100644 index 2f68aee..0000000 --- a/chrome/common/debug_flags.h +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_COMMON_DEBUG_FLAGS_H__ -#define CHROME_COMMON_DEBUG_FLAGS_H__ -#pragma once - -#include "content/common/child_process_info.h" - -class CommandLine; - -class DebugFlags { - public: - - // Updates the command line arguments with debug-related flags. If - // debug flags have been used with this process, they will be - // filtered and added to command_line as needed. is_in_sandbox must - // be true if the child process will be in a sandbox. - // - // Returns true if the caller should "help" the child process by - // calling the JIT debugger on it. It may only happen if - // is_in_sandbox is true. - static bool ProcessDebugFlags(CommandLine* command_line, - ChildProcessInfo::ProcessType type, - bool is_in_sandbox); -}; - -#endif // CHROME_COMMON_DEBUG_FLAGS_H__ diff --git a/chrome/common/font_descriptor_mac.h b/chrome/common/font_descriptor_mac.h deleted file mode 100644 index 37b963e..0000000 --- a/chrome/common/font_descriptor_mac.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_COMMON_FONT_DESCRIPTOR_MAC_H_ -#define CHROME_COMMON_FONT_DESCRIPTOR_MAC_H_ -#pragma once - -#include "base/string16.h" - -#ifdef __OBJC__ -@class NSFont; -#else -class NSFont; -#endif - -// Container to allow serializing an NSFont over IPC. -struct FontDescriptor { - explicit FontDescriptor(NSFont* font); - - FontDescriptor() : font_point_size(0) {} - - // Return an autoreleased NSFont corresponding to the font description. - NSFont* nsFont() const; - - // Name of the font. - string16 font_name; - - // Size in points. - float font_point_size; -}; - -#endif // CHROME_COMMON_FONT_DESCRIPTOR_MAC_H_ diff --git a/chrome/common/font_descriptor_mac.mm b/chrome/common/font_descriptor_mac.mm deleted file mode 100644 index 485c215..0000000 --- a/chrome/common/font_descriptor_mac.mm +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/common/font_descriptor_mac.h" - -#include <Cocoa/Cocoa.h> - -#include "base/sys_string_conversions.h" - -FontDescriptor::FontDescriptor(NSFont* font) { - font_name = base::SysNSStringToUTF16([font fontName]); - font_point_size = [font pointSize]; -} - -NSFont* FontDescriptor::nsFont() const { - NSString* font_name_ns = base::SysUTF16ToNSString(font_name); - NSFont* font = [NSFont fontWithName:font_name_ns size:font_point_size]; - return font; -} diff --git a/chrome/common/font_descriptor_mac_unittest.mm b/chrome/common/font_descriptor_mac_unittest.mm deleted file mode 100644 index 442e8e2..0000000 --- a/chrome/common/font_descriptor_mac_unittest.mm +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/common/font_descriptor_mac.h" - -#include <Cocoa/Cocoa.h> - -#include "base/logging.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "testing/platform_test.h" - -namespace { - -class FontSerializationTest : public PlatformTest {}; - - -// Compare 2 fonts, make sure they point at the same font definition and have -// the same style. Only Bold & Italic style attributes are tested since those -// are the only ones we care about at the moment. -bool CompareFonts(NSFont* font1, NSFont* font2) { - ATSFontRef id1 = CTFontGetPlatformFont(reinterpret_cast<CTFontRef>(font1), 0); - ATSFontRef id2 = CTFontGetPlatformFont(reinterpret_cast<CTFontRef>(font2), 0); - - if (id1 != id2) { - LOG(ERROR) << "ATSFontRefs for " - << [[font1 fontName] UTF8String] - << " and " - << [[font2 fontName] UTF8String] - << " are different"; - return false; - } - - CGFloat size1 = [font1 pointSize]; - CGFloat size2 = [font2 pointSize]; - if (size1 != size2) { - LOG(ERROR) << "font sizes for " - << [[font1 fontName] UTF8String] << " (" << size1 << ")" - << "and" - << [[font2 fontName] UTF8String] << " (" << size2 << ")" - << " are different"; - return false; - } - - NSFontTraitMask traits1 = [[NSFontManager sharedFontManager] - traitsOfFont:font1]; - NSFontTraitMask traits2 = [[NSFontManager sharedFontManager] - traitsOfFont:font2]; - - bool is_bold1 = traits1 & NSBoldFontMask; - bool is_bold2 = traits2 & NSBoldFontMask; - bool is_italic1 = traits1 & NSItalicFontMask; - bool is_italic2 = traits2 & NSItalicFontMask; - - if (is_bold1 != is_bold2 || is_italic1 != is_italic2) { - LOG(ERROR) << "Style information for " - << [[font1 fontName] UTF8String] - << " and " - << [[font2 fontName] UTF8String] - << " are different"; - return false; - } - - return true; -} - -// Verify that serialization and deserialization of fonts with various styles -// is performed correctly by FontDescriptor. -TEST_F(FontSerializationTest, StyledFonts) { - NSFont* plain_font = [NSFont systemFontOfSize:12.0]; - ASSERT_TRUE(plain_font != nil); - FontDescriptor desc_plain(plain_font); - EXPECT_TRUE(CompareFonts(plain_font, desc_plain.nsFont())); - - NSFont* bold_font = [NSFont boldSystemFontOfSize:30.0]; - ASSERT_TRUE(bold_font != nil); - FontDescriptor desc_bold(bold_font); - EXPECT_TRUE(CompareFonts(bold_font, desc_bold.nsFont())); - - NSFont* italic_bold_font = - [[NSFontManager sharedFontManager] - fontWithFamily:@"Courier" - traits:(NSBoldFontMask | NSItalicFontMask) - weight:5 - size:18.0]; - ASSERT_TRUE(italic_bold_font != nil); - FontDescriptor desc_italic_bold(italic_bold_font); - EXPECT_TRUE(CompareFonts(italic_bold_font, desc_italic_bold.nsFont())); -} - -} // namsepace diff --git a/chrome/common/font_loader_mac.h b/chrome/common/font_loader_mac.h deleted file mode 100644 index d25ec43..0000000 --- a/chrome/common/font_loader_mac.h +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_COMMON_FONT_LOADER_MAC_H_ -#define CHROME_COMMON_FONT_LOADER_MAC_H_ -#pragma once - -#include <ApplicationServices/ApplicationServices.h> - -#include "base/shared_memory.h" - -#ifdef __OBJC__ -@class NSFont; -#else -class NSFont; -#endif - -// Provides functionality to transmit fonts over IPC. -// -// Note about font formats: .dfont (datafork suitcase) fonts are currently not -// supported by this code since ATSFontActivateFromMemory() can't handle them -// directly. - -class FontLoader { - public: - // Load a font specified by |font_to_encode| into a shared memory buffer - // suitable for sending over IPC. - // - // On return: - // returns true on success, false on failure. - // |font_data| - shared memory buffer containing the raw data for the font - // file. - // |font_data_size| - size of data contained in |font_data|. - static bool LoadFontIntoBuffer(NSFont* font_to_encode, - base::SharedMemory* font_data, - uint32* font_data_size); - - // Given a shared memory buffer containing the raw data for a font file, load - // the font and return a container ref. - // - // |data| - A shared memory handle pointing to the raw data from a font file. - // |data_size| - Size of |data|. - // - // On return: - // returns true on success, false on failure. - // |font_container| - A font container corresponding to the designated font. - // The caller is responsible for releasing this value via ATSFontDeactivate() - // when done - static bool ATSFontContainerFromBuffer(base::SharedMemoryHandle font_data, - uint32 font_data_size, - ATSFontContainerRef* font_container); -}; - -#endif // CHROME_COMMON_FONT_LOADER_MAC_H_ diff --git a/chrome/common/font_loader_mac.mm b/chrome/common/font_loader_mac.mm deleted file mode 100644 index b910eb0..0000000 --- a/chrome/common/font_loader_mac.mm +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/common/font_loader_mac.h" - -#import <Cocoa/Cocoa.h> - -#include "base/basictypes.h" -#include "base/file_path.h" -#include "base/file_util.h" -#include "base/logging.h" -#include "base/mac/mac_util.h" -#include "base/sys_string_conversions.h" - -// static -bool FontLoader::LoadFontIntoBuffer(NSFont* font_to_encode, - base::SharedMemory* font_data, - uint32* font_data_size) { - CHECK(font_data && font_data_size); - *font_data_size = 0; - - // Used only for logging. - std::string font_name([[font_to_encode fontName] UTF8String]); - - // Load appropriate NSFont. - if (!font_to_encode) { - LOG(ERROR) << "Failed to load font " << font_name; - return false; - } - - // NSFont -> ATSFontRef. - ATSFontRef ats_font = - CTFontGetPlatformFont(reinterpret_cast<CTFontRef>(font_to_encode), NULL); - if (!ats_font) { - LOG(ERROR) << "Conversion to ATSFontRef failed for " << font_name; - return false; - } - - // ATSFontRef -> File path. - // Warning: Calling this function on a font activated from memory will result - // in failure with a -50 - paramErr. This may occur if - // CreateCGFontFromBuffer() is called in the same process as this function - // e.g. when writing a unit test that exercises these two functions together. - // If said unit test were to load a system font and activate it from memory - // it becomes impossible for the system to the find the original file ref - // since the font now lives in memory as far as it's concerned. - FSRef font_fsref; - if (ATSFontGetFileReference(ats_font, &font_fsref) != noErr) { - LOG(ERROR) << "Failed to find font file for " << font_name; - return false; - } - FilePath font_path = FilePath(base::mac::PathFromFSRef(font_fsref)); - - // Load file into shared memory buffer. - int64 font_file_size_64 = -1; - if (!file_util::GetFileSize(font_path, &font_file_size_64)) { - LOG(ERROR) << "Couldn't get font file size for " << font_path.value(); - return false; - } - - if (font_file_size_64 <= 0 || font_file_size_64 >= kint32max) { - LOG(ERROR) << "Bad size for font file " << font_path.value(); - return false; - } - - int32 font_file_size_32 = static_cast<int32>(font_file_size_64); - if (!font_data->CreateAndMapAnonymous(font_file_size_32)) { - LOG(ERROR) << "Failed to create shmem area for " << font_name; - return false; - } - - int32 amt_read = file_util::ReadFile(font_path, - reinterpret_cast<char*>(font_data->memory()), - font_file_size_32); - if (amt_read != font_file_size_32) { - LOG(ERROR) << "Failed to read font data for " << font_path.value(); - return false; - } - - *font_data_size = font_file_size_32; - return true; -} - -// static -bool FontLoader::ATSFontContainerFromBuffer(base::SharedMemoryHandle font_data, - uint32 font_data_size, - ATSFontContainerRef* font_container) -{ - CHECK(font_container); - - using base::SharedMemory; - DCHECK(SharedMemory::IsHandleValid(font_data)); - DCHECK_GT(font_data_size, 0U); - - SharedMemory shm(font_data, true); - if (!shm.Map(font_data_size)) - return false; - - // A value of 3 means the font is private and can't be seen by anyone else. - // This is the value used by WebKit when activating remote fonts. - const ATSFontContext kFontContextPrivate = 3; - OSStatus err = ATSFontActivateFromMemory(shm.memory(), font_data_size, - kFontContextPrivate, kATSFontFormatUnspecified, NULL, - kATSOptionFlagsDefault, font_container); - if (err != noErr || !font_container) - return false; - - return true; -} diff --git a/chrome/common/main_function_params.h b/chrome/common/main_function_params.h deleted file mode 100644 index e4a5fcc..0000000 --- a/chrome/common/main_function_params.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Wrapper to the parameter list for the "main" entry points (browser, renderer, -// plugin) to shield the call sites from the differences between platforms -// (e.g., POSIX doesn't need to pass any sandbox information). - -#ifndef CHROME_COMMON_MAIN_FUNCTION_PARAMS_H_ -#define CHROME_COMMON_MAIN_FUNCTION_PARAMS_H_ -#pragma once - -#include "base/command_line.h" -#include "chrome/common/sandbox_init_wrapper.h" - -namespace base { -namespace mac { -class ScopedNSAutoreleasePool; -} -} - -class Task; - -struct MainFunctionParams { - MainFunctionParams(const CommandLine& cl, const SandboxInitWrapper& sb, - base::mac::ScopedNSAutoreleasePool* pool) - : command_line_(cl), sandbox_info_(sb), autorelease_pool_(pool), - ui_task(NULL) { } - const CommandLine& command_line_; - const SandboxInitWrapper& sandbox_info_; - base::mac::ScopedNSAutoreleasePool* autorelease_pool_; - // Used by InProcessBrowserTest. If non-null BrowserMain schedules this - // task to run on the MessageLoop and BrowserInit is not invoked. - Task* ui_task; -}; - -#endif // CHROME_COMMON_MAIN_FUNCTION_PARAMS_H_ diff --git a/chrome/common/render_messages.cc b/chrome/common/render_messages.cc index 9ba1106..e7068d5 100644 --- a/chrome/common/render_messages.cc +++ b/chrome/common/render_messages.cc @@ -24,7 +24,7 @@ #include "webkit/plugins/npapi/webplugin.h" #if defined(OS_MACOSX) -#include "chrome/common/font_descriptor_mac.h" +#include "content/common/font_descriptor_mac.h" #endif #define IPC_MESSAGE_IMPL diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index 6873afe..dcbca37 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -38,7 +38,7 @@ #endif #if defined(OS_MACOSX) -#include "chrome/common/font_descriptor_mac.h" +#include "content/common/font_descriptor_mac.h" #endif // TODO(mpcomplete): rename ViewMsg and ViewHostMsg to something that makes diff --git a/chrome/common/sandbox_init_wrapper.h b/chrome/common/sandbox_init_wrapper.h deleted file mode 100644 index 3c70a7a..0000000 --- a/chrome/common/sandbox_init_wrapper.h +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_COMMON_SANDBOX_INIT_WRAPPER_H_ -#define CHROME_COMMON_SANDBOX_INIT_WRAPPER_H_ -#pragma once - -// Wraps the sandbox initialization and platform variables to consolodate -// the code and reduce the number of platform ifdefs elsewhere. The POSIX -// version of this wrapper is basically empty. - -#include "build/build_config.h" - -#include <string> - -#include "base/basictypes.h" -#if defined(OS_WIN) -#include "sandbox/src/sandbox.h" -#endif - -class CommandLine; - -#if defined(OS_WIN) - -class SandboxInitWrapper { - public: - SandboxInitWrapper() : broker_services_(), target_services_() { } - // SetServices() needs to be called before InitializeSandbox() on Win32 with - // the info received from the chrome exe main. - void SetServices(sandbox::SandboxInterfaceInfo* sandbox_info); - sandbox::BrokerServices* BrokerServices() const { return broker_services_; } - sandbox::TargetServices* TargetServices() const { return target_services_; } - - // Initialize the sandbox for renderer, gpu, utility, worker, nacl, and - // plug-in processes, depending on the command line flags. The browser - // process is not sandboxed. - // Returns true if the sandbox was initialized succesfully, false if an error - // occurred. If process_type isn't one that needs sandboxing true is always - // returned. - bool InitializeSandbox(const CommandLine& parsed_command_line, - const std::string& process_type); - private: - sandbox::BrokerServices* broker_services_; - sandbox::TargetServices* target_services_; - - DISALLOW_COPY_AND_ASSIGN(SandboxInitWrapper); -}; - -#elif defined(OS_POSIX) - -class SandboxInitWrapper { - public: - SandboxInitWrapper() { } - - // Initialize the sandbox for renderer and plug-in processes, depending on - // the command line flags. The browser process is not sandboxed. - // Returns true if the sandbox was initialized succesfully, false if an error - // occurred. If process_type isn't one that needs sandboxing true is always - // returned. - bool InitializeSandbox(const CommandLine& parsed_command_line, - const std::string& process_type); - - private: - DISALLOW_COPY_AND_ASSIGN(SandboxInitWrapper); -}; - -#endif - -#endif // CHROME_COMMON_SANDBOX_INIT_WRAPPER_H_ diff --git a/chrome/common/sandbox_init_wrapper_linux.cc b/chrome/common/sandbox_init_wrapper_linux.cc deleted file mode 100644 index ffb711d..0000000 --- a/chrome/common/sandbox_init_wrapper_linux.cc +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/common/sandbox_init_wrapper.h" - -#include "base/command_line.h" - -bool SandboxInitWrapper::InitializeSandbox(const CommandLine& command_line, - const std::string& process_type) { - // TODO(port): Does Linux need to do anything here? - return true; -} diff --git a/chrome/common/sandbox_init_wrapper_mac.cc b/chrome/common/sandbox_init_wrapper_mac.cc deleted file mode 100644 index b9cfa50..0000000 --- a/chrome/common/sandbox_init_wrapper_mac.cc +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/common/sandbox_init_wrapper.h" - -#include "base/command_line.h" -#include "base/file_path.h" -#include "base/logging.h" -#include "chrome/common/chrome_switches.h" -#include "chrome/common/sandbox_mac.h" - -bool SandboxInitWrapper::InitializeSandbox(const CommandLine& command_line, - const std::string& process_type) { - using sandbox::Sandbox; - - if (command_line.HasSwitch(switches::kNoSandbox)) - return true; - - Sandbox::SandboxProcessType sandbox_process_type; - FilePath allowed_dir; // Empty by default. - - if (process_type.empty()) { - // Browser process isn't sandboxed. - return true; - } else if (process_type == switches::kRendererProcess) { - if (!command_line.HasSwitch(switches::kDisable3DAPIs) && - !command_line.HasSwitch(switches::kDisableExperimentalWebGL) && - command_line.HasSwitch(switches::kInProcessWebGL)) { - // TODO(kbr): this check seems to be necessary only on this - // platform because the sandbox is initialized later. Remove - // this once this flag is removed. - return true; - } else { - sandbox_process_type = Sandbox::SANDBOX_TYPE_RENDERER; - } - } else if (process_type == switches::kExtensionProcess) { - // Extension processes are just renderers [they use RenderMain()] with a - // different set of command line flags. - // If we ever get here it means something has changed in regards - // to the extension process mechanics and we should probably reexamine - // how we sandbox extension processes since they are no longer identical - // to renderers. - NOTREACHED(); - return true; - } else if (process_type == switches::kUtilityProcess) { - // Utility process sandbox. - sandbox_process_type = Sandbox::SANDBOX_TYPE_UTILITY; - allowed_dir = - command_line.GetSwitchValuePath(switches::kUtilityProcessAllowedDir); - } else if (process_type == switches::kWorkerProcess) { - // Worker process sandbox. - sandbox_process_type = Sandbox::SANDBOX_TYPE_WORKER; - } else if (process_type == switches::kNaClLoaderProcess) { - // Native Client sel_ldr (user untrusted code) sandbox. - sandbox_process_type = Sandbox::SANDBOX_TYPE_NACL_LOADER; - } else if (process_type == switches::kGpuProcess) { - sandbox_process_type = Sandbox::SANDBOX_TYPE_GPU; - } else if ((process_type == switches::kPluginProcess) || - (process_type == switches::kProfileImportProcess) || - (process_type == switches::kServiceProcess)) { - return true; - } else { - // Failsafe: If you hit an unreached here, is your new process type in need - // of sandboxing? - NOTREACHED(); - return true; - } - - // Warm up APIs before turning on the sandbox. - Sandbox::SandboxWarmup(sandbox_process_type); - - // Actually sandbox the process. - return Sandbox::EnableSandbox(sandbox_process_type, allowed_dir); -} diff --git a/chrome/common/sandbox_init_wrapper_win.cc b/chrome/common/sandbox_init_wrapper_win.cc deleted file mode 100644 index ec9ef54..0000000 --- a/chrome/common/sandbox_init_wrapper_win.cc +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/common/sandbox_init_wrapper.h" - -#include "base/command_line.h" -#include "base/logging.h" - -#include "chrome/common/chrome_switches.h" - -void SandboxInitWrapper::SetServices(sandbox::SandboxInterfaceInfo* info) { - if (!info) - return; - if (info->legacy) { - // Looks like we are in the case when the new chrome.dll is being launched - // by the old chrome.exe, the old chrome exe has SandboxInterfaceInfo as a - // union, while now we have a struct. - // TODO(cpu): Remove this nasty hack after M10 release. - broker_services_ = reinterpret_cast<sandbox::BrokerServices*>(info->legacy); - target_services_ = reinterpret_cast<sandbox::TargetServices*>(info->legacy); - } else { - // Normal case, both the exe and the dll are the same version. Both - // interface pointers cannot be non-zero. A process can either be a target - // or a broker but not both. - broker_services_ = info->broker_services; - target_services_ = info->target_services; - DCHECK(!(target_services_ && broker_services_)); - } -} - -bool SandboxInitWrapper::InitializeSandbox(const CommandLine& command_line, - const std::string& process_type) { - if (command_line.HasSwitch(switches::kNoSandbox)) - return true; - if ((process_type == switches::kRendererProcess) || - (process_type == switches::kExtensionProcess) || - (process_type == switches::kWorkerProcess) || - (process_type == switches::kNaClLoaderProcess) || - (process_type == switches::kUtilityProcess)) { - // The above five process types must be sandboxed unless --no-sandbox - // is present in the command line. - if (!target_services_) - return false; - } else { - // Other process types might or might not be sandboxed. - // TODO(cpu): clean this mess. - if (!target_services_) - return true; - } - return (sandbox::SBOX_ALL_OK == target_services_->Init()); -} diff --git a/chrome/common/sandbox_mac.h b/chrome/common/sandbox_mac.h deleted file mode 100644 index e81f72e..0000000 --- a/chrome/common/sandbox_mac.h +++ /dev/null @@ -1,180 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_COMMON_SANDBOX_MAC_H_ -#define CHROME_COMMON_SANDBOX_MAC_H_ -#pragma once - -#include <string> - -#include "base/basictypes.h" -#include "base/hash_tables.h" -#include "base/gtest_prod_util.h" - -class FilePath; - -#if __OBJC__ -@class NSArray; -@class NSString; -#else -class NSArray; -class NSString; -#endif - -namespace sandbox { - -// Class representing a substring of the sandbox profile tagged with its type. -class SandboxSubstring { - public: - enum SandboxSubstringType { - PLAIN, // Just a plain string, no escaping necessary. - LITERAL, // Escape for use in (literal ...) expression. - REGEX, // Escape for use in (regex ...) expression. - }; - - SandboxSubstring() {} - - explicit SandboxSubstring(const std::string& value) - : value_(value), - type_(PLAIN) {} - - SandboxSubstring(const std::string& value, SandboxSubstringType type) - : value_(value), - type_(type) {} - - const std::string& value() { return value_; } - SandboxSubstringType type() { return type_; } - - private: - std::string value_; - SandboxSubstringType type_; -}; - -class Sandbox { - public: - // A map of variable name -> string to substitute in its place. - typedef base::hash_map<std::string, SandboxSubstring> - SandboxVariableSubstitions; - - enum SandboxProcessType { - SANDBOX_TYPE_FIRST_TYPE, // Placeholder to ease iteration. - - SANDBOX_TYPE_RENDERER = SANDBOX_TYPE_FIRST_TYPE, - - // The worker process uses the most restrictive sandbox which has almost - // *everything* locked down. Only a couple of /System/Library/ paths and - // some other very basic operations (e.g., reading metadata to allow - // following symlinks) are permitted. - SANDBOX_TYPE_WORKER, - - // Utility process is as restrictive as the worker process except full - // access is allowed to one configurable directory. - SANDBOX_TYPE_UTILITY, - - // Native Client sandbox for the user's untrusted code. - SANDBOX_TYPE_NACL_LOADER, - - // GPU process. - SANDBOX_TYPE_GPU, - - SANDBOX_AFTER_TYPE_LAST_TYPE, // Placeholder to ease iteration. - }; - - // Warm up System APIs that empirically need to be accessed before the Sandbox - // is turned on. |sandbox_type| is the type of sandbox to warm up. - static void SandboxWarmup(SandboxProcessType sandbox_type); - - // Turns on the OS X sandbox for this process. - // |sandbox_type| - type of Sandbox to use. - // |allowed_dir| - directory to allow access to, currently the only sandbox - // profile that supports this is SANDBOX_TYPE_UTILITY . - // - // Returns true on success, false if an error occurred enabling the sandbox. - static bool EnableSandbox(SandboxProcessType sandbox_type, - const FilePath& allowed_dir); - - - // Exposed for testing purposes, used by an accessory function of our tests - // so we can't use FRIEND_TEST. - - // Build the Sandbox command necessary to allow access to a named directory - // indicated by |allowed_dir|. - // Returns a string containing the sandbox profile commands necessary to allow - // access to that directory or nil if an error occured. - - // The header comment for PostProcessSandboxProfile() explains how variable - // substition works in sandbox templates. - // The returned string contains embedded variables. The function fills in - // |substitutions| to contain the values for these variables. - static NSString* BuildAllowDirectoryAccessSandboxString( - const FilePath& allowed_dir, - SandboxVariableSubstitions* substitutions); - - // Assemble the final sandbox profile from a template by removing comments - // and substituting variables. - // - // |sandbox_template| is a string which contains 2 entitites to operate on: - // - // - Comments - The sandbox comment syntax is used to make the OS sandbox - // optionally ignore commands it doesn't support. e.g. - // ;10.6_ONLY (foo) - // Where (foo) is some command that is only supported on OS X 10.6. - // The ;10.6_ONLY comment can then be removed from the template to enable - // (foo) as appropriate. - // - // - Variables - denoted by @variable_name@ . These are defined in the - // sandbox template in cases where another string needs to be substituted at - // runtime. e.g. @HOMEDIR_AS_LITERAL@ is substituted at runtime for the user's - // home directory escaped appropriately for a (literal ...) expression. - // - // |comments_to_remove| is a list of NSStrings containing the comments to - // remove. - // |substitutions| is a hash of "variable name" -> "string to substitute". - // Where the replacement string is tagged with information on how it is to be - // escaped e.g. used as part of a regex string or a literal. - // - // On output |final_sandbox_profile_str| contains the final sandbox profile. - // Returns true on success, false otherwise. - static bool PostProcessSandboxProfile( - NSString* in_sandbox_data, - NSArray* comments_to_remove, - SandboxVariableSubstitions& substitutions, - std::string *final_sandbox_profile_str); - - private: - // Escape |src_utf8| for use in a plain string variable in a sandbox - // configuraton file. On return |dst| is set to the quoted output. - // Returns: true on success, false otherwise. - static bool QuotePlainString(const std::string& src_utf8, std::string* dst); - - // Escape |str_utf8| for use in a regex literal in a sandbox - // configuraton file. On return |dst| is set to the utf-8 encoded quoted - // output. - // - // The implementation of this function is based on empirical testing of the - // OS X sandbox on 10.5.8 & 10.6.2 which is undocumented and subject to - // change. - // - // Note: If str_utf8 contains any characters < 32 || >125 then the function - // fails and false is returned. - // - // Returns: true on success, false otherwise. - static bool QuoteStringForRegex(const std::string& str_utf8, - std::string* dst); - - // Convert provided path into a "canonical" path matching what the Sandbox - // expects i.e. one without symlinks. - // This path is not necessarily unique e.g. in the face of hardlinks. - static void GetCanonicalSandboxPath(FilePath* path); - - FRIEND_TEST(MacDirAccessSandboxTest, StringEscape); - FRIEND_TEST(MacDirAccessSandboxTest, RegexEscape); - FRIEND_TEST(MacDirAccessSandboxTest, SandboxAccess); - - DISALLOW_IMPLICIT_CONSTRUCTORS(Sandbox); -}; - -} // namespace sandbox - -#endif // CHROME_COMMON_SANDBOX_MAC_H_ diff --git a/chrome/common/sandbox_mac.mm b/chrome/common/sandbox_mac.mm deleted file mode 100644 index 0ae572c..0000000 --- a/chrome/common/sandbox_mac.mm +++ /dev/null @@ -1,579 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/common/sandbox_mac.h" - -#import <Cocoa/Cocoa.h> -#import <OpenGL/OpenGL.h> - -extern "C" { -#include <sandbox.h> -} -#include <signal.h> -#include <sys/param.h> - -#include "app/gfx/gl/gl_context.h" -#include "base/basictypes.h" -#include "base/command_line.h" -#include "base/file_util.h" -#include "base/mac/mac_util.h" -#include "base/rand_util_c.h" -#include "base/mac/scoped_cftyperef.h" -#include "base/mac/scoped_nsautorelease_pool.h" -#include "base/string16.h" -#include "base/string_util.h" -#include "base/sys_info.h" -#include "base/sys_string_conversions.h" -#include "base/utf_string_conversions.h" -#include "chrome/common/chrome_application_mac.h" -#include "chrome/common/chrome_switches.h" -#include "unicode/uchar.h" - -namespace { - -// Try to escape |c| as a "SingleEscapeCharacter" (\n, etc). If successful, -// returns true and appends the escape sequence to |dst|. -bool EscapeSingleChar(char c, std::string* dst) { - const char *append = NULL; - switch (c) { - case '\b': - append = "\\b"; - break; - case '\f': - append = "\\f"; - break; - case '\n': - append = "\\n"; - break; - case '\r': - append = "\\r"; - break; - case '\t': - append = "\\t"; - break; - case '\\': - append = "\\\\"; - break; - case '"': - append = "\\\""; - break; - } - - if (!append) { - return false; - } - - dst->append(append); - return true; -} - -} // namespace - -namespace sandbox { - - -// static -bool Sandbox::QuotePlainString(const std::string& src_utf8, std::string* dst) { - dst->clear(); - - const char* src = src_utf8.c_str(); - int32_t length = src_utf8.length(); - int32_t position = 0; - while (position < length) { - UChar32 c; - U8_NEXT(src, position, length, c); // Macro increments |position|. - DCHECK_GE(c, 0); - if (c < 0) - return false; - - if (c < 128) { // EscapeSingleChar only handles ASCII. - char as_char = static_cast<char>(c); - if (EscapeSingleChar(as_char, dst)) { - continue; - } - } - - if (c < 32 || c > 126) { - // Any characters that aren't printable ASCII get the \u treatment. - unsigned int as_uint = static_cast<unsigned int>(c); - base::StringAppendF(dst, "\\u%04X", as_uint); - continue; - } - - // If we got here we know that the character in question is strictly - // in the ASCII range so there's no need to do any kind of encoding - // conversion. - dst->push_back(static_cast<char>(c)); - } - return true; -} - -// static -bool Sandbox::QuoteStringForRegex(const std::string& str_utf8, - std::string* dst) { - // Characters with special meanings in sandbox profile syntax. - const char regex_special_chars[] = { - '\\', - - // Metacharacters - '^', - '.', - '[', - ']', - '$', - '(', - ')', - '|', - - // Quantifiers - '*', - '+', - '?', - '{', - '}', - }; - - // Anchor regex at start of path. - dst->assign("^"); - - const char* src = str_utf8.c_str(); - int32_t length = str_utf8.length(); - int32_t position = 0; - while (position < length) { - UChar32 c; - U8_NEXT(src, position, length, c); // Macro increments |position|. - DCHECK_GE(c, 0); - if (c < 0) - return false; - - // The Mac sandbox regex parser only handles printable ASCII characters. - // 33 >= c <= 126 - if (c < 32 || c > 125) { - return false; - } - - for (size_t i = 0; i < arraysize(regex_special_chars); ++i) { - if (c == regex_special_chars[i]) { - dst->push_back('\\'); - break; - } - } - - dst->push_back(static_cast<char>(c)); - } - - // Make sure last element of path is interpreted as a directory. Leaving this - // off would allow access to files if they start with the same name as the - // directory. - dst->append("(/|$)"); - - return true; -} - -// Warm up System APIs that empirically need to be accessed before the Sandbox -// is turned on. -// This method is layed out in blocks, each one containing a separate function -// that needs to be warmed up. The OS version on which we found the need to -// enable the function is also noted. -// This function is tested on the following OS versions: -// 10.5.6, 10.6.0 - -// static -void Sandbox::SandboxWarmup(SandboxProcessType sandbox_type) { - base::mac::ScopedNSAutoreleasePool scoped_pool; - - { // CGColorSpaceCreateWithName(), CGBitmapContextCreate() - 10.5.6 - base::mac::ScopedCFTypeRef<CGColorSpaceRef> rgb_colorspace( - CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB)); - - // Allocate a 1x1 image. - char data[4]; - base::mac::ScopedCFTypeRef<CGContextRef> context( - CGBitmapContextCreate(data, 1, 1, 8, 1 * 4, - rgb_colorspace, - kCGImageAlphaPremultipliedFirst | - kCGBitmapByteOrder32Host)); - - // Load in the color profiles we'll need (as a side effect). - (void) base::mac::GetSRGBColorSpace(); - (void) base::mac::GetSystemColorSpace(); - - // CGColorSpaceCreateSystemDefaultCMYK - 10.6 - base::mac::ScopedCFTypeRef<CGColorSpaceRef> cmyk_colorspace( - CGColorSpaceCreateWithName(kCGColorSpaceGenericCMYK)); - } - - { // [-NSColor colorUsingColorSpaceName] - 10.5.6 - NSColor* color = [NSColor controlTextColor]; - [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace]; - } - - { // localtime() - 10.5.6 - time_t tv = {0}; - localtime(&tv); - } - - { // Gestalt() tries to read /System/Library/CoreServices/SystemVersion.plist - // on 10.5.6 - int32 tmp; - base::SysInfo::OperatingSystemVersionNumbers(&tmp, &tmp, &tmp); - } - - { // CGImageSourceGetStatus() - 10.6 - // Create a png with just enough data to get everything warmed up... - char png_header[] = {0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A}; - NSData* data = [NSData dataWithBytes:png_header - length:arraysize(png_header)]; - base::mac::ScopedCFTypeRef<CGImageSourceRef> img( - CGImageSourceCreateWithData((CFDataRef)data, - NULL)); - CGImageSourceGetStatus(img); - } - - { - // Allow access to /dev/urandom. - GetUrandomFD(); - } - - // Process-type dependent warm-up. - switch (sandbox_type) { - case SANDBOX_TYPE_GPU: - { // GPU-related stuff is very slow without this, probably because - // the sandbox prevents loading graphics drivers or some such. - CGLPixelFormatAttribute attribs[] = { (CGLPixelFormatAttribute)0 }; - CGLPixelFormatObj format; - GLint n; - CGLChoosePixelFormat(attribs, &format, &n); - if (format) - CGLReleasePixelFormat(format); - } - - { - // Preload either the desktop GL or the osmesa so, depending on the - // --use-gl flag. - gfx::GLContext::InitializeOneOff(); - } - break; - - default: - // To shut up a gcc warning. - break; - } -} - -// static -NSString* Sandbox::BuildAllowDirectoryAccessSandboxString( - const FilePath& allowed_dir, - SandboxVariableSubstitions* substitutions) { - // A whitelist is used to determine which directories can be statted - // This means that in the case of an /a/b/c/d/ directory, we may be able to - // stat the leaf directory, but not it's parent. - // The extension code in Chrome calls realpath() which fails if it can't call - // stat() on one of the parent directories in the path. - // The solution to this is to allow statting the parent directories themselves - // but not their contents. We need to add a separate rule for each parent - // directory. - - // The sandbox only understands "real" paths. This resolving step is - // needed so the caller doesn't need to worry about things like /var - // being a link to /private/var (like in the paths CreateNewTempDirectory() - // returns). - FilePath allowed_dir_canonical(allowed_dir); - GetCanonicalSandboxPath(&allowed_dir_canonical); - - // Collect a list of all parent directories. - FilePath last_path = allowed_dir_canonical; - std::vector<FilePath> subpaths; - for (FilePath path = allowed_dir_canonical.DirName(); - path.value() != last_path.value(); - path = path.DirName()) { - subpaths.push_back(path); - last_path = path; - } - - // Iterate through all parents and allow stat() on them explicitly. - NSString* sandbox_command = @"(allow file-read-metadata "; - for (std::vector<FilePath>::reverse_iterator i = subpaths.rbegin(); - i != subpaths.rend(); - ++i) { - std::string subdir_escaped; - if (!QuotePlainString(i->value(), &subdir_escaped)) { - LOG(FATAL) << "String quoting failed " << i->value(); - return nil; - } - - NSString* subdir_escaped_ns = - base::SysUTF8ToNSString(subdir_escaped.c_str()); - sandbox_command = - [sandbox_command stringByAppendingFormat:@"(literal \"%@\")", - subdir_escaped_ns]; - } - - // Finally append the leaf directory. Unlike it's parents (for which only - // stat() should be allowed), the leaf directory needs full access. - (*substitutions)["ALLOWED_DIR"] = - SandboxSubstring(allowed_dir_canonical.value(), - SandboxSubstring::REGEX); - sandbox_command = - [sandbox_command - stringByAppendingString:@") (allow file-read* file-write*" - " (regex #\"@ALLOWED_DIR@\") )"]; - return sandbox_command; -} - -// Load the appropriate template for the given sandbox type. -// Returns the template as an NSString or nil on error. -NSString* LoadSandboxTemplate(Sandbox::SandboxProcessType sandbox_type) { - // We use a custom sandbox definition file to lock things down as - // tightly as possible. - NSString* sandbox_config_filename = nil; - switch (sandbox_type) { - case Sandbox::SANDBOX_TYPE_RENDERER: - sandbox_config_filename = @"renderer"; - break; - case Sandbox::SANDBOX_TYPE_WORKER: - sandbox_config_filename = @"worker"; - break; - case Sandbox::SANDBOX_TYPE_UTILITY: - sandbox_config_filename = @"utility"; - break; - case Sandbox::SANDBOX_TYPE_NACL_LOADER: - // The Native Client loader is used for safeguarding the user's - // untrusted code within Native Client. - sandbox_config_filename = @"nacl_loader"; - break; - case Sandbox::SANDBOX_TYPE_GPU: - sandbox_config_filename = @"gpu"; - break; - default: - NOTREACHED(); - return nil; - } - - // Read in the sandbox profile and the common prefix file. - NSString* common_sandbox_prefix_path = - [base::mac::MainAppBundle() pathForResource:@"common" - ofType:@"sb"]; - NSString* common_sandbox_prefix_data = - [NSString stringWithContentsOfFile:common_sandbox_prefix_path - encoding:NSUTF8StringEncoding - error:NULL]; - - if (!common_sandbox_prefix_data) { - LOG(FATAL) << "Failed to find the sandbox profile on disk " - << [common_sandbox_prefix_path fileSystemRepresentation]; - return nil; - } - - NSString* sandbox_profile_path = - [base::mac::MainAppBundle() pathForResource:sandbox_config_filename - ofType:@"sb"]; - NSString* sandbox_data = - [NSString stringWithContentsOfFile:sandbox_profile_path - encoding:NSUTF8StringEncoding - error:NULL]; - - if (!sandbox_data) { - LOG(FATAL) << "Failed to find the sandbox profile on disk " - << [sandbox_profile_path fileSystemRepresentation]; - return nil; - } - - // Prefix sandbox_data with common_sandbox_prefix_data. - return [common_sandbox_prefix_data stringByAppendingString:sandbox_data]; -} - -// Retrieve OS X version, output parameters are self explanatory. -void GetOSVersion(bool* snow_leopard_or_higher) { - int32 major_version, minor_version, bugfix_version; - base::SysInfo::OperatingSystemVersionNumbers(&major_version, - &minor_version, - &bugfix_version); - *snow_leopard_or_higher = - (major_version > 10 || (major_version == 10 && minor_version >= 6)); -} - -// static -bool Sandbox::PostProcessSandboxProfile( - NSString* sandbox_template, - NSArray* comments_to_remove, - SandboxVariableSubstitions& substitutions, - std::string *final_sandbox_profile_str) { - NSString* sandbox_data = [[sandbox_template copy] autorelease]; - - // Remove comments, e.g. ;10.6_ONLY . - for (NSString* to_remove in comments_to_remove) { - sandbox_data = [sandbox_data stringByReplacingOccurrencesOfString:to_remove - withString:@""]; - } - - // Split string on "@" characters. - std::vector<std::string> raw_sandbox_pieces; - if (Tokenize([sandbox_data UTF8String], "@", &raw_sandbox_pieces) == 0) { - LOG(FATAL) << "Bad Sandbox profile, should contain at least one token (" - << [sandbox_data UTF8String] - << ")"; - return false; - } - - // Iterate over string pieces and substitute variables, escaping as necessary. - size_t output_string_length = 0; - std::vector<std::string> processed_sandbox_pieces(raw_sandbox_pieces.size()); - for (std::vector<std::string>::iterator it = raw_sandbox_pieces.begin(); - it != raw_sandbox_pieces.end(); - ++it) { - std::string new_piece; - SandboxVariableSubstitions::iterator replacement_it = - substitutions.find(*it); - if (replacement_it == substitutions.end()) { - new_piece = *it; - } else { - // Found something to substitute. - SandboxSubstring& replacement = replacement_it->second; - switch (replacement.type()) { - case SandboxSubstring::PLAIN: - new_piece = replacement.value(); - break; - - case SandboxSubstring::LITERAL: - QuotePlainString(replacement.value(), &new_piece); - break; - - case SandboxSubstring::REGEX: - QuoteStringForRegex(replacement.value(), &new_piece); - break; - } - } - output_string_length += new_piece.size(); - processed_sandbox_pieces.push_back(new_piece); - } - - // Build final output string. - final_sandbox_profile_str->reserve(output_string_length); - - for (std::vector<std::string>::iterator it = processed_sandbox_pieces.begin(); - it != processed_sandbox_pieces.end(); - ++it) { - final_sandbox_profile_str->append(*it); - } - return true; -} - - -// Turns on the OS X sandbox for this process. - -// static -bool Sandbox::EnableSandbox(SandboxProcessType sandbox_type, - const FilePath& allowed_dir) { - // Sanity - currently only SANDBOX_TYPE_UTILITY supports a directory being - // passed in. - if (sandbox_type != SANDBOX_TYPE_UTILITY) { - DCHECK(allowed_dir.empty()) - << "Only SANDBOX_TYPE_UTILITY allows a custom directory parameter."; - } - - NSString* sandbox_data = LoadSandboxTemplate(sandbox_type); - if (!sandbox_data) { - return false; - } - - SandboxVariableSubstitions substitutions; - if (!allowed_dir.empty()) { - // Add the sandbox commands necessary to access the given directory. - // Note: this function must be called before PostProcessSandboxProfile() - // since the string it inserts contains variables that need substitution. - NSString* allowed_dir_sandbox_command = - BuildAllowDirectoryAccessSandboxString(allowed_dir, &substitutions); - - if (allowed_dir_sandbox_command) { // May be nil if function fails. - sandbox_data = [sandbox_data - stringByReplacingOccurrencesOfString:@";ENABLE_DIRECTORY_ACCESS" - withString:allowed_dir_sandbox_command]; - } - } - - NSMutableArray* tokens_to_remove = [NSMutableArray array]; - - // Enable verbose logging if enabled on the command line. (See common.sb - // for details). - const CommandLine* command_line = CommandLine::ForCurrentProcess(); - bool enable_logging = - command_line->HasSwitch(switches::kEnableSandboxLogging);; - if (enable_logging) { - [tokens_to_remove addObject:@";ENABLE_LOGGING"]; - } - - bool snow_leopard_or_higher; - GetOSVersion(&snow_leopard_or_higher); - - // Without this, the sandbox will print a message to the system log every - // time it denies a request. This floods the console with useless spew. The - // (with no-log) syntax is only supported on 10.6+ - if (snow_leopard_or_higher && !enable_logging) { - substitutions["DISABLE_SANDBOX_DENIAL_LOGGING"] = - SandboxSubstring("(with no-log)"); - } else { - substitutions["DISABLE_SANDBOX_DENIAL_LOGGING"] = SandboxSubstring(""); - } - - // Splice the path of the user's home directory into the sandbox profile - // (see renderer.sb for details). - std::string home_dir = base::SysNSStringToUTF8(NSHomeDirectory()); - - FilePath home_dir_canonical(home_dir); - GetCanonicalSandboxPath(&home_dir_canonical); - - substitutions["USER_HOMEDIR_AS_LITERAL"] = - SandboxSubstring(home_dir_canonical.value(), - SandboxSubstring::LITERAL); - - if (snow_leopard_or_higher) { - // 10.6-only Sandbox rules. - [tokens_to_remove addObject:@";10.6_ONLY"]; - } else { - // Sandbox rules only for versions before 10.6. - [tokens_to_remove addObject:@";BEFORE_10.6"]; - } - - // All information needed to assemble the final profile has been collected. - // Merge it all together. - std::string final_sandbox_profile_str; - if (!PostProcessSandboxProfile(sandbox_data, tokens_to_remove, substitutions, - &final_sandbox_profile_str)) { - return false; - } - - // Initialize sandbox. - char* error_buff = NULL; - int error = sandbox_init(final_sandbox_profile_str.c_str(), 0, &error_buff); - bool success = (error == 0 && error_buff == NULL); - LOG_IF(FATAL, !success) << "Failed to initialize sandbox: " - << error - << " " - << error_buff; - sandbox_free_error(error_buff); - return success; -} - -// static -void Sandbox::GetCanonicalSandboxPath(FilePath* path) { - int fd = HANDLE_EINTR(open(path->value().c_str(), O_RDONLY)); - if (fd < 0) { - PLOG(FATAL) << "GetCanonicalSandboxPath() failed for: " - << path->value(); - return; - } - file_util::ScopedFD file_closer(&fd); - - FilePath::CharType canonical_path[MAXPATHLEN]; - if (HANDLE_EINTR(fcntl(fd, F_GETPATH, canonical_path)) != 0) { - PLOG(FATAL) << "GetCanonicalSandboxPath() failed for: " - << path->value(); - return; - } - - *path = FilePath(canonical_path); -} - -} // namespace sandbox diff --git a/chrome/common/sandbox_mac_diraccess_unittest.mm b/chrome/common/sandbox_mac_diraccess_unittest.mm deleted file mode 100644 index fed540d..0000000 --- a/chrome/common/sandbox_mac_diraccess_unittest.mm +++ /dev/null @@ -1,304 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#import <Cocoa/Cocoa.h> -#include <dirent.h> - -extern "C" { -#include <sandbox.h> -} - -#include "base/file_util.h" -#include "base/file_path.h" -#include "base/test/multiprocess_test.h" -#include "base/sys_string_conversions.h" -#include "base/utf_string_conversions.h" -#include "chrome/common/sandbox_mac.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "testing/multiprocess_func_list.h" - -namespace { - -static const char* kSandboxAccessPathKey = "sandbox_dir"; -static const char* kDeniedSuffix = "_denied"; - -} // namespace - -// Tests need to be in the same namespace as the sandbox::Sandbox class to be -// useable with FRIEND_TEST() declaration. -namespace sandbox { - -class MacDirAccessSandboxTest : public base::MultiProcessTest { - public: - bool CheckSandbox(const std::string& directory_to_try) { - setenv(kSandboxAccessPathKey, directory_to_try.c_str(), 1); - base::ProcessHandle child_process = SpawnChild("mac_sandbox_path_access", - false); - int code = -1; - if (!base::WaitForExitCode(child_process, &code)) { - LOG(WARNING) << "base::WaitForExitCode failed"; - return false; - } - return code == 0; - } -}; - -TEST_F(MacDirAccessSandboxTest, StringEscape) { - const struct string_escape_test_data { - const char* to_escape; - const char* escaped; - } string_escape_cases[] = { - {"", ""}, - {"\b\f\n\r\t\\\"", "\\b\\f\\n\\r\\t\\\\\\\""}, - {"/'", "/'"}, - {"sandwich", "sandwich"}, - {"(sandwich)", "(sandwich)"}, - {"^\u2135.\u2136$", "^\\u2135.\\u2136$"}, - }; - - for (size_t i = 0; i < ARRAYSIZE_UNSAFE(string_escape_cases); ++i) { - std::string out; - std::string in(string_escape_cases[i].to_escape); - EXPECT_TRUE(Sandbox::QuotePlainString(in, &out)); - EXPECT_EQ(string_escape_cases[i].escaped, out); - } -} - -TEST_F(MacDirAccessSandboxTest, RegexEscape) { - const std::string kSandboxEscapeSuffix("(/|$)"); - const struct regex_test_data { - const wchar_t *to_escape; - const char* escaped; - } regex_cases[] = { - {L"", ""}, - {L"/'", "/'"}, // / & ' characters don't need escaping. - {L"sandwich", "sandwich"}, - {L"(sandwich)", "\\(sandwich\\)"}, - }; - - // Check that all characters whose values are smaller than 32 [1F] are - // rejected by the regex escaping code. - { - std::string out; - char fail_string[] = {31, 0}; - char ok_string[] = {32, 0}; - EXPECT_FALSE(Sandbox::QuoteStringForRegex(fail_string, &out)); - EXPECT_TRUE(Sandbox::QuoteStringForRegex(ok_string, &out)); - } - - // Check that all characters whose values are larger than 126 [7E] are - // rejected by the regex escaping code. - { - std::string out; - EXPECT_TRUE(Sandbox::QuoteStringForRegex("}", &out)); // } == 0x7D == 125 - EXPECT_FALSE(Sandbox::QuoteStringForRegex("~", &out)); // ~ == 0x7E == 126 - EXPECT_FALSE( - Sandbox::QuoteStringForRegex(WideToUTF8(L"^\u2135.\u2136$"), &out)); - } - - { - for (size_t i = 0; i < ARRAYSIZE_UNSAFE(regex_cases); ++i) { - std::string out; - std::string in = WideToUTF8(regex_cases[i].to_escape); - EXPECT_TRUE(Sandbox::QuoteStringForRegex(in, &out)); - std::string expected("^"); - expected.append(regex_cases[i].escaped); - expected.append(kSandboxEscapeSuffix); - EXPECT_EQ(expected, out); - } - } - - { - std::string in_utf8("\\^.$|()[]*+?{}"); - std::string expected; - expected.push_back('^'); - for (size_t i = 0; i < in_utf8.length(); ++i) { - expected.push_back('\\'); - expected.push_back(in_utf8[i]); - } - expected.append(kSandboxEscapeSuffix); - - std::string out; - EXPECT_TRUE(Sandbox::QuoteStringForRegex(in_utf8, &out)); - EXPECT_EQ(expected, out); - - } -} - -// A class to handle auto-deleting a directory. -class ScopedDirectoryDelete { - public: - inline void operator()(FilePath* x) const { - if (x) { - file_util::Delete(*x, true); - } - } -}; - -typedef scoped_ptr_malloc<FilePath, ScopedDirectoryDelete> ScopedDirectory; - -TEST_F(MacDirAccessSandboxTest, SandboxAccess) { - using file_util::CreateDirectory; - - FilePath tmp_dir; - ASSERT_TRUE(file_util::CreateNewTempDirectory("", &tmp_dir)); - // This step is important on OS X since the sandbox only understands "real" - // paths and the paths CreateNewTempDirectory() returns are empirically in - // /var which is a symlink to /private/var . - Sandbox::GetCanonicalSandboxPath(&tmp_dir); - ScopedDirectory cleanup(&tmp_dir); - - const char* sandbox_dir_cases[] = { - "simple_dir_name", - "^hello++ $", // Regex. - "\\^.$|()[]*+?{}", // All regex characters. - }; - - for (size_t i = 0; i < ARRAYSIZE_UNSAFE(sandbox_dir_cases); ++i) { - const char* sandbox_dir_name = sandbox_dir_cases[i]; - FilePath sandbox_dir = tmp_dir.Append(sandbox_dir_name); - ASSERT_TRUE(CreateDirectory(sandbox_dir)); - ScopedDirectory cleanup_sandbox(&sandbox_dir); - - // Create a sibling directory of the sandbox dir, whose name has sandbox dir - // as a substring but to which access is denied. - std::string sibling_sandbox_dir_name_denied = - std::string(sandbox_dir_cases[i]) + kDeniedSuffix; - FilePath sibling_sandbox_dir = tmp_dir.Append( - sibling_sandbox_dir_name_denied.c_str()); - ASSERT_TRUE(CreateDirectory(sibling_sandbox_dir)); - ScopedDirectory cleanup_sandbox_sibling(&sibling_sandbox_dir); - - EXPECT_TRUE(CheckSandbox(sandbox_dir.value())); - } -} - -MULTIPROCESS_TEST_MAIN(mac_sandbox_path_access) { - char *sandbox_allowed_dir = getenv(kSandboxAccessPathKey); - if (!sandbox_allowed_dir) - return -1; - - // Build up a sandbox profile that only allows access to a single directory. - NSString *sandbox_profile = - @"(version 1)" \ - "(deny default)" \ - "(allow signal (target self))" \ - "(allow sysctl-read)" \ - ";ENABLE_DIRECTORY_ACCESS"; - - std::string allowed_dir(sandbox_allowed_dir); - Sandbox::SandboxVariableSubstitions substitutions; - NSString* allow_dir_sandbox_code = - Sandbox::BuildAllowDirectoryAccessSandboxString( - FilePath(sandbox_allowed_dir), - &substitutions); - sandbox_profile = [sandbox_profile - stringByReplacingOccurrencesOfString:@";ENABLE_DIRECTORY_ACCESS" - withString:allow_dir_sandbox_code]; - - std::string final_sandbox_profile_str; - if (!Sandbox::PostProcessSandboxProfile(sandbox_profile, - [NSArray array], - substitutions, - &final_sandbox_profile_str)) { - LOG(ERROR) << "Call to PostProcessSandboxProfile() failed"; - return -1; - } - - // Enable Sandbox. - char* error_buff = NULL; - int error = sandbox_init(final_sandbox_profile_str.c_str(), 0, &error_buff); - if (error == -1) { - LOG(ERROR) << "Failed to Initialize Sandbox: " << error_buff; - return -1; - } - sandbox_free_error(error_buff); - - // Test Sandbox. - - // We should be able to list the contents of the sandboxed directory. - DIR *file_list = NULL; - file_list = opendir(sandbox_allowed_dir); - if (!file_list) { - PLOG(ERROR) << "Sandbox overly restrictive: call to opendir(" - << sandbox_allowed_dir - << ") failed"; - return -1; - } - closedir(file_list); - - // Test restrictions on accessing files. - FilePath allowed_dir_path(sandbox_allowed_dir); - FilePath allowed_file = allowed_dir_path.Append("ok_to_write"); - FilePath denied_file1 = allowed_dir_path.DirName().Append("cant_access"); - - // Try to write a file who's name has the same prefix as the directory we - // allow access to. - FilePath basename = allowed_dir_path.BaseName(); - FilePath allowed_parent_dir = allowed_dir_path.DirName(); - std::string tricky_filename = basename.value() + "123"; - FilePath denied_file2 = allowed_parent_dir.Append(tricky_filename); - - if (open(allowed_file.value().c_str(), O_WRONLY | O_CREAT) <= 0) { - PLOG(ERROR) << "Sandbox overly restrictive: failed to write (" - << allowed_file.value() - << ")"; - return -1; - } - - // Test that we deny access to a sibling of the sandboxed directory whose - // name has the sandboxed directory name as a substring. e.g. if the sandbox - // directory is /foo/baz then test /foo/baz_denied. - { - struct stat tmp_stat_info; - std::string denied_sibling = - std::string(sandbox_allowed_dir) + kDeniedSuffix; - if (stat(denied_sibling.c_str(), &tmp_stat_info) > 0) { - PLOG(ERROR) << "Sandbox breach: was able to stat (" - << denied_sibling.c_str() - << ")"; - return -1; - } - } - - // Test that we can stat parent directories of the "allowed" directory. - { - struct stat tmp_stat_info; - if (stat(allowed_parent_dir.value().c_str(), &tmp_stat_info) != 0) { - PLOG(ERROR) << "Sandbox overly restrictive: unable to stat (" - << allowed_parent_dir.value() - << ")"; - return -1; - } - } - - // Test that we can't stat files outside the "allowed" directory. - { - struct stat tmp_stat_info; - if (stat(denied_file1.value().c_str(), &tmp_stat_info) > 0) { - PLOG(ERROR) << "Sandbox breach: was able to stat (" - << denied_file1.value() - << ")"; - return -1; - } - } - - if (open(denied_file1.value().c_str(), O_WRONLY | O_CREAT) > 0) { - PLOG(ERROR) << "Sandbox breach: was able to write (" - << denied_file1.value() - << ")"; - return -1; - } - - if (open(denied_file2.value().c_str(), O_WRONLY | O_CREAT) > 0) { - PLOG(ERROR) << "Sandbox breach: was able to write (" - << denied_file2.value() - << ")"; - return -1; - } - - return 0; -} - -} // namespace sandbox diff --git a/chrome/common/sandbox_mac_fontloading_unittest.mm b/chrome/common/sandbox_mac_fontloading_unittest.mm deleted file mode 100644 index 17f4a4a..0000000 --- a/chrome/common/sandbox_mac_fontloading_unittest.mm +++ /dev/null @@ -1,179 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#import <Cocoa/Cocoa.h> - -#include "base/file_util.h" -#include "base/logging.h" -#include "base/mac/scoped_cftyperef.h" -#include "base/scoped_ptr.h" -#include "base/shared_memory.h" -#include "chrome/common/font_loader_mac.h" -#include "chrome/common/sandbox_mac_unittest_helper.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace { - -using sandboxtest::MacSandboxTest; -using sandbox::Sandbox; - -bool CGFontFromFontContainer(ATSFontContainerRef container, CGFontRef* out) { - // Count the number of fonts that were loaded. - ItemCount fontCount = 0; - OSStatus err = ATSFontFindFromContainer(container, kATSOptionFlagsDefault, 0, - NULL, &fontCount); - - if (err != noErr || fontCount < 1) { - return false; - } - - // Load font from container. - ATSFontRef font_ref_ats = 0; - ATSFontFindFromContainer(container, kATSOptionFlagsDefault, 1, - &font_ref_ats, NULL); - - if (!font_ref_ats) { - return false; - } - - // Convert to cgFont. - CGFontRef font_ref_cg = CGFontCreateWithPlatformFont(&font_ref_ats); - - if (!font_ref_cg) { - return false; - } - - *out = font_ref_cg; - return true; -} - -class ScopedFontContainer { - public: - explicit ScopedFontContainer(ATSFontContainerRef ref) - : container_ref(ref) {} - - ~ScopedFontContainer() { - ATSFontDeactivate(container_ref, NULL, kATSOptionFlagsDefault); - } - - ATSFontContainerRef container_ref; -}; - -class FontLoadingTestCase : public sandboxtest::MacSandboxTestCase { - public: - FontLoadingTestCase() : font_data_length_(-1) {} - virtual bool BeforeSandboxInit(); - virtual bool SandboxedTest(); - private: - scoped_ptr<base::SharedMemory> font_shmem_; - size_t font_data_length_; -}; -REGISTER_SANDBOX_TEST_CASE(FontLoadingTestCase); - - -// Load raw font data into shared memory object. -bool FontLoadingTestCase::BeforeSandboxInit() { - std::string font_data; - if (!file_util::ReadFileToString(FilePath(test_data_.c_str()), &font_data)) { - LOG(ERROR) << "Failed to read font data from file (" << test_data_ << ")"; - return false; - } - - font_data_length_ = font_data.length(); - if (font_data_length_ <= 0) { - LOG(ERROR) << "No font data: " << font_data_length_; - return false; - } - - font_shmem_.reset(new base::SharedMemory); - if (!font_shmem_.get()) { - LOG(ERROR) << "Failed to create shared memory object."; - return false; - } - - if (!font_shmem_->CreateAndMapAnonymous(font_data_length_)) { - LOG(ERROR) << "SharedMemory::Create failed"; - return false; - } - - memcpy(font_shmem_->memory(), font_data.c_str(), font_data_length_); - if (!font_shmem_->Unmap()) { - LOG(ERROR) << "SharedMemory::Unmap failed"; - return false; - } - return true; -} - -bool FontLoadingTestCase::SandboxedTest() { - base::SharedMemoryHandle shmem_handle; - if (!font_shmem_->ShareToProcess(NULL, &shmem_handle)) { - LOG(ERROR) << "SharedMemory::ShareToProcess failed"; - return false; - } - - ATSFontContainerRef font_container; - if (!FontLoader::ATSFontContainerFromBuffer(shmem_handle, font_data_length_, - &font_container)) { - LOG(ERROR) << "Call to CreateCGFontFromBuffer() failed"; - return false; - } - - // Unload the font container when done. - ScopedFontContainer scoped_unloader(font_container); - - CGFontRef cg_font_ref; - if (!CGFontFromFontContainer(font_container, &cg_font_ref)) { - LOG(ERROR) << "CGFontFromFontContainer failed"; - return false; - } - - if (!cg_font_ref) { - LOG(ERROR) << "Got NULL CGFontRef"; - return false; - } - base::mac::ScopedCFTypeRef<CGFontRef> cgfont(cg_font_ref); - - CTFontRef ct_font_ref = - CTFontCreateWithGraphicsFont(cgfont.get(), 16.0, NULL, NULL); - base::mac::ScopedCFTypeRef<CTFontRef> ctfont(ct_font_ref); - - if (!ct_font_ref) { - LOG(ERROR) << "CTFontCreateWithGraphicsFont() failed"; - return false; - } - - // Do something with the font to make sure it's loaded. - CGFloat cap_height = CTFontGetCapHeight(ct_font_ref); - - if (cap_height <= 0.0) { - LOG(ERROR) << "Got bad value for CTFontGetCapHeight " << cap_height; - return false; - } - - return true; -} - -TEST_F(MacSandboxTest, FontLoadingTest) { - FilePath temp_file_path; - FILE* temp_file = file_util::CreateAndOpenTemporaryFile(&temp_file_path); - ASSERT_TRUE(temp_file); - file_util::ScopedFILE temp_file_closer(temp_file); - - base::SharedMemory font_data; - uint32 font_data_size; - NSFont* srcFont = [NSFont fontWithName:@"Geeza Pro" size:16.0]; - EXPECT_TRUE(FontLoader::LoadFontIntoBuffer(srcFont, - &font_data, &font_data_size)); - EXPECT_GT(font_data_size, 0U); - - file_util::WriteFileDescriptor(fileno(temp_file), - static_cast<const char *>(font_data.memory()), font_data_size); - - ASSERT_TRUE(RunTestInSandbox(Sandbox::SANDBOX_TYPE_RENDERER, - "FontLoadingTestCase", temp_file_path.value().c_str())); - temp_file_closer.reset(); - ASSERT_TRUE(file_util::Delete(temp_file_path, false)); -} - -} // namespace diff --git a/chrome/common/sandbox_mac_system_access_unittest.mm b/chrome/common/sandbox_mac_system_access_unittest.mm deleted file mode 100644 index 382aa2c..0000000 --- a/chrome/common/sandbox_mac_system_access_unittest.mm +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#import <Cocoa/Cocoa.h> - -#include "base/logging.h" -#include "base/sys_string_conversions.h" -#include "chrome/common/sandbox_mac.h" -#include "chrome/common/sandbox_mac_unittest_helper.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace { - -using sandboxtest::MacSandboxTest; - -//--------------------- Clipboard Sandboxing ---------------------- -// Test case for checking sandboxing of clipboard access. -class MacSandboxedClipboardTestCase : public sandboxtest::MacSandboxTestCase { - public: - MacSandboxedClipboardTestCase(); - virtual ~MacSandboxedClipboardTestCase(); - - virtual bool SandboxedTest(); - - virtual void SetTestData(const char* test_data); - private: - NSString* clipboard_name_; -}; - -REGISTER_SANDBOX_TEST_CASE(MacSandboxedClipboardTestCase); - -MacSandboxedClipboardTestCase::MacSandboxedClipboardTestCase() : - clipboard_name_(nil) {} - -MacSandboxedClipboardTestCase::~MacSandboxedClipboardTestCase() { - [clipboard_name_ release]; -} - -bool MacSandboxedClipboardTestCase::SandboxedTest() { - // Shouldn't be able to open the pasteboard in the sandbox. - - if ([clipboard_name_ length] == 0) { - LOG(ERROR) << "Clipboard name is empty"; - return false; - } - - NSPasteboard* pb = [NSPasteboard pasteboardWithName:clipboard_name_]; - if (pb != nil) { - LOG(ERROR) << "Was able to access named clipboard"; - return false; - } - - pb = [NSPasteboard generalPasteboard]; - if (pb != nil) { - LOG(ERROR) << "Was able to access system clipboard"; - return false; - } - - return true; -} - -void MacSandboxedClipboardTestCase::SetTestData(const char* test_data) { - clipboard_name_ = [base::SysUTF8ToNSString(test_data) retain]; -} - -TEST_F(MacSandboxTest, ClipboardAccess) { - NSPasteboard* pb = [NSPasteboard pasteboardWithUniqueName]; - EXPECT_EQ([[pb types] count], 0U); - - std::string pasteboard_name = base::SysNSStringToUTF8([pb name]); - EXPECT_TRUE(RunTestInAllSandboxTypes("MacSandboxedClipboardTestCase", - pasteboard_name.c_str())); - - // After executing the test, the clipboard should still be empty. - EXPECT_EQ([[pb types] count], 0U); -} - -//--------------------- File Access Sandboxing ---------------------- -// Test case for checking sandboxing of filesystem apis. -class MacSandboxedFileAccessTestCase : public sandboxtest::MacSandboxTestCase { - public: - virtual bool SandboxedTest(); -}; - -REGISTER_SANDBOX_TEST_CASE(MacSandboxedFileAccessTestCase); - -bool MacSandboxedFileAccessTestCase::SandboxedTest() { - return open("/etc/passwd", O_RDONLY) == -1; -} - -TEST_F(MacSandboxTest, FileAccess) { - EXPECT_TRUE(RunTestInAllSandboxTypes("MacSandboxedFileAccessTestCase", NULL)); -} - -} // namespace diff --git a/chrome/common/sandbox_mac_unittest_helper.h b/chrome/common/sandbox_mac_unittest_helper.h deleted file mode 100644 index ace4767..0000000 --- a/chrome/common/sandbox_mac_unittest_helper.h +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_COMMON_SANDBOX_MAC_UNITTEST_HELPER_H_ -#define CHROME_COMMON_SANDBOX_MAC_UNITTEST_HELPER_H_ -#pragma once - -#include "base/test/multiprocess_test.h" -#include "chrome/common/sandbox_mac.h" - -namespace sandboxtest { - -// Helpers for writing unit tests that runs in the context of the Mac sandbox. -// -// How to write a sandboxed test: -// 1. Create a class that inherits from MacSandboxTestCase and overrides -// its functions to run code before or after the sandbox is initialised in a -// subprocess. -// 2. Register the class you just created with the REGISTER_SANDBOX_TEST_CASE() -// macro. -// 3. Write a test [using TEST_F()] that inherits from MacSandboxTest and call -// one of its helper functions to launch the test. -// -// Example: -// class TestCaseThatRunsInSandboxedSubprocess : -// public sandboxtest::MacSandboxTestCase { -// public: -// virtual bool SandboxedTest() { -// .. test code that runs in sandbox goes here .. -// return true; // always succeed. -// } -// }; -// -// // Register the test case you just created. -// REGISTER_SANDBOX_TEST_CASE(TestCaseThatRunsInSandboxedSubprocess); -// -// TEST_F(MacSandboxTest, ATest) { -// EXPECT_TRUE(RunTestInAllSandboxTypes( -// "TestCaseThatRunsInSandboxedSubprocess", -// NULL)); -// } - -// Base test type with helper functions to spawn a subprocess that exercises -// a given test in the sandbox. -class MacSandboxTest : public base::MultiProcessTest { - public: - // Runs a test specified by |test_name| in a sandbox of the type specified - // by |sandbox_type|. |test_data| is a custom string that a test can pass - // to the child process runing in the sandbox. - // Returns true if the test passes, false if either of the functions in - // the corresponding MacSandboxTestCase return false. - bool RunTestInSandbox(sandbox::Sandbox::SandboxProcessType sandbox_type, - const char* test_name, - const char* test_data); - - // Runs the test specified by |test_name| in all the different sandbox types, - // one by one. - // Returns true if the test passes, false if either of the functions in - // the corresponding MacSandboxTestCase return false in any of the spawned - // processes. - bool RunTestInAllSandboxTypes(const char* test_name, - const char* test_data); -}; - -// Class to ease writing test cases that run inside the OS X sandbox. -// This class is instantiated in a subprocess, and allows you to run test code -// at various stages of execution. -// Note that you must register the subclass you create with the -// REGISTER_SANDBOX_TEST_CASE so it's visible to the test driver. -class MacSandboxTestCase { - public: - virtual ~MacSandboxTestCase() {} - - // Code that runs in the sandboxed subprocess before the sandbox is - // initialized. - // Returning false from this function will cause the entire test case to fail. - virtual bool BeforeSandboxInit(); - - // Code that runs in the sandboxed subprocess when the sandbox has been - // enabled. - // Returning false from this function will cause the entire test case to fail. - virtual bool SandboxedTest() = 0; - - // The data that's passed in the |user_data| parameter of - // RunTest[s]InSandbox() is passed to this function. - virtual void SetTestData(const char* test_data); - - protected: - std::string test_data_; -}; - -// Plumbing to support the REGISTER_SANDBOX_TEST_CASE macro. -namespace internal { - -// Register a test case with a given name. -void AddSandboxTestCase(const char* test_name, MacSandboxTestCase* test_class); - -// Construction of this class causes a new entry to be placed in a global -// map. -template <class T> struct RegisterSandboxTest { - RegisterSandboxTest(const char* test_name) { - AddSandboxTestCase(test_name, new T); - } -}; - -#define REGISTER_SANDBOX_TEST_CASE(class_name) \ - namespace { \ - sandboxtest::internal::RegisterSandboxTest<class_name> \ - register_test##class_name(#class_name); \ - } // namespace - -} // namespace internal - -} // namespace sandboxtest - -#endif // CHROME_COMMON_SANDBOX_MAC_UNITTEST_HELPER_H_ diff --git a/chrome/common/sandbox_mac_unittest_helper.mm b/chrome/common/sandbox_mac_unittest_helper.mm deleted file mode 100644 index e437289..0000000 --- a/chrome/common/sandbox_mac_unittest_helper.mm +++ /dev/null @@ -1,170 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/common/sandbox_mac_unittest_helper.h" - -extern "C" { -#include <sandbox.h> -} - -#include <map> - -#include "base/file_path.h" -#include "base/logging.h" -#include "base/scoped_ptr.h" -#include "chrome/common/sandbox_mac.h" -#include "testing/multiprocess_func_list.h" - -using sandbox::Sandbox; - -namespace { - -const char* kSandboxTypeKey = "CHROMIUM_SANDBOX_SANDBOX_TYPE"; -const char* kSandboxTestNameKey = "CHROMIUM_SANDBOX_TEST_NAME"; -const char* kTestDataKey = "CHROMIUM_SANDBOX_USER_DATA"; - -} // namespace - -namespace sandboxtest { - -// Support infrastructure for REGISTER_SANDBOX_TEST_CASE macro. -namespace internal { - -typedef std::map<std::string,MacSandboxTestCase*> SandboxTestMap; - -// A function that returns a common map from string -> test case class. -SandboxTestMap& GetSandboxTestMap() { - static SandboxTestMap test_map; - return test_map; -} - -void AddSandboxTestCase(const char* test_name, MacSandboxTestCase* test_class) { - SandboxTestMap& test_map = GetSandboxTestMap(); - if (test_map.find(test_name) != test_map.end()) { - LOG(ERROR) << "Trying to register duplicate test" << test_name; - NOTREACHED(); - } - test_map[test_name] = test_class; -} - -} // namespace internal - -bool MacSandboxTest::RunTestInAllSandboxTypes(const char* test_name, - const char* test_data) { - // Go through all the sandbox types, and run the test case in each of them - // if one fails, abort. - for(int i = static_cast<int>(Sandbox::SANDBOX_TYPE_FIRST_TYPE); - i < Sandbox::SANDBOX_AFTER_TYPE_LAST_TYPE; - ++i) { - - if (!RunTestInSandbox(static_cast<Sandbox::SandboxProcessType>(i), - test_name, test_data)) { - LOG(ERROR) << "Sandboxed test (" << test_name << ")" << - "Failed in sandbox type " << i << - "user data: (" << test_data << ")"; - return false; - } - } - return true; -} - -bool MacSandboxTest::RunTestInSandbox(Sandbox::SandboxProcessType sandbox_type, - const char* test_name, - const char* test_data) { - std::stringstream s; - s << static_cast<int>(static_cast<int>(sandbox_type)); - setenv(kSandboxTypeKey, s.str().c_str(), 1); - setenv(kSandboxTestNameKey, test_name, 1); - if (test_data) - setenv(kTestDataKey, test_data, 1); - - base::ProcessHandle child_process = SpawnChild("mac_sandbox_test_runner", - false); - int code = -1; - if (!base::WaitForExitCode(child_process, &code)) { - LOG(WARNING) << "base::WaitForExitCode failed"; - return false; - } - return code == 0; -} - -bool MacSandboxTestCase::BeforeSandboxInit() { - return true; -} - -void MacSandboxTestCase::SetTestData(const char* test_data) { - test_data_ = test_data; -} - -// Given a test name specified by |name| return that test case. -// If no test case is found for the given name, return NULL. -MacSandboxTestCase *SandboxTestForName(const char* name) { - using internal::SandboxTestMap; - using internal::GetSandboxTestMap; - - SandboxTestMap all_tests = GetSandboxTestMap(); - - SandboxTestMap::iterator it = all_tests.find(name); - if (it == all_tests.end()) { - LOG(ERROR) << "Couldn't find sandbox test case(" << name << ")"; - return NULL; - } - - return it->second; -} - -} // namespace sandboxtest - -namespace { - -// Main function for driver process that enables the sandbox and runs test -// code. -MULTIPROCESS_TEST_MAIN(mac_sandbox_test_runner) { - // Extract parameters. - char* sandbox_type_str = getenv(kSandboxTypeKey); - if (!sandbox_type_str) { - LOG(ERROR) << "Sandbox type not specified"; - return -1; - } - Sandbox::SandboxProcessType sandbox_type = - static_cast<Sandbox::SandboxProcessType>(atoi(sandbox_type_str)); - char* sandbox_test_name = getenv(kSandboxTestNameKey); - if (!sandbox_test_name) { - LOG(ERROR) << "Sandbox test name not specified"; - return -1; - } - - const char* test_data = getenv(kTestDataKey); - - // Find Test Function to run; - scoped_ptr<sandboxtest::MacSandboxTestCase> - test_case(sandboxtest::SandboxTestForName(sandbox_test_name)); - if (!test_case.get()) { - LOG(ERROR) << "Invalid sandbox test name (" << sandbox_test_name << ")"; - return -1; - } - test_case->SetTestData(test_data); - - // Run Test. - if (!test_case->BeforeSandboxInit()) { - LOG(ERROR) << sandbox_test_name << "Failed test before sandbox init"; - return -1; - } - - Sandbox::SandboxWarmup(sandbox_type); - - if (!Sandbox::EnableSandbox(sandbox_type, FilePath())) { - LOG(ERROR) << "Failed to initialize sandbox " << sandbox_type; - return -1; - } - - if (!test_case->SandboxedTest()) { - LOG(ERROR) << sandbox_test_name << "Failed sandboxed test"; - return -1; - } - - return 0; -} - -} // namespace diff --git a/chrome/common/sandbox_policy.cc b/chrome/common/sandbox_policy.cc index 319f181..756346e 100644 --- a/chrome/common/sandbox_policy.cc +++ b/chrome/common/sandbox_policy.cc @@ -20,8 +20,8 @@ #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" -#include "chrome/common/debug_flags.h" #include "content/common/child_process_info.h" +#include "content/common/debug_flags.h" #include "sandbox/src/sandbox.h" static sandbox::BrokerServices* g_broker_services = NULL; diff --git a/chrome/gpu/gpu_main.cc b/chrome/gpu/gpu_main.cc index a2b9e5f..16a3add 100644 --- a/chrome/gpu/gpu_main.cc +++ b/chrome/gpu/gpu_main.cc @@ -14,14 +14,14 @@ #include "base/stringprintf.h" #include "base/threading/platform_thread.h" #include "build/build_config.h" -#include "chrome/common/main_function_params.h" #include "content/common/content_switches.h" +#include "content/common/main_function_params.h" #include "chrome/gpu/gpu_config.h" #include "chrome/gpu/gpu_process.h" #include "chrome/gpu/gpu_thread.h" #if defined(OS_MACOSX) -#include "chrome/common/chrome_application_mac.h" +#include "content/common/chrome_application_mac.h" #endif #if defined(USE_X11) diff --git a/chrome/gpu/gpu_thread.cc b/chrome/gpu/gpu_thread.cc index 11ff453..a944907 100644 --- a/chrome/gpu/gpu_thread.cc +++ b/chrome/gpu/gpu_thread.cc @@ -22,8 +22,8 @@ #include "ipc/ipc_channel_handle.h" #if defined(OS_MACOSX) -#include "chrome/common/sandbox_init_wrapper.h" -#include "chrome/common/sandbox_mac.h" +#include "content/common/sandbox_init_wrapper.h" +#include "content/common/sandbox_mac.h" #elif defined(OS_WIN) #include "sandbox/src/sandbox.h" #endif diff --git a/chrome/nacl/nacl_main.cc b/chrome/nacl/nacl_main.cc index 11194d9..b026c78 100644 --- a/chrome/nacl/nacl_main.cc +++ b/chrome/nacl/nacl_main.cc @@ -15,12 +15,12 @@ #include "chrome/common/chrome_switches.h" #include "chrome/common/hi_res_timer_manager.h" #include "chrome/common/logging_chrome.h" -#include "chrome/common/main_function_params.h" #include "chrome/common/result_codes.h" #include "chrome/common/sandbox_policy.h" #include "chrome/nacl/nacl_main_platform_delegate.h" #include "chrome/nacl/nacl_thread.h" #include "content/common/child_process.h" +#include "content/common/main_function_params.h" #include "ui/base/system_monitor/system_monitor.h" #if defined(OS_WIN) diff --git a/chrome/nacl/nacl_main_platform_delegate.h b/chrome/nacl/nacl_main_platform_delegate.h index 007f346..b1c56f6 100644 --- a/chrome/nacl/nacl_main_platform_delegate.h +++ b/chrome/nacl/nacl_main_platform_delegate.h @@ -7,7 +7,7 @@ #pragma once #include "base/native_library.h" -#include "chrome/common/main_function_params.h" +#include "content/common/main_function_params.h" typedef bool (*RunNaClLoaderTests)(void); const char kNaClLoaderTestCall[] = "RunNaClLoaderTests"; diff --git a/chrome/nacl/nacl_main_platform_delegate_mac.mm b/chrome/nacl/nacl_main_platform_delegate_mac.mm index 39ba8c8..19e7df7 100644 --- a/chrome/nacl/nacl_main_platform_delegate_mac.mm +++ b/chrome/nacl/nacl_main_platform_delegate_mac.mm @@ -10,7 +10,7 @@ #include "base/logging.h" #include "base/native_library.h" #include "chrome/common/chrome_switches.h" -#include "chrome/common/sandbox_mac.h" +#include "content/common/sandbox_mac.h" NaClMainPlatformDelegate::NaClMainPlatformDelegate( const MainFunctionParams& parameters) diff --git a/chrome/plugin/plugin_main.cc b/chrome/plugin/plugin_main.cc index fa45585..a3e9174 100644 --- a/chrome/plugin/plugin_main.cc +++ b/chrome/plugin/plugin_main.cc @@ -18,9 +18,9 @@ #include "chrome/common/default_plugin.h" #include "chrome/common/hi_res_timer_manager.h" #include "chrome/common/logging_chrome.h" -#include "chrome/common/main_function_params.h" #include "chrome/plugin/plugin_thread.h" #include "content/common/child_process.h" +#include "content/common/main_function_params.h" #include "ui/base/system_monitor/system_monitor.h" #if defined(OS_WIN) diff --git a/chrome/plugin/plugin_main_mac.mm b/chrome/plugin/plugin_main_mac.mm index 5d10a3b..122dc39 100644 --- a/chrome/plugin/plugin_main_mac.mm +++ b/chrome/plugin/plugin_main_mac.mm @@ -5,9 +5,9 @@ #include "base/environment.h" #include "base/scoped_ptr.h" #include "base/string_util.h" -#include "chrome/common/chrome_application_mac.h" #include "chrome/common/plugin_carbon_interpose_constants_mac.h" #include "chrome/plugin/plugin_interpose_util_mac.h" +#include "content/common/chrome_application_mac.h" #if !defined(__LP64__) void TrimInterposeEnvironment() { diff --git a/chrome/ppapi_plugin/ppapi_plugin_main.cc b/chrome/ppapi_plugin/ppapi_plugin_main.cc index 801c46a..dfa5a92 100644 --- a/chrome/ppapi_plugin/ppapi_plugin_main.cc +++ b/chrome/ppapi_plugin/ppapi_plugin_main.cc @@ -6,9 +6,9 @@ #include "base/threading/platform_thread.h" #include "build/build_config.h" #include "chrome/common/chrome_switches.h" -#include "chrome/common/main_function_params.h" #include "chrome/ppapi_plugin/ppapi_thread.h" #include "content/common/child_process.h" +#include "content/common/main_function_params.h" // Main function for starting the PPAPI plugin process. int PpapiPluginMain(const MainFunctionParams& parameters) { diff --git a/chrome/profile_import/profile_import_main.cc b/chrome/profile_import/profile_import_main.cc index 037ea22..9b07737 100644 --- a/chrome/profile_import/profile_import_main.cc +++ b/chrome/profile_import/profile_import_main.cc @@ -8,9 +8,9 @@ #include "base/threading/platform_thread.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/logging_chrome.h" -#include "chrome/common/main_function_params.h" #include "chrome/profile_import/profile_import_thread.h" #include "content/common/child_process.h" +#include "content/common/main_function_params.h" // Mainline routine for running as the profile import process. int ProfileImportMain(const MainFunctionParams& parameters) { diff --git a/chrome/renderer/renderer_main.cc b/chrome/renderer/renderer_main.cc index 7ac5760..985350b 100644 --- a/chrome/renderer/renderer_main.cc +++ b/chrome/renderer/renderer_main.cc @@ -25,12 +25,12 @@ #include "chrome/common/gfx_resource_provider.h" #include "chrome/common/hi_res_timer_manager.h" #include "chrome/common/logging_chrome.h" -#include "chrome/common/main_function_params.h" #include "chrome/common/net/net_resource_provider.h" #include "chrome/common/pepper_plugin_registry.h" #include "chrome/renderer/renderer_main_platform_delegate.h" #include "chrome/renderer/render_process_impl.h" #include "chrome/renderer/render_thread.h" +#include "content/common/main_function_params.h" #include "grit/generated_resources.h" #include "net/base/net_module.h" #include "ui/base/system_monitor/system_monitor.h" diff --git a/chrome/renderer/renderer_main_platform_delegate.h b/chrome/renderer/renderer_main_platform_delegate.h index 9a8b38b..c57e90e 100644 --- a/chrome/renderer/renderer_main_platform_delegate.h +++ b/chrome/renderer/renderer_main_platform_delegate.h @@ -6,7 +6,7 @@ #define CHROME_RENDERER_RENDERER_MAIN_PLATFORM_DELEGATE_H_ #pragma once -#include "chrome/common/main_function_params.h" +#include "content/common/main_function_params.h" class RendererMainPlatformDelegate { public: diff --git a/chrome/renderer/renderer_main_platform_delegate_mac.mm b/chrome/renderer/renderer_main_platform_delegate_mac.mm index 4da959e..d3ac431 100644 --- a/chrome/renderer/renderer_main_platform_delegate_mac.mm +++ b/chrome/renderer/renderer_main_platform_delegate_mac.mm @@ -7,9 +7,9 @@ #import <Cocoa/Cocoa.h> #include "base/command_line.h" -#import "chrome/common/chrome_application_mac.h" #include "chrome/common/chrome_switches.h" -#include "chrome/common/sandbox_mac.h" +#import "content/common/chrome_application_mac.h" +#include "content/common/sandbox_mac.h" #include "third_party/WebKit/Source/WebKit/mac/WebCoreSupport/WebSystemInterface.h" RendererMainPlatformDelegate::RendererMainPlatformDelegate( diff --git a/chrome/renderer/renderer_main_unittest.cc b/chrome/renderer/renderer_main_unittest.cc index 653e02f..ad26a78 100644 --- a/chrome/renderer/renderer_main_unittest.cc +++ b/chrome/renderer/renderer_main_unittest.cc @@ -8,7 +8,7 @@ #include "base/test/multiprocess_test.h" #include "base/test/test_timeouts.h" #include "chrome/common/chrome_switches.h" -#include "chrome/common/main_function_params.h" +#include "content/common/main_function_params.h" #include "ipc/ipc_channel.h" #include "ipc/ipc_switches.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/chrome/renderer/renderer_webkitclient_impl.cc b/chrome/renderer/renderer_webkitclient_impl.cc index ae149a6..542bb21 100644 --- a/chrome/renderer/renderer_webkitclient_impl.cc +++ b/chrome/renderer/renderer_webkitclient_impl.cc @@ -50,8 +50,8 @@ #endif #if defined(OS_MACOSX) -#include "chrome/common/font_descriptor_mac.h" -#include "chrome/common/font_loader_mac.h" +#include "content/common/font_descriptor_mac.h" +#include "content/common/font_loader_mac.h" #include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebSandboxSupport.h" #endif diff --git a/chrome/renderer/safe_browsing/render_view_fake_resources_test.cc b/chrome/renderer/safe_browsing/render_view_fake_resources_test.cc index 06c6164..b6aa02f 100644 --- a/chrome/renderer/safe_browsing/render_view_fake_resources_test.cc +++ b/chrome/renderer/safe_browsing/render_view_fake_resources_test.cc @@ -10,16 +10,16 @@ #include "base/process.h" #include "base/shared_memory.h" #include "chrome/common/dom_storage_common.h" -#include "chrome/common/main_function_params.h" #include "chrome/common/render_messages.h" #include "chrome/common/render_messages_params.h" -#include "chrome/common/sandbox_init_wrapper.h" #include "chrome/renderer/mock_render_process.h" #include "chrome/renderer/render_thread.h" #include "chrome/renderer/render_view.h" #include "chrome/renderer/renderer_main_platform_delegate.h" +#include "content/common/main_function_params.h" #include "content/common/resource_messages.h" #include "content/common/resource_response.h" +#include "content/common/sandbox_init_wrapper.h" #include "googleurl/src/gurl.h" #include "net/base/upload_data.h" #include "net/http/http_response_headers.h" diff --git a/chrome/service/service_main.cc b/chrome/service/service_main.cc index 86d3de1..b87f510 100644 --- a/chrome/service/service_main.cc +++ b/chrome/service/service_main.cc @@ -5,14 +5,14 @@ #include "base/debug/debugger.h" #include "base/message_loop.h" #include "chrome/common/chrome_switches.h" -#include "chrome/common/main_function_params.h" #include "chrome/common/service_process_util.h" #include "chrome/service/service_process.h" +#include "content/common/main_function_params.h" #if defined(OS_WIN) #include "chrome/common/sandbox_policy.h" #elif defined(OS_MACOSX) -#include "chrome/common/chrome_application_mac.h" +#include "content/common/chrome_application_mac.h" #endif // defined(OS_WIN) // Mainline routine for running as the service process. diff --git a/chrome/test/automation/proxy_launcher.cc b/chrome/test/automation/proxy_launcher.cc index e6cd724..baeff496 100644 --- a/chrome/test/automation/proxy_launcher.cc +++ b/chrome/test/automation/proxy_launcher.cc @@ -17,7 +17,6 @@ #include "chrome/common/automation_constants.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_switches.h" -#include "chrome/common/debug_flags.h" #include "chrome/common/logging_chrome.h" #include "chrome/common/url_constants.h" #include "chrome/test/chrome_process_util.h" @@ -26,6 +25,7 @@ #include "chrome/test/automation/automation_proxy.h" #include "chrome/test/ui/ui_test.h" #include "content/common/child_process_info.h" +#include "content/common/debug_flags.h" namespace { diff --git a/chrome/test/in_process_browser_test.cc b/chrome/test/in_process_browser_test.cc index 21790c3..0fda2e5 100644 --- a/chrome/test/in_process_browser_test.cc +++ b/chrome/test/in_process_browser_test.cc @@ -27,7 +27,6 @@ #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/logging_chrome.h" -#include "chrome/common/main_function_params.h" #include "chrome/common/url_constants.h" #include "chrome/test/test_launcher_utils.h" #include "chrome/test/testing_browser_process.h" @@ -35,6 +34,7 @@ #include "content/browser/browser_thread.h" #include "content/browser/renderer_host/render_process_host.h" #include "content/browser/tab_contents/tab_contents.h" +#include "content/common/main_function_params.h" #include "content/common/notification_type.h" #include "net/base/mock_host_resolver.h" #include "net/test/test_server.h" diff --git a/chrome/test/render_view_test.h b/chrome/test/render_view_test.h index 96e9c77..c83a8d4 100644 --- a/chrome/test/render_view_test.h +++ b/chrome/test/render_view_test.h @@ -10,14 +10,14 @@ #include "base/command_line.h" #include "base/scoped_ptr.h" -#include "chrome/common/main_function_params.h" #include "chrome/common/native_web_keyboard_event.h" -#include "chrome/common/sandbox_init_wrapper.h" #include "chrome/renderer/mock_keyboard.h" #include "chrome/renderer/mock_render_thread.h" #include "chrome/renderer/render_view.h" #include "chrome/renderer/renderer_main_platform_delegate.h" #include "chrome/renderer/renderer_webkitclient_impl.h" +#include "content/common/main_function_params.h" +#include "content/common/sandbox_init_wrapper.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc index 2424006..11314fe 100644 --- a/chrome/test/ui/ui_test.cc +++ b/chrome/test/ui/ui_test.cc @@ -36,7 +36,6 @@ #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" -#include "chrome/common/debug_flags.h" #include "chrome/common/logging_chrome.h" #include "chrome/common/json_value_serializer.h" #include "chrome/common/url_constants.h" @@ -49,6 +48,7 @@ #include "chrome/test/chrome_process_util.h" #include "chrome/test/test_launcher_utils.h" #include "chrome/test/test_switches.h" +#include "content/common/debug_flags.h" #include "googleurl/src/gurl.h" #include "net/base/net_util.h" diff --git a/chrome/test/unit/chrome_test_suite.cc b/chrome/test/unit/chrome_test_suite.cc index 28f55e7..d6860ca 100644 --- a/chrome/test/unit/chrome_test_suite.cc +++ b/chrome/test/unit/chrome_test_suite.cc @@ -23,7 +23,7 @@ #if defined(OS_MACOSX) #include "base/mac/mac_util.h" -#include "chrome/common/chrome_application_mac.h" +#include "content/common/chrome_application_mac.h" #endif #if defined(OS_POSIX) diff --git a/chrome/utility/utility_main.cc b/chrome/utility/utility_main.cc index 2a45459..ef84260 100644 --- a/chrome/utility/utility_main.cc +++ b/chrome/utility/utility_main.cc @@ -14,15 +14,15 @@ #include "chrome/common/extensions/extension_l10n_util.h" #include "chrome/common/hi_res_timer_manager.h" #include "chrome/common/logging_chrome.h" -#include "chrome/common/main_function_params.h" #include "chrome/utility/utility_thread.h" #include "content/common/child_process.h" +#include "content/common/main_function_params.h" #include "ui/base/system_monitor/system_monitor.h" #include "ui/base/ui_base_switches.h" #if defined(OS_WIN) #include "chrome/common/chrome_switches.h" -#include "chrome/common/sandbox_init_wrapper.h" +#include "content/common/sandbox_init_wrapper.h" #include "sandbox/src/sandbox.h" #endif // defined(OS_WIN) diff --git a/chrome/worker/worker_main.cc b/chrome/worker/worker_main.cc index 1c7b831..83bb4a2 100644 --- a/chrome/worker/worker_main.cc +++ b/chrome/worker/worker_main.cc @@ -10,13 +10,13 @@ #include "chrome/common/chrome_switches.h" #include "chrome/common/hi_res_timer_manager.h" #include "chrome/common/logging_chrome.h" -#include "chrome/common/main_function_params.h" #include "chrome/worker/worker_thread.h" #include "content/common/child_process.h" +#include "content/common/main_function_params.h" #include "ui/base/system_monitor/system_monitor.h" #if defined(OS_WIN) -#include "chrome/common/sandbox_init_wrapper.h" +#include "content/common/sandbox_init_wrapper.h" #include "sandbox/src/sandbox.h" #endif |