OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "android_webview/renderer/aw_render_view_ext.h" | 5 #include "android_webview/renderer/aw_render_view_ext.h" |
6 | 6 |
7 #include "android_webview/common/render_view_messages.h" | 7 #include "android_webview/common/render_view_messages.h" |
| 8 #include "content/public/common/url_constants.h" |
8 #include "content/public/renderer/render_view.h" | 9 #include "content/public/renderer/render_view.h" |
| 10 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" |
| 11 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" |
9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
13 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" | |
14 | 16 |
15 namespace android_webview { | 17 namespace android_webview { |
16 | 18 |
17 AwRenderViewExt::AwRenderViewExt(content::RenderView* render_view) | 19 AwRenderViewExt::AwRenderViewExt(content::RenderView* render_view) |
18 : content::RenderViewObserver(render_view) { | 20 : content::RenderViewObserver(render_view) { |
| 21 render_view->GetWebView()->setPermissionClient(this); |
19 } | 22 } |
20 | 23 |
21 AwRenderViewExt::~AwRenderViewExt() {} | 24 AwRenderViewExt::~AwRenderViewExt() {} |
22 | 25 |
23 // static | 26 // static |
24 void AwRenderViewExt::RenderViewCreated(content::RenderView* render_view) { | 27 void AwRenderViewExt::RenderViewCreated(content::RenderView* render_view) { |
25 new AwRenderViewExt(render_view); // |render_view| takes ownership. | 28 new AwRenderViewExt(render_view); // |render_view| takes ownership. |
26 } | 29 } |
27 | 30 |
28 bool AwRenderViewExt::OnMessageReceived(const IPC::Message& message) { | 31 bool AwRenderViewExt::OnMessageReceived(const IPC::Message& message) { |
(...skipping 12 matching lines...) Expand all Loading... |
41 if (webview) { | 44 if (webview) { |
42 WebKit::WebVector<WebKit::WebElement> images; | 45 WebKit::WebVector<WebKit::WebElement> images; |
43 webview->mainFrame()->document().images(images); | 46 webview->mainFrame()->document().images(images); |
44 hasImages = !images.isEmpty(); | 47 hasImages = !images.isEmpty(); |
45 } | 48 } |
46 } | 49 } |
47 Send(new AwViewHostMsg_DocumentHasImagesResponse(routing_id(), id, | 50 Send(new AwViewHostMsg_DocumentHasImagesResponse(routing_id(), id, |
48 hasImages)); | 51 hasImages)); |
49 } | 52 } |
50 | 53 |
| 54 bool AwRenderViewExt::allowImage(WebKit::WebFrame* frame, |
| 55 bool enabled_per_settings, |
| 56 const WebKit::WebURL& image_url) { |
| 57 // Implementing setBlockNetworkImages, so allow local scheme images to be |
| 58 // loaded. |
| 59 if (enabled_per_settings) |
| 60 return true; |
| 61 |
| 62 // For compatibility, only blacklist network schemes instead of whitelisting. |
| 63 const GURL url(image_url); |
| 64 return !(url.SchemeIs(chrome::kHttpScheme) || |
| 65 url.SchemeIs(chrome::kHttpsScheme) || |
| 66 url.SchemeIs(chrome::kFtpScheme)); |
| 67 } |
| 68 |
51 } // namespace android_webview | 69 } // namespace android_webview |
OLD | NEW |