Chromium Code Reviews| 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..e023956c897a51c10daf979741b4bf84c32ba4f3 100644 |
| --- a/chrome/browser/shell_integration_win.cc |
| +++ b/chrome/browser/shell_integration_win.cc |
| @@ -56,6 +56,15 @@ namespace { |
| const wchar_t kAppListAppNameSuffix[] = L"AppList"; |
| const char kAsyncSetAsDefaultExperimentName[] = "AsyncSetAsDefault"; |
| +// A prefix shared by multiple groups that kicks off the generic set-as-default |
|
gab
2016/01/12 01:26:46
nit: I guess for consistency s/set-as-default/Asyn
Patrick Monette
2016/01/12 01:29:33
Done.
|
| +// experiment. |
| +const char kAsyncSetAsDefaultExperimentEnabledGroupPrefix[] = "Enabled"; |
| +// One of the group names for the AsyncSetAsDefault experiment. Unlike other |
| +// "Enabled" groups, this group doesn't reset the current default browser choice |
| +// in the registry. |
| +const char kAsyncSetAsDefaultExperimentEnabledNoRegistryGroupName[] = |
| + "EnabledNoRegistry"; |
| + |
| const char kEnableAsyncSetAsDefault[] = "enable-async-set-as-default"; |
| const char kDisableAsyncSetAsDefault[] = "disable-async-set-as-default"; |
| @@ -279,13 +288,24 @@ 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)) |
| return true; |
| - return base::StartsWith(group_name, "Enabled", base::CompareCase::SENSITIVE); |
| + return base::StartsWith(group_name, |
| + kAsyncSetAsDefaultExperimentEnabledGroupPrefix, |
| + base::CompareCase::SENSITIVE); |
| +} |
| + |
| +// Returns true if the default browser choice should be reset for the current |
| +// user. |
| +bool ShouldResetDefaultBrowser() { |
| + return !base::StartsWith( |
| + base::FieldTrialList::FindFullName(kAsyncSetAsDefaultExperimentName), |
| + kAsyncSetAsDefaultExperimentEnabledNoRegistryGroupName, |
| + base::CompareCase::SENSITIVE); |
| } |
| bool RegisterBrowser() { |
| @@ -720,7 +740,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()); |