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 // Implements the Chrome Extensions Debugger API. | 5 // Implements the Chrome Extensions Debugger API. |
6 | 6 |
7 #include "chrome/browser/extensions/extension_debugger_api.h" | 7 #include "chrome/browser/extensions/extension_debugger_api.h" |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" | 26 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" |
27 #include "chrome/common/chrome_notification_types.h" | 27 #include "chrome/common/chrome_notification_types.h" |
28 #include "chrome/common/extensions/extension.h" | 28 #include "chrome/common/extensions/extension.h" |
29 #include "chrome/common/extensions/extension_error_utils.h" | 29 #include "chrome/common/extensions/extension_error_utils.h" |
30 #include "content/public/browser/devtools_agent_host_registry.h" | 30 #include "content/public/browser/devtools_agent_host_registry.h" |
31 #include "content/public/browser/devtools_client_host.h" | 31 #include "content/public/browser/devtools_client_host.h" |
32 #include "content/public/browser/devtools_manager.h" | 32 #include "content/public/browser/devtools_manager.h" |
33 #include "content/public/browser/notification_service.h" | 33 #include "content/public/browser/notification_service.h" |
34 #include "content/public/browser/notification_source.h" | 34 #include "content/public/browser/notification_source.h" |
35 #include "content/public/browser/render_view_host.h" | 35 #include "content/public/browser/render_view_host.h" |
36 #include "content/public/browser/render_view_host_delegate.h" | |
37 #include "content/public/browser/web_contents.h" | 36 #include "content/public/browser/web_contents.h" |
38 #include "content/public/common/content_client.h" | 37 #include "content/public/common/content_client.h" |
39 #include "grit/generated_resources.h" | 38 #include "grit/generated_resources.h" |
40 #include "ui/base/l10n/l10n_util.h" | 39 #include "ui/base/l10n/l10n_util.h" |
41 #include "webkit/glue/webkit_glue.h" | 40 #include "webkit/glue/webkit_glue.h" |
42 | 41 |
43 using content::DevToolsAgentHost; | 42 using content::DevToolsAgentHost; |
44 using content::DevToolsAgentHostRegistry; | 43 using content::DevToolsAgentHostRegistry; |
45 using content::DevToolsClientHost; | 44 using content::DevToolsClientHost; |
46 using content::DevToolsManager; | 45 using content::DevToolsManager; |
| 46 using content::WebContents; |
47 | 47 |
48 namespace keys = extension_debugger_api_constants; | 48 namespace keys = extension_debugger_api_constants; |
49 | 49 |
50 using content::WebContents; | |
51 | 50 |
52 class ExtensionDevToolsInfoBarDelegate : public ConfirmInfoBarDelegate { | 51 class ExtensionDevToolsInfoBarDelegate : public ConfirmInfoBarDelegate { |
53 public: | 52 public: |
54 ExtensionDevToolsInfoBarDelegate( | 53 ExtensionDevToolsInfoBarDelegate( |
55 InfoBarTabHelper* infobar_helper, | 54 InfoBarTabHelper* infobar_helper, |
56 const std::string& client_name); | 55 const std::string& client_name); |
57 virtual ~ExtensionDevToolsInfoBarDelegate(); | 56 virtual ~ExtensionDevToolsInfoBarDelegate(); |
58 | 57 |
59 private: | 58 private: |
60 // ConfirmInfoBarDelegate: | 59 // ConfirmInfoBarDelegate: |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 | 138 |
140 ExtensionDevToolsClientHost* Lookup(WebContents* contents) { | 139 ExtensionDevToolsClientHost* Lookup(WebContents* contents) { |
141 for (std::set<DevToolsClientHost*>::iterator it = client_hosts_.begin(); | 140 for (std::set<DevToolsClientHost*>::iterator it = client_hosts_.begin(); |
142 it != client_hosts_.end(); ++it) { | 141 it != client_hosts_.end(); ++it) { |
143 DevToolsAgentHost* agent_host = | 142 DevToolsAgentHost* agent_host = |
144 DevToolsManager::GetInstance()->GetDevToolsAgentHostFor(*it); | 143 DevToolsManager::GetInstance()->GetDevToolsAgentHostFor(*it); |
145 if (!agent_host) | 144 if (!agent_host) |
146 continue; | 145 continue; |
147 content::RenderViewHost* rvh = | 146 content::RenderViewHost* rvh = |
148 DevToolsAgentHostRegistry::GetRenderViewHost(agent_host); | 147 DevToolsAgentHostRegistry::GetRenderViewHost(agent_host); |
149 if (rvh && rvh->GetDelegate() && | 148 if (rvh && WebContents::FromRenderViewHost(rvh) == contents) |
150 rvh->GetDelegate()->GetAsWebContents() == contents) | |
151 return static_cast<ExtensionDevToolsClientHost*>(*it); | 149 return static_cast<ExtensionDevToolsClientHost*>(*it); |
152 } | 150 } |
153 return NULL; | 151 return NULL; |
154 } | 152 } |
155 | 153 |
156 private: | 154 private: |
157 std::set<DevToolsClientHost*> client_hosts_; | 155 std::set<DevToolsClientHost*> client_hosts_; |
158 }; | 156 }; |
159 | 157 |
160 } // namespace | 158 } // namespace |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 return; | 485 return; |
488 } | 486 } |
489 | 487 |
490 Value* result_body; | 488 Value* result_body; |
491 if (dictionary->Get("result", &result_body)) | 489 if (dictionary->Get("result", &result_body)) |
492 result_.reset(result_body->DeepCopy()); | 490 result_.reset(result_body->DeepCopy()); |
493 else | 491 else |
494 result_.reset(new DictionaryValue()); | 492 result_.reset(new DictionaryValue()); |
495 SendResponse(true); | 493 SendResponse(true); |
496 } | 494 } |
OLD | NEW |