OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/extensions/extension_devtools_bridge.h" | 5 #include "chrome/browser/extensions/extension_devtools_bridge.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "chrome/browser/debugger/devtools_manager.h" | 9 #include "chrome/browser/debugger/devtools_manager.h" |
10 #include "chrome/browser/extensions/extension_devtools_events.h" | 10 #include "chrome/browser/extensions/extension_devtools_events.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 std::string json("[{}]"); | 66 std::string json("[{}]"); |
67 profile_->GetExtensionMessageService()->DispatchEventToRenderers( | 67 profile_->GetExtensionMessageService()->DispatchEventToRenderers( |
68 on_tab_close_event_name_, json, profile_->IsOffTheRecord(), GURL()); | 68 on_tab_close_event_name_, json, profile_->IsOffTheRecord(), GURL()); |
69 | 69 |
70 // This may result in this object being destroyed. | 70 // This may result in this object being destroyed. |
71 extension_devtools_manager_->BridgeClosingForTab(tab_id_); | 71 extension_devtools_manager_->BridgeClosingForTab(tab_id_); |
72 } | 72 } |
73 | 73 |
74 void ExtensionDevToolsBridge::SendMessageToClient(const IPC::Message& msg) { | 74 void ExtensionDevToolsBridge::SendMessageToClient(const IPC::Message& msg) { |
75 IPC_BEGIN_MESSAGE_MAP(ExtensionDevToolsBridge, msg) | 75 IPC_BEGIN_MESSAGE_MAP(ExtensionDevToolsBridge, msg) |
76 IPC_MESSAGE_HANDLER(DevToolsClientMsg_RpcMessage, OnRpcMessage); | 76 IPC_MESSAGE_HANDLER(DevToolsClientMsg_DispatchToAPU, OnDispatchToAPU); |
77 IPC_MESSAGE_UNHANDLED_ERROR() | 77 IPC_MESSAGE_UNHANDLED_ERROR() |
78 IPC_END_MESSAGE_MAP() | 78 IPC_END_MESSAGE_MAP() |
79 } | 79 } |
80 | 80 |
81 static const char kApuAgentClassName[] = "ApuAgentDelegate"; | 81 void ExtensionDevToolsBridge::OnDispatchToAPU(const std::string& data) { |
82 static const char kApuPageEventMessageName[] = "dispatchToApu"; | |
83 | |
84 void ExtensionDevToolsBridge::OnRpcMessage(const DevToolsMessageData& data) { | |
85 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); | 82 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); |
86 | 83 |
87 if (data.class_name == kApuAgentClassName | 84 std::string json = StringPrintf("[%s]", data.c_str()); |
88 && data.method_name == kApuPageEventMessageName) { | 85 profile_->GetExtensionMessageService()->DispatchEventToRenderers( |
89 std::string json = StringPrintf("[%s]", data.arguments[0].c_str()); | 86 on_page_event_name_, json, profile_->IsOffTheRecord(), GURL()); |
90 profile_->GetExtensionMessageService()->DispatchEventToRenderers( | |
91 on_page_event_name_, json, profile_->IsOffTheRecord(), GURL()); | |
92 } | |
93 } | 87 } |
94 | 88 |
OLD | NEW |