From b11953f046bbe1637041981df4a434cb96b8df30 Mon Sep 17 00:00:00 2001 From: "mark@chromium.org" Date: Tue, 19 Apr 2011 22:58:58 +0000 Subject: Mac Canary: Don't offer to set as the default browser. This includes some light refactoring to give all platforms a platform_util::CanSetAsDefaultBrowser() function. The .xib change links the set-as-default button with the new IBOutlet. BUG=79814 TEST=Canary.app should never offer to set as the default browser in the first run dialog or in an infobar. Review URL: http://codereview.chromium.org/6881058 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@82179 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/app/nibs/FirstRunDialog.xib | 58 ++++++++++++++++++++++------ chrome/browser/platform_util.h | 5 ++- chrome/browser/platform_util_common_linux.cc | 4 ++ chrome/browser/platform_util_mac.mm | 4 ++ chrome/browser/platform_util_win.cc | 5 +++ chrome/browser/shell_integration_mac.mm | 8 +++- chrome/browser/ui/browser_init.cc | 9 ++--- chrome/browser/ui/cocoa/first_run_dialog.h | 3 +- chrome/browser/ui/cocoa/first_run_dialog.mm | 6 +++ 9 files changed, 81 insertions(+), 21 deletions(-) diff --git a/chrome/app/nibs/FirstRunDialog.xib b/chrome/app/nibs/FirstRunDialog.xib index 773172f..cf2caf6 100644 --- a/chrome/app/nibs/FirstRunDialog.xib +++ b/chrome/app/nibs/FirstRunDialog.xib @@ -2,17 +2,16 @@ 1050 - 10F2108 - 823 - 1038.29 + 10J869 + 851 + 1038.35 461.00 com.apple.InterfaceBuilder.CocoaPlugin - 823 + 851 YES - YES @@ -46,7 +45,7 @@ ^IDS_FIRSTRUN_DLG_MAC_WINDOW_TITLE$IDS_PRODUCT_NAME NSWindow - {1.79769e+308, 1.79769e+308} + {3.40282e+38, 3.40282e+38} 274 @@ -57,6 +56,7 @@ 268 {{45, 128}, {389, 18}} + YES 67239424 @@ -98,6 +98,7 @@ 268 {{13, 25}, {390, 17}} + YES 68288064 @@ -111,7 +112,7 @@ controlColor 3 - MC42NjY2NjY2NjY3AA + MC42NjY2NjY2ODY1AA @@ -142,6 +143,7 @@ {{408, -25}, {96, 96}} + YES 130560 @@ -160,10 +162,12 @@ {480, 55} + {{0, 197}, {480, 55}} + {0, 0} 67239424 @@ -185,7 +189,7 @@ 3 - MCAwLjgwMDAwMDAxAA + MCAwLjgwMDAwMDAxMTkAA @@ -200,6 +204,7 @@ 10 {{0, 194}, {480, 5}} + {0, 0} 67239424 @@ -209,7 +214,7 @@ 3 - MCAwLjgwMDAwMDAxAA + MCAwLjgwMDAwMDAxMTkAA 3 @@ -222,6 +227,7 @@ 268 {{28, 152}, {435, 17}} + YES 68288064 @@ -238,6 +244,7 @@ 10 {{-1, 57}, {480, 5}} + {0, 0} 67239424 @@ -247,7 +254,7 @@ 3 - MCAwLjgwMDAwMDAxAA + MCAwLjgwMDAwMDAxMTkAA 3 @@ -260,6 +267,7 @@ 266 {{45, 103}, {389, 19}} + YES -2080244224 @@ -287,6 +295,7 @@ 289 {{14, 12}, {306, 32}} + YES 67239424 @@ -305,6 +314,7 @@ {{146, 0}, {334, 52}} + GTMWidthBasedTweaker @@ -312,6 +322,7 @@ 268 {{63, 80}, {359, 19}} + YES -2080244224 @@ -329,9 +340,10 @@ {480, 248} + {{0, 0}, {1680, 1028}} - {1.79769e+308, 1.79769e+308} + {3.40282e+38, 3.40282e+38} ChromeUILocalizer @@ -463,6 +475,14 @@ 130 + + + setAsDefaultCheckbox_ + + + + 131 + @@ -737,7 +757,7 @@ - 130 + 131 @@ -790,12 +810,14 @@ YES objectsToSize_ + setAsDefaultCheckbox_ statsCheckbox_ YES NSArray NSButton + NSButton @@ -803,6 +825,7 @@ YES objectsToSize_ + setAsDefaultCheckbox_ statsCheckbox_ @@ -812,6 +835,10 @@ NSArray + setAsDefaultCheckbox_ + NSButton + + statsCheckbox_ NSButton @@ -1017,6 +1044,13 @@ NSView IBProjectSource + browser/ui/cocoa/nsview_additions.h + + + + NSView + + IBProjectSource browser/ui/cocoa/view_id_util.h diff --git a/chrome/browser/platform_util.h b/chrome/browser/platform_util.h index 37d5171..41fa0ed 100644 --- a/chrome/browser/platform_util.h +++ b/chrome/browser/platform_util.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -60,6 +60,9 @@ bool SimpleYesNoBox(gfx::NativeWindow parent, // beta, but "" for stable). std::string GetVersionStringModifier(); +// Returns true if the running browser can be set as the default browser. +bool CanSetAsDefaultBrowser(); + } #endif // CHROME_BROWSER_PLATFORM_UTIL_H_ diff --git a/chrome/browser/platform_util_common_linux.cc b/chrome/browser/platform_util_common_linux.cc index feb1568..195dc66 100644 --- a/chrome/browser/platform_util_common_linux.cc +++ b/chrome/browser/platform_util_common_linux.cc @@ -134,4 +134,8 @@ std::string GetVersionStringModifier() { return modifier; } +bool CanSetAsDefaultBrowser() { + return true; +} + } // namespace platform_util diff --git a/chrome/browser/platform_util_mac.mm b/chrome/browser/platform_util_mac.mm index 8cd5851..9a61775 100644 --- a/chrome/browser/platform_util_mac.mm +++ b/chrome/browser/platform_util_mac.mm @@ -209,4 +209,8 @@ std::string GetVersionStringModifier() { #endif } +bool CanSetAsDefaultBrowser() { + return GetVersionStringModifier().compare("canary") != 0; +} + } // namespace platform_util diff --git a/chrome/browser/platform_util_win.cc b/chrome/browser/platform_util_win.cc index af1449c..2076b64 100644 --- a/chrome/browser/platform_util_win.cc +++ b/chrome/browser/platform_util_win.cc @@ -19,6 +19,7 @@ #include "base/utf_string_conversions.h" #include "base/win/registry.h" #include "base/win/scoped_comptr.h" +#include "chrome/installer/util/browser_distribution.h" #include "chrome/installer/util/google_update_constants.h" #include "chrome/installer/util/google_update_settings.h" #include "chrome/installer/util/install_util.h" @@ -211,4 +212,8 @@ std::string GetVersionStringModifier() { #endif } +bool CanSetAsDefaultBrowser() { + return BrowserDistribution::GetDistribution()->CanSetAsDefault(); +} + } // namespace platform_util diff --git a/chrome/browser/shell_integration_mac.mm b/chrome/browser/shell_integration_mac.mm index 15258a9..7bf1dcb 100644 --- a/chrome/browser/shell_integration_mac.mm +++ b/chrome/browser/shell_integration_mac.mm @@ -1,15 +1,19 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/shell_integration.h" #include "base/mac/mac_util.h" +#include "chrome/browser/platform_util.h" #import "third_party/mozilla/NSWorkspace+Utils.h" // Sets Chromium as default browser (only for current user). Returns false if -// this operation fails (which we can't check for). +// this operation fails. bool ShellIntegration::SetAsDefaultBrowser() { + if (!platform_util::CanSetAsDefaultBrowser()) + return false; + // We really do want the main bundle here, not base::mac::MainAppBundle(), // which is the bundle for the framework. NSString* identifier = [[NSBundle mainBundle] bundleIdentifier]; diff --git a/chrome/browser/ui/browser_init.cc b/chrome/browser/ui/browser_init.cc index 7f94444..71cd400 100644 --- a/chrome/browser/ui/browser_init.cc +++ b/chrome/browser/ui/browser_init.cc @@ -30,6 +30,7 @@ #include "chrome/browser/net/predictor_api.h" #include "chrome/browser/net/url_fixer_upper.h" #include "chrome/browser/notifications/desktop_notification_service.h" +#include "chrome/browser/platform_util.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/prefs/session_startup_pref.h" #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" @@ -283,12 +284,10 @@ CheckDefaultBrowserTask::~CheckDefaultBrowserTask() { } void CheckDefaultBrowserTask::Run() { - if (ShellIntegration::IsDefaultBrowser()) + if (ShellIntegration::IsDefaultBrowser() || + !platform_util::CanSetAsDefaultBrowser()) { return; -#if defined(OS_WIN) - if (!BrowserDistribution::GetDistribution()->CanSetAsDefault()) - return; -#endif + } BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, new NotifyNotDefaultBrowserTask()); } diff --git a/chrome/browser/ui/cocoa/first_run_dialog.h b/chrome/browser/ui/cocoa/first_run_dialog.h index 3e575a3..92d529d 100644 --- a/chrome/browser/ui/cocoa/first_run_dialog.h +++ b/chrome/browser/ui/cocoa/first_run_dialog.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -17,6 +17,7 @@ BOOL makeDefaultBrowser_; IBOutlet NSArray* objectsToSize_; + IBOutlet NSButton* setAsDefaultCheckbox_; IBOutlet NSButton* statsCheckbox_; BOOL beenSized_; } diff --git a/chrome/browser/ui/cocoa/first_run_dialog.mm b/chrome/browser/ui/cocoa/first_run_dialog.mm index 2b4d052..15fb608 100644 --- a/chrome/browser/ui/cocoa/first_run_dialog.mm +++ b/chrome/browser/ui/cocoa/first_run_dialog.mm @@ -12,6 +12,7 @@ #include "chrome/browser/first_run/first_run.h" #include "chrome/browser/first_run/first_run_dialog.h" #include "chrome/browser/google/google_util.h" +#include "chrome/browser/platform_util.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/search_engines/template_url_model.h" #import "chrome/browser/ui/cocoa/search_engine_dialog_controller.h" @@ -187,6 +188,11 @@ void ShowFirstRunDialog(Profile* profile, - (void)show { NSWindow* win = [self window]; + if (!platform_util::CanSetAsDefaultBrowser()) { + [setAsDefaultCheckbox_ setHidden:YES]; + makeDefaultBrowser_ = NO; + } + // Only support the sizing the window once. DCHECK(!beenSized_) << "ShowWindow was called twice?"; if (!beenSized_) { -- cgit v1.1