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 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( | 111 extensions::ExtensionSystem::Get(profile_)->event_router()-> |
112 on_tab_close_event_name_, arguments.Pass(), profile_, GURL(), | 112 DispatchEventToRenderers( |
113 extensions::EventFilteringInfo()); | 113 on_tab_close_event_name_, arguments.Pass(), profile_, GURL(), |
| 114 extensions::EventFilteringInfo()); |
114 | 115 |
115 // This may result in this object being destroyed. | 116 // This may result in this object being destroyed. |
116 extension_devtools_manager_->BridgeClosingForTab(tab_id_); | 117 extension_devtools_manager_->BridgeClosingForTab(tab_id_); |
117 } | 118 } |
118 | 119 |
119 void ExtensionDevToolsBridge::DispatchOnInspectorFrontend( | 120 void ExtensionDevToolsBridge::DispatchOnInspectorFrontend( |
120 const std::string& data) { | 121 const std::string& data) { |
121 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); | 122 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); |
122 | 123 |
123 scoped_ptr<base::ListValue> arguments(new base::ListValue()); | 124 scoped_ptr<base::ListValue> arguments(new base::ListValue()); |
124 if (!data.empty()) { | 125 if (!data.empty()) { |
125 arguments->Append(base::JSONReader::Read(data)); | 126 arguments->Append(base::JSONReader::Read(data)); |
126 } | 127 } |
127 | 128 |
128 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( | 129 extensions::ExtensionSystem::Get(profile_)->event_router()-> |
129 on_page_event_name_, arguments.Pass(), profile_, GURL(), | 130 DispatchEventToRenderers( |
130 extensions::EventFilteringInfo()); | 131 on_page_event_name_, arguments.Pass(), profile_, GURL(), |
| 132 extensions::EventFilteringInfo()); |
131 } | 133 } |
132 | 134 |
133 void ExtensionDevToolsBridge::ContentsReplaced(WebContents* new_contents) { | 135 void ExtensionDevToolsBridge::ContentsReplaced(WebContents* new_contents) { |
134 // We don't update the tab id as it needs to remain the same so that we can | 136 // We don't update the tab id as it needs to remain the same so that we can |
135 // properly unregister. | 137 // properly unregister. |
136 } | 138 } |
OLD | NEW |