summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authormmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-20 20:10:20 +0000
committermmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-20 20:10:20 +0000
commit90dba0763114f7f07d24e751cfd1c6bba0480dad (patch)
treedf088d6e1f3a683623785d8dac2390abe6355589 /chrome/renderer
parent92e44ddd24903955bea38d01e2fbc7e4b1156d8f (diff)
downloadchromium_src-90dba0763114f7f07d24e751cfd1c6bba0480dad.zip
chromium_src-90dba0763114f7f07d24e751cfd1c6bba0480dad.tar.gz
chromium_src-90dba0763114f7f07d24e751cfd1c6bba0480dad.tar.bz2
Don't load plugins on prerendered pages until the pages are displayed.
BUG=61745 TEST=in progress Review URL: http://codereview.chromium.org/6247013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71992 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r--chrome/renderer/blocked_plugin.cc9
-rw-r--r--chrome/renderer/blocked_plugin.h6
-rw-r--r--chrome/renderer/navigation_state.cc1
-rw-r--r--chrome/renderer/navigation_state.h11
-rw-r--r--chrome/renderer/render_view.cc50
-rw-r--r--chrome/renderer/render_view.h4
6 files changed, 70 insertions, 11 deletions
diff --git a/chrome/renderer/blocked_plugin.cc b/chrome/renderer/blocked_plugin.cc
index 7ec6eed..f85e2ed 100644
--- a/chrome/renderer/blocked_plugin.cc
+++ b/chrome/renderer/blocked_plugin.cc
@@ -53,10 +53,12 @@ BlockedPlugin::BlockedPlugin(RenderView* render_view,
const WebPluginParams& params,
const WebPreferences& preferences,
int template_id,
- const string16& message)
+ const string16& message,
+ bool is_blocked_for_prerendering)
: RenderViewObserver(render_view),
frame_(frame),
- plugin_params_(params) {
+ plugin_params_(params),
+ is_blocked_for_prerendering_(is_blocked_for_prerendering) {
const base::StringPiece template_html(
ResourceBundle::GetSharedInstance().GetRawDataResource(template_id));
@@ -132,6 +134,9 @@ bool BlockedPlugin::OnMessageReceived(const IPC::Message& message) {
&message, this, this, &BlockedPlugin::OnMenuItemSelected);
} else if (message.type() == ViewMsg_LoadBlockedPlugins::ID) {
LoadPlugin();
+ } else if (message.type() == ViewMsg_DisplayPrerenderedPage::ID) {
+ if (is_blocked_for_prerendering_)
+ LoadPlugin();
}
return false;
diff --git a/chrome/renderer/blocked_plugin.h b/chrome/renderer/blocked_plugin.h
index 39cfc54..40916e9 100644
--- a/chrome/renderer/blocked_plugin.h
+++ b/chrome/renderer/blocked_plugin.h
@@ -29,7 +29,8 @@ class BlockedPlugin : public RenderViewObserver,
const WebKit::WebPluginParams& params,
const WebPreferences& settings,
int template_id,
- const string16& message);
+ const string16& message,
+ bool is_blocked_for_prerendering);
webkit::npapi::WebViewPlugin* plugin() { return plugin_; }
@@ -66,6 +67,9 @@ class BlockedPlugin : public RenderViewObserver,
webkit::npapi::WebViewPlugin* plugin_;
// The name of the plugin that was blocked.
string16 name_;
+ // True iff the plugin was blocked because the page was being prerendered.
+ // Plugin will automatically be loaded when the page is displayed.
+ bool is_blocked_for_prerendering_;
};
#endif // CHROME_RENDERER_BLOCKED_PLUGIN_H_
diff --git a/chrome/renderer/navigation_state.cc b/chrome/renderer/navigation_state.cc
index 47759f8..dff7ee4 100644
--- a/chrome/renderer/navigation_state.cc
+++ b/chrome/renderer/navigation_state.cc
@@ -44,6 +44,7 @@ NavigationState::NavigationState(PageTransition::Type transition_type,
pending_page_id_(pending_page_id),
pending_history_list_offset_(pending_history_list_offset),
postpone_loading_data_(false),
+ is_prerendering_(false),
cache_policy_override_set_(false),
cache_policy_override_(WebKit::WebURLRequest::UseProtocolCachePolicy),
user_script_idle_scheduler_(NULL),
diff --git a/chrome/renderer/navigation_state.h b/chrome/renderer/navigation_state.h
index 6a4cdb5..cebd5a6 100644
--- a/chrome/renderer/navigation_state.h
+++ b/chrome/renderer/navigation_state.h
@@ -32,6 +32,8 @@ class NavigationState : public WebKit::WebDataSource::ExtraData {
RELOAD, // User pressed reload.
HISTORY_LOAD, // Back or forward.
NORMAL_LOAD, // User entered URL, or omnibox search.
+ PRERENDER_LOAD, // Navigation started as the speculatively
+ // prendering of a linked page.
LINK_LOAD, // (deprecated) Included next 4 categories.
LINK_LOAD_NORMAL, // Commonly following of link.
LINK_LOAD_RELOAD, // JS/link directed reload.
@@ -211,6 +213,11 @@ class NavigationState : public WebKit::WebDataSource::ExtraData {
postponed_data_.append(data, data_len);
}
+ bool is_prerendering() const { return is_prerendering_; }
+ void set_is_prerendering(bool is_prerendering) {
+ is_prerendering_ = is_prerendering;
+ }
+
int http_status_code() const { return http_status_code_; }
void set_http_status_code(int http_status_code) {
http_status_code_ = http_status_code;
@@ -302,6 +309,10 @@ class NavigationState : public WebKit::WebDataSource::ExtraData {
bool postpone_loading_data_;
std::string postponed_data_;
+ // True if page is being prerendered. False once prerendered page is
+ // displayed.
+ bool is_prerendering_;
+
bool cache_policy_override_set_;
WebKit::WebURLRequest::CachePolicy cache_policy_override_;
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index e903c88..6c17b6d 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -1025,6 +1025,8 @@ bool RenderView::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences)
IPC_MESSAGE_HANDLER(ViewMsg_SetAltErrorPageURL, OnSetAltErrorPageURL)
IPC_MESSAGE_HANDLER(ViewMsg_InstallMissingPlugin, OnInstallMissingPlugin)
+ IPC_MESSAGE_HANDLER(ViewMsg_DisplayPrerenderedPage,
+ OnDisplayPrerenderedPage)
IPC_MESSAGE_HANDLER(ViewMsg_RunFileChooserResponse, OnFileChooserResponse)
IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode)
IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage,
@@ -1453,8 +1455,14 @@ void RenderView::OnNavigate(const ViewMsg_Navigate_Params& params) {
}
}
- if (navigation_state)
- navigation_state->set_load_type(NavigationState::NORMAL_LOAD);
+ if (navigation_state) {
+ if (params.navigation_type != ViewMsg_Navigate_Params::PRERENDER) {
+ navigation_state->set_load_type(NavigationState::NORMAL_LOAD);
+ } else {
+ navigation_state->set_load_type(NavigationState::PRERENDER_LOAD);
+ navigation_state->set_is_prerendering(true);
+ }
+ }
main_frame->loadRequest(request);
}
@@ -2709,7 +2717,8 @@ WebPlugin* RenderView::createPlugin(WebFrame* frame,
params,
*group,
IDR_BLOCKED_PLUGIN_HTML,
- IDS_PLUGIN_OUTDATED);
+ IDS_PLUGIN_OUTDATED,
+ false);
}
if (!info.enabled)
@@ -2720,6 +2729,18 @@ WebPlugin* RenderView::createPlugin(WebFrame* frame,
if (info.path.value() == webkit::npapi::kDefaultPluginLibraryName ||
plugin_setting == CONTENT_SETTING_ALLOW ||
host_setting == CONTENT_SETTING_ALLOW) {
+ // Delay loading plugins if prerendering.
+ WebDataSource* ds = frame->dataSource();
+ NavigationState* navigation_state = NavigationState::FromDataSource(ds);
+ if (navigation_state->is_prerendering()) {
+ return CreatePluginPlaceholder(frame,
+ params,
+ *group,
+ IDR_CLICK_TO_PLAY_PLUGIN_HTML,
+ IDS_PLUGIN_LOAD,
+ true);
+ }
+
scoped_refptr<webkit::ppapi::PluginModule> pepper_module(
pepper_delegate_.CreatePepperPlugin(info.path));
if (pepper_module)
@@ -2735,13 +2756,15 @@ WebPlugin* RenderView::createPlugin(WebFrame* frame,
params,
*group,
IDR_CLICK_TO_PLAY_PLUGIN_HTML,
- IDS_PLUGIN_LOAD);
+ IDS_PLUGIN_LOAD,
+ false);
} else {
return CreatePluginPlaceholder(frame,
params,
*group,
IDR_BLOCKED_PLUGIN_HTML,
- IDS_PLUGIN_BLOCKED);
+ IDS_PLUGIN_BLOCKED,
+ false);
}
}
@@ -4383,7 +4406,8 @@ WebPlugin* RenderView::CreatePluginPlaceholder(
const WebPluginParams& params,
const webkit::npapi::PluginGroup& group,
int resource_id,
- int message_id) {
+ int message_id,
+ bool is_blocked_for_prerendering) {
// |blocked_plugin| will delete itself when the WebViewPlugin
// is destroyed.
BlockedPlugin* blocked_plugin =
@@ -4394,7 +4418,8 @@ WebPlugin* RenderView::CreatePluginPlaceholder(
webkit_preferences_,
resource_id,
l10n_util::GetStringFUTF16(message_id,
- group.GetGroupName()));
+ group.GetGroupName()),
+ is_blocked_for_prerendering);
return blocked_plugin->plugin();
}
@@ -4686,6 +4711,17 @@ void RenderView::OnInstallMissingPlugin() {
first_default_plugin_->InstallMissingPlugin();
}
+void RenderView::OnDisplayPrerenderedPage() {
+ NavigationState* navigation_state = pending_navigation_state_.get();
+ if (!navigation_state) {
+ WebDataSource* ds = webview()->mainFrame()->dataSource();
+ navigation_state = NavigationState::FromDataSource(ds);
+ }
+
+ DCHECK(navigation_state->is_prerendering());
+ navigation_state->set_is_prerendering(false);
+}
+
void RenderView::OnFileChooserResponse(const std::vector<FilePath>& paths) {
// This could happen if we navigated to a different page before the user
// closed the chooser.
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index 1b74d68..80f1bc49 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -889,6 +889,7 @@ class RenderView : public RenderWidget,
const std::string& origin,
const std::string& target);
void OnInstallMissingPlugin();
+ void OnDisplayPrerenderedPage();
void OnMediaPlayerActionAt(const gfx::Point& location,
const WebKit::WebMediaPlayerAction& action);
void OnMoveOrResizeStarted();
@@ -1000,7 +1001,8 @@ class RenderView : public RenderWidget,
const WebKit::WebPluginParams& params,
const webkit::npapi::PluginGroup& group,
int resource_id,
- int message_id);
+ int message_id,
+ bool is_blocked_for_prerendering);
// Sends an IPC notification that the specified content type was blocked.
// If the content type requires it, |resource_identifier| names the specific