diff options
author | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-28 17:27:17 +0000 |
---|---|---|
committer | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-28 17:27:17 +0000 |
commit | 79b663c6e6ddf89e85cdc566b5d4f368465bb858 (patch) | |
tree | 868c35191ee02c8bd7da15b69edc7114007e211a /chrome_frame/chrome_launcher.h | |
parent | 84b5647e4a43a55b9b0e8b211684f48222569218 (diff) | |
download | chromium_src-79b663c6e6ddf89e85cdc566b5d4f368465bb858.zip chromium_src-79b663c6e6ddf89e85cdc566b5d4f368465bb858.tar.gz chromium_src-79b663c6e6ddf89e85cdc566b5d4f368465bb858.tar.bz2 |
Rewrite of chrome_launcher.exe. ETW-based perf tests suggest that this is on average about 50% faster than the previous version.
Review URL: http://codereview.chromium.org/2278003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48500 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/chrome_launcher.h')
-rw-r--r-- | chrome_frame/chrome_launcher.h | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/chrome_frame/chrome_launcher.h b/chrome_frame/chrome_launcher.h index 86dc03f..da2540e 100644 --- a/chrome_frame/chrome_launcher.h +++ b/chrome_frame/chrome_launcher.h @@ -7,40 +7,45 @@ #include <string> -#include "base/file_path.h" +// arraysize macro shamelessly stolen from base\basictypes.h +template <typename T, size_t N> +char (&ArraySizeHelper(T (&array)[N]))[N]; -class CommandLine; +#define arraysize(array) (sizeof(ArraySizeHelper(array))) namespace chrome_launcher { // The base name of the chrome_launcher.exe file. extern const wchar_t kLauncherExeBaseName[]; -// Creates a command line suitable for launching Chrome. You can add any -// flags needed before launching. -// -// The command-line may use the Chrome executable directly, or use an in-between -// process if needed for security/elevation purposes. You must delete the -// returned command line. -CommandLine* CreateLaunchCommandLine(); - -// Fills in a new command line from the flags on this process's command line -// that we are allowing Low Integrity to invoke. -// -// Logs a warning for any flags that were passed that are not allowed to be -// invoked by Low Integrity. -void SanitizeCommandLine(const CommandLine& original, CommandLine* sanitized); +// Returns true if command_line contains only flags that we allow through. +// Returns false if command_line contains any unrecognized flags. +bool IsValidCommandLine(const wchar_t* command_line); // Given a command-line without an initial program part, launch our associated // chrome.exe with a sanitized version of that command line. Returns true iff // successful. bool SanitizeAndLaunchChrome(const wchar_t* command_line); -// Returns the full path to the Chrome executable. -FilePath GetChromeExecutablePath(); +// Returns a pointer to the position in command_line the string right after the +// name of the executable. This is equivalent to the second element of the +// array returned by CommandLineToArgvW. Returns NULL if there are no further +// arguments. +const wchar_t* GetArgumentsStart(const wchar_t* command_line); -// The type of the CfLaunchChrome entrypoint exported from this DLL. -typedef int (__stdcall *CfLaunchChromeProc)(); +// Returns the full path to the Chrome executable. +bool GetChromeExecutablePath(std::wstring* chrome_path); + +// Returns whether a given argument is considered a valid flag. Only accepts +// flags of the forms: +// --foo +// --foo=bar +bool IsValidArgument(const std::wstring& argument); + +// Returns a string that is equivalent in input_str without any leading +// or trailing whitespace. Returns an empty string if input_str contained only +// whitespace. +std::wstring TrimWhiteSpace(const wchar_t* input_str); } // namespace chrome_launcher |