| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/browser/devtools/devtools_frontend_host_impl.h" | 5 #include "content/browser/devtools/devtools_frontend_host_impl.h" |
| 6 | 6 |
| 7 #include "content/browser/bad_message.h" | 7 #include "content/browser/bad_message.h" |
| 8 #include "content/common/devtools_messages.h" | 8 #include "content/common/devtools_messages.h" |
| 9 #include "content/public/browser/navigation_entry.h" | 9 #include "content/public/browser/navigation_entry.h" |
| 10 #include "content/public/browser/render_frame_host.h" | 10 #include "content/public/browser/render_frame_host.h" |
| 11 #include "content/public/browser/web_contents.h" | 11 #include "content/public/browser/web_contents.h" |
| 12 #include "content/public/common/content_client.h" | 12 #include "content/public/common/content_client.h" |
| 13 #include "grit/devtools_resources_map.h" | 13 #include "grit/devtools_resources_map.h" |
| 14 | 14 |
| 15 namespace content { | 15 namespace content { |
| 16 | 16 |
| 17 namespace { |
| 18 const char kCompatibilityScript[] = "devtools.js"; |
| 19 } |
| 20 |
| 17 // static | 21 // static |
| 18 DevToolsFrontendHost* DevToolsFrontendHost::Create( | 22 DevToolsFrontendHost* DevToolsFrontendHost::Create( |
| 19 RenderFrameHost* frontend_main_frame, | 23 RenderFrameHost* frontend_main_frame, |
| 20 DevToolsFrontendHost::Delegate* delegate) { | 24 DevToolsFrontendHost::Delegate* delegate) { |
| 21 return new DevToolsFrontendHostImpl(frontend_main_frame, delegate); | 25 return new DevToolsFrontendHostImpl(frontend_main_frame, delegate); |
| 22 } | 26 } |
| 23 | 27 |
| 24 // static | 28 // static |
| 25 base::StringPiece DevToolsFrontendHost::GetFrontendResource( | 29 base::StringPiece DevToolsFrontendHost::GetFrontendResource( |
| 26 const std::string& path) { | 30 const std::string& path) { |
| 27 for (size_t i = 0; i < kDevtoolsResourcesSize; ++i) { | 31 for (size_t i = 0; i < kDevtoolsResourcesSize; ++i) { |
| 28 if (path == kDevtoolsResources[i].name) { | 32 if (path == kDevtoolsResources[i].name) { |
| 29 return GetContentClient()->GetDataResource( | 33 return GetContentClient()->GetDataResource( |
| 30 kDevtoolsResources[i].value, ui::SCALE_FACTOR_NONE); | 34 kDevtoolsResources[i].value, ui::SCALE_FACTOR_NONE); |
| 31 } | 35 } |
| 32 } | 36 } |
| 33 return std::string(); | 37 return std::string(); |
| 34 } | 38 } |
| 35 | 39 |
| 36 DevToolsFrontendHostImpl::DevToolsFrontendHostImpl( | 40 DevToolsFrontendHostImpl::DevToolsFrontendHostImpl( |
| 37 RenderFrameHost* frontend_main_frame, | 41 RenderFrameHost* frontend_main_frame, |
| 38 DevToolsFrontendHost::Delegate* delegate) | 42 DevToolsFrontendHost::Delegate* delegate) |
| 39 : WebContentsObserver( | 43 : WebContentsObserver( |
| 40 WebContents::FromRenderFrameHost(frontend_main_frame)), | 44 WebContents::FromRenderFrameHost(frontend_main_frame)), |
| 41 delegate_(delegate) { | 45 delegate_(delegate) { |
| 42 frontend_main_frame->Send( | 46 frontend_main_frame->Send(new DevToolsMsg_SetupDevToolsClient( |
| 43 new DevToolsMsg_SetupDevToolsClient(frontend_main_frame->GetRoutingID())); | 47 frontend_main_frame->GetRoutingID(), |
| 48 DevToolsFrontendHost::GetFrontendResource( |
| 49 kCompatibilityScript).as_string())); |
| 44 } | 50 } |
| 45 | 51 |
| 46 DevToolsFrontendHostImpl::~DevToolsFrontendHostImpl() { | 52 DevToolsFrontendHostImpl::~DevToolsFrontendHostImpl() { |
| 47 } | 53 } |
| 48 | 54 |
| 49 void DevToolsFrontendHostImpl::BadMessageRecieved() { | 55 void DevToolsFrontendHostImpl::BadMessageRecieved() { |
| 50 bad_message::ReceivedBadMessage(web_contents()->GetRenderProcessHost(), | 56 bad_message::ReceivedBadMessage(web_contents()->GetRenderProcessHost(), |
| 51 bad_message::DFH_BAD_EMBEDDER_MESSAGE); | 57 bad_message::DFH_BAD_EMBEDDER_MESSAGE); |
| 52 } | 58 } |
| 53 | 59 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 71 const std::string& message) { | 77 const std::string& message) { |
| 72 delegate_->HandleMessageFromDevToolsFrontendToBackend(message); | 78 delegate_->HandleMessageFromDevToolsFrontendToBackend(message); |
| 73 } | 79 } |
| 74 | 80 |
| 75 void DevToolsFrontendHostImpl::OnDispatchOnEmbedder( | 81 void DevToolsFrontendHostImpl::OnDispatchOnEmbedder( |
| 76 const std::string& message) { | 82 const std::string& message) { |
| 77 delegate_->HandleMessageFromDevToolsFrontend(message); | 83 delegate_->HandleMessageFromDevToolsFrontend(message); |
| 78 } | 84 } |
| 79 | 85 |
| 80 } // namespace content | 86 } // namespace content |
| OLD | NEW |