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

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: stop using HashPassword as it has legacy behavior. 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. 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 #include "content/browser/renderer_host/pepper_message_filter.h" 5 #include "content/browser/renderer_host/pepper_message_filter.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/file_path.h"
12 #include "base/file_util.h"
11 #include "base/logging.h" 13 #include "base/logging.h"
12 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
14 #include "base/process_util.h" 16 #include "base/process_util.h"
15 #include "base/threading/sequenced_worker_pool.h" 17 #include "base/threading/sequenced_worker_pool.h"
16 #include "base/threading/worker_pool.h" 18 #include "base/threading/worker_pool.h"
17 #include "base/values.h" 19 #include "base/values.h"
18 #include "build/build_config.h" 20 #include "build/build_config.h"
19 #include "content/browser/renderer_host/pepper_lookup_request.h" 21 #include "content/browser/renderer_host/pepper_lookup_request.h"
20 #include "content/browser/renderer_host/pepper_tcp_server_socket.h" 22 #include "content/browser/renderer_host/pepper_tcp_server_socket.h"
21 #include "content/browser/renderer_host/pepper_tcp_socket.h" 23 #include "content/browser/renderer_host/pepper_tcp_socket.h"
22 #include "content/browser/renderer_host/pepper_udp_socket.h" 24 #include "content/browser/renderer_host/pepper_udp_socket.h"
23 #include "content/browser/renderer_host/render_process_host_impl.h" 25 #include "content/browser/renderer_host/render_process_host_impl.h"
24 #include "content/browser/renderer_host/render_view_host_impl.h" 26 #include "content/browser/renderer_host/render_view_host_impl.h"
25 #include "content/common/pepper_messages.h" 27 #include "content/common/pepper_messages.h"
28 #include "content/public/browser/browser_context.h"
26 #include "content/public/browser/browser_thread.h" 29 #include "content/public/browser/browser_thread.h"
27 #include "content/public/browser/content_browser_client.h" 30 #include "content/public/browser/content_browser_client.h"
28 #include "content/public/browser/font_list_async.h" 31 #include "content/public/browser/font_list_async.h"
29 #include "content/public/browser/resource_context.h" 32 #include "content/public/browser/resource_context.h"
30 #include "content/public/browser/site_instance.h" 33 #include "content/public/browser/site_instance.h"
31 #include "content/public/common/content_client.h" 34 #include "content/public/common/content_client.h"
32 #include "net/base/address_family.h" 35 #include "net/base/address_family.h"
33 #include "net/base/address_list.h" 36 #include "net/base/address_list.h"
34 #include "net/base/cert_verifier.h" 37 #include "net/base/cert_verifier.h"
35 #include "net/base/host_port_pair.h" 38 #include "net/base/host_port_pair.h"
(...skipping 12 matching lines...) Expand all
48 51
49 using content::BrowserThread; 52 using content::BrowserThread;
50 using content::RenderViewHostImpl; 53 using content::RenderViewHostImpl;
51 using ppapi::NetAddressPrivateImpl; 54 using ppapi::NetAddressPrivateImpl;
52 55
53 namespace { 56 namespace {
54 57
55 const size_t kMaxSocketsAllowed = 1024; 58 const size_t kMaxSocketsAllowed = 1024;
56 const uint32 kInvalidSocketID = 0; 59 const uint32 kInvalidSocketID = 0;
57 60
61 // The ID is a 256-bit hash digest hex-encoded.
62 const int kDRMIdentifierSize = (256 / 8) * 2;
63 // The path to the file containing the DRM ID.
64 // It is mirrored from
65 // chrome/browser/chromeos/system/drm_settings.cc
66 const char kDRMIdentifierFile[] = "Pepper DRM ID.0";
67
58 } // namespace 68 } // namespace
59 69
60 PepperMessageFilter::PepperMessageFilter( 70 PepperMessageFilter::PepperMessageFilter(
61 ProcessType type, 71 ProcessType type,
62 int process_id, 72 int process_id,
63 content::ResourceContext* resource_context) 73 content::BrowserContext* browser_context)
64 : process_type_(type), 74 : process_type_(type),
65 process_id_(process_id), 75 process_id_(process_id),
66 resource_context_(resource_context), 76 resource_context_(browser_context ?
77 browser_context->GetResourceContext() : NULL),
67 host_resolver_(NULL), 78 host_resolver_(NULL),
68 next_socket_id_(1) { 79 next_socket_id_(1) {
69 DCHECK(type == RENDERER); 80 DCHECK(type == RENDERER);
81 DCHECK(browser_context);
82 browser_path_ = browser_context->GetPath();
70 DCHECK(resource_context_); 83 DCHECK(resource_context_);
71 } 84 }
72 85
73 PepperMessageFilter::PepperMessageFilter(ProcessType type, 86 PepperMessageFilter::PepperMessageFilter(ProcessType type,
74 net::HostResolver* host_resolver) 87 net::HostResolver* host_resolver)
75 : process_type_(type), 88 : process_type_(type),
76 process_id_(0), 89 process_id_(0),
77 resource_context_(NULL), 90 resource_context_(NULL),
78 host_resolver_(host_resolver), 91 host_resolver_(host_resolver),
79 next_socket_id_(1) { 92 next_socket_id_(1),
93 browser_path_("") {
brettw 2012/05/03 20:34:21 Don't use "" in here, that just makes it do extra
Will Drewry 2012/05/03 21:58:49 Done.
Will Drewry 2012/05/03 21:58:49 Done.
80 DCHECK(type == PLUGIN); 94 DCHECK(type == PLUGIN);
81 DCHECK(host_resolver); 95 DCHECK(host_resolver);
82 } 96 }
83 97
84 void PepperMessageFilter::OverrideThreadForMessage( 98 void PepperMessageFilter::OverrideThreadForMessage(
85 const IPC::Message& message, 99 const IPC::Message& message,
86 BrowserThread::ID* thread) { 100 BrowserThread::ID* thread) {
87 if (message.type() == PpapiHostMsg_PPBTCPSocket_Connect::ID || 101 if (message.type() == PpapiHostMsg_PPBTCPSocket_Connect::ID ||
88 message.type() == PpapiHostMsg_PPBTCPSocket_ConnectWithNetAddress::ID || 102 message.type() == PpapiHostMsg_PPBTCPSocket_ConnectWithNetAddress::ID ||
89 message.type() == PpapiHostMsg_PPBUDPSocket_Bind::ID || 103 message.type() == PpapiHostMsg_PPBUDPSocket_Bind::ID ||
90 message.type() == PpapiHostMsg_PPBTCPServerSocket_Listen::ID || 104 message.type() == PpapiHostMsg_PPBTCPServerSocket_Listen::ID ||
91 message.type() == PpapiHostMsg_PPBHostResolver_Resolve::ID) { 105 message.type() == PpapiHostMsg_PPBHostResolver_Resolve::ID) {
92 *thread = BrowserThread::UI; 106 *thread = BrowserThread::UI;
93 } else if (message.type() == PpapiHostMsg_PPBFlash_GetDeviceID::ID) { 107 } else if (message.type() == PpapiHostMsg_PPBFlash_GetDeviceID::ID) {
brettw 2012/05/03 20:34:21 You need to update this for your message.
Will Drewry 2012/05/03 21:58:49 Done. Awesomely, the IO thread hooks in ReadFile
94 *thread = BrowserThread::FILE; 108 *thread = BrowserThread::FILE;
95 } 109 }
96 } 110 }
97 111
98 bool PepperMessageFilter::OnMessageReceived(const IPC::Message& msg, 112 bool PepperMessageFilter::OnMessageReceived(const IPC::Message& msg,
99 bool* message_was_ok) { 113 bool* message_was_ok) {
100 bool handled = true; 114 bool handled = true;
101 IPC_BEGIN_MESSAGE_MAP_EX(PepperMessageFilter, msg, *message_was_ok) 115 IPC_BEGIN_MESSAGE_MAP_EX(PepperMessageFilter, msg, *message_was_ok)
102 IPC_MESSAGE_HANDLER(PepperMsg_GetLocalTimeZoneOffset, 116 IPC_MESSAGE_HANDLER(PepperMsg_GetLocalTimeZoneOffset,
103 OnGetLocalTimeZoneOffset) 117 OnGetLocalTimeZoneOffset)
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 OnNetworkMonitorStart) 152 OnNetworkMonitorStart)
139 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBNetworkMonitor_Stop, 153 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBNetworkMonitor_Stop,
140 OnNetworkMonitorStop) 154 OnNetworkMonitorStop)
141 155
142 // X509 certificate messages. 156 // X509 certificate messages.
143 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBX509Certificate_ParseDER, 157 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBX509Certificate_ParseDER,
144 OnX509CertificateParseDER); 158 OnX509CertificateParseDER);
145 159
146 // Flash messages. 160 // Flash messages.
147 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_UpdateActivity, OnUpdateActivity) 161 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_UpdateActivity, OnUpdateActivity)
148 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetDeviceID, OnGetDeviceID) 162 IPC_MESSAGE_HANDLER(PepperMsg_GetDeviceID, OnGetDeviceID)
149 163
150 IPC_MESSAGE_UNHANDLED(handled = false) 164 IPC_MESSAGE_UNHANDLED(handled = false)
151 IPC_END_MESSAGE_MAP_EX() 165 IPC_END_MESSAGE_MAP_EX()
152 return handled; 166 return handled;
153 } 167 }
154 168
155 void PepperMessageFilter::OnIPAddressChanged() { 169 void PepperMessageFilter::OnIPAddressChanged() {
156 GetAndSendNetworkList(); 170 GetAndSendNetworkList();
157 } 171 }
158 172
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 // than the screensaver timeout, it won't go on. 640 // than the screensaver timeout, it won't go on.
627 int value = 0; 641 int value = 0;
628 if (SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT, 0, &value, 0)) 642 if (SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT, 0, &value, 0))
629 SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, value, NULL, 0); 643 SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, value, NULL, 0);
630 #else 644 #else
631 // TODO(brettw) implement this for other platforms. 645 // TODO(brettw) implement this for other platforms.
632 #endif 646 #endif
633 } 647 }
634 648
635 void PepperMessageFilter::OnGetDeviceID(std::string* id) { 649 void PepperMessageFilter::OnGetDeviceID(std::string* id) {
636 // TODO(brettw) implement this. 650 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
637 *id = "<undefined>"; 651 *id = "";
brettw 2012/05/03 20:34:21 id->clear(); is probably better.
Will Drewry 2012/05/03 21:58:49 Done.
652
653 // This method should not be called with high frequency and its
654 // useful to be able to validate use with a VLOG.
655 VLOG(1) << "DRM ID requested.";
656
657 if (browser_path_.empty()) {
658 LOG(ERROR) << "GetDeviceID requested from outside the RENDERER context.";
659 return;
660 }
661
662 // TODO(wad,brettw) Add OffTheRecord() enforcement here.
663 // Normally this is left for the plugin to do, but in the
664 // future we should check here as an added safeguard.
665
666 // Grab the contents of the DRM identifier file.
667 FilePath drm_id_file = browser_path_;
668 drm_id_file = drm_id_file.AppendASCII(kDRMIdentifierFile);
669 char id_buf[kDRMIdentifierSize];
670 if (file_util::ReadFile(drm_id_file, id_buf, kDRMIdentifierSize) !=
671 kDRMIdentifierSize) {
672 VLOG(1) << "file not readable: " << drm_id_file.value();
673 return;
674 }
675 id->assign(id_buf, kDRMIdentifierSize);
638 } 676 }
639 677
640 void PepperMessageFilter::GetFontFamiliesComplete( 678 void PepperMessageFilter::GetFontFamiliesComplete(
641 IPC::Message* reply_msg, 679 IPC::Message* reply_msg,
642 scoped_ptr<base::ListValue> result) { 680 scoped_ptr<base::ListValue> result) {
643 std::string output; 681 std::string output;
644 for (size_t i = 0; i < result->GetSize(); i++) { 682 for (size_t i = 0; i < result->GetSize(); i++) {
645 base::ListValue* cur_font; 683 base::ListValue* cur_font;
646 if (!result->GetList(i, &cur_font)) 684 if (!result->GetList(i, &cur_font))
647 continue; 685 continue;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 network_copy.state = PP_NETWORKLIST_UP; 795 network_copy.state = PP_NETWORKLIST_UP;
758 network_copy.display_name = network.name; 796 network_copy.display_name = network.name;
759 network_copy.mtu = 0; 797 network_copy.mtu = 0;
760 } 798 }
761 for (NetworkMonitorIdSet::iterator it = network_monitor_ids_.begin(); 799 for (NetworkMonitorIdSet::iterator it = network_monitor_ids_.begin();
762 it != network_monitor_ids_.end(); ++it) { 800 it != network_monitor_ids_.end(); ++it) {
763 Send(new PpapiMsg_PPBNetworkMonitor_NetworkList( 801 Send(new PpapiMsg_PPBNetworkMonitor_NetworkList(
764 ppapi::API_ID_PPB_NETWORKMANAGER_PRIVATE, *it, *list_copy)); 802 ppapi::API_ID_PPB_NETWORKMANAGER_PRIVATE, *it, *list_copy));
765 } 803 }
766 } 804 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698