1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/renderer/chrome_render_frame_observer.h"
7 #include "chrome/common/prerender_messages.h"
8 #include "chrome/renderer/prerender/prerender_helper.h"
10 ChromeRenderFrameObserver::ChromeRenderFrameObserver(
11 content::RenderFrame
* render_frame
)
12 : content::RenderFrameObserver(render_frame
) {
15 ChromeRenderFrameObserver::~ChromeRenderFrameObserver() {
18 bool ChromeRenderFrameObserver::OnMessageReceived(const IPC::Message
& message
) {
20 IPC_BEGIN_MESSAGE_MAP(ChromeRenderFrameObserver
, message
)
21 IPC_MESSAGE_HANDLER(PrerenderMsg_SetIsPrerendering
, OnSetIsPrerendering
);
27 void ChromeRenderFrameObserver::OnSetIsPrerendering(bool is_prerendering
) {
28 if (is_prerendering
) {
29 // If the PrerenderHelper for this frame already exists, don't create it. It
30 // can already be created for subframes during handling of
31 // RenderFrameCreated, if the parent frame was prerendering at time of
33 if (prerender::PrerenderHelper::Get(render_frame()))
36 // The PrerenderHelper will destroy itself either after recording histograms
37 // or on destruction of the RenderView.
38 new prerender::PrerenderHelper(render_frame());