| 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_writer.h" | 7 #include "base/json/json_writer.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "chrome/browser/extensions/extension_devtools_events.h" | 12 #include "chrome/browser/extensions/extension_devtools_events.h" |
| 13 #include "chrome/browser/extensions/extension_devtools_manager.h" | 13 #include "chrome/browser/extensions/extension_devtools_manager.h" |
| 14 #include "chrome/browser/extensions/extension_event_router.h" | 14 #include "chrome/browser/extensions/extension_event_router.h" |
| 15 #include "chrome/browser/extensions/extension_system.h" | 15 #include "chrome/browser/extensions/extension_system.h" |
| 16 #include "chrome/browser/extensions/extension_tab_util.h" | 16 #include "chrome/browser/extensions/extension_tab_util.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 18 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 19 #include "content/public/browser/devtools_agent_host_registry.h" | 19 #include "content/public/browser/devtools_agent_host_registry.h" |
| 20 #include "content/public/browser/devtools_manager.h" | 20 #include "content/public/browser/devtools_manager.h" |
| 21 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
| 22 | 22 |
| 23 using content::DevToolsAgentHost; | 23 using content::DevToolsAgentHost; |
| 24 using content::DevToolsAgentHostRegistry; | 24 using content::DevToolsAgentHostRegistry; |
| 25 using content::DevToolsManager; | 25 using content::DevToolsManager; |
| 26 using content::WebContents; | 26 using content::WebContents; |
| 27 | 27 |
| 28 ExtensionDevToolsBridge::ExtensionDevToolsBridge(int tab_id, | 28 ExtensionDevToolsBridge::ExtensionDevToolsBridge(int tab_id, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 50 std::string json; | 50 std::string json; |
| 51 base::JSONWriter::Write(&message, &json); | 51 base::JSONWriter::Write(&message, &json); |
| 52 return json; | 52 return json; |
| 53 } | 53 } |
| 54 | 54 |
| 55 bool ExtensionDevToolsBridge::RegisterAsDevToolsClientHost() { | 55 bool ExtensionDevToolsBridge::RegisterAsDevToolsClientHost() { |
| 56 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); | 56 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); |
| 57 | 57 |
| 58 Browser* browser; | 58 Browser* browser; |
| 59 TabStripModel* tab_strip; | 59 TabStripModel* tab_strip; |
| 60 TabContentsWrapper* contents; | 60 TabContents* contents; |
| 61 int tab_index; | 61 int tab_index; |
| 62 if (ExtensionTabUtil::GetTabById(tab_id_, profile_, true, | 62 if (ExtensionTabUtil::GetTabById(tab_id_, profile_, true, |
| 63 &browser, &tab_strip, | 63 &browser, &tab_strip, |
| 64 &contents, &tab_index)) { | 64 &contents, &tab_index)) { |
| 65 DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); | 65 DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); |
| 66 DevToolsAgentHost* agent = DevToolsAgentHostRegistry::GetDevToolsAgentHost( | 66 DevToolsAgentHost* agent = DevToolsAgentHostRegistry::GetDevToolsAgentHost( |
| 67 contents->web_contents()->GetRenderViewHost()); | 67 contents->web_contents()->GetRenderViewHost()); |
| 68 if (devtools_manager->GetDevToolsClientHostFor(agent)) | 68 if (devtools_manager->GetDevToolsClientHostFor(agent)) |
| 69 return false; | 69 return false; |
| 70 | 70 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 119 |
| 120 std::string json = base::StringPrintf("[%s]", data.c_str()); | 120 std::string json = base::StringPrintf("[%s]", data.c_str()); |
| 121 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( | 121 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( |
| 122 on_page_event_name_, json, profile_, GURL()); | 122 on_page_event_name_, json, profile_, GURL()); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void ExtensionDevToolsBridge::ContentsReplaced(WebContents* new_contents) { | 125 void ExtensionDevToolsBridge::ContentsReplaced(WebContents* new_contents) { |
| 126 // We don't update the tab id as it needs to remain the same so that we can | 126 // We don't update the tab id as it needs to remain the same so that we can |
| 127 // properly unregister. | 127 // properly unregister. |
| 128 } | 128 } |
| OLD | NEW |