OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/api/mdns/mdns_api.h" | 5 #include "chrome/browser/extensions/api/mdns/mdns_api.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/strings/stringprintf.h" | |
10 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
11 #include "chrome/common/extensions/api/mdns.h" | 12 #include "chrome/common/extensions/api/mdns.h" |
13 #include "content/public/browser/render_frame_host.h" | |
12 #include "content/public/browser/render_process_host.h" | 14 #include "content/public/browser/render_process_host.h" |
13 #include "content/public/browser/render_view_host.h" | 15 #include "content/public/browser/web_contents.h" |
14 #include "extensions/browser/extension_host.h" | 16 #include "extensions/browser/extension_host.h" |
15 #include "extensions/browser/extension_registry.h" | 17 #include "extensions/browser/extension_registry.h" |
16 #include "extensions/common/extension_messages.h" | |
17 | 18 |
18 namespace extensions { | 19 namespace extensions { |
19 | 20 |
20 namespace mdns = api::mdns; | 21 namespace mdns = api::mdns; |
21 | 22 |
22 namespace { | 23 namespace { |
23 | 24 |
24 // Whitelisted mDNS service types. | 25 // Whitelisted mDNS service types. |
25 const char kCastServiceType[] = "_googlecast._tcp.local"; | 26 const char kCastServiceType[] = "_googlecast._tcp.local"; |
26 const char kPrivetServiceType[] = "_privet._tcp.local"; | 27 const char kPrivetServiceType[] = "_privet._tcp.local"; |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
204 &extension_ids, | 205 &extension_ids, |
205 nullptr /* service_types */); | 206 nullptr /* service_types */); |
206 | 207 |
207 std::string logged_message(std::string("[chrome.mdns] ") + message); | 208 std::string logged_message(std::string("[chrome.mdns] ") + message); |
208 | 209 |
209 // Log to the consoles of the background pages for those extensions. | 210 // Log to the consoles of the background pages for those extensions. |
210 for (const std::string& extension_id : extension_ids) { | 211 for (const std::string& extension_id : extension_ids) { |
211 extensions::ExtensionHost* host = | 212 extensions::ExtensionHost* host = |
212 extensions::ProcessManager::Get(browser_context_) | 213 extensions::ProcessManager::Get(browser_context_) |
213 ->GetBackgroundHostForExtension(extension_id); | 214 ->GetBackgroundHostForExtension(extension_id); |
214 if (!host) | 215 content::RenderFrameHost* rfh = |
not at google - send to devlin
2015/06/19 23:14:58
This should probably use ProcessManager::GetRender
Devlin
2015/06/19 23:53:51
That would be a change in behavior, and it would b
not at google - send to devlin
2015/06/22 17:54:10
I think it's more weird to log it to the backgroun
Devlin
2015/06/22 19:52:32
Added a TODO. I'd like to (try) to avoid behavior
| |
215 continue; | 216 host ? host->host_contents()->GetMainFrame() : nullptr; |
216 content::RenderViewHost* rvh = host->render_view_host(); | 217 if (rfh) |
217 if (!rvh) | 218 rfh->AddMessageToConsole(level, logged_message); |
218 continue; | |
219 rvh->Send(new ExtensionMsg_AddMessageToConsole( | |
220 rvh->GetRoutingID(), | |
221 level, | |
222 logged_message)); | |
223 } | 219 } |
224 } | 220 } |
225 | 221 |
226 } // namespace extensions | 222 } // namespace extensions |
OLD | NEW |