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 "chrome/browser/first_run/upgrade_util.h" | 5 #include "chrome/browser/first_run/upgrade_util.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/base_paths.h" | 10 #include "base/base_paths.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 98 |
99 // Having just ascertained that we can swap, now check that we should: if | 99 // Having just ascertained that we can swap, now check that we should: if |
100 // we are given an explicit --chrome-version flag, don't rename unless the | 100 // we are given an explicit --chrome-version flag, don't rename unless the |
101 // specified version matches the "pv" value. In practice, this is used to | 101 // specified version matches the "pv" value. In practice, this is used to |
102 // defer Chrome Frame updates until the current version of the Chrome Frame | 102 // defer Chrome Frame updates until the current version of the Chrome Frame |
103 // DLL component is loaded. | 103 // DLL component is loaded. |
104 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); | 104 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); |
105 if (cmd_line.HasSwitch(switches::kChromeVersion)) { | 105 if (cmd_line.HasSwitch(switches::kChromeVersion)) { |
106 std::string version_string = | 106 std::string version_string = |
107 cmd_line.GetSwitchValueASCII(switches::kChromeVersion); | 107 cmd_line.GetSwitchValueASCII(switches::kChromeVersion); |
108 scoped_ptr<Version> cmd_version( | 108 Version cmd_version(version_string); |
109 Version::GetVersionFromString(version_string)); | |
110 | 109 |
111 std::wstring pv_value; | 110 std::wstring pv_value; |
112 if (key.ReadValue(google_update::kRegVersionField, | 111 if (key.ReadValue(google_update::kRegVersionField, |
113 &pv_value) == ERROR_SUCCESS) { | 112 &pv_value) == ERROR_SUCCESS) { |
114 scoped_ptr<Version> pv_version( | 113 Version pv_version(WideToASCII(pv_value)); |
115 Version::GetVersionFromString(WideToASCII(pv_value))); | 114 if (cmd_version.IsValid() && pv_version.IsValid() && |
116 if (cmd_version.get() && pv_version.get() && | 115 !cmd_version.Equals(pv_version)) { |
117 !cmd_version->Equals(*pv_version.get())) { | |
118 return false; | 116 return false; |
119 } | 117 } |
120 } | 118 } |
121 } | 119 } |
122 | 120 |
123 // First try to rename exe by launching rename command ourselves. | 121 // First try to rename exe by launching rename command ourselves. |
124 std::wstring rename_cmd; | 122 std::wstring rename_cmd; |
125 if (key.ReadValue(google_update::kRegRenameCmdField, | 123 if (key.ReadValue(google_update::kRegRenameCmdField, |
126 &rename_cmd) == ERROR_SUCCESS) { | 124 &rename_cmd) == ERROR_SUCCESS) { |
127 base::ProcessHandle handle; | 125 base::ProcessHandle handle; |
(...skipping 24 matching lines...) Expand all Loading... |
152 return false; | 150 return false; |
153 // At this point the chrome.exe has been swapped with the new one. | 151 // At this point the chrome.exe has been swapped with the new one. |
154 if (!RelaunchChromeBrowser(command_line)) { | 152 if (!RelaunchChromeBrowser(command_line)) { |
155 // The re-launch fails. Feel free to panic now. | 153 // The re-launch fails. Feel free to panic now. |
156 NOTREACHED(); | 154 NOTREACHED(); |
157 } | 155 } |
158 return true; | 156 return true; |
159 } | 157 } |
160 | 158 |
161 } // namespace upgrade_util | 159 } // namespace upgrade_util |
OLD | NEW |