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"
15 XWalkPermissionClient::XWalkPermissionClient(content::RenderFrame* render_frame)
16 : content::RenderFrameObserver(render_frame) {
17 render_frame->GetWebFrame()->setPermissionClient(this);
20 XWalkPermissionClient::~XWalkPermissionClient() {
23 bool XWalkPermissionClient::allowImage(bool enabled_per_settings,
24 const blink::WebURL& image_url) {
25 // Implementing setBlockNetworkImages, so allow local scheme images to be
27 if (enabled_per_settings)
30 // For compatibility, only blacklist network schemes instead of whitelisting.
31 const GURL url(image_url);
32 return !(url.SchemeIs(url::kHttpScheme) ||
33 url.SchemeIs(url::kHttpsScheme) ||
34 url.SchemeIs(url::kFtpScheme));