| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/shell_integration.h" | 5 #include "chrome/browser/shell_integration.h" |
| 6 | 6 |
| 7 #include "base/mac/bundle_locations.h" | 7 #include "base/mac/bundle_locations.h" |
| 8 #include "base/mac/foundation_util.h" | 8 #include "base/mac/foundation_util.h" |
| 9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
| 10 #include "chrome/common/channel_info.h" | 10 #include "chrome/common/channel_info.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 [default_client caseInsensitiveCompare:identifier]; | 46 [default_client caseInsensitiveCompare:identifier]; |
| 47 return result == NSOrderedSame; | 47 return result == NSOrderedSame; |
| 48 } | 48 } |
| 49 | 49 |
| 50 } // namespace | 50 } // namespace |
| 51 | 51 |
| 52 // Sets Chromium as default browser to be used by the operating system. This | 52 // Sets Chromium as default browser to be used by the operating system. This |
| 53 // applies only for the current user. Returns false if this cannot be done, or | 53 // applies only for the current user. Returns false if this cannot be done, or |
| 54 // if the operation fails. | 54 // if the operation fails. |
| 55 bool SetAsDefaultBrowser() { | 55 bool SetAsDefaultBrowser() { |
| 56 if (CanSetAsDefaultBrowser()) | 56 if (!CanSetAsDefaultBrowser()) |
| 57 return false; | 57 return false; |
| 58 | 58 |
| 59 // We really do want the outer bundle here, not the main bundle since setting | 59 // We really do want the outer bundle here, not the main bundle since setting |
| 60 // a shortcut to Chrome as the default browser doesn't make sense. | 60 // a shortcut to Chrome as the default browser doesn't make sense. |
| 61 NSString* identifier = [base::mac::OuterBundle() bundleIdentifier]; | 61 NSString* identifier = [base::mac::OuterBundle() bundleIdentifier]; |
| 62 if (!identifier) | 62 if (!identifier) |
| 63 return false; | 63 return false; |
| 64 | 64 |
| 65 [[NSWorkspace sharedWorkspace] setDefaultBrowserWithIdentifier:identifier]; | 65 [[NSWorkspace sharedWorkspace] setDefaultBrowserWithIdentifier:identifier]; |
| 66 return true; | 66 return true; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 NSString* my_identifier = [base::mac::MainBundle() bundleIdentifier]; | 146 NSString* my_identifier = [base::mac::MainBundle() bundleIdentifier]; |
| 147 if (!my_identifier) | 147 if (!my_identifier) |
| 148 return UNKNOWN_DEFAULT; | 148 return UNKNOWN_DEFAULT; |
| 149 | 149 |
| 150 NSString* protocol_ns = [NSString stringWithUTF8String:protocol.c_str()]; | 150 NSString* protocol_ns = [NSString stringWithUTF8String:protocol.c_str()]; |
| 151 return IsIdentifierDefaultProtocolClient(my_identifier, protocol_ns) ? | 151 return IsIdentifierDefaultProtocolClient(my_identifier, protocol_ns) ? |
| 152 IS_DEFAULT : NOT_DEFAULT; | 152 IS_DEFAULT : NOT_DEFAULT; |
| 153 } | 153 } |
| 154 | 154 |
| 155 } // namespace shell_integration | 155 } // namespace shell_integration |
| OLD | NEW |