Respond with QuotaExceededError when IndexedDB has no disk space on open.
[chromium-blink-merge.git] / content / browser / devtools / devtools_frontend_host.cc
blobbfa623a140ea327a4f9ae13ff57bf31dd0d0b8f6
1 // Copyright (c) 2012 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/browser/devtools/devtools_frontend_host.h"
7 #include "content/browser/devtools/devtools_manager_impl.h"
8 #include "content/browser/renderer_host/render_view_host_impl.h"
9 #include "content/browser/web_contents/web_contents_impl.h"
10 #include "content/common/devtools_messages.h"
11 #include "content/public/browser/devtools_client_host.h"
12 #include "content/public/browser/devtools_frontend_host_delegate.h"
14 namespace content {
16 // static
17 DevToolsClientHost* DevToolsClientHost::CreateDevToolsFrontendHost(
18 WebContents* client_web_contents,
19 DevToolsFrontendHostDelegate* delegate) {
20 return new DevToolsFrontendHost(
21 static_cast<WebContentsImpl*>(client_web_contents), delegate);
24 // static
25 void DevToolsClientHost::SetupDevToolsFrontendClient(
26 RenderViewHost* frontend_rvh) {
27 frontend_rvh->Send(new DevToolsMsg_SetupDevToolsClient(
28 frontend_rvh->GetRoutingID()));
31 DevToolsFrontendHost::DevToolsFrontendHost(
32 WebContentsImpl* web_contents,
33 DevToolsFrontendHostDelegate* delegate)
34 : WebContentsObserver(web_contents),
35 delegate_(delegate) {
38 DevToolsFrontendHost::~DevToolsFrontendHost() {
39 DevToolsManager::GetInstance()->ClientHostClosing(this);
42 void DevToolsFrontendHost::DispatchOnInspectorFrontend(
43 const std::string& message) {
44 if (!web_contents())
45 return;
46 RenderViewHostImpl* target_host =
47 static_cast<RenderViewHostImpl*>(web_contents()->GetRenderViewHost());
48 target_host->Send(new DevToolsClientMsg_DispatchOnInspectorFrontend(
49 target_host->GetRoutingID(),
50 message));
53 void DevToolsFrontendHost::InspectedContentsClosing() {
54 delegate_->InspectedContentsClosing();
57 void DevToolsFrontendHost::ReplacedWithAnotherClient() {
60 bool DevToolsFrontendHost::OnMessageReceived(
61 const IPC::Message& message) {
62 bool handled = true;
63 IPC_BEGIN_MESSAGE_MAP(DevToolsFrontendHost, message)
64 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DispatchOnInspectorBackend,
65 OnDispatchOnInspectorBackend)
66 IPC_MESSAGE_HANDLER(DevToolsHostMsg_DispatchOnEmbedder,
67 OnDispatchOnEmbedder)
68 IPC_MESSAGE_UNHANDLED(handled = false)
69 IPC_END_MESSAGE_MAP()
70 return handled;
73 void DevToolsFrontendHost::RenderProcessGone(
74 base::TerminationStatus status) {
75 switch(status) {
76 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION:
77 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED:
78 case base::TERMINATION_STATUS_PROCESS_CRASHED:
79 DevToolsManager::GetInstance()->ClientHostClosing(this);
80 break;
81 default:
82 break;
86 void DevToolsFrontendHost::OnDispatchOnInspectorBackend(
87 const std::string& message) {
88 DevToolsManagerImpl::GetInstance()->DispatchOnInspectorBackend(this, message);
91 void DevToolsFrontendHost::OnDispatchOnEmbedder(
92 const std::string& message) {
93 delegate_->DispatchOnEmbedder(message);
96 } // namespace content