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

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

Issue 104833006: Switch ContentSettingsObserver to be a RenderFrameObserver instead of a RenderViewObserver (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years 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 | Annotate | Revision Log
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 19 matching lines...) Expand all
30 #include "third_party/WebKit/public/web/WebNodeList.h" 30 #include "third_party/WebKit/public/web/WebNodeList.h"
31 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" 31 #include "third_party/WebKit/public/web/WebSecurityOrigin.h"
32 #include "third_party/WebKit/public/web/WebView.h" 32 #include "third_party/WebKit/public/web/WebView.h"
33 #include "url/url_canon.h" 33 #include "url/url_canon.h"
34 #include "url/url_util.h" 34 #include "url/url_util.h"
35 35
36 namespace android_webview { 36 namespace android_webview {
37 37
38 namespace { 38 namespace {
39 39
40 bool AllowMixedContent(const blink::WebURL& url) {
41 // We treat non-standard schemes as "secure" in the WebView to allow them to
42 // be used for request interception.
43 // TODO(benm): Tighten this restriction by requiring embedders to register
44 // their custom schemes? See b/9420953.
45 GURL gurl(url);
46 return !gurl.IsStandard();
47 }
48
49 GURL GetAbsoluteUrl(const blink::WebNode& node, const string16& url_fragment) { 40 GURL GetAbsoluteUrl(const blink::WebNode& node, const string16& url_fragment) {
50 return GURL(node.document().completeURL(url_fragment)); 41 return GURL(node.document().completeURL(url_fragment));
51 } 42 }
52 43
53 string16 GetHref(const blink::WebElement& element) { 44 string16 GetHref(const blink::WebElement& element) {
54 // Get the actual 'href' attribute, which might relative if valid or can 45 // Get the actual 'href' attribute, which might relative if valid or can
55 // possibly contain garbage otherwise, so not using absoluteLinkURL here. 46 // possibly contain garbage otherwise, so not using absoluteLinkURL here.
56 return element.getAttribute("href"); 47 return element.getAttribute("href");
57 } 48 }
58 49
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 } else if (is_editable) { 129 } else if (is_editable) {
139 data->type = AwHitTestData::EDIT_TEXT_TYPE; 130 data->type = AwHitTestData::EDIT_TEXT_TYPE;
140 DCHECK(data->extra_data_for_type.length() == 0); 131 DCHECK(data->extra_data_for_type.length() == 0);
141 } 132 }
142 } 133 }
143 134
144 } // namespace 135 } // namespace
145 136
146 AwRenderViewExt::AwRenderViewExt(content::RenderView* render_view) 137 AwRenderViewExt::AwRenderViewExt(content::RenderView* render_view)
147 : content::RenderViewObserver(render_view), page_scale_factor_(0.0f) { 138 : content::RenderViewObserver(render_view), page_scale_factor_(0.0f) {
148 render_view->GetWebView()->setPermissionClient(this);
149 } 139 }
150 140
151 AwRenderViewExt::~AwRenderViewExt() { 141 AwRenderViewExt::~AwRenderViewExt() {
152 } 142 }
153 143
154 // static 144 // static
155 void AwRenderViewExt::RenderViewCreated(content::RenderView* render_view) { 145 void AwRenderViewExt::RenderViewCreated(content::RenderView* render_view) {
156 new AwRenderViewExt(render_view); // |render_view| takes ownership. 146 new AwRenderViewExt(render_view); // |render_view| takes ownership.
157 } 147 }
158 148
(...skipping 20 matching lines...) Expand all
179 if (webview) { 169 if (webview) {
180 blink::WebVector<blink::WebElement> images; 170 blink::WebVector<blink::WebElement> images;
181 webview->mainFrame()->document().images(images); 171 webview->mainFrame()->document().images(images);
182 hasImages = !images.isEmpty(); 172 hasImages = !images.isEmpty();
183 } 173 }
184 } 174 }
185 Send(new AwViewHostMsg_DocumentHasImagesResponse(routing_id(), id, 175 Send(new AwViewHostMsg_DocumentHasImagesResponse(routing_id(), id,
186 hasImages)); 176 hasImages));
187 } 177 }
188 178
189 bool AwRenderViewExt::allowDisplayingInsecureContent(
190 blink::WebFrame* frame,
191 bool enabled_per_settings,
192 const blink::WebSecurityOrigin& origin,
193 const blink::WebURL& url) {
194 return enabled_per_settings ? true : AllowMixedContent(url);
195 }
196
197 bool AwRenderViewExt::allowRunningInsecureContent(
198 blink::WebFrame* frame,
199 bool enabled_per_settings,
200 const blink::WebSecurityOrigin& origin,
201 const blink::WebURL& url) {
202 return enabled_per_settings ? true : AllowMixedContent(url);
203 }
204
205 void AwRenderViewExt::DidCommitProvisionalLoad(blink::WebFrame* frame, 179 void AwRenderViewExt::DidCommitProvisionalLoad(blink::WebFrame* frame,
206 bool is_new_navigation) { 180 bool is_new_navigation) {
207 content::DocumentState* document_state = 181 content::DocumentState* document_state =
208 content::DocumentState::FromDataSource(frame->dataSource()); 182 content::DocumentState::FromDataSource(frame->dataSource());
209 if (document_state->can_load_local_resources()) { 183 if (document_state->can_load_local_resources()) {
210 blink::WebSecurityOrigin origin = frame->document().securityOrigin(); 184 blink::WebSecurityOrigin origin = frame->document().securityOrigin();
211 origin.grantLoadLocalResources(); 185 origin.grantLoadLocalResources();
212 } 186 }
213 } 187 }
214 188
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 render_view()->GetWebView()->setFixedLayoutSize(size); 318 render_view()->GetWebView()->setFixedLayoutSize(size);
345 } 319 }
346 320
347 void AwRenderViewExt::OnSetBackgroundColor(SkColor c) { 321 void AwRenderViewExt::OnSetBackgroundColor(SkColor c) {
348 if (!render_view() || !render_view()->GetWebView()) 322 if (!render_view() || !render_view()->GetWebView())
349 return; 323 return;
350 render_view()->GetWebView()->setBaseBackgroundColor(c); 324 render_view()->GetWebView()->setBaseBackgroundColor(c);
351 } 325 }
352 326
353 } // namespace android_webview 327 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698