[email protected] | d1e2779 | 2009-10-15 02:22:58 | [diff] [blame] | 1 | // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CHROME_FRAME_CHROME_LAUNCHER_H_ |
| 6 | #define CHROME_FRAME_CHROME_LAUNCHER_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | |
[email protected] | 79b663c | 2010-05-28 17:27:17 | [diff] [blame] | 10 | // arraysize macro shamelessly stolen from base\basictypes.h |
| 11 | template <typename T, size_t N> |
| 12 | char (&ArraySizeHelper(T (&array)[N]))[N]; |
[email protected] | 66ff735 | 2009-10-15 05:09:50 | [diff] [blame] | 13 | |
[email protected] | 79b663c | 2010-05-28 17:27:17 | [diff] [blame] | 14 | #define arraysize(array) (sizeof(ArraySizeHelper(array))) |
[email protected] | d1e2779 | 2009-10-15 02:22:58 | [diff] [blame] | 15 | |
| 16 | namespace chrome_launcher { |
| 17 | |
| 18 | // The base name of the chrome_launcher.exe file. |
| 19 | extern const wchar_t kLauncherExeBaseName[]; |
| 20 | |
[email protected] | 79b663c | 2010-05-28 17:27:17 | [diff] [blame] | 21 | // Returns true if command_line contains only flags that we allow through. |
| 22 | // Returns false if command_line contains any unrecognized flags. |
| 23 | bool IsValidCommandLine(const wchar_t* command_line); |
[email protected] | d1e2779 | 2009-10-15 02:22:58 | [diff] [blame] | 24 | |
| 25 | // Given a command-line without an initial program part, launch our associated |
[email protected] | 66ff735 | 2009-10-15 05:09:50 | [diff] [blame] | 26 | // chrome.exe with a sanitized version of that command line. Returns true iff |
[email protected] | d1e2779 | 2009-10-15 02:22:58 | [diff] [blame] | 27 | // successful. |
| 28 | bool SanitizeAndLaunchChrome(const wchar_t* command_line); |
| 29 | |
[email protected] | 79b663c | 2010-05-28 17:27:17 | [diff] [blame] | 30 | // Returns a pointer to the position in command_line the string right after the |
| 31 | // name of the executable. This is equivalent to the second element of the |
| 32 | // array returned by CommandLineToArgvW. Returns NULL if there are no further |
| 33 | // arguments. |
| 34 | const wchar_t* GetArgumentsStart(const wchar_t* command_line); |
[email protected] | d1e2779 | 2009-10-15 02:22:58 | [diff] [blame] | 35 | |
[email protected] | 79b663c | 2010-05-28 17:27:17 | [diff] [blame] | 36 | // Returns the full path to the Chrome executable. |
| 37 | bool GetChromeExecutablePath(std::wstring* chrome_path); |
| 38 | |
| 39 | // Returns whether a given argument is considered a valid flag. Only accepts |
| 40 | // flags of the forms: |
| 41 | // --foo |
| 42 | // --foo=bar |
| 43 | bool IsValidArgument(const std::wstring& argument); |
| 44 | |
| 45 | // Returns a string that is equivalent in input_str without any leading |
| 46 | // or trailing whitespace. Returns an empty string if input_str contained only |
| 47 | // whitespace. |
| 48 | std::wstring TrimWhiteSpace(const wchar_t* input_str); |
[email protected] | d1e2779 | 2009-10-15 02:22:58 | [diff] [blame] | 49 | |
| 50 | } // namespace chrome_launcher |
| 51 | |
| 52 | #endif // CHROME_FRAME_CHROME_LAUNCHER_H_ |