OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "win8/delegate_execute/delegate_execute_operation.h" | 5 #include "win8/delegate_execute/delegate_execute_operation.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
| 10 #include "base/win/windows_version.h" |
10 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
11 #include "win8/delegate_execute/delegate_execute_util.h" | 12 #include "win8/delegate_execute/delegate_execute_util.h" |
12 | 13 |
13 namespace delegate_execute { | 14 namespace delegate_execute { |
14 | 15 |
15 DelegateExecuteOperation::DelegateExecuteOperation() | 16 DelegateExecuteOperation::DelegateExecuteOperation() |
16 : operation_type_(DELEGATE_EXECUTE) { | 17 : operation_type_(DELEGATE_EXECUTE) { |
17 } | 18 } |
18 | 19 |
19 DelegateExecuteOperation::~DelegateExecuteOperation() { | 20 DelegateExecuteOperation::~DelegateExecuteOperation() { |
20 } | 21 } |
21 | 22 |
22 bool DelegateExecuteOperation::Init(const CommandLine* cmd_line) { | 23 bool DelegateExecuteOperation::Init(const CommandLine* cmd_line) { |
23 base::FilePath shortcut( | 24 if (base::win::GetVersion() >= base::win::VERSION_WIN7) { |
24 cmd_line->GetSwitchValuePath(switches::kRelaunchShortcut)); | 25 base::FilePath shortcut( |
25 if (shortcut.empty()) { | 26 cmd_line->GetSwitchValuePath(switches::kRelaunchShortcut)); |
26 operation_type_ = DELEGATE_EXECUTE; | 27 // On Windows 7 the command line coming in may not have a path to the |
27 return true; | 28 // shortcut to launch Chrome. We ignore the shortcut and just do a regular |
| 29 // ShellExecute of chrome.exe in this case. |
| 30 if (shortcut.empty() && |
| 31 base::win::GetVersion() >= base::win::VERSION_WIN8) { |
| 32 operation_type_ = DELEGATE_EXECUTE; |
| 33 return true; |
| 34 } |
| 35 relaunch_shortcut_ = shortcut; |
28 } | 36 } |
29 relaunch_shortcut_ = shortcut; | |
30 mutex_ = cmd_line->GetSwitchValueNative(switches::kWaitForMutex); | 37 mutex_ = cmd_line->GetSwitchValueNative(switches::kWaitForMutex); |
31 if (mutex_.empty()) | 38 if (mutex_.empty()) |
32 return false; | 39 return false; |
33 // Add the mode forcing flags, if any. | 40 // Add the mode forcing flags, if any. |
34 const char* the_switch = NULL; | 41 const char* the_switch = NULL; |
35 | 42 |
36 if (cmd_line->HasSwitch(switches::kForceDesktop)) | 43 if (cmd_line->HasSwitch(switches::kForceDesktop)) |
37 the_switch = switches::kForceDesktop; | 44 the_switch = switches::kForceDesktop; |
38 else if (cmd_line->HasSwitch(switches::kForceImmersive)) | 45 else if (cmd_line->HasSwitch(switches::kForceImmersive)) |
39 the_switch = switches::kForceImmersive; | 46 the_switch = switches::kForceImmersive; |
40 | 47 |
41 relaunch_flags_ = ParametersFromSwitch(the_switch); | 48 relaunch_flags_ = ParametersFromSwitch(the_switch); |
42 | 49 |
43 operation_type_ = RELAUNCH_CHROME; | 50 operation_type_ = RELAUNCH_CHROME; |
44 return true; | 51 return true; |
45 } | 52 } |
46 | 53 |
47 DWORD DelegateExecuteOperation::GetParentPid() const { | 54 DWORD DelegateExecuteOperation::GetParentPid() const { |
48 std::vector<base::string16> parts; | 55 std::vector<base::string16> parts; |
49 base::SplitString(mutex_, L'.', &parts); | 56 base::SplitString(mutex_, L'.', &parts); |
50 if (parts.size() != 3) | 57 if (parts.size() != 3) |
51 return 0; | 58 return 0; |
52 DWORD pid; | 59 DWORD pid; |
53 if (!base::StringToUint(parts[2], reinterpret_cast<uint32*>(&pid))) | 60 if (!base::StringToUint(parts[2], reinterpret_cast<uint32*>(&pid))) |
54 return 0; | 61 return 0; |
55 return pid; | 62 return pid; |
56 } | 63 } |
57 | 64 |
58 } // namespace delegate_execute | 65 } // namespace delegate_execute |
OLD | NEW |