4
4
5
5
#include " chrome/browser/renderer_host/pepper/pepper_flash_drm_host.h"
6
6
7
+ #include < cmath>
8
+
7
9
#if defined(OS_WIN)
8
10
#include < Windows.h>
9
11
#endif
12
14
#include " base/compiler_specific.h"
13
15
#include " base/logging.h"
14
16
#include " base/memory/ref_counted.h"
17
+ #include " base/strings/string_number_conversions.h"
15
18
#include " build/build_config.h"
16
19
#include " content/public/browser/browser_ppapi_host.h"
17
20
#include " content/public/browser/browser_thread.h"
18
21
#include " content/public/browser/child_process_security_policy.h"
19
22
#include " content/public/browser/render_frame_host.h"
20
23
#include " content/public/common/pepper_plugin_info.h"
24
+ #include " net/base/net_util.h"
21
25
#include " ppapi/c/pp_errors.h"
22
26
#include " ppapi/host/dispatch_host_message.h"
23
27
#include " ppapi/host/host_message_context.h"
@@ -38,7 +42,30 @@ using content::BrowserPpapiHost;
38
42
namespace chrome {
39
43
40
44
namespace {
45
+
41
46
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
+
42
69
}
43
70
44
71
#if defined(OS_WIN)
@@ -149,7 +176,15 @@ int32_t PepperFlashDRMHost::OnResourceMessageReceived(
149
176
150
177
int32_t PepperFlashDRMHost::OnHostMsgGetDeviceID (
151
178
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);
153
188
return PP_OK;
154
189
}
155
190
0 commit comments