OLD | NEW |
---|---|
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 "chrome/browser/renderer_host/pepper/pepper_flash_browser_host.h" | 5 #include "chrome/browser/renderer_host/pepper/pepper_flash_browser_host.h" |
6 | 6 |
7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "chrome/browser/content_settings/cookie_settings_factory.h" | 9 #include "chrome/browser/content_settings/cookie_settings_factory.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
11 #include "components/content_settings/core/browser/cookie_settings.h" | 11 #include "components/content_settings/core/browser/cookie_settings.h" |
12 #include "content/public/browser/browser_context.h" | 12 #include "content/public/browser/browser_context.h" |
13 #include "content/public/browser/browser_ppapi_host.h" | 13 #include "content/public/browser/browser_ppapi_host.h" |
14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
15 #include "content/public/browser/render_process_host.h" | 15 #include "content/public/browser/render_process_host.h" |
16 #include "device/power_save_blocker/power_save_blocker.h" | |
16 #include "ipc/ipc_message_macros.h" | 17 #include "ipc/ipc_message_macros.h" |
17 #include "ppapi/c/pp_errors.h" | 18 #include "ppapi/c/pp_errors.h" |
18 #include "ppapi/c/private/ppb_flash.h" | 19 #include "ppapi/c/private/ppb_flash.h" |
19 #include "ppapi/host/dispatch_host_message.h" | 20 #include "ppapi/host/dispatch_host_message.h" |
20 #include "ppapi/proxy/ppapi_messages.h" | 21 #include "ppapi/proxy/ppapi_messages.h" |
21 #include "ppapi/proxy/resource_message_params.h" | 22 #include "ppapi/proxy/resource_message_params.h" |
22 #include "ppapi/shared_impl/time_conversion.h" | 23 #include "ppapi/shared_impl/time_conversion.h" |
23 #include "url/gurl.h" | 24 #include "url/gurl.h" |
24 | 25 |
25 #if defined(OS_WIN) | 26 #if defined(OS_WIN) |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
73 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Flash_GetLocalTimeZoneOffset, | 74 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Flash_GetLocalTimeZoneOffset, |
74 OnGetLocalTimeZoneOffset) | 75 OnGetLocalTimeZoneOffset) |
75 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0( | 76 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0( |
76 PpapiHostMsg_Flash_GetLocalDataRestrictions, OnGetLocalDataRestrictions) | 77 PpapiHostMsg_Flash_GetLocalDataRestrictions, OnGetLocalDataRestrictions) |
77 PPAPI_END_MESSAGE_MAP() | 78 PPAPI_END_MESSAGE_MAP() |
78 return PP_ERROR_FAILED; | 79 return PP_ERROR_FAILED; |
79 } | 80 } |
80 | 81 |
81 int32_t PepperFlashBrowserHost::OnUpdateActivity( | 82 int32_t PepperFlashBrowserHost::OnUpdateActivity( |
82 ppapi::host::HostMessageContext* host_context) { | 83 ppapi::host::HostMessageContext* host_context) { |
83 #if defined(OS_WIN) | 84 device::PowerSaveBlocker* blocker = new device::PowerSaveBlocker( |
84 // Reading then writing back the same value to the screensaver timeout system | 85 device::PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, |
85 // setting resets the countdown which prevents the screensaver from turning | 86 device::PowerSaveBlocker::kReasonOther, "Requested By PepperFlash", |
86 // on "for a while". As long as the plugin pings us with this message faster | 87 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI), |
87 // than the screensaver timeout, it won't go on. | 88 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE)); |
88 int value = 0; | 89 auto delete_blocker = [](device::PowerSaveBlocker* blocker) { |
89 if (SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT, 0, &value, 0)) | 90 delete blocker; |
90 SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, value, NULL, 0); | 91 }; |
91 #elif defined(OS_MACOSX) | 92 // There is no specification for how long OnUpdateActivity should prevent the |
92 UpdateSystemActivity(OverallAct); | 93 // screen from going to sleep. Empirically, twitch.tv calls this method every |
93 #else | 94 // 10 seconds. Be conservative and allow 45 seconds before deleting the block. |
94 // TODO(brettw) implement this for other platforms. | 95 BrowserThread::PostDelayedTask(BrowserThread::IO, FROM_HERE, |
95 #endif | 96 base::Bind(delete_blocker, blocker), |
97 base::TimeDelta::FromSeconds(45)); | |
bbudge
2016/10/13 19:53:51
Since this is a plugin API, it seems bad to allow
ccameron
2016/10/14 21:39:43
Sure -- switched it to a DelayTimer impl.
| |
96 return PP_OK; | 98 return PP_OK; |
97 } | 99 } |
98 | 100 |
99 int32_t PepperFlashBrowserHost::OnGetLocalTimeZoneOffset( | 101 int32_t PepperFlashBrowserHost::OnGetLocalTimeZoneOffset( |
100 ppapi::host::HostMessageContext* host_context, | 102 ppapi::host::HostMessageContext* host_context, |
101 const base::Time& t) { | 103 const base::Time& t) { |
102 // The reason for this processing being in the browser process is that on | 104 // The reason for this processing being in the browser process is that on |
103 // Linux, the localtime calls require filesystem access prohibited by the | 105 // Linux, the localtime calls require filesystem access prohibited by the |
104 // sandbox. | 106 // sandbox. |
105 host_context->reply_msg = PpapiPluginMsg_Flash_GetLocalTimeZoneOffsetReply( | 107 host_context->reply_msg = PpapiPluginMsg_Flash_GetLocalTimeZoneOffsetReply( |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
157 restrictions = PP_FLASHLSORESTRICTIONS_BLOCK; | 159 restrictions = PP_FLASHLSORESTRICTIONS_BLOCK; |
158 else if (cookie_settings_->IsCookieSessionOnly(plugin_url)) | 160 else if (cookie_settings_->IsCookieSessionOnly(plugin_url)) |
159 restrictions = PP_FLASHLSORESTRICTIONS_IN_MEMORY; | 161 restrictions = PP_FLASHLSORESTRICTIONS_IN_MEMORY; |
160 } | 162 } |
161 SendReply(reply_context, | 163 SendReply(reply_context, |
162 PpapiPluginMsg_Flash_GetLocalDataRestrictionsReply( | 164 PpapiPluginMsg_Flash_GetLocalDataRestrictionsReply( |
163 static_cast<int32_t>(restrictions))); | 165 static_cast<int32_t>(restrictions))); |
164 } | 166 } |
165 | 167 |
166 } // namespace chrome | 168 } // namespace chrome |
OLD | NEW |