Skip to content

Commit bdcffb1

Browse files
committed
Merge pull request nwjs#406 from zhchbin/issue403
Implement HandleExternalProtocol of the ShellResourceDispatcherHostDelegate
2 parents bd95121 + 0bcc984 commit bdcffb1

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/browser/shell_resource_dispatcher_host_delegate.cc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020

2121
#include "content/nw/src/browser/shell_resource_dispatcher_host_delegate.h"
2222

23+
#include "chrome/browser/platform_util.h"
2324
#include "content/nw/src/browser/shell_login_dialog.h"
25+
#include "content/public/browser/browser_thread.h"
26+
2427

2528
namespace content {
2629

@@ -49,4 +52,22 @@ ShellResourceDispatcherHostDelegate::CreateLoginDelegate(
4952
return new ShellLoginDialog(auth_info, request);
5053
}
5154

55+
bool ShellResourceDispatcherHostDelegate::HandleExternalProtocol(
56+
const GURL& url, int child_id, int route_id) {
57+
#if defined(OS_MACOSX)
58+
// This must run on the UI thread on OS X.
59+
platform_util::OpenExternal(url);
60+
#else
61+
// Otherwise put this work on the file thread. On Windows ShellExecute may
62+
// block for a significant amount of time, and it shouldn't hurt on Linux.
63+
BrowserThread::PostTask(
64+
BrowserThread::FILE,
65+
FROM_HERE,
66+
base::Bind(&platform_util::OpenExternal, url));
67+
#endif
68+
69+
return true;
70+
}
71+
72+
5273
} // namespace content

src/browser/shell_resource_dispatcher_host_delegate.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ class ShellResourceDispatcherHostDelegate
2222
net::AuthChallengeInfo* auth_info) OVERRIDE;
2323
virtual ResourceDispatcherHostLoginDelegate* CreateLoginDelegate(
2424
net::AuthChallengeInfo* auth_info, net::URLRequest* request) OVERRIDE;
25+
virtual bool HandleExternalProtocol(const GURL& url,
26+
int child_id,
27+
int route_id) OVERRIDE;
2528

2629
// Used for content_browsertests.
2730
void set_login_request_callback(

0 commit comments

Comments
 (0)