|
@@ -5,9 +5,7 @@
|
|
|
#include "atom/browser/atom_resource_dispatcher_host_delegate.h"
|
|
|
|
|
|
#include "atom/browser/atom_browser_context.h"
|
|
|
-#include "atom/browser/web_contents_permission_helper.h"
|
|
|
#include "atom/browser/web_contents_preferences.h"
|
|
|
-#include "atom/common/platform_util.h"
|
|
|
#include "base/strings/utf_string_conversions.h"
|
|
|
#include "content/public/browser/browser_thread.h"
|
|
|
#include "content/public/browser/download_manager.h"
|
|
@@ -28,36 +26,6 @@ namespace atom {
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
-void OnOpenExternal(const GURL& escaped_url, bool allowed) {
|
|
|
- if (allowed)
|
|
|
- platform_util::OpenExternal(
|
|
|
-#if defined(OS_WIN)
|
|
|
- base::UTF8ToUTF16(escaped_url.spec()),
|
|
|
-#else
|
|
|
- escaped_url,
|
|
|
-#endif
|
|
|
- true);
|
|
|
-}
|
|
|
-
|
|
|
-void HandleExternalProtocolInUI(
|
|
|
- const GURL& url,
|
|
|
- const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter,
|
|
|
- bool has_user_gesture) {
|
|
|
- content::WebContents* web_contents = web_contents_getter.Run();
|
|
|
- if (!web_contents)
|
|
|
- return;
|
|
|
-
|
|
|
- auto* permission_helper =
|
|
|
- WebContentsPermissionHelper::FromWebContents(web_contents);
|
|
|
- if (!permission_helper)
|
|
|
- return;
|
|
|
-
|
|
|
- GURL escaped_url(net::EscapeExternalHandlerValue(url.spec()));
|
|
|
- auto callback = base::Bind(&OnOpenExternal, escaped_url);
|
|
|
- permission_helper->RequestOpenExternalPermission(callback, has_user_gesture,
|
|
|
- url);
|
|
|
-}
|
|
|
-
|
|
|
#if defined(ENABLE_PDF_VIEWER)
|
|
|
void OnPdfResourceIntercepted(
|
|
|
const GURL& original_url,
|
|
@@ -103,16 +71,6 @@ void OnPdfResourceIntercepted(
|
|
|
|
|
|
AtomResourceDispatcherHostDelegate::AtomResourceDispatcherHostDelegate() {}
|
|
|
|
|
|
-bool AtomResourceDispatcherHostDelegate::HandleExternalProtocol(
|
|
|
- const GURL& url,
|
|
|
- content::ResourceRequestInfo* info) {
|
|
|
- BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
|
|
|
- base::BindOnce(&HandleExternalProtocolInUI, url,
|
|
|
- info->GetWebContentsGetterForRequest(),
|
|
|
- info->HasUserGesture()));
|
|
|
- return true;
|
|
|
-}
|
|
|
-
|
|
|
bool AtomResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream(
|
|
|
net::URLRequest* request,
|
|
|
const std::string& mime_type,
|