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

Unified Diff: chrome/browser/ui/startup/startup_browser_creator.cc

Issue 1349163008: Setting chrome as the default browser is now fixed on Windows 10 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compilation again Created 5 years, 2 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/ui/startup/startup_browser_creator.cc
diff --git a/chrome/browser/ui/startup/startup_browser_creator.cc b/chrome/browser/ui/startup/startup_browser_creator.cc
index f114fb6db5500558618a6e68b44da2bd89030703..8553942b943d4f7bf5f500458b1aae6baf8b4855 100644
--- a/chrome/browser/ui/startup/startup_browser_creator.cc
+++ b/chrome/browser/ui/startup/startup_browser_creator.cc
@@ -106,6 +106,14 @@ using content::ChildProcessSecurityPolicy;
namespace {
+#if defined(OS_WIN)
+const wchar_t kSetDefaultBrowserHelpUrl[] =
+ L"https://support.google.com/chrome?p=default_browser";
+
+// Not thread-safe. Always use or modify this callback on the UI thread.
+base::Closure* g_default_browser_callback = nullptr;
+#endif // defined(OS_WIN)
+
// Keeps track on which profiles have been launched.
class ProfileLaunchObserver : public content::NotificationObserver {
public:
@@ -484,6 +492,34 @@ void StartupBrowserCreator::RegisterLocalStatePrefs(
#endif
}
+
+#if defined(OS_WIN)
+// static
+bool StartupBrowserCreator::SetDefaultBrowserCallback(
+ const base::Closure& callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ if (!g_default_browser_callback) {
+ // This won't leak because the worker class invoking this function always
+ // calls ClearDefaultBrowserCallback() in its destructor.
+ g_default_browser_callback = new base::Closure(callback);
+ return true;
+ }
+ return false;
+}
+
+// static
+void StartupBrowserCreator::ClearDefaultBrowserCallback() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ delete g_default_browser_callback;
+ g_default_browser_callback = nullptr;
+}
+
+// static
+const wchar_t* StartupBrowserCreator::GetDefaultBrowserUrl() {
+ return kSetDefaultBrowserHelpUrl;
+}
+#endif // defined(OS_WIN)
+
// static
std::vector<GURL> StartupBrowserCreator::GetURLsFromCommandLine(
const base::CommandLine& command_line,
@@ -550,6 +586,7 @@ bool StartupBrowserCreator::ProcessCmdLineImpl(
Profile* last_used_profile,
const Profiles& last_opened_profiles,
StartupBrowserCreator* browser_creator) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
TRACE_EVENT0("startup", "StartupBrowserCreator::ProcessCmdLineImpl");
DCHECK(last_used_profile);
@@ -689,12 +726,25 @@ bool StartupBrowserCreator::ProcessCmdLineImpl(
}
#if defined(OS_WIN)
+ // Intercept a specific url when setting the default browser asynchronously.
+ // This only happens on Windows 10+.
+ if (g_default_browser_callback) {
+ base::CommandLine::StringType default_browser_url_(
+ kSetDefaultBrowserHelpUrl);
+ for (const auto& arg : command_line.GetArgs()) {
+ if (arg == default_browser_url_) {
+ g_default_browser_callback->Run();
+ return true;
+ }
+ }
+ }
+
// Log whether this process was a result of an action in the Windows Jumplist.
if (command_line.HasSwitch(switches::kWinJumplistAction)) {
jumplist::LogJumplistActionFromSwitchValue(
command_line.GetSwitchValueASCII(switches::kWinJumplistAction));
}
-#endif
+#endif // defined(OS_WIN)
chrome::startup::IsProcessStartup is_process_startup = process_startup ?
chrome::startup::IS_PROCESS_STARTUP :

Powered by Google App Engine
This is Rietveld 408576698