OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/mac_util.h" | 7 #include "base/mac/mac_util.h" |
8 #include "base/mac/foundation_util.h" | 8 #include "base/mac/foundation_util.h" |
9 #include "chrome/common/chrome_version_info.h" | 9 #include "chrome/common/chrome_version_info.h" |
10 #import "third_party/mozilla/NSWorkspace+Utils.h" | 10 #import "third_party/mozilla/NSWorkspace+Utils.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 return true; | 31 return true; |
32 } | 32 } |
33 | 33 |
34 // Sets Chromium as the default application to be used by the operating system | 34 // Sets Chromium as the default application to be used by the operating system |
35 // for the given protocol. This applies only for the current user. Returns false | 35 // for the given protocol. This applies only for the current user. Returns false |
36 // if this cannot be done, or if the operation fails. | 36 // if this cannot be done, or if the operation fails. |
37 bool ShellIntegration::SetAsDefaultProtocolClient(const std::string& protocol) { | 37 bool ShellIntegration::SetAsDefaultProtocolClient(const std::string& protocol) { |
38 if (protocol.empty()) | 38 if (protocol.empty()) |
39 return false; | 39 return false; |
40 | 40 |
41 if (!CanSetAsDefaultProtocolClient(protocol)) | 41 if (!CanSetAsDefaultProtocolClient()) |
42 return false; | 42 return false; |
43 | 43 |
44 // We really do want the main bundle here, not base::mac::MainAppBundle(), | 44 // We really do want the main bundle here, not base::mac::MainAppBundle(), |
45 // which is the bundle for the framework. | 45 // which is the bundle for the framework. |
46 NSString* identifier = [[NSBundle mainBundle] bundleIdentifier]; | 46 NSString* identifier = [[NSBundle mainBundle] bundleIdentifier]; |
47 if (!identifier) | 47 if (!identifier) |
48 return false; | 48 return false; |
49 | 49 |
50 NSString* protocol_ns = [NSString stringWithUTF8String:protocol.c_str()]; | 50 NSString* protocol_ns = [NSString stringWithUTF8String:protocol.c_str()]; |
51 OSStatus return_code = | 51 OSStatus return_code = |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 // We really do want the main bundle here, not base::mac::MainAppBundle(), | 120 // We really do want the main bundle here, not base::mac::MainAppBundle(), |
121 // which is the bundle for the framework. | 121 // which is the bundle for the framework. |
122 NSString* my_identifier = [[NSBundle mainBundle] bundleIdentifier]; | 122 NSString* my_identifier = [[NSBundle mainBundle] bundleIdentifier]; |
123 if (!my_identifier) | 123 if (!my_identifier) |
124 return UNKNOWN_DEFAULT_WEB_CLIENT; | 124 return UNKNOWN_DEFAULT_WEB_CLIENT; |
125 | 125 |
126 NSString* protocol_ns = [NSString stringWithUTF8String:protocol.c_str()]; | 126 NSString* protocol_ns = [NSString stringWithUTF8String:protocol.c_str()]; |
127 return IsIdentifierDefaultProtocolClient(my_identifier, protocol_ns) ? | 127 return IsIdentifierDefaultProtocolClient(my_identifier, protocol_ns) ? |
128 IS_DEFAULT_WEB_CLIENT : NOT_DEFAULT_WEB_CLIENT; | 128 IS_DEFAULT_WEB_CLIENT : NOT_DEFAULT_WEB_CLIENT; |
129 } | 129 } |
OLD | NEW |