Merge from Chromium at DEPS revision r167172
This commit was generated by merge_to_master.py.
Change-Id: Ib8d56fd5ae39a2d7e8c91dcd76cc6d13f25f2aab
diff --git a/chrome/renderer/frame_sniffer.cc b/chrome/renderer/frame_sniffer.cc
new file mode 100644
index 0000000..20844b2
--- /dev/null
+++ b/chrome/renderer/frame_sniffer.cc
@@ -0,0 +1,37 @@
+// 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.
+
+#include "chrome/renderer/frame_sniffer.h"
+
+#include "base/logging.h"
+#include "chrome/common/render_messages.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLError.h"
+
+FrameSniffer::FrameSniffer(content::RenderView* render_view,
+ const string16 &unique_frame_name)
+ : content::RenderViewObserver(render_view),
+ unique_frame_name_(unique_frame_name) {
+}
+
+FrameSniffer::~FrameSniffer() {
+}
+
+void FrameSniffer::DidFailProvisionalLoad(WebKit::WebFrame* frame,
+ const WebKit::WebURLError& error) {
+ if (!ShouldSniffFrame(frame))
+ return;
+ Send(new ChromeViewHostMsg_FrameLoadingError(routing_id(), -error.reason));
+}
+
+void FrameSniffer::DidCommitProvisionalLoad(WebKit::WebFrame* frame,
+ bool is_new_navigation) {
+ if (!ShouldSniffFrame(frame))
+ return;
+ Send(new ChromeViewHostMsg_FrameLoadingCompleted(routing_id()));
+}
+
+bool FrameSniffer::ShouldSniffFrame(WebKit::WebFrame* frame) {
+ return frame->uniqueName() == unique_frame_name_;
+}