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

Side by Side Diff: content/browser/renderer_host/pepper_message_filter.cc

Issue 10342013: Generate and connect a Pepper identifier for Chrome OS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
battre 2012/05/03 09:57:43 Nit: You accidentally deleted this header
drewry 2012/05/03 13:57:18 Done.
2 // Use of this source code is governed by a BSD-style license that can be 1 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 2 // found in the LICENSE file.
4 3
5 #include "content/browser/renderer_host/pepper_message_filter.h" 4 #include "content/browser/renderer_host/pepper_message_filter.h"
6 5
7 #include "base/bind.h" 6 #include "base/bind.h"
8 #include "base/bind_helpers.h" 7 #include "base/bind_helpers.h"
9 #include "base/callback.h" 8 #include "base/callback.h"
10 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/file_path.h"
11 #include "base/file_util.h"
11 #include "base/logging.h" 12 #include "base/logging.h"
12 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
14 #include "base/process_util.h" 15 #include "base/process_util.h"
15 #include "base/threading/sequenced_worker_pool.h" 16 #include "base/threading/sequenced_worker_pool.h"
16 #include "base/threading/worker_pool.h" 17 #include "base/threading/worker_pool.h"
17 #include "base/values.h" 18 #include "base/values.h"
18 #include "build/build_config.h" 19 #include "build/build_config.h"
19 #include "content/browser/renderer_host/pepper_lookup_request.h" 20 #include "content/browser/renderer_host/pepper_lookup_request.h"
20 #include "content/browser/renderer_host/pepper_tcp_server_socket.h" 21 #include "content/browser/renderer_host/pepper_tcp_server_socket.h"
21 #include "content/browser/renderer_host/pepper_tcp_socket.h" 22 #include "content/browser/renderer_host/pepper_tcp_socket.h"
22 #include "content/browser/renderer_host/pepper_udp_socket.h" 23 #include "content/browser/renderer_host/pepper_udp_socket.h"
23 #include "content/browser/renderer_host/render_process_host_impl.h" 24 #include "content/browser/renderer_host/render_process_host_impl.h"
24 #include "content/browser/renderer_host/render_view_host_impl.h" 25 #include "content/browser/renderer_host/render_view_host_impl.h"
25 #include "content/common/pepper_messages.h" 26 #include "content/common/pepper_messages.h"
27 #include "content/public/browser/browser_context.h"
26 #include "content/public/browser/browser_thread.h" 28 #include "content/public/browser/browser_thread.h"
27 #include "content/public/browser/content_browser_client.h" 29 #include "content/public/browser/content_browser_client.h"
28 #include "content/public/browser/font_list_async.h" 30 #include "content/public/browser/font_list_async.h"
29 #include "content/public/browser/resource_context.h" 31 #include "content/public/browser/resource_context.h"
30 #include "content/public/browser/site_instance.h" 32 #include "content/public/browser/site_instance.h"
31 #include "content/public/common/content_client.h" 33 #include "content/public/common/content_client.h"
32 #include "net/base/address_family.h" 34 #include "net/base/address_family.h"
33 #include "net/base/address_list.h" 35 #include "net/base/address_list.h"
34 #include "net/base/cert_verifier.h" 36 #include "net/base/cert_verifier.h"
35 #include "net/base/host_port_pair.h" 37 #include "net/base/host_port_pair.h"
(...skipping 12 matching lines...) Expand all
48 50
49 using content::BrowserThread; 51 using content::BrowserThread;
50 using content::RenderViewHostImpl; 52 using content::RenderViewHostImpl;
51 using ppapi::NetAddressPrivateImpl; 53 using ppapi::NetAddressPrivateImpl;
52 54
53 namespace { 55 namespace {
54 56
55 const size_t kMaxSocketsAllowed = 1024; 57 const size_t kMaxSocketsAllowed = 1024;
56 const uint32 kInvalidSocketID = 0; 58 const uint32 kInvalidSocketID = 0;
57 59
60 // This is mirrored from
61 // chrome/browser/chromeos/system/drm_settings.cc
62 const char kDRMIdentifierFile[] = "Pepper DRM ID.0";
battre 2012/05/03 09:57:43 nit: insert space because the following line is no
drewry 2012/05/03 13:57:18 I swapped the ordering to avoid confusion
63 // The DRM identifier is 32 bytes hexencoded at present.
64 const int kDRMIdentifierSize = 64;
battre 2012/05/03 09:57:43 so why is this 64?
drewry 2012/05/03 13:57:18 I commented slightly better and uses a constant ex
65
58 } // namespace 66 } // namespace
59 67
60 PepperMessageFilter::PepperMessageFilter( 68 PepperMessageFilter::PepperMessageFilter(
61 ProcessType type, 69 ProcessType type,
62 int process_id, 70 int process_id,
63 content::ResourceContext* resource_context) 71 content::BrowserContext* browser_context)
64 : process_type_(type), 72 : process_type_(type),
65 process_id_(process_id), 73 process_id_(process_id),
66 resource_context_(resource_context), 74 resource_context_(browser_context ?
75 browser_context->GetResourceContext(): NULL),
battre 2012/05/03 09:57:43 nit: +2 spaces at beginning of line +1 space infro
drewry 2012/05/03 13:57:18 Done.
67 host_resolver_(NULL), 76 host_resolver_(NULL),
68 next_socket_id_(1) { 77 next_socket_id_(1) {
69 DCHECK(type == RENDERER); 78 DCHECK(type == RENDERER);
79 DCHECK(browser_context);
80 browser_path_ = browser_context->GetPath();
70 DCHECK(resource_context_); 81 DCHECK(resource_context_);
71 } 82 }
72 83
73 PepperMessageFilter::PepperMessageFilter(ProcessType type, 84 PepperMessageFilter::PepperMessageFilter(ProcessType type,
74 net::HostResolver* host_resolver) 85 net::HostResolver* host_resolver)
75 : process_type_(type), 86 : process_type_(type),
76 process_id_(0), 87 process_id_(0),
77 resource_context_(NULL), 88 resource_context_(NULL),
78 host_resolver_(host_resolver), 89 host_resolver_(host_resolver),
79 next_socket_id_(1) { 90 next_socket_id_(1),
91 browser_path_("") {
80 DCHECK(type == PLUGIN); 92 DCHECK(type == PLUGIN);
81 DCHECK(host_resolver); 93 DCHECK(host_resolver);
82 } 94 }
83 95
84 void PepperMessageFilter::OverrideThreadForMessage( 96 void PepperMessageFilter::OverrideThreadForMessage(
85 const IPC::Message& message, 97 const IPC::Message& message,
86 BrowserThread::ID* thread) { 98 BrowserThread::ID* thread) {
87 if (message.type() == PpapiHostMsg_PPBTCPSocket_Connect::ID || 99 if (message.type() == PpapiHostMsg_PPBTCPSocket_Connect::ID ||
88 message.type() == PpapiHostMsg_PPBTCPSocket_ConnectWithNetAddress::ID || 100 message.type() == PpapiHostMsg_PPBTCPSocket_ConnectWithNetAddress::ID ||
89 message.type() == PpapiHostMsg_PPBUDPSocket_Bind::ID || 101 message.type() == PpapiHostMsg_PPBUDPSocket_Bind::ID ||
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 OnNetworkMonitorStart) 150 OnNetworkMonitorStart)
139 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBNetworkMonitor_Stop, 151 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBNetworkMonitor_Stop,
140 OnNetworkMonitorStop) 152 OnNetworkMonitorStop)
141 153
142 // X509 certificate messages. 154 // X509 certificate messages.
143 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBX509Certificate_ParseDER, 155 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBX509Certificate_ParseDER,
144 OnX509CertificateParseDER); 156 OnX509CertificateParseDER);
145 157
146 // Flash messages. 158 // Flash messages.
147 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_UpdateActivity, OnUpdateActivity) 159 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_UpdateActivity, OnUpdateActivity)
148 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetDeviceID, OnGetDeviceID) 160 IPC_MESSAGE_HANDLER(PepperMsg_GetDeviceID, OnGetDeviceID)
149 161
150 IPC_MESSAGE_UNHANDLED(handled = false) 162 IPC_MESSAGE_UNHANDLED(handled = false)
151 IPC_END_MESSAGE_MAP_EX() 163 IPC_END_MESSAGE_MAP_EX()
152 return handled; 164 return handled;
153 } 165 }
154 166
155 void PepperMessageFilter::OnIPAddressChanged() { 167 void PepperMessageFilter::OnIPAddressChanged() {
156 GetAndSendNetworkList(); 168 GetAndSendNetworkList();
157 } 169 }
158 170
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 // than the screensaver timeout, it won't go on. 638 // than the screensaver timeout, it won't go on.
627 int value = 0; 639 int value = 0;
628 if (SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT, 0, &value, 0)) 640 if (SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT, 0, &value, 0))
629 SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, value, NULL, 0); 641 SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, value, NULL, 0);
630 #else 642 #else
631 // TODO(brettw) implement this for other platforms. 643 // TODO(brettw) implement this for other platforms.
632 #endif 644 #endif
633 } 645 }
634 646
635 void PepperMessageFilter::OnGetDeviceID(std::string* id) { 647 void PepperMessageFilter::OnGetDeviceID(std::string* id) {
636 // TODO(brettw) implement this. 648 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
637 *id = "<undefined>"; 649 *id = "";
650
651 if (browser_path_.empty()) {
652 LOG(ERROR) << "GetDeviceID requested from outside the RENDERER context.";
653 return;
654 }
655
656 // TODO(wad,brettw) Add OffTheRecord() enforcement here.
657 // Normally this is left for the plugin to do, but in the
658 // future we should check here as an added safeguard.
659
660 // Grab the contents of the DRM identifier file.
661 FilePath drm_id_file = browser_path_;
662 drm_id_file = drm_id_file.AppendASCII(kDRMIdentifierFile);
663 char id_buf[kDRMIdentifierSize];
664 if (file_util::ReadFile(drm_id_file, id_buf, kDRMIdentifierSize) !=
665 kDRMIdentifierSize) {
666 VLOG(1) << "file not readable: " << drm_id_file.value();
667 *id = "";
battre 2012/05/03 09:57:43 return;
drewry 2012/05/03 13:57:18 Done.
668 }
669 id->assign(id_buf, kDRMIdentifierSize);
638 } 670 }
639 671
640 void PepperMessageFilter::GetFontFamiliesComplete( 672 void PepperMessageFilter::GetFontFamiliesComplete(
641 IPC::Message* reply_msg, 673 IPC::Message* reply_msg,
642 scoped_ptr<base::ListValue> result) { 674 scoped_ptr<base::ListValue> result) {
643 std::string output; 675 std::string output;
644 for (size_t i = 0; i < result->GetSize(); i++) { 676 for (size_t i = 0; i < result->GetSize(); i++) {
645 base::ListValue* cur_font; 677 base::ListValue* cur_font;
646 if (!result->GetList(i, &cur_font)) 678 if (!result->GetList(i, &cur_font))
647 continue; 679 continue;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 network_copy.state = PP_NETWORKLIST_UP; 789 network_copy.state = PP_NETWORKLIST_UP;
758 network_copy.display_name = network.name; 790 network_copy.display_name = network.name;
759 network_copy.mtu = 0; 791 network_copy.mtu = 0;
760 } 792 }
761 for (NetworkMonitorIdSet::iterator it = network_monitor_ids_.begin(); 793 for (NetworkMonitorIdSet::iterator it = network_monitor_ids_.begin();
762 it != network_monitor_ids_.end(); ++it) { 794 it != network_monitor_ids_.end(); ++it) {
763 Send(new PpapiMsg_PPBNetworkMonitor_NetworkList( 795 Send(new PpapiMsg_PPBNetworkMonitor_NetworkList(
764 ppapi::API_ID_PPB_NETWORKMANAGER_PRIVATE, *it, *list_copy)); 796 ppapi::API_ID_PPB_NETWORKMANAGER_PRIVATE, *it, *list_copy));
765 } 797 }
766 } 798 }
OLDNEW
« no previous file with comments | « content/browser/renderer_host/pepper_message_filter.h ('k') | content/browser/renderer_host/render_process_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698