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..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()); |