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

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

Issue 10453041: Support for interactive set-chrome-as-default in Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed for unittests + a typo or two. Created 8 years, 7 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/default_browser_prompt.cc
diff --git a/chrome/browser/ui/startup/default_browser_prompt.cc b/chrome/browser/ui/startup/default_browser_prompt.cc
index 53ddb0c62ce5383d6deea51658bfa3d3f3cc46fc..f3d0d790c8dd45b1c77b8c4418db8f296d38f577 100644
--- a/chrome/browser/ui/startup/default_browser_prompt.cc
+++ b/chrome/browser/ui/startup/default_browser_prompt.cc
@@ -31,11 +31,26 @@ using content::BrowserThread;
namespace {
+// Calls the appropriate function for setting Chrome as the default browser.
+// This requires IO access (registry) and may result in interaction with a
+// modal system UI.
+void SetChromeAsDefaultBrowser(bool interactive_flow) {
+ if (interactive_flow) {
+ UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.SetAsDefaultUI", 1);
+ if (!ShellIntegration::SetAsDefaultBrowserInteractive())
+ UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.SetAsDefaultUIFailed", 1);
grt (UTC plus 2) 2012/06/01 14:36:39 please make sure that the description for this in
motek. 2012/06/01 20:50:17 Ack.
+ } else {
+ UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.SetAsDefault", 1);
+ ShellIntegration::SetAsDefaultBrowser();
+ }
+}
+
// The delegate for the infobar shown when Chrome is not the default browser.
class DefaultBrowserInfoBarDelegate : public ConfirmInfoBarDelegate {
public:
- explicit DefaultBrowserInfoBarDelegate(InfoBarTabHelper* infobar_helper,
- PrefService* prefs);
+ DefaultBrowserInfoBarDelegate(InfoBarTabHelper* infobar_helper,
+ PrefService* prefs,
+ bool interactive_flow_required);
private:
virtual ~DefaultBrowserInfoBarDelegate();
@@ -61,6 +76,10 @@ class DefaultBrowserInfoBarDelegate : public ConfirmInfoBarDelegate {
// Whether the info-bar should be dismissed on the next navigation.
bool should_expire_;
+ // Whether changing the default application will require entering the
+ // modal-UI flow.
+ bool interactive_flow_required_;
+
// Used to delay the expiration of the info-bar.
base::WeakPtrFactory<DefaultBrowserInfoBarDelegate> weak_factory_;
@@ -69,11 +88,13 @@ class DefaultBrowserInfoBarDelegate : public ConfirmInfoBarDelegate {
DefaultBrowserInfoBarDelegate::DefaultBrowserInfoBarDelegate(
InfoBarTabHelper* infobar_helper,
- PrefService* prefs)
+ PrefService* prefs,
+ bool interactive_flow_required)
: ConfirmInfoBarDelegate(infobar_helper),
prefs_(prefs),
action_taken_(false),
should_expire_(false),
+ interactive_flow_required_(interactive_flow_required),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
// We want the info-bar to stick-around for few seconds and then be hidden
// on the next navigation after that.
@@ -115,11 +136,11 @@ bool DefaultBrowserInfoBarDelegate::NeedElevation(InfoBarButton button) const {
bool DefaultBrowserInfoBarDelegate::Accept() {
action_taken_ = true;
- UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.SetAsDefault", 1);
BrowserThread::PostTask(
BrowserThread::FILE,
FROM_HERE,
- base::Bind(base::IgnoreResult(&ShellIntegration::SetAsDefaultBrowser)));
+ base::Bind(&SetChromeAsDefaultBrowser, interactive_flow_required_));
+
return true;
}
@@ -132,14 +153,15 @@ bool DefaultBrowserInfoBarDelegate::Cancel() {
}
void CheckDefaultBrowserCallback() {
- if (ShellIntegration::IsDefaultBrowser() ||
- !ShellIntegration::CanSetAsDefaultBrowser()) {
- return;
+ if (!ShellIntegration::IsDefaultBrowser()) {
+ ShellIntegration::DefaultSettingsChangePermission default_change_mode =
+ ShellIntegration::CanSetAsDefaultBrowser();
+
+ if (default_change_mode != ShellIntegration::CHANGE_DEFAULT_NOT_ALLOWED) {
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
+ base::Bind(&browser::internal::NotifyNotDefaultBrowserCallback));
+ }
}
- BrowserThread::PostTask(
- BrowserThread::UI,
- FROM_HERE,
- base::Bind(&browser::internal::NotifyNotDefaultBrowserCallback));
}
} // namespace
@@ -192,9 +214,12 @@ void NotifyNotDefaultBrowserCallback() {
if (infobar_helper->infobar_count() > 0)
return;
+ bool interactive_flow = ShellIntegration::CanSetAsDefaultBrowser() ==
+ ShellIntegration::CHANGE_DEFAULT_INTERACTIVE;
infobar_helper->AddInfoBar(
new DefaultBrowserInfoBarDelegate(infobar_helper,
- tab->profile()->GetPrefs()));
+ tab->profile()->GetPrefs(),
+ interactive_flow));
}
} // namespace internal

Powered by Google App Engine
This is Rietveld 408576698