Use volume serial number as device id
This commit is contained in:
parent
8832d7b77b
commit
57da8908b2
1 changed files with 36 additions and 1 deletions
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
#include "chrome/browser/renderer_host/pepper/pepper_flash_drm_host.h"
|
#include "chrome/browser/renderer_host/pepper/pepper_flash_drm_host.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -12,12 +14,14 @@
|
||||||
#include "base/compiler_specific.h"
|
#include "base/compiler_specific.h"
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/memory/ref_counted.h"
|
#include "base/memory/ref_counted.h"
|
||||||
|
#include "base/strings/string_number_conversions.h"
|
||||||
#include "build/build_config.h"
|
#include "build/build_config.h"
|
||||||
#include "content/public/browser/browser_ppapi_host.h"
|
#include "content/public/browser/browser_ppapi_host.h"
|
||||||
#include "content/public/browser/browser_thread.h"
|
#include "content/public/browser/browser_thread.h"
|
||||||
#include "content/public/browser/child_process_security_policy.h"
|
#include "content/public/browser/child_process_security_policy.h"
|
||||||
#include "content/public/browser/render_frame_host.h"
|
#include "content/public/browser/render_frame_host.h"
|
||||||
#include "content/public/common/pepper_plugin_info.h"
|
#include "content/public/common/pepper_plugin_info.h"
|
||||||
|
#include "net/base/net_util.h"
|
||||||
#include "ppapi/c/pp_errors.h"
|
#include "ppapi/c/pp_errors.h"
|
||||||
#include "ppapi/host/dispatch_host_message.h"
|
#include "ppapi/host/dispatch_host_message.h"
|
||||||
#include "ppapi/host/host_message_context.h"
|
#include "ppapi/host/host_message_context.h"
|
||||||
|
@ -38,7 +42,30 @@ using content::BrowserPpapiHost;
|
||||||
namespace chrome {
|
namespace chrome {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const char kVoucherFilename[] = "plugin.vch";
|
const char kVoucherFilename[] = "plugin.vch";
|
||||||
|
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
bool GetSystemVolumeSerialNumber(std::string* number) {
|
||||||
|
// Find the system root path (e.g: C:\).
|
||||||
|
wchar_t system_path[MAX_PATH + 1];
|
||||||
|
if (!GetSystemDirectoryW(system_path, MAX_PATH))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
wchar_t* first_slash = wcspbrk(system_path, L"\\/");
|
||||||
|
if (first_slash != NULL)
|
||||||
|
*(first_slash + 1) = 0;
|
||||||
|
|
||||||
|
DWORD number_local = 0;
|
||||||
|
if (!GetVolumeInformationW(system_path, NULL, 0, &number_local, NULL, NULL,
|
||||||
|
NULL, 0))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
*number = base::IntToString(std::abs(static_cast<int>(number_local)));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
|
@ -149,7 +176,15 @@ int32_t PepperFlashDRMHost::OnResourceMessageReceived(
|
||||||
|
|
||||||
int32_t PepperFlashDRMHost::OnHostMsgGetDeviceID(
|
int32_t PepperFlashDRMHost::OnHostMsgGetDeviceID(
|
||||||
ppapi::host::HostMessageContext* context) {
|
ppapi::host::HostMessageContext* context) {
|
||||||
context->reply_msg = PpapiPluginMsg_FlashDRM_GetDeviceIDReply("");
|
static std::string id;
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
if (id.empty() && !GetSystemVolumeSerialNumber(&id))
|
||||||
|
id = net::GetHostName();
|
||||||
|
#else
|
||||||
|
if (id.empty())
|
||||||
|
id = net::GetHostName();
|
||||||
|
#endif
|
||||||
|
context->reply_msg = PpapiPluginMsg_FlashDRM_GetDeviceIDReply(id);
|
||||||
return PP_OK;
|
return PP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue