| 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_reader.h" |
| 8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 101 |
| 102 // 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 |
| 103 // the extension. | 103 // the extension. |
| 104 void ExtensionDevToolsBridge::InspectedContentsClosing() { | 104 void ExtensionDevToolsBridge::InspectedContentsClosing() { |
| 105 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); | 105 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); |
| 106 | 106 |
| 107 // 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 |
| 108 // event in extensions. | 108 // event in extensions. |
| 109 scoped_ptr<base::ListValue> arguments(new base::ListValue()); | 109 scoped_ptr<base::ListValue> arguments(new base::ListValue()); |
| 110 arguments->Set(0, new base::DictionaryValue()); | 110 arguments->Set(0, new base::DictionaryValue()); |
| 111 scoped_ptr<extensions::Event> event(new extensions::Event( |
| 112 on_tab_close_event_name_, arguments.Pass())); |
| 113 event->restrict_to_profile = profile_; |
| 111 extensions::ExtensionSystem::Get(profile_)->event_router()-> | 114 extensions::ExtensionSystem::Get(profile_)->event_router()-> |
| 112 DispatchEventToRenderers( | 115 BroadcastEvent(event.Pass()); |
| 113 on_tab_close_event_name_, arguments.Pass(), profile_, GURL(), | |
| 114 extensions::EventFilteringInfo()); | |
| 115 | 116 |
| 116 // This may result in this object being destroyed. | 117 // This may result in this object being destroyed. |
| 117 extension_devtools_manager_->BridgeClosingForTab(tab_id_); | 118 extension_devtools_manager_->BridgeClosingForTab(tab_id_); |
| 118 } | 119 } |
| 119 | 120 |
| 120 void ExtensionDevToolsBridge::DispatchOnInspectorFrontend( | 121 void ExtensionDevToolsBridge::DispatchOnInspectorFrontend( |
| 121 const std::string& data) { | 122 const std::string& data) { |
| 122 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); | 123 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); |
| 123 | 124 |
| 124 scoped_ptr<base::ListValue> arguments(new base::ListValue()); | 125 scoped_ptr<base::ListValue> arguments(new base::ListValue()); |
| 125 if (!data.empty()) { | 126 if (!data.empty()) { |
| 126 arguments->Append(base::JSONReader::Read(data)); | 127 arguments->Append(base::JSONReader::Read(data)); |
| 127 } | 128 } |
| 128 | 129 |
| 130 scoped_ptr<extensions::Event> event(new extensions::Event( |
| 131 on_page_event_name_, arguments.Pass())); |
| 132 event->restrict_to_profile = profile_; |
| 129 extensions::ExtensionSystem::Get(profile_)->event_router()-> | 133 extensions::ExtensionSystem::Get(profile_)->event_router()-> |
| 130 DispatchEventToRenderers( | 134 BroadcastEvent(event.Pass()); |
| 131 on_page_event_name_, arguments.Pass(), profile_, GURL(), | |
| 132 extensions::EventFilteringInfo()); | |
| 133 } | 135 } |
| 134 | 136 |
| 135 void ExtensionDevToolsBridge::ContentsReplaced(WebContents* new_contents) { | 137 void ExtensionDevToolsBridge::ContentsReplaced(WebContents* new_contents) { |
| 136 // We don't update the tab id as it needs to remain the same so that we can | 138 // We don't update the tab id as it needs to remain the same so that we can |
| 137 // properly unregister. | 139 // properly unregister. |
| 138 } | 140 } |
| 139 | 141 |
| 140 void ExtensionDevToolsBridge::ReplacedWithAnotherClient() { | 142 void ExtensionDevToolsBridge::ReplacedWithAnotherClient() { |
| 141 } | 143 } |
| OLD | NEW |