Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/json/json_reader.h" | |
| 7 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 8 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/stringprintf.h" | |
| 9 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 10 #include "base/stringprintf.h" | |
| 11 #include "base/values.h" | 12 #include "base/values.h" |
| 12 #include "chrome/browser/extensions/extension_devtools_events.h" | 13 #include "chrome/browser/extensions/extension_devtools_events.h" |
| 13 #include "chrome/browser/extensions/extension_devtools_manager.h" | 14 #include "chrome/browser/extensions/extension_devtools_manager.h" |
| 14 #include "chrome/browser/extensions/extension_event_router.h" | 15 #include "chrome/browser/extensions/extension_event_router.h" |
| 15 #include "chrome/browser/extensions/extension_system.h" | 16 #include "chrome/browser/extensions/extension_system.h" |
| 16 #include "chrome/browser/extensions/extension_tab_util.h" | 17 #include "chrome/browser/extensions/extension_tab_util.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 19 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 19 #include "content/public/browser/devtools_agent_host_registry.h" | 20 #include "content/public/browser/devtools_agent_host_registry.h" |
| 20 #include "content/public/browser/devtools_manager.h" | 21 #include "content/public/browser/devtools_manager.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 DevToolsManager::GetInstance()->ClientHostClosing(this); | 99 DevToolsManager::GetInstance()->ClientHostClosing(this); |
| 99 } | 100 } |
| 100 | 101 |
| 101 // If the tab we are looking at is going away then we fire a closing event at | 102 // If the tab we are looking at is going away then we fire a closing event at |
| 102 // the extension. | 103 // the extension. |
| 103 void ExtensionDevToolsBridge::InspectedContentsClosing() { | 104 void ExtensionDevToolsBridge::InspectedContentsClosing() { |
| 104 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); | 105 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); |
| 105 | 106 |
| 106 // TODO(knorton): Remove this event in favor of the standard tabs.onRemoved | 107 // TODO(knorton): Remove this event in favor of the standard tabs.onRemoved |
| 107 // event in extensions. | 108 // event in extensions. |
| 108 std::string json("[{}]"); | 109 base::ListValue* arguments = new base::ListValue(); |
|
miket_OOO
2012/07/10 22:33:19
args?
| |
| 110 arguments->Set(0, new base::DictionaryValue()); | |
| 109 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( | 111 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( |
| 110 on_tab_close_event_name_, json, profile_, GURL(), | 112 on_tab_close_event_name_, arguments, profile_, GURL(), |
| 111 extensions::EventFilteringInfo()); | 113 extensions::EventFilteringInfo()); |
| 112 | 114 |
| 113 // This may result in this object being destroyed. | 115 // This may result in this object being destroyed. |
| 114 extension_devtools_manager_->BridgeClosingForTab(tab_id_); | 116 extension_devtools_manager_->BridgeClosingForTab(tab_id_); |
| 115 } | 117 } |
| 116 | 118 |
| 117 void ExtensionDevToolsBridge::DispatchOnInspectorFrontend( | 119 void ExtensionDevToolsBridge::DispatchOnInspectorFrontend( |
| 118 const std::string& data) { | 120 const std::string& data) { |
| 119 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); | 121 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); |
| 120 | 122 |
| 121 std::string json = base::StringPrintf("[%s]", data.c_str()); | 123 base::ListValue* arguments = new base::ListValue(); |
|
miket_OOO
2012/07/10 22:33:19
same
| |
| 124 arguments->Append(base::JSONReader::Read(data)); | |
| 125 | |
| 122 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( | 126 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( |
| 123 on_page_event_name_, json, profile_, GURL(), | 127 on_page_event_name_, arguments, profile_, GURL(), |
| 124 extensions::EventFilteringInfo()); | 128 extensions::EventFilteringInfo()); |
| 125 } | 129 } |
| 126 | 130 |
| 127 void ExtensionDevToolsBridge::ContentsReplaced(WebContents* new_contents) { | 131 void ExtensionDevToolsBridge::ContentsReplaced(WebContents* new_contents) { |
| 128 // We don't update the tab id as it needs to remain the same so that we can | 132 // We don't update the tab id as it needs to remain the same so that we can |
| 129 // properly unregister. | 133 // properly unregister. |
| 130 } | 134 } |
| OLD | NEW |