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

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: Test for default browser callback + comments Created 5 years, 3 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 f7fac34905f789c96ce28d0107dca525986da7ce..42da742d0cf2e4ca046510e8c48dc54234ebc22d 100644
--- a/chrome/browser/ui/startup/startup_browser_creator.cc
+++ b/chrome/browser/ui/startup/startup_browser_creator.cc
@@ -106,6 +106,12 @@ using content::ChildProcessSecurityPolicy;
namespace {
+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;
+
// Keeps track on which profiles have been launched.
class ProfileLaunchObserver : public content::NotificationObserver {
public:
@@ -446,6 +452,31 @@ void StartupBrowserCreator::RegisterLocalStatePrefs(
}
// static
+bool StartupBrowserCreator::SetDefaultBrowserCallback(
+ const base::Closure& callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ if (!g_default_browser_callback) {
+ g_default_browser_callback = new base::Closure(callback);
Peter Kasting 2015/09/25 20:52:27 Nit: I might add a comment here on why this can't
Patrick Monette 2015/09/28 23:46:38 Done.
+ return true;
+ }
+ return false;
+}
+
+// static
+void StartupBrowserCreator::ClearDefaultBrowserCallback() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ if (g_default_browser_callback) {
grt (UTC plus 2) 2015/09/28 14:31:04 delete null is well-defined in C++, so you could r
Patrick Monette 2015/09/28 23:46:38 Done.
+ delete g_default_browser_callback;
+ g_default_browser_callback = nullptr;
+ }
+}
+
+// static
+const wchar_t* StartupBrowserCreator::GetDefaultBrowserUrl() {
+ return kSetDefaultBrowserHelpUrl;
+}
+
+// static
std::vector<GURL> StartupBrowserCreator::GetURLsFromCommandLine(
const base::CommandLine& command_line,
const base::FilePath& cur_dir,
@@ -511,6 +542,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);
@@ -650,12 +682,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