summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/frame_sniffer.h
blob: c5c2316e474456584c96b366666d8fd2ab2c7744 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_RENDERER_FRAME_SNIFFER_H_
#define CHROME_RENDERER_FRAME_SNIFFER_H_

#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "content/public/renderer/render_view_observer.h"

// Class which observes events from the frame with specific name and sends IPC
// messages to be handled by RenderViewHostObserver.
class FrameSniffer : public content::RenderViewObserver {
 public:
  FrameSniffer(content::RenderView* render_view,
               const string16 &unique_frame_name);
  virtual ~FrameSniffer();

  // Implements RenderViewObserver.
  virtual void DidFailProvisionalLoad(
      WebKit::WebFrame* frame, const WebKit::WebURLError& error) OVERRIDE;
  virtual void DidCommitProvisionalLoad(WebKit::WebFrame* frame,
                                        bool is_new_navigation) OVERRIDE;

 private:
  bool ShouldSniffFrame(WebKit::WebFrame* frame);

  // Name of the frame to be monitored.
  string16 unique_frame_name_;

  DISALLOW_COPY_AND_ASSIGN(FrameSniffer);
};

#endif  // CHROME_RENDERER_FRAME_SNIFFER_H_