Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Side by Side Diff: chrome/browser/extensions/api/mdns/mdns_api.cc

Issue 1200503002: [Extensions] Kill off ExtensionMsg_AddMessageToConsole (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Latest master Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 // Get all the extensions with an onServiceList listener for a particular 201 // Get all the extensions with an onServiceList listener for a particular
201 // service type. 202 // service type.
202 std::set<std::string> extension_ids; 203 std::set<std::string> extension_ids;
203 GetValidOnServiceListListeners(service_type, 204 GetValidOnServiceListListeners(service_type,
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.
211 // TODO(devlin): It's a little weird to log to the background pages,
212 // especially when it might be dormant. We should probably just log to a place
213 // like the ErrorConsole instead.
210 for (const std::string& extension_id : extension_ids) { 214 for (const std::string& extension_id : extension_ids) {
211 extensions::ExtensionHost* host = 215 extensions::ExtensionHost* host =
212 extensions::ProcessManager::Get(browser_context_) 216 extensions::ProcessManager::Get(browser_context_)
213 ->GetBackgroundHostForExtension(extension_id); 217 ->GetBackgroundHostForExtension(extension_id);
214 if (!host) 218 content::RenderFrameHost* rfh =
215 continue; 219 host ? host->host_contents()->GetMainFrame() : nullptr;
216 content::RenderViewHost* rvh = host->render_view_host(); 220 if (rfh)
217 if (!rvh) 221 rfh->AddMessageToConsole(level, logged_message);
218 continue;
219 rvh->Send(new ExtensionMsg_AddMessageToConsole(
220 rvh->GetRoutingID(),
221 level,
222 logged_message));
223 } 222 }
224 } 223 }
225 224
226 } // namespace extensions 225 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698