Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: content/browser/renderer_host/pepper/pepper_flash_browser_host.cc

Issue 11516020: Refactor PPB_Flash GetLocalTimeZoneOffset to the new PPAPI resource model (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/pepper/pepper_flash_browser_host.h" 5 #include "content/browser/renderer_host/pepper/pepper_flash_browser_host.h"
6 6
7 #include "base/time.h"
7 #include "content/public/browser/browser_ppapi_host.h" 8 #include "content/public/browser/browser_ppapi_host.h"
8 #include "ipc/ipc_message_macros.h" 9 #include "ipc/ipc_message_macros.h"
9 #include "ppapi/c/pp_errors.h" 10 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/host/dispatch_host_message.h" 11 #include "ppapi/host/dispatch_host_message.h"
11 #include "ppapi/proxy/ppapi_messages.h" 12 #include "ppapi/proxy/ppapi_messages.h"
12 #include "ppapi/proxy/resource_message_params.h" 13 #include "ppapi/proxy/resource_message_params.h"
14 #include "ppapi/shared_impl/time_conversion.h"
13 15
14 #ifdef OS_WIN 16 #ifdef OS_WIN
15 #include <windows.h> 17 #include <windows.h>
16 #elif defined(OS_MACOSX) 18 #elif defined(OS_MACOSX)
17 #include <CoreServices/CoreServices.h> 19 #include <CoreServices/CoreServices.h>
18 #endif 20 #endif
19 21
20 namespace content { 22 namespace content {
21 23
22 PepperFlashBrowserHost::PepperFlashBrowserHost( 24 PepperFlashBrowserHost::PepperFlashBrowserHost(
23 BrowserPpapiHost* host, 25 BrowserPpapiHost* host,
24 PP_Instance instance, 26 PP_Instance instance,
25 PP_Resource resource) 27 PP_Resource resource)
26 : ResourceHost(host->GetPpapiHost(), instance, resource) { 28 : ResourceHost(host->GetPpapiHost(), instance, resource) {
27 } 29 }
28 30
29 PepperFlashBrowserHost::~PepperFlashBrowserHost() { 31 PepperFlashBrowserHost::~PepperFlashBrowserHost() {
30 } 32 }
31 33
32 int32_t PepperFlashBrowserHost::OnResourceMessageReceived( 34 int32_t PepperFlashBrowserHost::OnResourceMessageReceived(
33 const IPC::Message& msg, 35 const IPC::Message& msg,
34 ppapi::host::HostMessageContext* context) { 36 ppapi::host::HostMessageContext* context) {
35 IPC_BEGIN_MESSAGE_MAP(PepperFlashBrowserHost, msg) 37 IPC_BEGIN_MESSAGE_MAP(PepperFlashBrowserHost, msg)
36 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_Flash_UpdateActivity, 38 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_Flash_UpdateActivity,
37 OnMsgUpdateActivity); 39 OnMsgUpdateActivity);
40 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Flash_GetLocalTimeZoneOffset,
41 OnMsgGetLocalTimeZoneOffset);
38 IPC_END_MESSAGE_MAP() 42 IPC_END_MESSAGE_MAP()
39 return PP_ERROR_FAILED; 43 return PP_ERROR_FAILED;
40 } 44 }
41 45
42 int32_t PepperFlashBrowserHost::OnMsgUpdateActivity( 46 int32_t PepperFlashBrowserHost::OnMsgUpdateActivity(
43 ppapi::host::HostMessageContext* host_context) { 47 ppapi::host::HostMessageContext* host_context) {
44 #if defined(OS_WIN) 48 #if defined(OS_WIN)
45 // Reading then writing back the same value to the screensaver timeout system 49 // Reading then writing back the same value to the screensaver timeout system
46 // setting resets the countdown which prevents the screensaver from turning 50 // setting resets the countdown which prevents the screensaver from turning
47 // on "for a while". As long as the plugin pings us with this message faster 51 // on "for a while". As long as the plugin pings us with this message faster
48 // than the screensaver timeout, it won't go on. 52 // than the screensaver timeout, it won't go on.
49 int value = 0; 53 int value = 0;
50 if (SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT, 0, &value, 0)) 54 if (SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT, 0, &value, 0))
51 SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, value, NULL, 0); 55 SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, value, NULL, 0);
52 #elif defined(OS_MACOSX) 56 #elif defined(OS_MACOSX)
53 UpdateSystemActivity(OverallAct); 57 UpdateSystemActivity(OverallAct);
54 #else 58 #else
55 // TODO(brettw) implement this for other platforms. 59 // TODO(brettw) implement this for other platforms.
56 #endif 60 #endif
57 return PP_OK; 61 return PP_OK;
58 } 62 }
59 63
64 int32_t PepperFlashBrowserHost::OnMsgGetLocalTimeZoneOffset(
65 ppapi::host::HostMessageContext* host_context,
66 const base::Time& t) {
67 // The reason for this processing being in the browser process is that on
68 // Linux, the localtime calls require filesystem access prohibited by the
69 // sandbox.
70 host_context->reply_msg = PpapiPluginMsg_Flash_GetLocalTimeZoneOffsetReply(
71 ppapi::PPGetLocalTimeZoneOffset(t));
72 return PP_OK;
73 }
74
60 } // namespace content 75 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698