Skip to content

Commit 57da890

Browse files
committed
Use volume serial number as device id
1 parent 8832d7b commit 57da890

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

chromium_src/chrome/browser/renderer_host/pepper/pepper_flash_drm_host.cc

+36-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#include "chrome/browser/renderer_host/pepper/pepper_flash_drm_host.h"
66

7+
#include <cmath>
8+
79
#if defined(OS_WIN)
810
#include <Windows.h>
911
#endif
@@ -12,12 +14,14 @@
1214
#include "base/compiler_specific.h"
1315
#include "base/logging.h"
1416
#include "base/memory/ref_counted.h"
17+
#include "base/strings/string_number_conversions.h"
1518
#include "build/build_config.h"
1619
#include "content/public/browser/browser_ppapi_host.h"
1720
#include "content/public/browser/browser_thread.h"
1821
#include "content/public/browser/child_process_security_policy.h"
1922
#include "content/public/browser/render_frame_host.h"
2023
#include "content/public/common/pepper_plugin_info.h"
24+
#include "net/base/net_util.h"
2125
#include "ppapi/c/pp_errors.h"
2226
#include "ppapi/host/dispatch_host_message.h"
2327
#include "ppapi/host/host_message_context.h"
@@ -38,7 +42,30 @@ using content::BrowserPpapiHost;
3842
namespace chrome {
3943

4044
namespace {
45+
4146
const char kVoucherFilename[] = "plugin.vch";
47+
48+
#if defined(OS_WIN)
49+
bool GetSystemVolumeSerialNumber(std::string* number) {
50+
// Find the system root path (e.g: C:\).
51+
wchar_t system_path[MAX_PATH + 1];
52+
if (!GetSystemDirectoryW(system_path, MAX_PATH))
53+
return false;
54+
55+
wchar_t* first_slash = wcspbrk(system_path, L"\\/");
56+
if (first_slash != NULL)
57+
*(first_slash + 1) = 0;
58+
59+
DWORD number_local = 0;
60+
if (!GetVolumeInformationW(system_path, NULL, 0, &number_local, NULL, NULL,
61+
NULL, 0))
62+
return false;
63+
64+
*number = base::IntToString(std::abs(static_cast<int>(number_local)));
65+
return true;
66+
}
67+
#endif
68+
4269
}
4370

4471
#if defined(OS_WIN)
@@ -149,7 +176,15 @@ int32_t PepperFlashDRMHost::OnResourceMessageReceived(
149176

150177
int32_t PepperFlashDRMHost::OnHostMsgGetDeviceID(
151178
ppapi::host::HostMessageContext* context) {
152-
context->reply_msg = PpapiPluginMsg_FlashDRM_GetDeviceIDReply("");
179+
static std::string id;
180+
#if defined(OS_WIN)
181+
if (id.empty() && !GetSystemVolumeSerialNumber(&id))
182+
id = net::GetHostName();
183+
#else
184+
if (id.empty())
185+
id = net::GetHostName();
186+
#endif
187+
context->reply_msg = PpapiPluginMsg_FlashDRM_GetDeviceIDReply(id);
153188
return PP_OK;
154189
}
155190

0 commit comments

Comments
 (0)