blob: 21dad2f94de92840f0cc084a31c3908cba1febde [file] [log] [blame]
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001// Copyright (c) 2011 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/frame_sniffer.h"
6
7#include "base/logging.h"
8#include "chrome/common/render_messages.h"
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +01009#include "third_party/WebKit/public/platform/WebURLError.h"
Torne (Richard Coles)7d4cd472013-06-19 11:58:07 +010010#include "third_party/WebKit/public/web/WebFrame.h"
Torne (Richard Coles)58218062012-11-14 11:43:16 +000011
12FrameSniffer::FrameSniffer(content::RenderView* render_view,
13 const string16 &unique_frame_name)
14 : content::RenderViewObserver(render_view),
15 unique_frame_name_(unique_frame_name) {
16}
17
18FrameSniffer::~FrameSniffer() {
19}
20
21void FrameSniffer::DidFailProvisionalLoad(WebKit::WebFrame* frame,
22 const WebKit::WebURLError& error) {
23 if (!ShouldSniffFrame(frame))
24 return;
25 Send(new ChromeViewHostMsg_FrameLoadingError(routing_id(), -error.reason));
26}
27
28void FrameSniffer::DidCommitProvisionalLoad(WebKit::WebFrame* frame,
29 bool is_new_navigation) {
30 if (!ShouldSniffFrame(frame))
31 return;
32 Send(new ChromeViewHostMsg_FrameLoadingCompleted(routing_id()));
33}
34
35bool FrameSniffer::ShouldSniffFrame(WebKit::WebFrame* frame) {
36 return frame->uniqueName() == unique_frame_name_;
37}