Roll src/third_party/WebKit 3de3302:4cf36d6 (svn 198021:198025)
[chromium-blink-merge.git] / content / shell / renderer / shell_render_view_observer.cc
blob9dd4309858eb5e463be2321ad6d6e5f811d9a6cd
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 "content/shell/renderer/shell_render_view_observer.h"
7 #include "base/command_line.h"
8 #include "content/public/renderer/render_thread.h"
9 #include "content/public/renderer/render_view.h"
10 #include "content/public/renderer/render_view_observer.h"
11 #include "content/shell/common/shell_messages.h"
12 #include "content/shell/common/shell_switches.h"
13 #include "content/shell/renderer/ipc_echo.h"
14 #include "third_party/WebKit/public/web/WebTestingSupport.h"
15 #include "third_party/WebKit/public/web/WebView.h"
17 namespace content {
19 ShellRenderViewObserver::ShellRenderViewObserver(RenderView* render_view)
20 : RenderViewObserver(render_view) {
23 ShellRenderViewObserver::~ShellRenderViewObserver() {
26 void ShellRenderViewObserver::DidClearWindowObject(
27 blink::WebLocalFrame* frame) {
28 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
29 switches::kExposeInternalsForTesting)) {
30 blink::WebTestingSupport::injectInternalsObject(frame);
33 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
34 switches::kExposeIpcEcho)) {
35 RenderView* view = render_view();
36 if (!ipc_echo_)
37 ipc_echo_.reset(new IPCEcho(view->GetWebView()->mainFrame()->document(),
38 RenderThread::Get(), view->GetRoutingID()));
39 ipc_echo_->Install(view->GetWebView()->mainFrame());
43 bool ShellRenderViewObserver::OnMessageReceived(const IPC::Message& message) {
44 bool handled = true;
45 IPC_BEGIN_MESSAGE_MAP(ShellRenderViewObserver, message)
46 IPC_MESSAGE_HANDLER(ShellViewMsg_EchoPong, OnEchoPong)
47 IPC_MESSAGE_UNHANDLED(handled = false)
48 IPC_END_MESSAGE_MAP()
50 return handled;
53 void ShellRenderViewObserver::OnEchoPong(int id, const std::string& body) {
54 ipc_echo_->DidRespondEcho(id, body.size());
57 } // namespace content