OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/shell/renderer/shell_render_view_observer.h" | 5 #include "content/shell/renderer/shell_render_view_observer.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "content/public/renderer/render_thread.h" | 8 #include "content/public/renderer/render_thread.h" |
9 #include "content/public/renderer/render_view.h" | 9 #include "content/public/renderer/render_view.h" |
10 #include "content/public/renderer/render_view_observer.h" | 10 #include "content/public/renderer/render_view_observer.h" |
11 #include "content/shell/common/shell_messages.h" | 11 #include "content/shell/common/shell_messages.h" |
12 #include "content/shell/common/shell_switches.h" | 12 #include "content/shell/common/shell_switches.h" |
13 #include "content/shell/renderer/ipc_echo.h" | 13 #include "content/shell/renderer/ipc_echo.h" |
14 #include "third_party/WebKit/public/web/WebTestingSupport.h" | 14 #include "third_party/WebKit/public/web/WebTestingSupport.h" |
15 #include "third_party/WebKit/public/web/WebView.h" | 15 #include "third_party/WebKit/public/web/WebView.h" |
16 | 16 |
17 namespace content { | 17 namespace content { |
18 | 18 |
19 ShellRenderViewObserver::ShellRenderViewObserver(RenderView* render_view) | 19 ShellRenderViewObserver::ShellRenderViewObserver(RenderView* render_view) |
20 : RenderViewObserver(render_view) { | 20 : RenderViewObserver(render_view) { |
21 } | 21 } |
22 | 22 |
23 ShellRenderViewObserver::~ShellRenderViewObserver() { | 23 ShellRenderViewObserver::~ShellRenderViewObserver() { |
24 } | 24 } |
25 | 25 |
26 void ShellRenderViewObserver::DidClearWindowObject( | 26 void ShellRenderViewObserver::DidClearWindowObject( |
27 blink::WebLocalFrame* frame) { | 27 blink::WebLocalFrame* frame) { |
28 if (CommandLine::ForCurrentProcess()->HasSwitch( | 28 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
29 switches::kExposeInternalsForTesting)) { | 29 switches::kExposeInternalsForTesting)) { |
30 blink::WebTestingSupport::injectInternalsObject(frame); | 30 blink::WebTestingSupport::injectInternalsObject(frame); |
31 } | 31 } |
32 | 32 |
33 if (CommandLine::ForCurrentProcess()->HasSwitch( | 33 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
34 switches::kExposeIpcEcho)) { | 34 switches::kExposeIpcEcho)) { |
35 RenderView* view = render_view(); | 35 RenderView* view = render_view(); |
36 if (!ipc_echo_) | 36 if (!ipc_echo_) |
37 ipc_echo_.reset(new IPCEcho(view->GetWebView()->mainFrame()->document(), | 37 ipc_echo_.reset(new IPCEcho(view->GetWebView()->mainFrame()->document(), |
38 RenderThread::Get(), view->GetRoutingID())); | 38 RenderThread::Get(), view->GetRoutingID())); |
39 ipc_echo_->Install(view->GetWebView()->mainFrame()); | 39 ipc_echo_->Install(view->GetWebView()->mainFrame()); |
40 } | 40 } |
41 } | 41 } |
42 | 42 |
43 bool ShellRenderViewObserver::OnMessageReceived(const IPC::Message& message) { | 43 bool ShellRenderViewObserver::OnMessageReceived(const IPC::Message& message) { |
44 bool handled = true; | 44 bool handled = true; |
45 IPC_BEGIN_MESSAGE_MAP(ShellRenderViewObserver, message) | 45 IPC_BEGIN_MESSAGE_MAP(ShellRenderViewObserver, message) |
46 IPC_MESSAGE_HANDLER(ShellViewMsg_EchoPong, OnEchoPong) | 46 IPC_MESSAGE_HANDLER(ShellViewMsg_EchoPong, OnEchoPong) |
47 IPC_MESSAGE_UNHANDLED(handled = false) | 47 IPC_MESSAGE_UNHANDLED(handled = false) |
48 IPC_END_MESSAGE_MAP() | 48 IPC_END_MESSAGE_MAP() |
49 | 49 |
50 return handled; | 50 return handled; |
51 } | 51 } |
52 | 52 |
53 void ShellRenderViewObserver::OnEchoPong(int id, const std::string& body) { | 53 void ShellRenderViewObserver::OnEchoPong(int id, const std::string& body) { |
54 ipc_echo_->DidRespondEcho(id, body.size()); | 54 ipc_echo_->DidRespondEcho(id, body.size()); |
55 } | 55 } |
56 | 56 |
57 } // namespace content | 57 } // namespace content |
OLD | NEW |