| 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/api/debugger/debugger_api.h" | 7 #include "chrome/browser/extensions/api/debugger/debugger_api.h" |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 public content::NotificationObserver, | 77 public content::NotificationObserver, |
| 78 public ExtensionRegistryObserver { | 78 public ExtensionRegistryObserver { |
| 79 public: | 79 public: |
| 80 ExtensionDevToolsClientHost(Profile* profile, | 80 ExtensionDevToolsClientHost(Profile* profile, |
| 81 DevToolsAgentHost* agent_host, | 81 DevToolsAgentHost* agent_host, |
| 82 const std::string& extension_id, | 82 const std::string& extension_id, |
| 83 const std::string& extension_name, | 83 const std::string& extension_name, |
| 84 const Debuggee& debuggee, | 84 const Debuggee& debuggee, |
| 85 infobars::InfoBar* infobar); | 85 infobars::InfoBar* infobar); |
| 86 | 86 |
| 87 virtual ~ExtensionDevToolsClientHost(); | 87 ~ExtensionDevToolsClientHost() override; |
| 88 | 88 |
| 89 const std::string& extension_id() { return extension_id_; } | 89 const std::string& extension_id() { return extension_id_; } |
| 90 DevToolsAgentHost* agent_host() { return agent_host_.get(); } | 90 DevToolsAgentHost* agent_host() { return agent_host_.get(); } |
| 91 void Close(); | 91 void Close(); |
| 92 void SendMessageToBackend(DebuggerSendCommandFunction* function, | 92 void SendMessageToBackend(DebuggerSendCommandFunction* function, |
| 93 const std::string& method, | 93 const std::string& method, |
| 94 SendCommand::Params::CommandParams* command_params); | 94 SendCommand::Params::CommandParams* command_params); |
| 95 | 95 |
| 96 // Marks connection as to-be-terminated by the user. | 96 // Marks connection as to-be-terminated by the user. |
| 97 void MarkAsDismissed(); | 97 void MarkAsDismissed(); |
| 98 | 98 |
| 99 // DevToolsAgentHostClient interface. | 99 // DevToolsAgentHostClient interface. |
| 100 virtual void AgentHostClosed( | 100 void AgentHostClosed(DevToolsAgentHost* agent_host, |
| 101 DevToolsAgentHost* agent_host, | 101 bool replaced_with_another_client) override; |
| 102 bool replaced_with_another_client) override; | 102 void DispatchProtocolMessage(DevToolsAgentHost* agent_host, |
| 103 virtual void DispatchProtocolMessage( | 103 const std::string& message) override; |
| 104 DevToolsAgentHost* agent_host, | |
| 105 const std::string& message) override; | |
| 106 | 104 |
| 107 private: | 105 private: |
| 108 void SendDetachedEvent(); | 106 void SendDetachedEvent(); |
| 109 | 107 |
| 110 // content::NotificationObserver implementation. | 108 // content::NotificationObserver implementation. |
| 111 virtual void Observe(int type, | 109 void Observe(int type, |
| 112 const content::NotificationSource& source, | 110 const content::NotificationSource& source, |
| 113 const content::NotificationDetails& details) override; | 111 const content::NotificationDetails& details) override; |
| 114 | 112 |
| 115 // ExtensionRegistryObserver implementation. | 113 // ExtensionRegistryObserver implementation. |
| 116 virtual void OnExtensionUnloaded( | 114 void OnExtensionUnloaded(content::BrowserContext* browser_context, |
| 117 content::BrowserContext* browser_context, | 115 const Extension* extension, |
| 118 const Extension* extension, | 116 UnloadedExtensionInfo::Reason reason) override; |
| 119 UnloadedExtensionInfo::Reason reason) override; | |
| 120 | 117 |
| 121 Profile* profile_; | 118 Profile* profile_; |
| 122 scoped_refptr<DevToolsAgentHost> agent_host_; | 119 scoped_refptr<DevToolsAgentHost> agent_host_; |
| 123 std::string extension_id_; | 120 std::string extension_id_; |
| 124 Debuggee debuggee_; | 121 Debuggee debuggee_; |
| 125 content::NotificationRegistrar registrar_; | 122 content::NotificationRegistrar registrar_; |
| 126 int last_request_id_; | 123 int last_request_id_; |
| 127 typedef std::map<int, scoped_refptr<DebuggerSendCommandFunction> > | 124 typedef std::map<int, scoped_refptr<DebuggerSendCommandFunction> > |
| 128 PendingRequests; | 125 PendingRequests; |
| 129 PendingRequests pending_requests_; | 126 PendingRequests pending_requests_; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 // successfully added. | 161 // successfully added. |
| 165 static infobars::InfoBar* Create(WebContents* web_contents, | 162 static infobars::InfoBar* Create(WebContents* web_contents, |
| 166 const std::string& client_name); | 163 const std::string& client_name); |
| 167 | 164 |
| 168 void set_client_host(ExtensionDevToolsClientHost* client_host) { | 165 void set_client_host(ExtensionDevToolsClientHost* client_host) { |
| 169 client_host_ = client_host; | 166 client_host_ = client_host; |
| 170 } | 167 } |
| 171 | 168 |
| 172 private: | 169 private: |
| 173 explicit ExtensionDevToolsInfoBarDelegate(const std::string& client_name); | 170 explicit ExtensionDevToolsInfoBarDelegate(const std::string& client_name); |
| 174 virtual ~ExtensionDevToolsInfoBarDelegate(); | 171 ~ExtensionDevToolsInfoBarDelegate() override; |
| 175 | 172 |
| 176 // ConfirmInfoBarDelegate: | 173 // ConfirmInfoBarDelegate: |
| 177 virtual void InfoBarDismissed() override; | 174 void InfoBarDismissed() override; |
| 178 virtual Type GetInfoBarType() const override; | 175 Type GetInfoBarType() const override; |
| 179 virtual bool ShouldExpireInternal( | 176 bool ShouldExpireInternal(const NavigationDetails& details) const override; |
| 180 const NavigationDetails& details) const override; | 177 base::string16 GetMessageText() const override; |
| 181 virtual base::string16 GetMessageText() const override; | 178 int GetButtons() const override; |
| 182 virtual int GetButtons() const override; | 179 bool Cancel() override; |
| 183 virtual bool Cancel() override; | |
| 184 | 180 |
| 185 std::string client_name_; | 181 std::string client_name_; |
| 186 ExtensionDevToolsClientHost* client_host_; | 182 ExtensionDevToolsClientHost* client_host_; |
| 187 | 183 |
| 188 DISALLOW_COPY_AND_ASSIGN(ExtensionDevToolsInfoBarDelegate); | 184 DISALLOW_COPY_AND_ASSIGN(ExtensionDevToolsInfoBarDelegate); |
| 189 }; | 185 }; |
| 190 | 186 |
| 191 // static | 187 // static |
| 192 infobars::InfoBar* ExtensionDevToolsInfoBarDelegate::Create( | 188 infobars::InfoBar* ExtensionDevToolsInfoBarDelegate::Create( |
| 193 WebContents* web_contents, | 189 WebContents* web_contents, |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 const std::vector<DevToolsTargetImpl*>& target_list) { | 736 const std::vector<DevToolsTargetImpl*>& target_list) { |
| 741 scoped_ptr<base::ListValue> result(new base::ListValue()); | 737 scoped_ptr<base::ListValue> result(new base::ListValue()); |
| 742 for (size_t i = 0; i < target_list.size(); ++i) | 738 for (size_t i = 0; i < target_list.size(); ++i) |
| 743 result->Append(SerializeTarget(*target_list[i])); | 739 result->Append(SerializeTarget(*target_list[i])); |
| 744 STLDeleteContainerPointers(target_list.begin(), target_list.end()); | 740 STLDeleteContainerPointers(target_list.begin(), target_list.end()); |
| 745 SetResult(result.release()); | 741 SetResult(result.release()); |
| 746 SendResponse(true); | 742 SendResponse(true); |
| 747 } | 743 } |
| 748 | 744 |
| 749 } // namespace extensions | 745 } // namespace extensions |
| OLD | NEW |