• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #include "chrome/renderer/chrome_render_frame_observer.h"
6 
7 #include "chrome/common/prerender_messages.h"
8 #include "chrome/renderer/prerender/prerender_helper.h"
9 
ChromeRenderFrameObserver(content::RenderFrame * render_frame)10 ChromeRenderFrameObserver::ChromeRenderFrameObserver(
11     content::RenderFrame* render_frame)
12     : content::RenderFrameObserver(render_frame) {
13 }
14 
~ChromeRenderFrameObserver()15 ChromeRenderFrameObserver::~ChromeRenderFrameObserver() {
16 }
17 
OnMessageReceived(const IPC::Message & message)18 bool ChromeRenderFrameObserver::OnMessageReceived(const IPC::Message& message) {
19   // Filter only.
20   IPC_BEGIN_MESSAGE_MAP(ChromeRenderFrameObserver, message)
21     IPC_MESSAGE_HANDLER(PrerenderMsg_SetIsPrerendering, OnSetIsPrerendering);
22   IPC_END_MESSAGE_MAP()
23 
24   return false;
25 }
26 
OnSetIsPrerendering(bool is_prerendering)27 void ChromeRenderFrameObserver::OnSetIsPrerendering(bool is_prerendering) {
28   if (is_prerendering) {
29     DCHECK(!prerender::PrerenderHelper::Get(render_frame()));
30     // The PrerenderHelper will destroy itself either after recording histograms
31     // or on destruction of the RenderView.
32     new prerender::PrerenderHelper(render_frame());
33   }
34 }
35