#include "content/public/browser/browser_ppapi_host.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_security_policy.h"
-#include "content/public/browser/render_widget_host.h"
-#include "content/public/browser/render_widget_host_view.h"
+#include "content/public/browser/render_frame_host.h"
#include "content/public/common/pepper_plugin_info.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/host/dispatch_host_message.h"
#include "ppapi/proxy/ppapi_messages.h"
#if defined(USE_AURA)
-#include "ui/aura/root_window.h"
+#include "ui/aura/window.h"
+#include "ui/aura/window_tree_host.h"
+#endif
+
+#if defined(OS_MACOSX)
+#include "chrome/browser/renderer_host/pepper/monitor_finder_mac.h"
#endif
using content::BrowserPpapiHost;
namespace chrome {
namespace {
-const base::FilePath::CharType kVoucherFilename[] =
- FILE_PATH_LITERAL("plugin.vch");
+const char kVoucherFilename[] = "plugin.vch";
}
-#if defined (OS_WIN)
+#if defined(OS_WIN)
// Helper class to get the UI thread which monitor is showing the
// window associated with the instance's render view. Since we get
// called by the IO thread and we cannot block, the first answer is
// right monitor.
class MonitorFinder : public base::RefCountedThreadSafe<MonitorFinder> {
public:
- MonitorFinder(int process_id, int render_id)
+ MonitorFinder(int process_id, int render_frame_id)
: process_id_(process_id),
- render_id_(render_id),
+ render_frame_id_(render_frame_id),
monitor_(NULL),
- request_sent_(0) {
- }
+ request_sent_(0) {}
int64_t GetMonitor() {
// We use |request_sent_| as an atomic boolean so that we
// to call and we can't cache the |monitor_| value.
if (InterlockedCompareExchange(&request_sent_, 1, 0) == 0) {
content::BrowserThread::PostTask(
- content::BrowserThread::UI, FROM_HERE,
+ content::BrowserThread::UI,
+ FROM_HERE,
base::Bind(&MonitorFinder::FetchMonitorFromWidget, this));
}
return reinterpret_cast<int64_t>(monitor_);
private:
friend class base::RefCountedThreadSafe<MonitorFinder>;
- ~MonitorFinder() { }
+ ~MonitorFinder() {}
void FetchMonitorFromWidget() {
InterlockedExchange(&request_sent_, 0);
- content::RenderWidgetHost* rwh =
- content::RenderWidgetHost::FromID(process_id_, render_id_);
- if (!rwh)
+ content::RenderFrameHost* rfh =
+ content::RenderFrameHost::FromID(process_id_, render_frame_id_);
+ if (!rfh)
return;
- content::RenderWidgetHostView* view = rwh->GetView();
- if (!view)
- return;
- gfx::NativeView native_view = view->GetNativeView();
+ gfx::NativeView native_view = rfh->GetNativeView();
#if defined(USE_AURA)
- aura::WindowEventDispatcher* dispatcher = native_view->GetDispatcher();
- if (!dispatcher)
+ aura::WindowTreeHost* host = native_view->GetHost();
+ if (!host)
return;
- HWND window = dispatcher->GetAcceleratedWidget();
+ HWND window = host->GetAcceleratedWidget();
#else
HWND window = native_view;
#endif
HMONITOR monitor = ::MonitorFromWindow(window, MONITOR_DEFAULTTONULL);
- InterlockedExchangePointer(reinterpret_cast<void* volatile *>(&monitor_),
+ InterlockedExchangePointer(reinterpret_cast<void* volatile*>(&monitor_),
monitor);
}
const int process_id_;
- const int render_id_;
+ const int render_frame_id_;
volatile HMONITOR monitor_;
volatile long request_sent_;
};
-#else
-// TODO(cpu): Support Mac and Linux someday.
+#elif !defined(OS_MACOSX)
+// TODO(cpu): Support Linux someday.
class MonitorFinder : public base::RefCountedThreadSafe<MonitorFinder> {
public:
- MonitorFinder(int, int) { }
+ MonitorFinder(int, int) {}
int64_t GetMonitor() { return 0; }
private:
friend class base::RefCountedThreadSafe<MonitorFinder>;
- ~MonitorFinder() { }
+ ~MonitorFinder() {}
};
#endif
PP_Instance instance,
PP_Resource resource)
: ppapi::host::ResourceHost(host->GetPpapiHost(), instance, resource),
- weak_factory_(this){
+ weak_factory_(this) {
// Grant permissions to read the flash voucher file.
int render_process_id;
- int render_view_id;
- bool success =
- host->GetRenderViewIDsForInstance(
- instance, &render_process_id, &render_view_id);
+ int render_frame_id;
+ bool success = host->GetRenderFrameIDsForInstance(
+ instance, &render_process_id, &render_frame_id);
base::FilePath plugin_dir = host->GetPluginPath().DirName();
DCHECK(!plugin_dir.empty() && success);
- base::FilePath voucher_file = plugin_dir.Append(
- base::FilePath(kVoucherFilename));
+ base::FilePath voucher_file = plugin_dir.AppendASCII(kVoucherFilename);
content::ChildProcessSecurityPolicy::GetInstance()->GrantReadFile(
render_process_id, voucher_file);
fetcher_ = new DeviceIDFetcher(render_process_id);
- monitor_finder_ = new MonitorFinder(render_process_id, render_view_id);
+ monitor_finder_ = new MonitorFinder(render_process_id, render_frame_id);
monitor_finder_->GetMonitor();
}
-PepperFlashDRMHost::~PepperFlashDRMHost() {
-}
+PepperFlashDRMHost::~PepperFlashDRMHost() {}
int32_t PepperFlashDRMHost::OnResourceMessageReceived(
const IPC::Message& msg,
ppapi::host::HostMessageContext* context) {
IPC_BEGIN_MESSAGE_MAP(PepperFlashDRMHost, msg)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_FlashDRM_GetDeviceID,
- OnHostMsgGetDeviceID)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_FlashDRM_GetHmonitor,
- OnHostMsgGetHmonitor)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_FlashDRM_GetDeviceID,
+ OnHostMsgGetDeviceID)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_FlashDRM_GetHmonitor,
+ OnHostMsgGetHmonitor)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_FlashDRM_MonitorIsExternal,
+ OnHostMsgMonitorIsExternal)
IPC_END_MESSAGE_MAP()
return PP_ERROR_FAILED;
}
if (monitor_id) {
context->reply_msg = PpapiPluginMsg_FlashDRM_GetHmonitorReply(monitor_id);
return PP_OK;
- } else {
- return PP_ERROR_FAILED;
}
+ return PP_ERROR_FAILED;
+}
+
+int32_t PepperFlashDRMHost::OnHostMsgMonitorIsExternal(
+ ppapi::host::HostMessageContext* context) {
+ int64_t monitor_id = monitor_finder_->GetMonitor();
+ if (monitor_id) {
+ // TODO(bbudge) get information about whether monitor is external.
+ context->reply_msg =
+ PpapiPluginMsg_FlashDRM_MonitorIsExternalReply(PP_FALSE);
+ return PP_OK;
+ }
+ return PP_ERROR_FAILED;
}
void PepperFlashDRMHost::GotDeviceID(