Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: chrome/installer/util/shell_util.cc

Issue 3823002: Move windows version-related stuff out of base/win_util and into base/win/win... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 11
12 #include <windows.h> 12 #include <windows.h>
13 #include <shlobj.h> 13 #include <shlobj.h>
14 14
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/file_path.h" 16 #include "base/file_path.h"
17 #include "base/file_util.h" 17 #include "base/file_util.h"
18 #include "base/logging.h" 18 #include "base/logging.h"
19 #include "base/registry.h" 19 #include "base/registry.h"
20 #include "base/scoped_ptr.h" 20 #include "base/scoped_ptr.h"
21 #include "base/stl_util-inl.h" 21 #include "base/stl_util-inl.h"
22 #include "base/string_number_conversions.h" 22 #include "base/string_number_conversions.h"
23 #include "base/string_split.h" 23 #include "base/string_split.h"
24 #include "base/string_util.h" 24 #include "base/string_util.h"
25 #include "base/utf_string_conversions.h" 25 #include "base/utf_string_conversions.h"
26 #include "base/values.h" 26 #include "base/values.h"
27 #include "base/win_util.h" 27 #include "base/win/windows_version.h"
28 #include "chrome/common/chrome_constants.h" 28 #include "chrome/common/chrome_constants.h"
29 #include "chrome/common/chrome_switches.h" 29 #include "chrome/common/chrome_switches.h"
30 #include "chrome/installer/util/browser_distribution.h" 30 #include "chrome/installer/util/browser_distribution.h"
31 #include "chrome/installer/util/install_util.h" 31 #include "chrome/installer/util/install_util.h"
32 #include "chrome/installer/util/master_preferences.h" 32 #include "chrome/installer/util/master_preferences.h"
33 33
34 #include "installer_util_strings.h" 34 #include "installer_util_strings.h"
35 35
36 namespace { 36 namespace {
37 37
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 // We are accessing GetDefaultUserProfileDirectory this way so that we do 542 // We are accessing GetDefaultUserProfileDirectory this way so that we do
543 // not have to declare dependency to Userenv.lib for chrome.exe 543 // not have to declare dependency to Userenv.lib for chrome.exe
544 typedef BOOL (WINAPI *PROFILE_FUNC)(LPWSTR, LPDWORD); 544 typedef BOOL (WINAPI *PROFILE_FUNC)(LPWSTR, LPDWORD);
545 HMODULE module = LoadLibrary(L"Userenv.dll"); 545 HMODULE module = LoadLibrary(L"Userenv.dll");
546 PROFILE_FUNC p = reinterpret_cast<PROFILE_FUNC>(GetProcAddress(module, 546 PROFILE_FUNC p = reinterpret_cast<PROFILE_FUNC>(GetProcAddress(module,
547 "GetDefaultUserProfileDirectoryW")); 547 "GetDefaultUserProfileDirectoryW"));
548 DWORD size = _countof(qlaunch); 548 DWORD size = _countof(qlaunch);
549 if ((p == NULL) || ((p)(qlaunch, &size) != TRUE)) 549 if ((p == NULL) || ((p)(qlaunch, &size) != TRUE))
550 return false; 550 return false;
551 *path = qlaunch; 551 *path = qlaunch;
552 if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) { 552 if (base::win::GetVersion() >= base::win::VERSION_VISTA) {
553 file_util::AppendToPath(path, L"AppData\\Roaming"); 553 file_util::AppendToPath(path, L"AppData\\Roaming");
554 } else { 554 } else {
555 file_util::AppendToPath(path, L"Application Data"); 555 file_util::AppendToPath(path, L"Application Data");
556 } 556 }
557 } else { 557 } else {
558 if (FAILED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 558 if (FAILED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL,
559 SHGFP_TYPE_CURRENT, qlaunch))) 559 SHGFP_TYPE_CURRENT, qlaunch)))
560 return false; 560 return false;
561 *path = qlaunch; 561 *path = qlaunch;
562 } 562 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 const std::wstring& chrome_exe, 609 const std::wstring& chrome_exe,
610 bool elevate_if_not_admin) { 610 bool elevate_if_not_admin) {
611 if (!BrowserDistribution::GetDistribution()->CanSetAsDefault()) 611 if (!BrowserDistribution::GetDistribution()->CanSetAsDefault())
612 return false; 612 return false;
613 613
614 ShellUtil::RegisterChromeBrowser(chrome_exe, L"", elevate_if_not_admin); 614 ShellUtil::RegisterChromeBrowser(chrome_exe, L"", elevate_if_not_admin);
615 615
616 bool ret = true; 616 bool ret = true;
617 // First use the new "recommended" way on Vista to make Chrome default 617 // First use the new "recommended" way on Vista to make Chrome default
618 // browser. 618 // browser.
619 if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) { 619 if (base::win::GetVersion() >= base::win::VERSION_VISTA) {
620 LOG(INFO) << "Registering Chrome as default browser on Vista."; 620 LOG(INFO) << "Registering Chrome as default browser on Vista.";
621 IApplicationAssociationRegistration* pAAR; 621 IApplicationAssociationRegistration* pAAR;
622 HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration, 622 HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration,
623 NULL, CLSCTX_INPROC, __uuidof(IApplicationAssociationRegistration), 623 NULL, CLSCTX_INPROC, __uuidof(IApplicationAssociationRegistration),
624 (void**)&pAAR); 624 (void**)&pAAR);
625 if (SUCCEEDED(hr)) { 625 if (SUCCEEDED(hr)) {
626 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 626 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
627 std::wstring app_name = dist->GetApplicationName(); 627 std::wstring app_name = dist->GetApplicationName();
628 std::wstring suffix; 628 std::wstring suffix;
629 if (ShellUtil::GetUserSpecificDefaultBrowserSuffix(&suffix)) 629 if (ShellUtil::GetUserSpecificDefaultBrowserSuffix(&suffix))
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 if (IsUserAnAdmin()) { 690 if (IsUserAnAdmin()) {
691 std::list<RegistryEntry*> entries; 691 std::list<RegistryEntry*> entries;
692 STLElementDeleter<std::list<RegistryEntry*>> entries_deleter(&entries); 692 STLElementDeleter<std::list<RegistryEntry*>> entries_deleter(&entries);
693 RegistryEntry::GetProgIdEntries(chrome_exe, suffix, &entries); 693 RegistryEntry::GetProgIdEntries(chrome_exe, suffix, &entries);
694 RegistryEntry::GetSystemEntries(chrome_exe, suffix, &entries); 694 RegistryEntry::GetSystemEntries(chrome_exe, suffix, &entries);
695 return AddRegistryEntries(HKEY_LOCAL_MACHINE, entries); 695 return AddRegistryEntries(HKEY_LOCAL_MACHINE, entries);
696 } 696 }
697 697
698 // If user is not an admin and OS is Vista, try to elevate and register. 698 // If user is not an admin and OS is Vista, try to elevate and register.
699 if (elevate_if_not_admin && 699 if (elevate_if_not_admin &&
700 win_util::GetWinVersion() >= win_util::WINVERSION_VISTA && 700 base::win::GetVersion() >= base::win::VERSION_VISTA &&
701 ElevateAndRegisterChrome(chrome_exe, suffix)) 701 ElevateAndRegisterChrome(chrome_exe, suffix))
702 return true; 702 return true;
703 703
704 // If we got to this point then all we can do is create ProgIds under HKCU 704 // If we got to this point then all we can do is create ProgIds under HKCU
705 // on XP as well as Vista. 705 // on XP as well as Vista.
706 std::list<RegistryEntry*> entries; 706 std::list<RegistryEntry*> entries;
707 STLElementDeleter<std::list<RegistryEntry*>> entries_deleter(&entries); 707 STLElementDeleter<std::list<RegistryEntry*>> entries_deleter(&entries);
708 RegistryEntry::GetProgIdEntries(chrome_exe, L"", &entries); 708 RegistryEntry::GetProgIdEntries(chrome_exe, L"", &entries);
709 return AddRegistryEntries(HKEY_CURRENT_USER, entries); 709 return AddRegistryEntries(HKEY_CURRENT_USER, entries);
710 } 710 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 } 806 }
807 } 807 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698