1 // Copyright 2013 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 "xwalk/runtime/renderer/android/xwalk_permission_client.h"
7 #include "content/public/common/url_constants.h"
8 #include "content/public/renderer/render_frame.h"
9 #include "third_party/WebKit/public/platform/WebURL.h"
10 #include "third_party/WebKit/public/web/WebFrame.h"
16 XWalkPermissionClient::XWalkPermissionClient(content::RenderFrame* render_frame)
17 : content::RenderFrameObserver(render_frame) {
18 render_frame->GetWebFrame()->setPermissionClient(this);
21 XWalkPermissionClient::~XWalkPermissionClient() {
24 bool XWalkPermissionClient::allowImage(blink::WebFrame* frame,
25 bool enabled_per_settings,
26 const blink::WebURL& image_url) {
27 // Implementing setBlockNetworkImages, so allow local scheme images to be
29 if (enabled_per_settings)
32 // For compatibility, only blacklist network schemes instead of whitelisting.
33 const GURL url(image_url);
34 return !(url.SchemeIs(url::kHttpScheme) ||
35 url.SchemeIs(url::kHttpsScheme) ||
36 url.SchemeIs(content::kFtpScheme));