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

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: 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 f0c27d6eb49706907e240ee44ed46cb54e2180b5..0028b5eeae206eb7fca712b3251d1707550b72a1 100644
--- a/chrome/browser/ui/startup/default_browser_prompt.cc
+++ b/chrome/browser/ui/startup/default_browser_prompt.cc
@@ -35,7 +35,8 @@ namespace {
class DefaultBrowserInfoBarDelegate : public ConfirmInfoBarDelegate {
public:
explicit DefaultBrowserInfoBarDelegate(InfoBarTabHelper* infobar_helper,
grt (UTC plus 2) 2012/05/25 20:27:38 remove "explicit" since there's more than one arg.
motek. 2012/05/28 17:40:33 Good point. Haven't noticed that.
- PrefService* prefs);
+ PrefService* prefs,
+ bool interactive_flow_required);
private:
virtual ~DefaultBrowserInfoBarDelegate();
@@ -51,6 +52,7 @@ class DefaultBrowserInfoBarDelegate : public ConfirmInfoBarDelegate {
virtual bool NeedElevation(InfoBarButton button) const OVERRIDE;
virtual bool Accept() OVERRIDE;
virtual bool Cancel() OVERRIDE;
+ static void SetChromeAsDefaultBrowser(bool interactive_flow);
grt (UTC plus 2) 2012/05/25 20:27:38 please separate this from the ConfirmInfoBarDelega
motek. 2012/05/28 17:40:33 Done.
// The prefs to use.
PrefService* prefs_;
@@ -61,6 +63,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 +75,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,14 +123,28 @@ 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(&DefaultBrowserInfoBarDelegate::SetChromeAsDefaultBrowser,
+ interactive_flow_required_));
+
return true;
}
+void DefaultBrowserInfoBarDelegate::SetChromeAsDefaultBrowser(
+ bool interactive_flow) {
+ if (interactive_flow) {
+ UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.SetAsDefaultUI", 1);
+ if (!ShellIntegration::StartSetAsDefaultBrowserInteractive()) {
grt (UTC plus 2) 2012/05/25 20:27:38 remove braces
+ UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.SetAsDefaultUIFailed", 1);
+ }
+ } else {
+ UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.SetAsDefault", 1);
+ ShellIntegration::SetAsDefaultBrowser();
+ }
+}
+
bool DefaultBrowserInfoBarDelegate::Cancel() {
action_taken_ = true;
UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.DontSetAsDefault", 1);
@@ -131,7 +153,8 @@ bool DefaultBrowserInfoBarDelegate::Cancel() {
return true;
}
-void NotifyNotDefaultBrowserCallback() {
+void NotifyNotDefaultBrowserCallback(
+ ShellIntegration::DefaultSettingsChangePermission operation_type) {
Browser* browser = BrowserList::GetLastActive();
if (!browser)
return; // Reached during ui tests.
@@ -147,18 +170,25 @@ void NotifyNotDefaultBrowserCallback() {
if (infobar_helper->infobar_count() > 0)
return;
+ bool interactive_flow = operation_type ==
+ ShellIntegration::CHANGE_DEFAULT_INTERACTIVE;
infobar_helper->AddInfoBar(
new DefaultBrowserInfoBarDelegate(infobar_helper,
- tab->profile()->GetPrefs()));
+ tab->profile()->GetPrefs(),
+ interactive_flow));
}
void CheckDefaultBrowserCallback() {
- if (ShellIntegration::IsDefaultBrowser() ||
- !ShellIntegration::CanSetAsDefaultBrowser()) {
- return;
- }
- BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
- base::Bind(&NotifyNotDefaultBrowserCallback));
+ if (!ShellIntegration::IsDefaultBrowser()) {
+ ShellIntegration::DefaultSettingsChangePermission default_change_mode =
+ ShellIntegration::CanSetAsDefaultBrowser();
+
+ if (ShellIntegration::CHANGE_DEFAULT_NOT_ALLOWED == default_change_mode)
grt (UTC plus 2) 2012/05/25 20:27:38 i think this looks better without the return: if (
motek. 2012/05/28 17:40:33 Done.
+ return;
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
+ base::Bind(&NotifyNotDefaultBrowserCallback,
+ default_change_mode));
+ }
}
} // namespace

Powered by Google App Engine
This is Rietveld 408576698