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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 client_host_ = client_host; | 150 client_host_ = client_host; |
151 } | 151 } |
152 | 152 |
153 private: | 153 private: |
154 explicit ExtensionDevToolsInfoBarDelegate(const std::string& client_name); | 154 explicit ExtensionDevToolsInfoBarDelegate(const std::string& client_name); |
155 virtual ~ExtensionDevToolsInfoBarDelegate(); | 155 virtual ~ExtensionDevToolsInfoBarDelegate(); |
156 | 156 |
157 // ConfirmInfoBarDelegate: | 157 // ConfirmInfoBarDelegate: |
158 virtual void InfoBarDismissed() OVERRIDE; | 158 virtual void InfoBarDismissed() OVERRIDE; |
159 virtual Type GetInfoBarType() const OVERRIDE; | 159 virtual Type GetInfoBarType() const OVERRIDE; |
160 virtual bool ShouldExpireInternal( | 160 virtual bool ShouldExpireInternal(const NavigationDetails& details) const |
161 const content::LoadCommittedDetails& details) const OVERRIDE; | 161 OVERRIDE; |
162 virtual base::string16 GetMessageText() const OVERRIDE; | 162 virtual base::string16 GetMessageText() const OVERRIDE; |
163 virtual int GetButtons() const OVERRIDE; | 163 virtual int GetButtons() const OVERRIDE; |
164 virtual bool Cancel() OVERRIDE; | 164 virtual bool Cancel() OVERRIDE; |
165 | 165 |
166 std::string client_name_; | 166 std::string client_name_; |
167 ExtensionDevToolsClientHost* client_host_; | 167 ExtensionDevToolsClientHost* client_host_; |
168 | 168 |
169 DISALLOW_COPY_AND_ASSIGN(ExtensionDevToolsInfoBarDelegate); | 169 DISALLOW_COPY_AND_ASSIGN(ExtensionDevToolsInfoBarDelegate); |
170 }; | 170 }; |
171 | 171 |
172 // static | 172 // static |
173 InfoBar* ExtensionDevToolsInfoBarDelegate::Create( | 173 InfoBar* ExtensionDevToolsInfoBarDelegate::Create( |
174 RenderViewHost* rvh, | 174 RenderViewHost* rvh, |
175 const std::string& client_name) { | 175 const std::string& client_name) { |
176 if (!rvh) | 176 if (!rvh) |
177 return NULL; | 177 return NULL; |
178 | 178 |
179 WebContents* web_contents = WebContents::FromRenderViewHost(rvh); | 179 WebContents* web_contents = WebContents::FromRenderViewHost(rvh); |
180 if (!web_contents) | 180 if (!web_contents) |
181 return NULL; | 181 return NULL; |
182 | 182 |
183 InfoBarService* infobar_service = | 183 InfoBarService* infobar_service = |
184 InfoBarService::FromWebContents(web_contents); | 184 InfoBarService::FromWebContents(web_contents); |
185 if (!infobar_service) | 185 if (!infobar_service) |
186 return NULL; | 186 return NULL; |
187 | 187 |
188 return infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar( | 188 return infobar_service->AddInfoBar( |
189 scoped_ptr<ConfirmInfoBarDelegate>( | 189 ConfirmInfoBarDelegate::CreateInfoBar(scoped_ptr<ConfirmInfoBarDelegate>( |
190 new ExtensionDevToolsInfoBarDelegate(client_name)))); | 190 new ExtensionDevToolsInfoBarDelegate(client_name)))); |
191 } | 191 } |
192 | 192 |
193 ExtensionDevToolsInfoBarDelegate::ExtensionDevToolsInfoBarDelegate( | 193 ExtensionDevToolsInfoBarDelegate::ExtensionDevToolsInfoBarDelegate( |
194 const std::string& client_name) | 194 const std::string& client_name) |
195 : ConfirmInfoBarDelegate(), | 195 : ConfirmInfoBarDelegate(), |
196 client_name_(client_name), | 196 client_name_(client_name), |
197 client_host_(NULL) { | 197 client_host_(NULL) { |
198 } | 198 } |
199 | 199 |
200 ExtensionDevToolsInfoBarDelegate::~ExtensionDevToolsInfoBarDelegate() { | 200 ExtensionDevToolsInfoBarDelegate::~ExtensionDevToolsInfoBarDelegate() { |
201 } | 201 } |
202 | 202 |
203 void ExtensionDevToolsInfoBarDelegate::InfoBarDismissed() { | 203 void ExtensionDevToolsInfoBarDelegate::InfoBarDismissed() { |
204 if (client_host_) | 204 if (client_host_) |
205 client_host_->MarkAsDismissed(); | 205 client_host_->MarkAsDismissed(); |
206 } | 206 } |
207 | 207 |
208 InfoBarDelegate::Type ExtensionDevToolsInfoBarDelegate::GetInfoBarType() const { | 208 InfoBarDelegate::Type ExtensionDevToolsInfoBarDelegate::GetInfoBarType() const { |
209 return WARNING_TYPE; | 209 return WARNING_TYPE; |
210 } | 210 } |
211 | 211 |
212 bool ExtensionDevToolsInfoBarDelegate::ShouldExpireInternal( | 212 bool ExtensionDevToolsInfoBarDelegate::ShouldExpireInternal( |
213 const content::LoadCommittedDetails& details) const { | 213 const NavigationDetails& details) const { |
214 return false; | 214 return false; |
215 } | 215 } |
216 | 216 |
217 base::string16 ExtensionDevToolsInfoBarDelegate::GetMessageText() const { | 217 base::string16 ExtensionDevToolsInfoBarDelegate::GetMessageText() const { |
218 return l10n_util::GetStringFUTF16(IDS_DEV_TOOLS_INFOBAR_LABEL, | 218 return l10n_util::GetStringFUTF16(IDS_DEV_TOOLS_INFOBAR_LABEL, |
219 base::UTF8ToUTF16(client_name_)); | 219 base::UTF8ToUTF16(client_name_)); |
220 } | 220 } |
221 | 221 |
222 int ExtensionDevToolsInfoBarDelegate::GetButtons() const { | 222 int ExtensionDevToolsInfoBarDelegate::GetButtons() const { |
223 return BUTTON_CANCEL; | 223 return BUTTON_CANCEL; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 } | 332 } |
333 | 333 |
334 ExtensionDevToolsClientHost::~ExtensionDevToolsClientHost() { | 334 ExtensionDevToolsClientHost::~ExtensionDevToolsClientHost() { |
335 // Ensure calling RemoveInfoBar() below won't result in Observe() trying to | 335 // Ensure calling RemoveInfoBar() below won't result in Observe() trying to |
336 // Close() us. | 336 // Close() us. |
337 registrar_.RemoveAll(); | 337 registrar_.RemoveAll(); |
338 | 338 |
339 if (infobar_) { | 339 if (infobar_) { |
340 static_cast<ExtensionDevToolsInfoBarDelegate*>( | 340 static_cast<ExtensionDevToolsInfoBarDelegate*>( |
341 infobar_->delegate())->set_client_host(NULL); | 341 infobar_->delegate())->set_client_host(NULL); |
342 InfoBarService::FromWebContents(WebContents::FromRenderViewHost( | 342 InfoBarService::FromWebContents( |
343 agent_host_->GetRenderViewHost()))->RemoveInfoBar(infobar_); | 343 WebContents::FromRenderViewHost(agent_host_->GetRenderViewHost())) |
| 344 ->infobar_manager() |
| 345 .RemoveInfoBar(infobar_); |
344 } | 346 } |
345 AttachedClientHosts::GetInstance()->Remove(this); | 347 AttachedClientHosts::GetInstance()->Remove(this); |
346 } | 348 } |
347 | 349 |
348 // DevToolsClientHost interface | 350 // DevToolsClientHost interface |
349 void ExtensionDevToolsClientHost::InspectedContentsClosing() { | 351 void ExtensionDevToolsClientHost::InspectedContentsClosing() { |
350 SendDetachedEvent(); | 352 SendDetachedEvent(); |
351 delete this; | 353 delete this; |
352 } | 354 } |
353 | 355 |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 | 713 |
712 void DebuggerGetTargetsFunction::SendTargetList( | 714 void DebuggerGetTargetsFunction::SendTargetList( |
713 const std::vector<DevToolsTargetImpl*>& target_list) { | 715 const std::vector<DevToolsTargetImpl*>& target_list) { |
714 scoped_ptr<base::ListValue> result(new base::ListValue()); | 716 scoped_ptr<base::ListValue> result(new base::ListValue()); |
715 for (size_t i = 0; i < target_list.size(); ++i) | 717 for (size_t i = 0; i < target_list.size(); ++i) |
716 result->Append(SerializeTarget(*target_list[i])); | 718 result->Append(SerializeTarget(*target_list[i])); |
717 STLDeleteContainerPointers(target_list.begin(), target_list.end()); | 719 STLDeleteContainerPointers(target_list.begin(), target_list.end()); |
718 SetResult(result.release()); | 720 SetResult(result.release()); |
719 SendResponse(true); | 721 SendResponse(true); |
720 } | 722 } |
OLD | NEW |