Upstream version 9.37.193.0
[platform/framework/web/crosswalk.git] / src / xwalk / runtime / renderer / android / xwalk_permission_client.cc
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.
4
5 #include "xwalk/runtime/renderer/android/xwalk_permission_client.h"
6
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"
11 #include "url/gurl.h"
12
13 namespace xwalk {
14
15 XWalkPermissionClient::XWalkPermissionClient(content::RenderFrame* render_frame)
16     : content::RenderFrameObserver(render_frame) {
17   render_frame->GetWebFrame()->setPermissionClient(this);
18 }
19
20 XWalkPermissionClient::~XWalkPermissionClient() {
21 }
22
23 bool XWalkPermissionClient::allowImage(bool enabled_per_settings,
24                                        const blink::WebURL& image_url) {
25   // Implementing setBlockNetworkImages, so allow local scheme images to be
26   // loaded.
27   if (enabled_per_settings)
28     return true;
29
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));
35 }
36
37 }  // namespace xwalk