Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Side by Side Diff: android_webview/renderer/aw_render_view_ext.cc

Issue 16940009: [Android WebView] Implement WebPermissionClient methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « android_webview/renderer/aw_render_view_ext.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <string> 7 #include <string>
8 8
9 #include "android_webview/common/aw_hit_test_data.h" 9 #include "android_webview/common/aw_hit_test_data.h"
10 #include "android_webview/common/render_view_messages.h" 10 #include "android_webview/common/render_view_messages.h"
(...skipping 16 matching lines...) Expand all
27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h"
28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeList.h" 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeList.h"
29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
31 #include "third_party/skia/include/core/SkPicture.h" 31 #include "third_party/skia/include/core/SkPicture.h"
32 32
33 namespace android_webview { 33 namespace android_webview {
34 34
35 namespace { 35 namespace {
36 36
37 bool allowMixedContent(const WebKit::WebURL& url) {
joth 2013/06/13 19:16:28 nit: wrong Camelification
38 // We treat non-standard schemes as "secure" in the WebView to allow them to
39 // be used for request interception.
40 // TODO(benm): Tighten this restriction by requiring embedders to register
41 // their custom schemes? See b/9420953.
42 GURL gurl(url);
43 return !gurl.IsStandard();
44 }
45
37 GURL GetAbsoluteUrl(const WebKit::WebNode& node, const string16& url_fragment) { 46 GURL GetAbsoluteUrl(const WebKit::WebNode& node, const string16& url_fragment) {
38 return GURL(node.document().completeURL(url_fragment)); 47 return GURL(node.document().completeURL(url_fragment));
39 } 48 }
40 49
41 string16 GetHref(const WebKit::WebElement& element) { 50 string16 GetHref(const WebKit::WebElement& element) {
42 // Get the actual 'href' attribute, which might relative if valid or can 51 // Get the actual 'href' attribute, which might relative if valid or can
43 // possibly contain garbage otherwise, so not using absoluteLinkURL here. 52 // possibly contain garbage otherwise, so not using absoluteLinkURL here.
44 return element.getAttribute("href"); 53 return element.getAttribute("href");
45 } 54 }
46 55
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 if (enabled_per_settings) 184 if (enabled_per_settings)
176 return true; 185 return true;
177 186
178 // For compatibility, only blacklist network schemes instead of whitelisting. 187 // For compatibility, only blacklist network schemes instead of whitelisting.
179 const GURL url(image_url); 188 const GURL url(image_url);
180 return !(url.SchemeIs(chrome::kHttpScheme) || 189 return !(url.SchemeIs(chrome::kHttpScheme) ||
181 url.SchemeIs(chrome::kHttpsScheme) || 190 url.SchemeIs(chrome::kHttpsScheme) ||
182 url.SchemeIs(chrome::kFtpScheme)); 191 url.SchemeIs(chrome::kFtpScheme));
183 } 192 }
184 193
194 bool AwRenderViewExt::allowDisplayingInsecureContent(
195 WebKit::WebFrame* frame,
196 bool enabled_per_settings,
197 const WebKit::WebSecurityOrigin& origin,
198 const WebKit::WebURL& url) {
199 return enabled_per_settings ? true : allowMixedContent(url);
200 }
201
202 bool AwRenderViewExt::allowRunningInsecureContent(
203 WebKit::WebFrame* frame,
204 bool enabled_per_settings,
205 const WebKit::WebSecurityOrigin& origin,
206 const WebKit::WebURL& url) {
207 return enabled_per_settings ? true : allowMixedContent(url);
208 }
209
185 void AwRenderViewExt::DidCommitProvisionalLoad(WebKit::WebFrame* frame, 210 void AwRenderViewExt::DidCommitProvisionalLoad(WebKit::WebFrame* frame,
186 bool is_new_navigation) { 211 bool is_new_navigation) {
187 content::DocumentState* document_state = 212 content::DocumentState* document_state =
188 content::DocumentState::FromDataSource(frame->dataSource()); 213 content::DocumentState::FromDataSource(frame->dataSource());
189 if (document_state->can_load_local_resources()) { 214 if (document_state->can_load_local_resources()) {
190 WebKit::WebSecurityOrigin origin = frame->document().securityOrigin(); 215 WebKit::WebSecurityOrigin origin = frame->document().securityOrigin();
191 origin.grantLoadLocalResources(); 216 origin.grantLoadLocalResources();
192 } 217 }
193 } 218 }
194 219
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 } 294 }
270 295
271 void AwRenderViewExt::OnSetInitialPageScale(double page_scale_factor) { 296 void AwRenderViewExt::OnSetInitialPageScale(double page_scale_factor) {
272 if (!render_view() || !render_view()->GetWebView()) 297 if (!render_view() || !render_view()->GetWebView())
273 return; 298 return;
274 render_view()->GetWebView()->setInitialPageScaleOverride( 299 render_view()->GetWebView()->setInitialPageScaleOverride(
275 page_scale_factor); 300 page_scale_factor);
276 } 301 }
277 302
278 } // namespace android_webview 303 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/renderer/aw_render_view_ext.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698