This source file includes following definitions.
- UpdateVisibilityState
- IsPrerendering
- OnMessageReceived
- OnSetIsPrerendering
#include "chrome/renderer/prerender/prerender_helper.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/histogram.h"
#include "chrome/common/prerender_messages.h"
#include "content/public/renderer/document_state.h"
#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/WebView.h"
using content::DocumentState;
namespace {
void UpdateVisibilityState(content::RenderFrame* render_frame) {
content::RenderView* render_view = render_frame->GetRenderView();
if (render_view->GetMainRenderFrame() == render_frame) {
render_view->GetWebView()->setVisibilityState(
render_view->GetVisibilityState(), false);
}
}
}
namespace prerender {
PrerenderHelper::PrerenderHelper(content::RenderFrame* render_frame)
: content::RenderFrameObserver(render_frame),
content::RenderFrameObserverTracker<PrerenderHelper>(render_frame) {
UpdateVisibilityState(render_frame);
}
PrerenderHelper::~PrerenderHelper() {
}
bool PrerenderHelper::IsPrerendering(const content::RenderFrame* render_frame) {
return PrerenderHelper::Get(render_frame) != NULL;
}
bool PrerenderHelper::OnMessageReceived(
const IPC::Message& message) {
IPC_BEGIN_MESSAGE_MAP(PrerenderHelper, message)
IPC_MESSAGE_HANDLER(PrerenderMsg_SetIsPrerendering, OnSetIsPrerendering)
IPC_END_MESSAGE_MAP()
return false;
}
void PrerenderHelper::OnSetIsPrerendering(bool is_prerendering) {
if (is_prerendering)
return;
content::RenderFrame* frame = render_frame();
delete this;
UpdateVisibilityState(frame);
}
}