1 // Copyright 2015 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.
5 #include "chrome/browser/net/net_error_diagnostics_dialog.h"
7 #include <CoreFoundation/CoreFoundation.h>
8 #include <CoreServices/CoreServices.h>
10 #include "base/logging.h"
11 #include "base/mac/scoped_cftyperef.h"
12 #include "base/strings/sys_string_conversions.h"
14 bool CanShowNetworkDiagnosticsDialog() {
18 void ShowNetworkDiagnosticsDialog(content::WebContents
* web_contents
,
19 const std::string
& failed_url
) {
20 base::ScopedCFTypeRef
<CFStringRef
> url_string_ref(
21 base::SysUTF8ToCFStringRef(failed_url
));
22 base::ScopedCFTypeRef
<CFURLRef
> url_ref(
23 CFURLCreateWithString(kCFAllocatorDefault
, url_string_ref
.get(),
28 base::ScopedCFTypeRef
<CFNetDiagnosticRef
> diagnostic_ref(
29 CFNetDiagnosticCreateWithURL(kCFAllocatorDefault
, url_ref
.get()));
30 if (!diagnostic_ref
.get())
33 CFNetDiagnosticDiagnoseProblemInteractively(diagnostic_ref
.get());