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
3// found in the LICENSE file.
4
5#import <Cocoa/Cocoa.h>
6
7#include "chrome/browser/ui/webui/options/advanced_options_utils.h"
8
9#include "base/logging.h"
10#include "base/mac/mac_logging.h"
11#include "base/mac/scoped_aedesc.h"
12
13using content::WebContents;
14
15namespace options {
16
17void AdvancedOptionsUtilities::ShowNetworkProxySettings(
18      WebContents* web_contents) {
19  NSArray* itemsToOpen = [NSArray arrayWithObject:[NSURL fileURLWithPath:
20      @"/System/Library/PreferencePanes/Network.prefPane"]];
21
22  const char* proxyPrefCommand = "Proxies";
23  base::mac::ScopedAEDesc<> openParams;
24  OSStatus status = AECreateDesc('ptru',
25                                 proxyPrefCommand,
26                                 strlen(proxyPrefCommand),
27                                 openParams.OutPointer());
28  OSSTATUS_LOG_IF(ERROR, status != noErr, status)
29      << "Failed to create open params";
30
31  LSLaunchURLSpec launchSpec = { 0 };
32  launchSpec.itemURLs = (CFArrayRef)itemsToOpen;
33  launchSpec.passThruParams = openParams;
34  launchSpec.launchFlags = kLSLaunchAsync | kLSLaunchDontAddToRecents;
35  LSOpenFromURLSpec(&launchSpec, NULL);
36}
37
38void AdvancedOptionsUtilities::ShowManageSSLCertificates(
39      WebContents* web_contents) {
40  NSString* const kKeychainBundleId = @"com.apple.keychainaccess";
41  [[NSWorkspace sharedWorkspace]
42   launchAppWithBundleIdentifier:kKeychainBundleId
43   options:0L
44   additionalEventParamDescriptor:nil
45   launchIdentifier:nil];
46}
47
48}  // namespace options
49