Upstream version 7.36.149.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
16 XWalkPermissionClient::XWalkPermissionClient(content::RenderFrame* render_frame)
17     : content::RenderFrameObserver(render_frame) {
18   render_frame->GetWebFrame()->setPermissionClient(this);
19 }
20
21 XWalkPermissionClient::~XWalkPermissionClient() {
22 }
23
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
28   // loaded.
29   if (enabled_per_settings)
30     return true;
31
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));
37 }
38
39 }  // namespace xwalk