summaryrefslogtreecommitdiffstats
path: root/win8/delegate_execute/delegate_execute_operation.h
blob: 3fc1b00a8b6fba139ea8a2a5c512cc551693025c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Copyright (c) 2012 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 WIN8_DELEGATE_EXECUTE_DELEGATE_EXECUTE_OPERATION_H_
#define WIN8_DELEGATE_EXECUTE_DELEGATE_EXECUTE_OPERATION_H_

#include <atldef.h>
#include <windows.h>

#include "base/basictypes.h"
#include "base/file_path.h"
#include "base/string16.h"

class CommandLine;

namespace delegate_execute {

// Parses a portion of the DelegateExecute handler's command line to determine
// the desired operation. The operation type is decided by looking at the
// command line. The operations are:
// DELEGATE_EXECUTE:
//   When the delegate_execute.exe is invoked by windows when a chrome
//   activation via the shell, possibly using ShellExecute. Control must
//   be given to ATLs WinMain.
// RELAUNCH_CHROME:
//   When the delegate_execute.exe is launched by chrome, when chrome needs
//   to re-launch itself. The required command line parameters are:
//     --relaunch-shortcut=<PathToShortcut>
//     --wait-for-mutex=<MutexNamePid>
//   The PathToShortcut must be the fully qualified file name to the chrome
//   shortcut that has the appId and other 'metro ready' parameters.
//   The MutexNamePid is a mutex name that also encodes the process id and
//   must follow the format <A>.<B>.<pid> where A and B are arbitray strings
//   (usually chrome.relaunch) and pid is the process id of chrome.
class DelegateExecuteOperation {
 public:
  enum OperationType {
    DELEGATE_EXECUTE,
    RELAUNCH_CHROME,
  };

  DelegateExecuteOperation();
  ~DelegateExecuteOperation();

  bool Init(const CommandLine* cmd_line);

  OperationType operation_type() const {
    return operation_type_;
  }

  const string16& relaunch_flags() const {
    return relaunch_flags_;
  }

  const string16& mutex() const {
    return mutex_;
  }

  // Returns the process id of the parent or 0 on failure.
  DWORD GetParentPid() const;

  const FilePath& shortcut() const {
    return relaunch_shortcut_;
  }

 private:
  OperationType operation_type_;
  string16 relaunch_flags_;
  FilePath relaunch_shortcut_;
  string16 mutex_;

  DISALLOW_COPY_AND_ASSIGN(DelegateExecuteOperation);
};

}  // namespace delegate_execute

#endif  // WIN8_DELEGATE_EXECUTE_DELEGATE_EXECUTE_OPERATION_H_