Commit 4c1882e8 authored by Hitoshi Yoshida's avatar Hitoshi Yoshida Committed by Commit Bot

Revert "Mac SxS: Don't ask to take default from other Chromium channels"

This reverts commit e2d335fb.

Reason for revert: This CL triggers a compile error.

Bug: 1110221

Original change's description:
> Mac SxS: Don't ask to take default from other Chromium channels
> 
> If another channel of Chromium is already default, don't ask to
> become default.
> 
> Bug: 1109417
> Change-Id: I095410b47a64731c7ca7fbafa5f3e3427ec89d42
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2318193
> Reviewed-by: Mark Mentovai <mark@chromium.org>
> Commit-Queue: Avi Drissman <avi@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#792144}

TBR=avi@chromium.org,mark@chromium.org

Change-Id: I59a405e113cca1abc28c9c01c34166d572c60c31
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1109417
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2322008Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Commit-Queue: Hitoshi Yoshida <peria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#792171}
parent 4ea902d2
......@@ -9,7 +9,6 @@
#include "base/mac/mac_util.h"
#include "base/mac/scoped_cftyperef.h"
#include "base/strings/sys_string_conversions.h"
#include "build/branding_buildflags.h"
#include "chrome/common/channel_info.h"
#include "components/version_info/version_info.h"
#import "third_party/mozilla/NSWorkspace+Utils.h"
......@@ -18,6 +17,20 @@ namespace shell_integration {
namespace {
// Returns true if |identifier| is the bundle id of the default browser.
bool IsIdentifierDefaultBrowser(NSString* identifier) {
NSString* default_browser =
[[NSWorkspace sharedWorkspace] defaultBrowserIdentifier];
if (!default_browser)
return false;
// We need to ensure we do the comparison case-insensitive as LS doesn't
// persist the case of our bundle id.
NSComparisonResult result =
[default_browser caseInsensitiveCompare:identifier];
return result == NSOrderedSame;
}
// Returns true if |identifier| is the bundle id of the default client
// application for the given protocol.
bool IsIdentifierDefaultProtocolClient(NSString* identifier,
......@@ -27,7 +40,8 @@ bool IsIdentifierDefaultProtocolClient(NSString* identifier,
if (!default_client)
return false;
// Do the comparison case-insensitively as LS smashes the case.
// We need to ensure we do the comparison case-insensitive as LS doesn't
// persist the case of our bundle id.
NSComparisonResult result =
[base::mac::CFToNSCast(default_client) caseInsensitiveCompare:identifier];
return result == NSOrderedSame;
......@@ -128,51 +142,12 @@ DefaultWebClientState GetDefaultBrowser() {
if (!my_identifier)
return UNKNOWN_DEFAULT;
base::ScopedCFTypeRef<CFStringRef> default_browser_cf(
LSCopyDefaultHandlerForURLScheme(CFSTR("http")));
if (!default_browser_cf)
return NOT_DEFAULT;
NSString* default_browser = base::mac::CFToNSCast(default_browser_cf);
// Do the comparison case-insensitively as LS smashes the case.
if ([default_browser caseInsensitiveCompare:my_identifier] == NSOrderedSame)
return IS_DEFAULT;
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
// Flavors of Chrome are of the constructions "com.google.Chrome" and
// "com.google.Chrome.beta". If the first three components match, then these
// are variant flavors.
auto three_components_only_lopper = [](NSString* bundle_id) {
NSMutableArray<NSString*>* parts =
[[bundle_id componentsSeparatedByString:@"."] mutableCopy];
while ([parts count] > 3)
[parts removeLastObject];
return [parts componentsJoinedByString:"."];
};
NSString* my_identifier_lopped = three_components_only_lopper(my_identifier);
NSString* default_browser_lopped =
three_components_only_lopper(default_browser);
// Do the comparisons case-insensitively as LS smashes the case.
if ([my_identifier_lopped caseInsensitiveCompare:default_browser_lopped] ==
NSOrderedSame) {
return OTHER_MODE_IS_DEFAULT;
}
#endif // BUILDFLAG(GOOGLE_CHROME_BRANDING)
return NOT_DEFAULT;
return IsIdentifierDefaultBrowser(my_identifier) ? IS_DEFAULT : NOT_DEFAULT;
}
// Returns true if Firefox is the default browser for the current user.
bool IsFirefoxDefaultBrowser() {
base::ScopedCFTypeRef<CFStringRef> default_browser(
LSCopyDefaultHandlerForURLScheme(CFSTR("http")));
if (!default_browser)
return false;
// Do the comparison case-insensitively as LS smashes the case.
return CFStringCompare(default_browser, CFSTR("org.mozilla.firefox"),
kCFCompareCaseInsensitive) == kCFCompareEqualTo;
return IsIdentifierDefaultBrowser(@"org.mozilla.firefox");
}
// Attempt to determine if this instance of Chrome is the default client
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment