| 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" | 
 |   16 #include "chrome/browser/extensions/extension_system_factory.h" | 
|   15 #include "chrome/browser/extensions/extension_tab_util.h" |   17 #include "chrome/browser/extensions/extension_tab_util.h" | 
|   16 #include "chrome/browser/profiles/profile.h" |   18 #include "chrome/browser/profiles/profile.h" | 
|   17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |   19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 
|   18 #include "content/public/browser/devtools_agent_host_registry.h" |   20 #include "content/public/browser/devtools_agent_host_registry.h" | 
|   19 #include "content/public/browser/devtools_manager.h" |   21 #include "content/public/browser/devtools_manager.h" | 
|   20 #include "content/public/browser/web_contents.h" |   22 #include "content/public/browser/web_contents.h" | 
|   21  |   23  | 
|   22 using content::DevToolsAgentHost; |   24 using content::DevToolsAgentHost; | 
|   23 using content::DevToolsAgentHostRegistry; |   25 using content::DevToolsAgentHostRegistry; | 
|   24 using content::DevToolsManager; |   26 using content::DevToolsManager; | 
|   25 using content::WebContents; |   27 using content::WebContents; | 
|   26  |   28  | 
|   27 ExtensionDevToolsBridge::ExtensionDevToolsBridge(int tab_id, |   29 ExtensionDevToolsBridge::ExtensionDevToolsBridge(int tab_id, | 
|   28                                                  Profile* profile) |   30                                                  Profile* profile) | 
|   29     : tab_id_(tab_id), |   31     : tab_id_(tab_id), | 
|   30       profile_(profile), |   32       profile_(profile), | 
|   31       on_page_event_name_( |   33       on_page_event_name_( | 
|   32           ExtensionDevToolsEvents::OnPageEventNameForTab(tab_id)), |   34           ExtensionDevToolsEvents::OnPageEventNameForTab(tab_id)), | 
|   33       on_tab_close_event_name_( |   35       on_tab_close_event_name_( | 
|   34           ExtensionDevToolsEvents::OnTabCloseEventNameForTab(tab_id)) { |   36           ExtensionDevToolsEvents::OnTabCloseEventNameForTab(tab_id)) { | 
|   35   extension_devtools_manager_ = profile_->GetExtensionDevToolsManager(); |   37   extension_devtools_manager_ = | 
 |   38       ExtensionSystemFactory::GetForProfile(profile)->devtools_manager(); | 
|   36   DCHECK(extension_devtools_manager_.get()); |   39   DCHECK(extension_devtools_manager_.get()); | 
|   37 } |   40 } | 
|   38  |   41  | 
|   39 ExtensionDevToolsBridge::~ExtensionDevToolsBridge() { |   42 ExtensionDevToolsBridge::~ExtensionDevToolsBridge() { | 
|   40 } |   43 } | 
|   41  |   44  | 
|   42 static std::string FormatDevToolsMessage(int id, const std::string& method) { |   45 static std::string FormatDevToolsMessage(int id, const std::string& method) { | 
|   43   DictionaryValue message; |   46   DictionaryValue message; | 
|   44   message.SetInteger("id", id); |   47   message.SetInteger("id", id); | 
|   45   message.SetString("method", method); |   48   message.SetString("method", method); | 
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  117  |  120  | 
|  118   std::string json = base::StringPrintf("[%s]", data.c_str()); |  121   std::string json = base::StringPrintf("[%s]", data.c_str()); | 
|  119   profile_->GetExtensionEventRouter()->DispatchEventToRenderers( |  122   profile_->GetExtensionEventRouter()->DispatchEventToRenderers( | 
|  120       on_page_event_name_, json, profile_, GURL()); |  123       on_page_event_name_, json, profile_, GURL()); | 
|  121 } |  124 } | 
|  122  |  125  | 
|  123 void ExtensionDevToolsBridge::TabReplaced(WebContents* new_tab) { |  126 void ExtensionDevToolsBridge::TabReplaced(WebContents* new_tab) { | 
|  124   // We don't update the tab id as it needs to remain the same so that we can |  127   // We don't update the tab id as it needs to remain the same so that we can | 
|  125   // properly unregister. |  128   // properly unregister. | 
|  126 } |  129 } | 
| OLD | NEW |