1 // Copyright (c) 2012 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.
5 #include "win8/delegate_execute/delegate_execute_operation.h"
7 #include "base/command_line.h"
8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/string_split.h"
10 #include "chrome/common/chrome_switches.h"
11 #include "win8/delegate_execute/delegate_execute_util.h"
13 namespace delegate_execute
{
15 DelegateExecuteOperation::DelegateExecuteOperation()
16 : operation_type_(DELEGATE_EXECUTE
) {
19 DelegateExecuteOperation::~DelegateExecuteOperation() {
22 bool DelegateExecuteOperation::Init(const CommandLine
* cmd_line
) {
23 base::FilePath
shortcut(
24 cmd_line
->GetSwitchValuePath(switches::kRelaunchShortcut
));
25 if (shortcut
.empty()) {
26 operation_type_
= DELEGATE_EXECUTE
;
29 relaunch_shortcut_
= shortcut
;
30 mutex_
= cmd_line
->GetSwitchValueNative(switches::kWaitForMutex
);
33 // Add the mode forcing flags, if any.
34 const char* the_switch
= NULL
;
36 if (cmd_line
->HasSwitch(switches::kForceDesktop
))
37 the_switch
= switches::kForceDesktop
;
38 else if (cmd_line
->HasSwitch(switches::kForceImmersive
))
39 the_switch
= switches::kForceImmersive
;
41 relaunch_flags_
= ParametersFromSwitch(the_switch
);
43 operation_type_
= RELAUNCH_CHROME
;
47 DWORD
DelegateExecuteOperation::GetParentPid() const {
48 std::vector
<base::string16
> parts
;
49 base::SplitString(mutex_
, L
'.', &parts
);
50 if (parts
.size() != 3)
53 if (!base::StringToUint(parts
[2], reinterpret_cast<uint32
*>(&pid
)))
58 } // namespace delegate_execute