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

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

Issue 1140293002: Improve the default browser settings dialog for Win10 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // 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 858 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 } 869 }
870 870
871 DWORD ret_val = 0; 871 DWORD ret_val = 0;
872 InstallUtil::ExecuteExeAsAdmin(cmd, &ret_val); 872 InstallUtil::ExecuteExeAsAdmin(cmd, &ret_val);
873 if (ret_val == 0) 873 if (ret_val == 0)
874 return true; 874 return true;
875 } 875 }
876 return false; 876 return false;
877 } 877 }
878 878
879 // Launches the Windows 'settings' modern app with the 'default apps' view
880 // focused. This only works for Windows 8 and and. The appModelId
881 // looks arbitrary but it is the same in Win8 and Win10 previews. There
882 // is no easy way to retrieve the appModelId from the registry.
883 bool LaunchDefaultAppsSettingsModernDialog() {
884 base::win::ScopedComPtr<IApplicationActivationManager> activator;
Will Harris 2015/05/16 05:04:02 msdn says this needs shobjidl.h included
885 HRESULT hr = activator.CreateInstance(CLSID_ApplicationActivationManager);
886 if (SUCCEEDED(hr)) {
887 DWORD pid = 0;
888 CoAllowSetForegroundWindow(activator.get(), nullptr);
889 hr = activator->ActivateApplication(
890 L"windows.immersivecontrolpanel_cw5n1h2txyewy"
891 L"!microsoft.windows.immersivecontrolpanel",
892 L"page=SettingsPageAppsDefaults", AO_NONE, &pid);
893 return SUCCEEDED(hr);
894 }
895 return false;
896 }
897
879 // Launches the Windows 7 and Windows 8 dialog for picking the application to 898 // Launches the Windows 7 and Windows 8 dialog for picking the application to
880 // handle the given protocol. Most importantly, this is used to set the default 899 // handle the given protocol. Most importantly, this is used to set the default
881 // handler for http (and, implicitly with it, https). In that case it is also 900 // handler for http (and, implicitly with it, https). In that case it is also
882 // known as the 'how do you want to open webpages' dialog. 901 // known as the 'how do you want to open webpages' dialog.
883 // It is required that Chrome be already *registered* for the given protocol. 902 // It is required that Chrome be already *registered* for the given protocol.
884 bool LaunchSelectDefaultProtocolHandlerDialog(const wchar_t* protocol) { 903 bool LaunchSelectDefaultProtocolHandlerDialog(const wchar_t* protocol) {
885 DCHECK(protocol); 904 DCHECK(protocol);
886 OPENASINFO open_as_info = {}; 905 OPENASINFO open_as_info = {};
887 open_as_info.pcszFile = protocol; 906 open_as_info.pcszFile = protocol;
888 open_as_info.oaifInFlags = 907 open_as_info.oaifInFlags =
(...skipping 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after
2054 BrowserDistribution::DEFAULT_BROWSER_FULL_CONTROL) { 2073 BrowserDistribution::DEFAULT_BROWSER_FULL_CONTROL) {
2055 return false; 2074 return false;
2056 } 2075 }
2057 2076
2058 if (!RegisterChromeBrowser(dist, chrome_exe, base::string16(), true)) 2077 if (!RegisterChromeBrowser(dist, chrome_exe, base::string16(), true))
2059 return false; 2078 return false;
2060 2079
2061 bool succeeded = true; 2080 bool succeeded = true;
2062 bool is_default = (GetChromeDefaultState() == IS_DEFAULT); 2081 bool is_default = (GetChromeDefaultState() == IS_DEFAULT);
2063 if (!is_default) { 2082 if (!is_default) {
2064 // On Windows 8, you can't set yourself as the default handler 2083 if (base::win::GetVersion() < base::win::VERSION_WIN10) {
2065 // programatically. In other words IApplicationAssociationRegistration 2084 // On Windows 8, you can't set yourself as the default handler
2066 // has been rendered useless. What you can do is to launch 2085 // programatically. In other words IApplicationAssociationRegistration
2067 // "Set Program Associations" section of the "Default Programs" 2086 // has been rendered useless. What you can do is to launch
2068 // control panel, which is a mess, or pop the concise "How you want to open 2087 // "Set Program Associations" section of the "Default Programs"
2069 // webpages?" dialog. We choose the latter. 2088 // control panel, which is a mess, or pop the concise "How you want to
2070 succeeded = LaunchSelectDefaultProtocolHandlerDialog(L"http"); 2089 // open webpages?" dialog. We choose the latter.
2090 succeeded = LaunchSelectDefaultProtocolHandlerDialog(L"http");
2091 } else {
2092 // On Windows 10, you can't even launch the associations dialog.
2093 // So we launch the settings dialog. Quoting from MSDN: "The Open With
2094 // dialog box can no longer be used to change the default program used to
2095 // open a file extension. You can only use SHOpenWithDialog to open
2096 // a single file."
2097 succeeded = LaunchDefaultAppsSettingsModernDialog();
2098 }
2071 is_default = (succeeded && GetChromeDefaultState() == IS_DEFAULT); 2099 is_default = (succeeded && GetChromeDefaultState() == IS_DEFAULT);
2072 } 2100 }
2073 if (succeeded && is_default) 2101 if (succeeded && is_default)
2074 RegisterChromeAsDefaultXPStyle(dist, CURRENT_USER, chrome_exe); 2102 RegisterChromeAsDefaultXPStyle(dist, CURRENT_USER, chrome_exe);
2075 return succeeded; 2103 return succeeded;
2076 } 2104 }
2077 2105
2078 bool ShellUtil::MakeChromeDefaultProtocolClient( 2106 bool ShellUtil::MakeChromeDefaultProtocolClient(
2079 BrowserDistribution* dist, 2107 BrowserDistribution* dist,
2080 const base::FilePath& chrome_exe, 2108 const base::FilePath& chrome_exe,
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
2480 base::string16 key_path(ShellUtil::kRegClasses); 2508 base::string16 key_path(ShellUtil::kRegClasses);
2481 key_path.push_back(base::FilePath::kSeparators[0]); 2509 key_path.push_back(base::FilePath::kSeparators[0]);
2482 key_path.append(prog_id); 2510 key_path.append(prog_id);
2483 return InstallUtil::DeleteRegistryKey( 2511 return InstallUtil::DeleteRegistryKey(
2484 HKEY_CURRENT_USER, key_path, WorkItem::kWow64Default); 2512 HKEY_CURRENT_USER, key_path, WorkItem::kWow64Default);
2485 2513
2486 // TODO(mgiuca): Remove the extension association entries. This requires that 2514 // TODO(mgiuca): Remove the extension association entries. This requires that
2487 // the extensions associated with a particular prog_id are stored in that 2515 // the extensions associated with a particular prog_id are stored in that
2488 // prog_id's key. 2516 // prog_id's key.
2489 } 2517 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698