Index: content/browser/renderer_host/pepper_message_filter.cc |
diff --git a/content/browser/renderer_host/pepper_message_filter.cc b/content/browser/renderer_host/pepper_message_filter.cc |
index 9babcd1b8ba656c1b7585e1504fcd4e4cc8688e8..48feb8311202a54df06a1ad5653b0e193ac61888 100644 |
--- a/content/browser/renderer_host/pepper_message_filter.cc |
+++ b/content/browser/renderer_host/pepper_message_filter.cc |
@@ -1,4 +1,3 @@ |
-// 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.
|
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
@@ -8,6 +7,8 @@ |
#include "base/bind_helpers.h" |
#include "base/callback.h" |
#include "base/compiler_specific.h" |
+#include "base/file_path.h" |
+#include "base/file_util.h" |
#include "base/logging.h" |
#include "base/memory/ref_counted.h" |
#include "base/memory/scoped_ptr.h" |
@@ -23,6 +24,7 @@ |
#include "content/browser/renderer_host/render_process_host_impl.h" |
#include "content/browser/renderer_host/render_view_host_impl.h" |
#include "content/common/pepper_messages.h" |
+#include "content/public/browser/browser_context.h" |
#include "content/public/browser/browser_thread.h" |
#include "content/public/browser/content_browser_client.h" |
#include "content/public/browser/font_list_async.h" |
@@ -55,18 +57,27 @@ namespace { |
const size_t kMaxSocketsAllowed = 1024; |
const uint32 kInvalidSocketID = 0; |
+// This is mirrored from |
+// chrome/browser/chromeos/system/drm_settings.cc |
+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
|
+// The DRM identifier is 32 bytes hexencoded at present. |
+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
|
+ |
} // namespace |
PepperMessageFilter::PepperMessageFilter( |
ProcessType type, |
int process_id, |
- content::ResourceContext* resource_context) |
+ content::BrowserContext* browser_context) |
: process_type_(type), |
process_id_(process_id), |
- resource_context_(resource_context), |
+ resource_context_(browser_context ? |
+ 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.
|
host_resolver_(NULL), |
next_socket_id_(1) { |
DCHECK(type == RENDERER); |
+ DCHECK(browser_context); |
+ browser_path_ = browser_context->GetPath(); |
DCHECK(resource_context_); |
} |
@@ -76,7 +87,8 @@ PepperMessageFilter::PepperMessageFilter(ProcessType type, |
process_id_(0), |
resource_context_(NULL), |
host_resolver_(host_resolver), |
- next_socket_id_(1) { |
+ next_socket_id_(1), |
+ browser_path_("") { |
DCHECK(type == PLUGIN); |
DCHECK(host_resolver); |
} |
@@ -145,7 +157,7 @@ bool PepperMessageFilter::OnMessageReceived(const IPC::Message& msg, |
// Flash messages. |
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_UpdateActivity, OnUpdateActivity) |
- IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetDeviceID, OnGetDeviceID) |
+ IPC_MESSAGE_HANDLER(PepperMsg_GetDeviceID, OnGetDeviceID) |
IPC_MESSAGE_UNHANDLED(handled = false) |
IPC_END_MESSAGE_MAP_EX() |
@@ -633,8 +645,28 @@ void PepperMessageFilter::OnUpdateActivity() { |
} |
void PepperMessageFilter::OnGetDeviceID(std::string* id) { |
- // TODO(brettw) implement this. |
- *id = "<undefined>"; |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
+ *id = ""; |
+ |
+ if (browser_path_.empty()) { |
+ LOG(ERROR) << "GetDeviceID requested from outside the RENDERER context."; |
+ return; |
+ } |
+ |
+ // TODO(wad,brettw) Add OffTheRecord() enforcement here. |
+ // Normally this is left for the plugin to do, but in the |
+ // future we should check here as an added safeguard. |
+ |
+ // Grab the contents of the DRM identifier file. |
+ FilePath drm_id_file = browser_path_; |
+ drm_id_file = drm_id_file.AppendASCII(kDRMIdentifierFile); |
+ char id_buf[kDRMIdentifierSize]; |
+ if (file_util::ReadFile(drm_id_file, id_buf, kDRMIdentifierSize) != |
+ kDRMIdentifierSize) { |
+ VLOG(1) << "file not readable: " << drm_id_file.value(); |
+ *id = ""; |
battre
2012/05/03 09:57:43
return;
drewry
2012/05/03 13:57:18
Done.
|
+ } |
+ id->assign(id_buf, kDRMIdentifierSize); |
} |
void PepperMessageFilter::GetFontFamiliesComplete( |