Home | History | Annotate | Download | only in chrome_frame
      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 
     10 // arraysize macro shamelessly stolen from base\basictypes.h
     11 template <typename T, size_t N>
     12 char (&ArraySizeHelper(T (&array)[N]))[N];
     13 
     14 #define arraysize(array) (sizeof(ArraySizeHelper(array)))
     15 
     16 namespace chrome_launcher {
     17 
     18 // The base name of the chrome_launcher.exe file.
     19 extern const wchar_t kLauncherExeBaseName[];
     20 
     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);
     24 
     25 // Given a command-line without an initial program part, launch our associated
     26 // chrome.exe with a sanitized version of that command line. Returns true iff
     27 // successful.
     28 bool SanitizeAndLaunchChrome(const wchar_t* command_line);
     29 
     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);
     35 
     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);
     49 
     50 }  // namespace chrome_launcher
     51 
     52 #endif  // CHROME_FRAME_CHROME_LAUNCHER_H_
     53