blob: da2540e3def7e5c200acd6d5758c4ec054fbb75e [file] [log] [blame]
[email protected]d1e27792009-10-15 02:22:581// 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]79b663c2010-05-28 17:27:1710// arraysize macro shamelessly stolen from base\basictypes.h
11template <typename T, size_t N>
12char (&ArraySizeHelper(T (&array)[N]))[N];
[email protected]66ff7352009-10-15 05:09:5013
[email protected]79b663c2010-05-28 17:27:1714#define arraysize(array) (sizeof(ArraySizeHelper(array)))
[email protected]d1e27792009-10-15 02:22:5815
16namespace chrome_launcher {
17
18// The base name of the chrome_launcher.exe file.
19extern const wchar_t kLauncherExeBaseName[];
20
[email protected]79b663c2010-05-28 17:27:1721// Returns true if command_line contains only flags that we allow through.
22// Returns false if command_line contains any unrecognized flags.
23bool IsValidCommandLine(const wchar_t* command_line);
[email protected]d1e27792009-10-15 02:22:5824
25// Given a command-line without an initial program part, launch our associated
[email protected]66ff7352009-10-15 05:09:5026// chrome.exe with a sanitized version of that command line. Returns true iff
[email protected]d1e27792009-10-15 02:22:5827// successful.
28bool SanitizeAndLaunchChrome(const wchar_t* command_line);
29
[email protected]79b663c2010-05-28 17:27:1730// 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.
34const wchar_t* GetArgumentsStart(const wchar_t* command_line);
[email protected]d1e27792009-10-15 02:22:5835
[email protected]79b663c2010-05-28 17:27:1736// Returns the full path to the Chrome executable.
37bool 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
43bool 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.
48std::wstring TrimWhiteSpace(const wchar_t* input_str);
[email protected]d1e27792009-10-15 02:22:5849
50} // namespace chrome_launcher
51
52#endif // CHROME_FRAME_CHROME_LAUNCHER_H_