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

Unified Diff: chrome/browser/shell_integration_win.cc

Issue 1575163002: New experiment without registry deletion (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add experiment Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/shell_integration_win.cc
diff --git a/chrome/browser/shell_integration_win.cc b/chrome/browser/shell_integration_win.cc
index 04bc80c220d314d2a3c7074f0c420cbde1eb233b..85b692e95463838ce125b33db12074cdc3c8c8cc 100644
--- a/chrome/browser/shell_integration_win.cc
+++ b/chrome/browser/shell_integration_win.cc
@@ -253,25 +253,6 @@ ShellIntegration::DefaultWebClientState
}
}
-// Resets the default browser choice for the current user.
-void ResetDefaultBrowser() {
- static const wchar_t* const kUrlAssociationKeyFormats[] = {
- L"SOFTWARE\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\"
- L"%ls\\UserChoice",
- L"SOFTWARE\\Microsoft\\Windows\\Roaming\\OpenWith\\UrlAssociations\\"
- L"%ls\\UserChoice"};
- static const wchar_t* const kProtocols[] = {L"http", L"https"};
-
- for (const wchar_t* format : kUrlAssociationKeyFormats) {
- for (const wchar_t* protocol : kProtocols) {
- base::win::RegKey registry_key(
- HKEY_CURRENT_USER, base::StringPrintf(format, protocol).c_str(),
- KEY_SET_VALUE);
- registry_key.DeleteValue(L"Hash");
- }
- }
-}
-
// Returns true if the AsyncSetAsDefault field trial is activated.
bool IsAsyncSetAsDefaultEnabled() {
using base::CommandLine;
@@ -279,7 +260,7 @@ bool IsAsyncSetAsDefaultEnabled() {
// Note: It's important to query the field trial state first, to ensure that
// UMA reports the correct group.
const std::string group_name =
- base::FieldTrialList::FindFullName("AsyncSetAsDefault");
+ base::FieldTrialList::FindFullName(kAsyncSetAsDefaultExperimentName);
if (CommandLine::ForCurrentProcess()->HasSwitch(kDisableAsyncSetAsDefault))
return false;
if (CommandLine::ForCurrentProcess()->HasSwitch(kEnableAsyncSetAsDefault))
@@ -300,6 +281,32 @@ bool RegisterBrowser() {
true);
}
+// Returns true if the default browser choice should be reset for the current
+// user.
+bool ShouldResetDefaultBrowser() {
+ return base::FieldTrialList::FindFullName(kAsyncSetAsDefaultExperimentName) !=
+ "EnabledNoRegistry";
gab 2016/01/11 23:41:00 Use StartsWith() instead of == for comparing group
Patrick Monette 2016/01/12 00:07:27 Done.
+}
+
+// Resets the default browser choice for the current user.
+void ResetDefaultBrowser() {
gab 2016/01/11 23:41:00 What's the reason to move the method? It appears u
Patrick Monette 2016/01/12 00:07:27 Just to make order of definition = order of use.
+ static const wchar_t* const kUrlAssociationKeyFormats[] = {
+ L"SOFTWARE\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\"
+ L"%ls\\UserChoice",
+ L"SOFTWARE\\Microsoft\\Windows\\Roaming\\OpenWith\\UrlAssociations\\"
+ L"%ls\\UserChoice"};
+ static const wchar_t* const kProtocols[] = {L"http", L"https"};
+
+ for (const wchar_t* format : kUrlAssociationKeyFormats) {
+ for (const wchar_t* protocol : kProtocols) {
+ base::win::RegKey registry_key(
+ HKEY_CURRENT_USER, base::StringPrintf(format, protocol).c_str(),
+ KEY_SET_VALUE);
+ registry_key.DeleteValue(L"Hash");
+ }
+ }
+}
+
} // namespace
// static
@@ -720,7 +727,8 @@ bool ShellIntegration::DefaultBrowserWorker::SetAsDefaultBrowserAsynchronous() {
if (!RegisterBrowser())
return false;
- ResetDefaultBrowser();
+ if (ShouldResetDefaultBrowser())
+ ResetDefaultBrowser();
base::CommandLine cmdline(base::FilePath(L"openwith.exe"));
cmdline.AppendArgNative(StartupBrowserCreator::GetDefaultBrowserUrl());
« 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