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

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: grt comments #1 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..6c29b2e4f4777ac533ed6ca4ddf35f2688949473 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";
grt (UTC plus 2) 2015/09/24 18:47:06 PK: it seems like this should be brand-specific. d
Peter Kasting 2015/09/24 20:34:10 Do we have any support pages for Chromium (not Chr
+
+// Not thread-safe. Always use or modify this callback on the UI thread.
+base::CancelableClosure async_set_as_default_filter_callback;
Peter Kasting 2015/09/23 23:01:39 The Google style guide bans the use of global or s
grt (UTC plus 2) 2015/09/24 18:24:12 i think CancelableClosure is overkill here since y
Peter Kasting 2015/09/24 20:34:10 One downside to this is it's prone to leaks. It's
grt (UTC plus 2) 2015/09/24 20:39:24 On the flipside, it means that there's a risk that
Patrick Monette 2015/09/25 20:06:25 Done.
+
// Keeps track on which profiles have been launched.
class ProfileLaunchObserver : public content::NotificationObserver {
public:
@@ -446,6 +452,23 @@ void StartupBrowserCreator::RegisterLocalStatePrefs(
}
// static
+void StartupBrowserCreator::SetAsyncSetAsDefaultFilter(base::Closure callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ async_set_as_default_filter_callback.Reset(callback);
+}
+
+// static
+void StartupBrowserCreator::ClearAsyncSetAsDefaultFilter() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ async_set_as_default_filter_callback.Cancel();
+}
+
+// static
+const wchar_t* StartupBrowserCreator::GetAsyncSetAsDefaultUrl() {
+ return kSetDefaultBrowserHelpUrl;
+}
+
+// static
std::vector<GURL> StartupBrowserCreator::GetURLsFromCommandLine(
const base::CommandLine& command_line,
const base::FilePath& cur_dir,
@@ -511,6 +534,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 +674,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 (!async_set_as_default_filter_callback.IsCancelled()) {
+ for (const auto& arg : command_line.GetArgs()) {
+ GURL url(arg);
Peter Kasting 2015/09/23 23:01:39 Nit: I wonder if it wouldn't be simpler to just st
Patrick Monette 2015/09/25 20:06:25 Done.
+ if (url.is_valid() &&
+ url == GURL(L"https://support.google.com/chrome?p=default_browser")) {
Peter Kasting 2015/09/23 23:01:39 Why are you not using the constant here?
Patrick Monette 2015/09/25 20:06:25 Using it now.
+ async_set_as_default_filter_callback.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