From 2872d7d601be4141fd488c69f26d7718841c7462 Mon Sep 17 00:00:00 2001 From: "brettw@chromium.org" Date: Fri, 22 Apr 2011 15:58:42 +0000 Subject: Merge 82575 - Proxy time zone requests to the browser. This is because the current codecan't run in the sandbox on Linux.TEST=manualBUG=80176Review URL: http://codereview.chromium.org/6891001 TBR=brettw@chromium.org TEST=80176 Review URL: http://codereview.chromium.org/6899026 git-svn-id: svn://svn.chromium.org/chrome/branches/742/src@82655 0039d316-1c4b-4281-b951-d872f2087c98 --- webkit/plugins/ppapi/mock_plugin_delegate.cc | 4 ++++ webkit/plugins/ppapi/mock_plugin_delegate.h | 1 + webkit/plugins/ppapi/plugin_delegate.h | 3 +++ webkit/plugins/ppapi/ppb_flash_impl.cc | 23 +++++++++-------------- 4 files changed, 17 insertions(+), 14 deletions(-) (limited to 'webkit/plugins') diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.cc b/webkit/plugins/ppapi/mock_plugin_delegate.cc index 4ac0a00..133226b 100644 --- a/webkit/plugins/ppapi/mock_plugin_delegate.cc +++ b/webkit/plugins/ppapi/mock_plugin_delegate.cc @@ -235,5 +235,9 @@ webkit_glue::P2PTransport* MockPluginDelegate::CreateP2PTransport() { return NULL; } +double MockPluginDelegate::GetLocalTimeZoneOffset(base::Time t) { + return 0.0; +} + } // namespace ppapi } // namespace webkit diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.h b/webkit/plugins/ppapi/mock_plugin_delegate.h index 32b80c7..4c3d740 100644 --- a/webkit/plugins/ppapi/mock_plugin_delegate.h +++ b/webkit/plugins/ppapi/mock_plugin_delegate.h @@ -102,6 +102,7 @@ class MockPluginDelegate : public PluginDelegate { virtual void SaveURLAs(const GURL& url); virtual P2PSocketDispatcher* GetP2PSocketDispatcher(); virtual webkit_glue::P2PTransport* CreateP2PTransport(); + virtual double GetLocalTimeZoneOffset(base::Time t); }; } // namespace ppapi diff --git a/webkit/plugins/ppapi/plugin_delegate.h b/webkit/plugins/ppapi/plugin_delegate.h index eefb1e6..761a808 100644 --- a/webkit/plugins/ppapi/plugin_delegate.h +++ b/webkit/plugins/ppapi/plugin_delegate.h @@ -13,6 +13,7 @@ #include "base/platform_file.h" #include "base/shared_memory.h" #include "base/sync_socket.h" +#include "base/time.h" #include "googleurl/src/gurl.h" #include "media/video/video_decode_accelerator.h" #include "ppapi/c/pp_completion_callback.h" @@ -387,6 +388,8 @@ class PluginDelegate { // Creates P2PTransport object. virtual webkit_glue::P2PTransport* CreateP2PTransport() = 0; + + virtual double GetLocalTimeZoneOffset(base::Time t) = 0; }; } // namespace ppapi diff --git a/webkit/plugins/ppapi/ppb_flash_impl.cc b/webkit/plugins/ppapi/ppb_flash_impl.cc index db9be46..8599d9c 100644 --- a/webkit/plugins/ppapi/ppb_flash_impl.cc +++ b/webkit/plugins/ppapi/ppb_flash_impl.cc @@ -73,20 +73,15 @@ void QuitMessageLoop(PP_Instance instance) { MessageLoop::current()->QuitNow(); } -double GetLocalTimeZoneOffset(PP_Time t) { - // Somewhat horrible: Explode it to local time and then unexplode it as if - // it were UTC. Also explode it to UTC and unexplode it (this avoids - // mismatching rounding or lack thereof). The time zone offset is their - // difference. - // - // TODO(brettw) this is duplicated in ppb_flash_proxy.cc, unify these! - base::Time cur = base::Time::FromDoubleT(t); - base::Time::Exploded exploded; - cur.LocalExplode(&exploded); - base::Time adj_time = base::Time::FromUTCExploded(exploded); - cur.UTCExplode(&exploded); - cur = base::Time::FromUTCExploded(exploded); - return (adj_time - cur).InSecondsF(); +double GetLocalTimeZoneOffset(PP_Instance pp_instance, PP_Time t) { + PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance); + if (!instance) + return 0.0; + + // We can't do the conversion here because on Linux, the localtime calls + // require filesystem access prohibited by the sandbox. + return instance->delegate()->GetLocalTimeZoneOffset( + base::Time::FromDoubleT(t)); } const PPB_Flash ppb_flash = { -- cgit v1.1