summaryrefslogtreecommitdiffstats
path: root/android_webview/renderer
diff options
context:
space:
mode:
authoravi <avi@chromium.org>2016-03-10 15:53:46 -0800
committerCommit bot <commit-bot@chromium.org>2016-03-10 23:55:46 +0000
commit0363eb92d2784e47b4afba897866b24277163111 (patch)
tree7b299736154c5e8e2574d09abae9a0a486b43e02 /android_webview/renderer
parentdb227315c9a1706155a3c66d9a41a509df73323a (diff)
downloadchromium_src-0363eb92d2784e47b4afba897866b24277163111.zip
chromium_src-0363eb92d2784e47b4afba897866b24277163111.tar.gz
chromium_src-0363eb92d2784e47b4afba897866b24277163111.tar.bz2
Move cache clearing from AwRenderViewExt to AwRenderFrameExt.
BUG=593473 TEST=no change Review URL: https://codereview.chromium.org/1785493002 Cr-Commit-Position: refs/heads/master@{#380494}
Diffstat (limited to 'android_webview/renderer')
-rw-r--r--android_webview/renderer/aw_render_frame_ext.cc16
-rw-r--r--android_webview/renderer/aw_render_frame_ext.h3
-rw-r--r--android_webview/renderer/aw_render_view_ext.cc12
-rw-r--r--android_webview/renderer/aw_render_view_ext.h1
4 files changed, 19 insertions, 13 deletions
diff --git a/android_webview/renderer/aw_render_frame_ext.cc b/android_webview/renderer/aw_render_frame_ext.cc
index 69b06f0..61c8025 100644
--- a/android_webview/renderer/aw_render_frame_ext.cc
+++ b/android_webview/renderer/aw_render_frame_ext.cc
@@ -17,6 +17,7 @@
#include "third_party/WebKit/public/web/WebElementCollection.h"
#include "third_party/WebKit/public/web/WebFrameWidget.h"
#include "third_party/WebKit/public/web/WebHitTestResult.h"
+#include "third_party/WebKit/public/web/WebImageCache.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h"
#include "third_party/WebKit/public/web/WebMeaningfulLayout.h"
#include "third_party/WebKit/public/web/WebNode.h"
@@ -146,6 +147,21 @@ void AwRenderFrameExt::DidCommitProvisionalLoad(bool is_new_navigation,
blink::WebSecurityOrigin origin = frame->document().getSecurityOrigin();
origin.grantLoadLocalResources();
}
+
+ // Clear the cache when we cross site boundaries in the main frame.
+ //
+ // We're trying to approximate what happens with a multi-process Chromium,
+ // where navigation across origins would cause a new render process to spin
+ // up, and thus start with a clear cache. Wiring up a signal from browser to
+ // renderer code to say "this navigation would have switched processes" would
+ // be disruptive, so this clearing of the cache is the compromise.
+ if (!frame->parent()) {
+ url::Origin new_origin(frame->document().url());
+ if (!new_origin.IsSameOriginWith(last_origin_)) {
+ last_origin_ = new_origin;
+ blink::WebImageCache::clear();
+ }
+ }
}
bool AwRenderFrameExt::OnMessageReceived(const IPC::Message& message) {
diff --git a/android_webview/renderer/aw_render_frame_ext.h b/android_webview/renderer/aw_render_frame_ext.h
index 09c9853..cb85969 100644
--- a/android_webview/renderer/aw_render_frame_ext.h
+++ b/android_webview/renderer/aw_render_frame_ext.h
@@ -10,6 +10,7 @@
#include "ui/gfx/geometry/point_f.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/geometry/size_f.h"
+#include "url/origin.h"
namespace blink {
enum WebMeaningfulLayout;
@@ -53,6 +54,8 @@ class AwRenderFrameExt : public content::RenderFrameObserver {
blink::WebView* GetWebView();
blink::WebFrameWidget* GetWebFrameWidget();
+ url::Origin last_origin_;
+
DISALLOW_COPY_AND_ASSIGN(AwRenderFrameExt);
};
diff --git a/android_webview/renderer/aw_render_view_ext.cc b/android_webview/renderer/aw_render_view_ext.cc
index eaec178..c14f14e 100644
--- a/android_webview/renderer/aw_render_view_ext.cc
+++ b/android_webview/renderer/aw_render_view_ext.cc
@@ -7,7 +7,6 @@
#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/render_view.h"
#include "third_party/WebKit/public/web/WebFrame.h"
-#include "third_party/WebKit/public/web/WebImageCache.h"
#include "third_party/WebKit/public/web/WebView.h"
namespace android_webview {
@@ -66,15 +65,4 @@ void AwRenderViewExt::CheckContentsSize() {
contents_size));
}
-void AwRenderViewExt::Navigate(const GURL& url) {
- // Navigate is called only on NEW navigations, so WebImageCache won't be
- // freed when the user just clicks on links, but only when a navigation is
- // started, for instance via loadUrl. A better approach would be clearing the
- // cache on cross-site boundaries, however this would require too many
- // changes both on the browser side (in RenderViewHostManger), to the
- // IPCmessages and to the RenderViewObserver. Thus, clearing decoding image
- // cache on Navigate, seems a more acceptable compromise.
- blink::WebImageCache::clear();
-}
-
} // namespace android_webview
diff --git a/android_webview/renderer/aw_render_view_ext.h b/android_webview/renderer/aw_render_view_ext.h
index f14c1da..25a264b 100644
--- a/android_webview/renderer/aw_render_view_ext.h
+++ b/android_webview/renderer/aw_render_view_ext.h
@@ -26,7 +26,6 @@ class AwRenderViewExt : public content::RenderViewObserver {
// RenderViewObserver:
void DidCommitCompositorFrame() override;
void DidUpdateLayout() override;
- void Navigate(const GURL& url) override;
void CheckContentsSize();
void PostCheckContentsSize();