summaryrefslogtreecommitdiffstats
path: root/chrome/browser/external_protocol_handler.cc
diff options
context:
space:
mode:
authoravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-21 21:24:36 +0000
committeravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-21 21:24:36 +0000
commit186812f1565d52b12aff9b99a76e79e170f35412 (patch)
treed7c1c683f92c43dc857e93766d9d7e9a2ab29b60 /chrome/browser/external_protocol_handler.cc
parent32eee5d094e9d919338038edffab4518899055ae (diff)
downloadchromium_src-186812f1565d52b12aff9b99a76e79e170f35412.zip
chromium_src-186812f1565d52b12aff9b99a76e79e170f35412.tar.gz
chromium_src-186812f1565d52b12aff9b99a76e79e170f35412.tar.bz2
Allow external whitelisted protocols on the Mac.
http://crbug.com/12287 Review URL: http://codereview.chromium.org/115660 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16657 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/external_protocol_handler.cc')
-rw-r--r--chrome/browser/external_protocol_handler.cc30
1 files changed, 27 insertions, 3 deletions
diff --git a/chrome/browser/external_protocol_handler.cc b/chrome/browser/external_protocol_handler.cc
index 118f2fe..bb139bd 100644
--- a/chrome/browser/external_protocol_handler.cc
+++ b/chrome/browser/external_protocol_handler.cc
@@ -25,6 +25,10 @@
#if defined(OS_WIN)
#include "base/registry.h"
#include "chrome/browser/views/external_protocol_dialog.h"
+#elif defined(OS_MACOSX)
+#include <ApplicationServices/ApplicationServices.h>
+#include "base/scoped_cftyperef.h"
+#include "base/sys_string_conversions.h"
#endif
// static
@@ -111,7 +115,7 @@ ExternalProtocolHandler::BlockState ExternalProtocolHandler::GetBlockState(
void ExternalProtocolHandler::LaunchUrl(const GURL& url,
int render_process_host_id,
int tab_contents_id) {
-#if defined(OS_WIN)
+#if !defined(OS_LINUX)
// Escape the input scheme to be sure that the command does not
// have parameters unexpected by the external program.
std::string escaped_url_string = EscapeExternalHandlerValue(url.spec());
@@ -120,6 +124,7 @@ void ExternalProtocolHandler::LaunchUrl(const GURL& url,
if (block_state == BLOCK)
return;
+#if defined(OS_WIN)
if (block_state == UNKNOWN) {
std::wstring command = ExternalProtocolDialog::GetApplicationForProtocol(
escaped_url);
@@ -136,6 +141,12 @@ void ExternalProtocolHandler::LaunchUrl(const GURL& url,
tab_contents_id);
return;
}
+#else
+ // For now, allow only whitelisted protocols to fire.
+ // TODO(port): implement dialog for Mac
+ if (block_state == UNKNOWN)
+ return;
+#endif
// Put this work on the file thread since ShellExecute may block for a
// significant amount of time.
@@ -149,7 +160,7 @@ void ExternalProtocolHandler::LaunchUrl(const GURL& url,
NewRunnableFunction(
&ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck,
escaped_url));
-#elif defined(OS_POSIX)
+#else
// TODO(port): Implement launching external handler.
NOTIMPLEMENTED();
#endif
@@ -199,7 +210,20 @@ void ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(const GURL& url) {
// bug 1136923.
return;
}
-#elif defined(OS_POSIX)
+#elif defined(OS_MACOSX)
+ scoped_cftyperef<CFStringRef> string_ref(
+ base::SysUTF8ToCFStringRef(url.spec()));
+ if (!string_ref)
+ return;
+
+ scoped_cftyperef<CFURLRef> url_ref(CFURLCreateWithString(kCFAllocatorDefault,
+ string_ref,
+ NULL));
+ if (!url_ref)
+ return;
+
+ LSOpenCFURLRef(url_ref, NULL);
+#elif defined(OS_LINUX)
// TODO(port): Implement launching external handler.
NOTIMPLEMENTED();
#endif