OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // This file defines functions that integrate Chrome in Windows shell. These | 5 // This file defines functions that integrate Chrome in Windows shell. These |
6 // functions can be used by Chrome as well as Chrome installer. All of the | 6 // functions can be used by Chrome as well as Chrome installer. All of the |
7 // work is done by the local functions defined in anonymous namespace in | 7 // work is done by the local functions defined in anonymous namespace in |
8 // this class. | 8 // this class. |
9 | 9 |
10 #include "chrome/installer/util/shell_util.h" | 10 #include "chrome/installer/util/shell_util.h" |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 | 299 |
300 // This method registers Chrome on Vista by launching an elevated setup.exe. | 300 // This method registers Chrome on Vista by launching an elevated setup.exe. |
301 // That will show the user the standard Vista elevation prompt. If the user | 301 // That will show the user the standard Vista elevation prompt. If the user |
302 // accepts it the new process will make the necessary changes and return SUCCESS | 302 // accepts it the new process will make the necessary changes and return SUCCESS |
303 // that we capture and return. | 303 // that we capture and return. |
304 bool ElevateAndRegisterChrome(BrowserDistribution* dist, | 304 bool ElevateAndRegisterChrome(BrowserDistribution* dist, |
305 const std::wstring& chrome_exe, | 305 const std::wstring& chrome_exe, |
306 const std::wstring& suffix) { | 306 const std::wstring& suffix) { |
307 FilePath exe_path = | 307 FilePath exe_path = |
308 FilePath::FromWStringHack(chrome_exe).DirName() | 308 FilePath::FromWStringHack(chrome_exe).DirName() |
309 .Append(installer_util::kSetupExe); | 309 .Append(installer::kSetupExe); |
310 if (!file_util::PathExists(exe_path)) { | 310 if (!file_util::PathExists(exe_path)) { |
311 HKEY reg_root = InstallUtil::IsPerUserInstall(chrome_exe.c_str()) ? | 311 HKEY reg_root = InstallUtil::IsPerUserInstall(chrome_exe.c_str()) ? |
312 HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; | 312 HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; |
313 RegKey key(reg_root, dist->GetUninstallRegPath().c_str(), KEY_READ); | 313 RegKey key(reg_root, dist->GetUninstallRegPath().c_str(), KEY_READ); |
314 std::wstring uninstall_string; | 314 std::wstring uninstall_string; |
315 key.ReadValue(installer_util::kUninstallStringField, &uninstall_string); | 315 key.ReadValue(installer::kUninstallStringField, &uninstall_string); |
316 CommandLine command_line = CommandLine::FromString(uninstall_string); | 316 CommandLine command_line = CommandLine::FromString(uninstall_string); |
317 exe_path = command_line.GetProgram(); | 317 exe_path = command_line.GetProgram(); |
318 } | 318 } |
319 | 319 |
320 if (file_util::PathExists(exe_path)) { | 320 if (file_util::PathExists(exe_path)) { |
321 CommandLine cmd(exe_path); | 321 CommandLine cmd(exe_path); |
322 cmd.AppendSwitchNative(installer_util::switches::kRegisterChromeBrowser, | 322 cmd.AppendSwitchNative(installer::switches::kRegisterChromeBrowser, |
323 chrome_exe); | 323 chrome_exe); |
324 if (!suffix.empty()) { | 324 if (!suffix.empty()) { |
325 cmd.AppendSwitchNative( | 325 cmd.AppendSwitchNative( |
326 installer_util::switches::kRegisterChromeBrowserSuffix, suffix); | 326 installer::switches::kRegisterChromeBrowserSuffix, suffix); |
327 } | 327 } |
328 | 328 |
329 CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 329 CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
330 if (browser_command_line.HasSwitch(switches::kChromeFrame)) { | 330 if (browser_command_line.HasSwitch(switches::kChromeFrame)) { |
331 cmd.AppendSwitch(installer_util::switches::kChromeFrame); | 331 cmd.AppendSwitch(installer::switches::kChromeFrame); |
332 } | 332 } |
333 | 333 |
334 DWORD ret_val = 0; | 334 DWORD ret_val = 0; |
335 InstallUtil::ExecuteExeAsAdmin(cmd, &ret_val); | 335 InstallUtil::ExecuteExeAsAdmin(cmd, &ret_val); |
336 if (ret_val == 0) | 336 if (ret_val == 0) |
337 return true; | 337 return true; |
338 } | 338 } |
339 return false; | 339 return false; |
340 } | 340 } |
341 | 341 |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
781 } | 781 } |
782 | 782 |
783 bool ShellUtil::UpdateChromeShortcut(BrowserDistribution* dist, | 783 bool ShellUtil::UpdateChromeShortcut(BrowserDistribution* dist, |
784 const std::wstring& chrome_exe, | 784 const std::wstring& chrome_exe, |
785 const std::wstring& shortcut, | 785 const std::wstring& shortcut, |
786 const std::wstring& description, | 786 const std::wstring& description, |
787 bool create_new) { | 787 bool create_new) { |
788 std::wstring chrome_path = file_util::GetDirectoryFromPath(chrome_exe); | 788 std::wstring chrome_path = file_util::GetDirectoryFromPath(chrome_exe); |
789 | 789 |
790 FilePath prefs_path(chrome_path); | 790 FilePath prefs_path(chrome_path); |
791 prefs_path = prefs_path.AppendASCII(installer_util::kDefaultMasterPrefs); | 791 prefs_path = prefs_path.AppendASCII(installer::kDefaultMasterPrefs); |
792 installer_util::MasterPreferences prefs(prefs_path); | 792 installer::MasterPreferences prefs(prefs_path); |
793 int icon_index = dist->GetIconIndex(); | 793 int icon_index = dist->GetIconIndex(); |
794 prefs.GetInt(installer_util::master_preferences::kChromeShortcutIconIndex, | 794 prefs.GetInt(installer::master_preferences::kChromeShortcutIconIndex, |
795 &icon_index); | 795 &icon_index); |
796 if (create_new) { | 796 if (create_new) { |
797 return file_util::CreateShortcutLink( | 797 return file_util::CreateShortcutLink( |
798 chrome_exe.c_str(), // target | 798 chrome_exe.c_str(), // target |
799 shortcut.c_str(), // shortcut | 799 shortcut.c_str(), // shortcut |
800 chrome_path.c_str(), // working dir | 800 chrome_path.c_str(), // working dir |
801 NULL, // arguments | 801 NULL, // arguments |
802 description.c_str(), // description | 802 description.c_str(), // description |
803 chrome_exe.c_str(), // icon file | 803 chrome_exe.c_str(), // icon file |
804 icon_index, // icon index | 804 icon_index, // icon index |
805 dist->GetBrowserAppId().c_str()); // app id | 805 dist->GetBrowserAppId().c_str()); // app id |
806 } else { | 806 } else { |
807 return file_util::UpdateShortcutLink( | 807 return file_util::UpdateShortcutLink( |
808 chrome_exe.c_str(), // target | 808 chrome_exe.c_str(), // target |
809 shortcut.c_str(), // shortcut | 809 shortcut.c_str(), // shortcut |
810 chrome_path.c_str(), // working dir | 810 chrome_path.c_str(), // working dir |
811 NULL, // arguments | 811 NULL, // arguments |
812 description.c_str(), // description | 812 description.c_str(), // description |
813 chrome_exe.c_str(), // icon file | 813 chrome_exe.c_str(), // icon file |
814 icon_index, // icon index | 814 icon_index, // icon index |
815 dist->GetBrowserAppId().c_str()); // app id | 815 dist->GetBrowserAppId().c_str()); // app id |
816 } | 816 } |
817 } | 817 } |
OLD | NEW |