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

Unified Diff: chrome/browser/shell_integration_win.cc

Issue 1896513002: Fix registerProtocolHandler implementation on Windows 8 and 10. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Round of comment #1 Created 4 years, 8 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
Index: chrome/browser/shell_integration_win.cc
diff --git a/chrome/browser/shell_integration_win.cc b/chrome/browser/shell_integration_win.cc
index 9a92a9c438eacc3dd186c19701c4a74d41639d37..0461b684d47c73e802e0605f41a22e5d28a5484f 100644
--- a/chrome/browser/shell_integration_win.cc
+++ b/chrome/browser/shell_integration_win.cc
@@ -43,6 +43,7 @@
#include "chrome/installer/util/browser_distribution.h"
#include "chrome/installer/util/create_reg_key_work_item.h"
#include "chrome/installer/util/install_util.h"
+#include "chrome/installer/util/scoped_user_protocol_entry.h"
#include "chrome/installer/util/set_reg_value_work_item.h"
#include "chrome/installer/util/shell_util.h"
#include "chrome/installer/util/util_constants.h"
@@ -237,7 +238,7 @@ class OpenSystemSettingsHelper {
public:
// Begin the monitoring and will call |on_finished_callback| when done.
// Takes in a null-terminated array of |protocols| whose registry keys must be
- // watched.
+ // watched. The array must contain at least one element.
static void Begin(const wchar_t* const protocols[],
const base::Closure& on_finished_callback) {
new OpenSystemSettingsHelper(protocols, on_finished_callback);
@@ -250,7 +251,9 @@ class OpenSystemSettingsHelper {
OpenSystemSettingsHelper(const wchar_t* const protocols[],
const base::Closure& on_finished_callback)
- : on_finished_callback_(on_finished_callback), weak_ptr_factory_(this) {
+ : scoped_user_protocol_entry_(protocols[0]),
+ on_finished_callback_(on_finished_callback),
+ weak_ptr_factory_(this) {
static const wchar_t kUrlAssociationFormat[] =
L"SOFTWARE\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\"
L"%ls\\UserChoice";
@@ -315,6 +318,8 @@ class OpenSystemSettingsHelper {
}
}
+ ScopedUserProtocolEntry scoped_user_protocol_entry_;
grt (UTC plus 2) 2016/04/18 19:00:56 nit: a comment here would be helpful to understand
grt (UTC plus 2) 2016/04/19 02:03:46 as per face-to-face discussion, i understand this
Patrick Monette 2016/04/19 14:36:13 I added a comment. I think shell util is due for a
+
// The function to call when the interaction with the system settings is
// finished.
base::Closure on_finished_callback_;
@@ -689,6 +694,28 @@ bool SetAsDefaultProtocolClientUsingIntentPicker(const std::string& protocol) {
return true;
}
+void SetAsDefaultProtocolClientUsingSystemSettings(
+ const std::string& protocol,
+ const base::Closure& on_finished_callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::FILE);
+
+ base::FilePath chrome_exe;
+ if (!PathService::Get(base::FILE_EXE, &chrome_exe)) {
+ NOTREACHED() << "Error getting app exe path";
+ on_finished_callback.Run();
+ return;
+ }
+
+ // The helper manages its own lifetime.
+ base::string16 wprotocol(base::UTF8ToUTF16(protocol));
+ static const wchar_t* const kProtocols[] = {wprotocol.c_str(), nullptr};
+ OpenSystemSettingsHelper::Begin(kProtocols, on_finished_callback);
+
+ BrowserDistribution* dist = BrowserDistribution::GetDistribution();
+ ShellUtil::ShowMakeChromeDefaultProtocolClientSystemUI(dist, chrome_exe,
+ wprotocol);
+}
+
} // namespace win
} // namespace shell_integration

Powered by Google App Engine
This is Rietveld 408576698