| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/common/aw_hit_test_data.h" | 5 #include "android_webview/common/aw_hit_test_data.h" |
| 6 #include "android_webview/common/render_view_messages.h" | 6 #include "android_webview/common/render_view_messages.h" |
| 7 #include "android_webview/renderer/aw_render_frame_ext.h" | 7 #include "android_webview/renderer/aw_render_frame_ext.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "content/public/renderer/android_content_detection_prefixes.h" | 9 #include "content/public/renderer/android_content_detection_prefixes.h" |
| 10 #include "content/public/renderer/document_state.h" | 10 #include "content/public/renderer/document_state.h" |
| 11 #include "content/public/renderer/render_frame.h" | 11 #include "content/public/renderer/render_frame.h" |
| 12 #include "content/public/renderer/render_view.h" | 12 #include "content/public/renderer/render_view.h" |
| 13 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 13 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
| 14 #include "third_party/WebKit/public/platform/WebSize.h" | 14 #include "third_party/WebKit/public/platform/WebSize.h" |
| 15 #include "third_party/WebKit/public/web/WebDocument.h" | 15 #include "third_party/WebKit/public/web/WebDocument.h" |
| 16 #include "third_party/WebKit/public/web/WebElement.h" | 16 #include "third_party/WebKit/public/web/WebElement.h" |
| 17 #include "third_party/WebKit/public/web/WebElementCollection.h" | 17 #include "third_party/WebKit/public/web/WebElementCollection.h" |
| 18 #include "third_party/WebKit/public/web/WebFrameWidget.h" | 18 #include "third_party/WebKit/public/web/WebFrameWidget.h" |
| 19 #include "third_party/WebKit/public/web/WebHitTestResult.h" | 19 #include "third_party/WebKit/public/web/WebHitTestResult.h" |
| 20 #include "third_party/WebKit/public/web/WebImageCache.h" |
| 20 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 21 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 21 #include "third_party/WebKit/public/web/WebMeaningfulLayout.h" | 22 #include "third_party/WebKit/public/web/WebMeaningfulLayout.h" |
| 22 #include "third_party/WebKit/public/web/WebNode.h" | 23 #include "third_party/WebKit/public/web/WebNode.h" |
| 23 #include "third_party/WebKit/public/web/WebView.h" | 24 #include "third_party/WebKit/public/web/WebView.h" |
| 24 #include "url/url_canon.h" | 25 #include "url/url_canon.h" |
| 25 #include "url/url_constants.h" | 26 #include "url/url_constants.h" |
| 26 #include "url/url_util.h" | 27 #include "url/url_util.h" |
| 27 | 28 |
| 28 namespace android_webview { | 29 namespace android_webview { |
| 29 | 30 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 140 |
| 140 void AwRenderFrameExt::DidCommitProvisionalLoad(bool is_new_navigation, | 141 void AwRenderFrameExt::DidCommitProvisionalLoad(bool is_new_navigation, |
| 141 bool is_same_page_navigation) { | 142 bool is_same_page_navigation) { |
| 142 blink::WebLocalFrame* frame = render_frame()->GetWebFrame(); | 143 blink::WebLocalFrame* frame = render_frame()->GetWebFrame(); |
| 143 content::DocumentState* document_state = | 144 content::DocumentState* document_state = |
| 144 content::DocumentState::FromDataSource(frame->dataSource()); | 145 content::DocumentState::FromDataSource(frame->dataSource()); |
| 145 if (document_state->can_load_local_resources()) { | 146 if (document_state->can_load_local_resources()) { |
| 146 blink::WebSecurityOrigin origin = frame->document().getSecurityOrigin(); | 147 blink::WebSecurityOrigin origin = frame->document().getSecurityOrigin(); |
| 147 origin.grantLoadLocalResources(); | 148 origin.grantLoadLocalResources(); |
| 148 } | 149 } |
| 150 |
| 151 // Clear the cache when we cross site boundaries in the main frame. |
| 152 // |
| 153 // We're trying to approximate what happens with a multi-process Chromium, |
| 154 // where navigation across origins would cause a new render process to spin |
| 155 // up, and thus start with a clear cache. Wiring up a signal from browser to |
| 156 // renderer code to say "this navigation would have switched processes" would |
| 157 // be disruptive, so this clearing of the cache is the compromise. |
| 158 if (!frame->parent()) { |
| 159 url::Origin new_origin(frame->document().url()); |
| 160 if (!new_origin.IsSameOriginWith(last_origin_)) { |
| 161 last_origin_ = new_origin; |
| 162 blink::WebImageCache::clear(); |
| 163 } |
| 164 } |
| 149 } | 165 } |
| 150 | 166 |
| 151 bool AwRenderFrameExt::OnMessageReceived(const IPC::Message& message) { | 167 bool AwRenderFrameExt::OnMessageReceived(const IPC::Message& message) { |
| 152 bool handled = true; | 168 bool handled = true; |
| 153 IPC_BEGIN_MESSAGE_MAP(AwRenderFrameExt, message) | 169 IPC_BEGIN_MESSAGE_MAP(AwRenderFrameExt, message) |
| 154 IPC_MESSAGE_HANDLER(AwViewMsg_DocumentHasImages, OnDocumentHasImagesRequest) | 170 IPC_MESSAGE_HANDLER(AwViewMsg_DocumentHasImages, OnDocumentHasImagesRequest) |
| 155 IPC_MESSAGE_HANDLER(AwViewMsg_DoHitTest, OnDoHitTest) | 171 IPC_MESSAGE_HANDLER(AwViewMsg_DoHitTest, OnDoHitTest) |
| 156 IPC_MESSAGE_HANDLER(AwViewMsg_SetTextZoomFactor, OnSetTextZoomFactor) | 172 IPC_MESSAGE_HANDLER(AwViewMsg_SetTextZoomFactor, OnSetTextZoomFactor) |
| 157 IPC_MESSAGE_HANDLER(AwViewMsg_ResetScrollAndScaleState, | 173 IPC_MESSAGE_HANDLER(AwViewMsg_ResetScrollAndScaleState, |
| 158 OnResetScrollAndScaleState) | 174 OnResetScrollAndScaleState) |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 } | 296 } |
| 281 | 297 |
| 282 blink::WebFrameWidget* AwRenderFrameExt::GetWebFrameWidget() { | 298 blink::WebFrameWidget* AwRenderFrameExt::GetWebFrameWidget() { |
| 283 if (!render_frame() || !render_frame()->GetRenderView()) | 299 if (!render_frame() || !render_frame()->GetRenderView()) |
| 284 return nullptr; | 300 return nullptr; |
| 285 | 301 |
| 286 return render_frame()->GetRenderView()->GetWebFrameWidget(); | 302 return render_frame()->GetRenderView()->GetWebFrameWidget(); |
| 287 } | 303 } |
| 288 | 304 |
| 289 } // namespace android_webview | 305 } // namespace android_webview |
| OLD | NEW |